Revision: 17924 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17924 Author: ton Date: 2008-12-18 18:38:21 +0100 (Thu, 18 Dec 2008)
Log Message: ----------- 2.5 Drawing and viewing code for view3d back (no not objects :). Quick test: converted 2250 ugly lines of code in 2.5 hours. With about 300k lines todo, this will be 333 hours = 30 days? Whoa! Modified Paths: -------------- branches/blender2.5/blender/source/blender/editors/include/ED_util.h branches/blender2.5/blender/source/blender/editors/space_view3d/Makefile branches/blender2.5/blender/source/blender/editors/space_view3d/SConscript branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h branches/blender2.5/blender/source/blender/makesdna/DNA_view3d_types.h Added Paths: ----------- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_draw.c branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_view.c Modified: branches/blender2.5/blender/source/blender/editors/include/ED_util.h =================================================================== --- branches/blender2.5/blender/source/blender/editors/include/ED_util.h 2008-12-18 16:15:52 UTC (rev 17923) +++ branches/blender2.5/blender/source/blender/editors/include/ED_util.h 2008-12-18 17:38:21 UTC (rev 17924) @@ -33,6 +33,11 @@ #define XIC 20 #define YIC 20 +/* proposal = put scene pointers on function calls? */ +#define BASACT (scene->basact) +#define OBACT (BASACT? BASACT->object: 0) + + void apply_keyb_grid(float *val, float fac1, float fac2, float fac3, int invert); int GetButStringLength(char *str); Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/Makefile =================================================================== --- branches/blender2.5/blender/source/blender/editors/space_view3d/Makefile 2008-12-18 16:15:52 UTC (rev 17923) +++ branches/blender2.5/blender/source/blender/editors/space_view3d/Makefile 2008-12-18 17:38:21 UTC (rev 17924) @@ -38,6 +38,8 @@ CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) +CPPFLAGS += -I$(NAN_BMFONT)/include + # not very neat.... CPPFLAGS += -I../../windowmanager CPPFLAGS += -I../../blenloader @@ -46,6 +48,7 @@ CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../python +CPPFLAGS += -I../../render/extern/include CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # own include Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/SConscript =================================================================== --- branches/blender2.5/blender/source/blender/editors/space_view3d/SConscript 2008-12-18 16:15:52 UTC (rev 17923) +++ branches/blender2.5/blender/source/blender/editors/space_view3d/SConscript 2008-12-18 17:38:21 UTC (rev 17924) @@ -5,5 +5,6 @@ incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' +incs += ' ../../render/extern/include #/intern/guardedalloc #intern/bmfont' env.BlenderLib ( 'bf_editors_space_view3d', sources, Split(incs), [], libtype=['core','intern'], priority=[35, 40] ) Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c 2008-12-18 16:15:52 UTC (rev 17923) +++ branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c 2008-12-18 17:38:21 UTC (rev 17924) @@ -189,17 +189,10 @@ static void view3d_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - float col[3], fac; + ScrArea *sa= CTX_wm_area(C); + View3D *v3d= sa->spacedata.first; /* XXX get from region */ - /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - /* swapbuffers indicator */ - fac= BLI_frand(); - glColor3f(fac, fac, fac); - glRecti(20, 2, 30, 12); + drawview3dspace(C, ar, v3d); } Added: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_draw.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_draw.c (rev 0) +++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_draw.c 2008-12-18 17:38:21 UTC (rev 17924) @@ -0,0 +1,1454 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> +#include <math.h> + +#include "DNA_action_types.h" +#include "DNA_armature_types.h" +#include "DNA_camera_types.h" +#include "DNA_key_types.h" +#include "DNA_object_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_userdef_types.h" +#include "DNA_view3d_types.h" +#include "DNA_world_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_rand.h" + +#include "BKE_anim.h" +#include "BKE_context.h" +#include "BKE_image.h" +#include "BKE_ipo.h" +#include "BKE_key.h" +#include "BKE_object.h" +#include "BKE_global.h" +#include "BKE_scene.h" +#include "BKE_screen.h" +#include "BKE_utildefines.h" + +#include "RE_pipeline.h" // make_stars + +#include "IMB_imbuf_types.h" +#include "IMB_imbuf.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" +#include "BMF_Api.h" + +#include "WM_api.h" + +#include "ED_screen.h" +#include "ED_util.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "view3d_intern.h" // own include + + + +static void star_stuff_init_func(void) +{ + cpack(-1); + glPointSize(1.0); + glBegin(GL_POINTS); +} +static void star_stuff_vertex_func(float* i) +{ + glVertex3fv(i); +} +static void star_stuff_term_func(void) +{ + glEnd(); +} + +void circf(float x, float y, float rad) +{ + GLUquadricObj *qobj = gluNewQuadric(); + + gluQuadricDrawStyle(qobj, GLU_FILL); + + glPushMatrix(); + + glTranslatef(x, y, 0.); + + gluDisk( qobj, 0.0, rad, 32, 1); + + glPopMatrix(); + + gluDeleteQuadric(qobj); +} + +void circ(float x, float y, float rad) +{ + GLUquadricObj *qobj = gluNewQuadric(); + + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); + + glPushMatrix(); + + glTranslatef(x, y, 0.); + + gluDisk( qobj, 0.0, rad, 32, 1); + + glPopMatrix(); + + gluDeleteQuadric(qobj); +} + + +/* ********* custom clipping *********** */ + +static void view3d_draw_clipping(View3D *v3d) +{ + BoundBox *bb= v3d->clipbb; + + UI_ThemeColorShade(TH_BACK, -8); + + glBegin(GL_QUADS); + + glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[1]); glVertex3fv(bb->vec[2]); glVertex3fv(bb->vec[3]); + glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[5]); glVertex3fv(bb->vec[1]); + glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[6]); glVertex3fv(bb->vec[5]); + glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[3]); glVertex3fv(bb->vec[2]); glVertex3fv(bb->vec[6]); + glVertex3fv(bb->vec[1]); glVertex3fv(bb->vec[5]); glVertex3fv(bb->vec[6]); glVertex3fv(bb->vec[2]); + glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[3]); + + glEnd(); +} + +void view3d_set_clipping(View3D *v3d) +{ + double plane[4]; + int a; + + for(a=0; a<4; a++) { + QUATCOPY(plane, v3d->clip[a]); + glClipPlane(GL_CLIP_PLANE0+a, plane); + glEnable(GL_CLIP_PLANE0+a); + } +} + +void view3d_clr_clipping(void) +{ + int a; + + for(a=0; a<4; a++) { + glDisable(GL_CLIP_PLANE0+a); + } +} + +int view3d_test_clipping(View3D *v3d, float *vec) +{ + /* vec in world coordinates, returns 1 if clipped */ + float view[3]; + + VECCOPY(view, vec); + + if(0.0f < v3d->clip[0][3] + INPR(view, v3d->clip[0])) + if(0.0f < v3d->clip[1][3] + INPR(view, v3d->clip[1])) + if(0.0f < v3d->clip[2][3] + INPR(view, v3d->clip[2])) + if(0.0f < v3d->clip[3][3] + INPR(view, v3d->clip[3])) + return 0; + + return 1; +} + +/* ********* end custom clipping *********** */ + + +static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, float dx) +{ + float fx, fy; + + x+= (wx); + y+= (wy); + fx= x/dx; + fx= x-dx*floor(fx); + + while(fx< ar->winx) { + fdrawline(fx, 0.0, fx, (float)ar->winy); + fx+= dx; + } + + fy= y/dx; + fy= y-dx*floor(fy); + + + while(fy< ar->winy) { + fdrawline(0.0, fy, (float)ar->winx, fy); + fy+= dx; + } + +} + +// not intern, called in editobject for constraint axis too +void make_axis_color(char *col, char *col2, char axis) +{ + if(axis=='x') { + col2[0]= col[0]>219?255:col[0]+36; + col2[1]= col[1]<26?0:col[1]-26; + col2[2]= col[2]<26?0:col[2]-26; + } + else if(axis=='y') { + col2[0]= col[0]<46?0:col[0]-36; + col2[1]= col[1]>189?255:col[1]+66; + col2[2]= col[2]<46?0:col[2]-36; + } + else { + col2[0]= col[0]<26?0:col[0]-26; + col2[1]= col[1]<26?0:col[1]-26; + col2[2]= col[2]>209?255:col[2]+46; + } + +} + +static void drawgrid(ARegion *ar, View3D *v3d) +{ + /* extern short bgpicmode; */ + float wx, wy, x, y, fw, fx, fy, dx; + float vec4[4]; + char col[3], col2[3]; + short sublines = v3d->gridsubdiv; + + vec4[0]=vec4[1]=vec4[2]=0.0; + vec4[3]= 1.0; + Mat4MulVec4fl(v3d->persmat, vec4); + fx= vec4[0]; + fy= vec4[1]; + fw= vec4[3]; + + wx= (ar->winx/2.0); /* because of rounding errors, grid at wrong location */ + wy= (ar->winy/2.0); + + x= (wx)*fx/fw; + y= (wy)*fy/fw; + + vec4[0]=vec4[1]=v3d->grid; + vec4[2]= 0.0; + vec4[3]= 1.0; + Mat4MulVec4fl(v3d->persmat, vec4); + fx= vec4[0]; + fy= vec4[1]; + fw= vec4[3]; + + dx= fabs(x-(wx)*fx/fw); + if(dx==0) dx= fabs(y-(wy)*fy/fw); + + glDepthMask(0); // disable write in zbuffer + + /* check zoom out */ + UI_ThemeColor(TH_GRID); + + if(dx<6.0) { + v3d->gridview*= sublines; + dx*= sublines; + + if(dx<6.0) { + v3d->gridview*= sublines; + dx*= sublines; + + if(dx<6.0) { + v3d->gridview*= sublines; + dx*=sublines; + if(dx<6.0); + else { + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx); + } + } + else { // start blending out + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + drawgrid_draw(ar, wx, wy, x, y, dx); + + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, sublines*dx); + } + } + else { // start blending out (6 < dx < 60) + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + drawgrid_draw(ar, wx, wy, x, y, dx); + + UI_ThemeColor(TH_GRID); @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs