diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-26 03:54:33 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-26 03:54:33 +0400 |
commit | 09144c3756f7b9b23461b522cf9711eb1c8db775 (patch) | |
tree | 3a037e82f54a35c09a67dcb236b8029d62dfd504 /source | |
parent | 1ce2c73816be97f72484ffa40a3187b24968c6b3 (diff) |
style cleanup: mostly whitespace around operators
Diffstat (limited to 'source')
16 files changed, 5161 insertions, 5145 deletions
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index 545ec42e72f..d0e344ef0d5 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -70,7 +70,7 @@ /* Set up drawing environment for drawing motion paths */ void draw_motion_paths_init(View3D *v3d, ARegion *ar) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; if (v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -79,15 +79,15 @@ void draw_motion_paths_init(View3D *v3d, ARegion *ar) } /* Draw the given motion path for an Object or a Bone - * - assumes that the viewport has already been initialized properly + * - assumes that the viewport has already been initialized properly * i.e. draw_motion_paths_init() has been called */ void draw_motion_path_instance(Scene *scene, - Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath) + Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath) { //RegionView3D *rv3d= ar->regiondata; bMotionPathVert *mpv, *mpv_start; - int i, stepsize= avs->path_step; + int i, stepsize = avs->path_step; int sfra, efra, len; @@ -99,21 +99,21 @@ void draw_motion_path_instance(Scene *scene, * the current frame to draw. However, this range is still * restricted by the limits of the original path. */ - sfra= CFRA - avs->path_bc; - efra= CFRA + avs->path_ac; - if (sfra < mpath->start_frame) sfra= mpath->start_frame; - if (efra > mpath->end_frame) efra= mpath->end_frame; + sfra = CFRA - avs->path_bc; + efra = CFRA + avs->path_ac; + if (sfra < mpath->start_frame) sfra = mpath->start_frame; + if (efra > mpath->end_frame) efra = mpath->end_frame; - len= efra - sfra; + len = efra - sfra; - sind= sfra - mpath->start_frame; - mpv_start= (mpath->points + sind); + sind = sfra - mpath->start_frame; + mpv_start = (mpath->points + sind); } else { - sfra= mpath->start_frame; + sfra = mpath->start_frame; efra = sfra + mpath->length; len = mpath->length; - mpv_start= mpath->points; + mpv_start = mpath->points; } if (len <= 0) { @@ -124,17 +124,17 @@ void draw_motion_path_instance(Scene *scene, glShadeModel(GL_SMOOTH); glBegin(GL_LINE_STRIP); - for (i=0, mpv=mpv_start; i < len; i++, mpv++) { - short sel= (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT); + for (i = 0, mpv = mpv_start; i < len; i++, mpv++) { + short sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT); float intensity; /* how faint */ /* set color - * - more intense for active/selected bones, less intense for unselected bones - * - black for before current frame, green for current frame, blue for after current frame - * - intensity decreases as distance from current frame increases + * - more intense for active/selected bones, less intense for unselected bones + * - black for before current frame, green for current frame, blue for after current frame + * - intensity decreases as distance from current frame increases */ - #define SET_INTENSITY(A, B, C, min, max) (((1.0f - ((C - B) / (C - A))) * (max-min)) + min) - if ((sfra+i) < CFRA) { + #define SET_INTENSITY(A, B, C, min, max) (((1.0f - ((C - B) / (C - A))) * (max - min)) + min) + if ((sfra + i) < CFRA) { /* black - before cfra */ if (sel) { // intensity= 0.5f; @@ -146,7 +146,7 @@ void draw_motion_path_instance(Scene *scene, } UI_ThemeColorBlend(TH_WIRE, TH_BACK, intensity); } - else if ((sfra+i) > CFRA) { + else if ((sfra + i) > CFRA) { /* blue - after cfra */ if (sel) { //intensity = 0.5f; @@ -161,10 +161,10 @@ void draw_motion_path_instance(Scene *scene, else { /* green - on cfra */ if (sel) { - intensity= 0.5f; + intensity = 0.5f; } else { - intensity= 0.99f; + intensity = 0.99f; } UI_ThemeColorBlendShade(TH_CFRAME, TH_BACK, intensity, 10); } @@ -182,28 +182,28 @@ void draw_motion_path_instance(Scene *scene, * NOTE: this is not really visible/noticeable */ glBegin(GL_POINTS); - for (i=0, mpv=mpv_start; i < len; i++, mpv++) + for (i = 0, mpv = mpv_start; i < len; i++, mpv++) glVertex3fv(mpv->co); glEnd(); /* Draw little white dots at each framestep value */ UI_ThemeColor(TH_TEXT_HI); glBegin(GL_POINTS); - for (i=0, mpv=mpv_start; i < len; i+=stepsize, mpv+=stepsize) + for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) glVertex3fv(mpv->co); glEnd(); /* Draw big green dot where the current frame is */ // NOTE: only do this when drawing keyframes for now... if ((avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) && - (sfra < CFRA) && (CFRA <= efra)) + (sfra < CFRA) && (CFRA <= efra)) { UI_ThemeColor(TH_CFRAME); glPointSize(6.0f); glBegin(GL_POINTS); - mpv = mpv_start + (CFRA - sfra); - glVertex3fv(mpv->co); + mpv = mpv_start + (CFRA - sfra); + glVertex3fv(mpv->co); glEnd(); glPointSize(1.0f); @@ -217,26 +217,26 @@ void draw_motion_path_instance(Scene *scene, if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) { unsigned char col[4]; UI_GetThemeColor3ubv(TH_TEXT_HI, col); - col[3]= 255; + col[3] = 255; - for (i=0, mpv=mpv_start; i < len; i+=stepsize, mpv+=stepsize) { + for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) { char numstr[32]; float co[3]; /* only draw framenum if several consecutive highlighted points don't occur on same point */ if (i == 0) { - sprintf(numstr, "%d", (i+sfra)); + sprintf(numstr, "%d", (i + sfra)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col); } - else if ((i > stepsize) && (i < len-stepsize)) { + else if ((i > stepsize) && (i < len - stepsize)) { bMotionPathVert *mpvP = (mpv - stepsize); bMotionPathVert *mpvN = (mpv + stepsize); - if ((equals_v3v3(mpv->co, mpvP->co)==0) || (equals_v3v3(mpv->co, mpvN->co)==0)) { - sprintf(numstr, "%d", (sfra+i)); + if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) { + sprintf(numstr, "%d", (sfra + i)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col); } } } @@ -246,7 +246,7 @@ void draw_motion_path_instance(Scene *scene, if (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) { unsigned char col[4]; - AnimData *adt= BKE_animdata_from_id(&ob->id); + AnimData *adt = BKE_animdata_from_id(&ob->id); DLRBT_Tree keys; /* build list of all keyframes in active action for object or pchan */ @@ -256,8 +256,8 @@ void draw_motion_path_instance(Scene *scene, /* it is assumed that keyframes for bones are all grouped in a single group * unless an option is set to always use the whole action */ - if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT)==0) { - bActionGroup *agrp= action_groups_find_named(adt->action, pchan->name); + if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) { + bActionGroup *agrp = action_groups_find_named(adt->action, pchan->name); if (agrp) { agroup_to_keylist(adt, agrp, &keys, NULL); @@ -272,14 +272,14 @@ void draw_motion_path_instance(Scene *scene, /* Draw slightly-larger yellow dots at each keyframe */ UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col); - col[3]= 255; + col[3] = 255; glPointSize(4.0f); // XXX perhaps a bit too big glColor3ubv(col); glBegin(GL_POINTS); - for (i=0, mpv=mpv_start; i < len; i++, mpv++) { - float mframe= (float)(sfra + i); + for (i = 0, mpv = mpv_start; i < len; i++, mpv++) { + float mframe = (float)(sfra + i); if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) glVertex3fv(mpv->co); @@ -291,15 +291,15 @@ void draw_motion_path_instance(Scene *scene, /* Draw frame numbers of keyframes */ if (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) { float co[3]; - for (i=0, mpv=mpv_start; i < len; i++, mpv++) { - float mframe= (float)(sfra + i); + for (i = 0, mpv = mpv_start; i < len; i++, mpv++) { + float mframe = (float)(sfra + i); if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) { char numstr[32]; - sprintf(numstr, "%d", (sfra+i)); + sprintf(numstr, "%d", (sfra + i)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col); } } } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index fae271e5bee..fec93b3b9aa 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -72,30 +72,30 @@ /* *************** Armature Drawing - Coloring API ***************************** */ /* global here is reset before drawing each bone */ -static ThemeWireColor *bcolor= NULL; +static ThemeWireColor *bcolor = NULL; /* values of colCode for set_pchan_glcolor */ enum { - PCHAN_COLOR_NORMAL = 0, /* normal drawing */ - PCHAN_COLOR_SOLID, /* specific case where "solid" color is needed */ - PCHAN_COLOR_CONSTS, /* "constraint" colors (which may/may-not be suppressed) */ - - PCHAN_COLOR_SPHEREBONE_BASE, /* for the 'stick' of sphere (envelope) bones */ - PCHAN_COLOR_SPHEREBONE_END, /* for the ends of sphere (envelope) bones */ - PCHAN_COLOR_LINEBONE /* for the middle of line-bones */ + PCHAN_COLOR_NORMAL = 0, /* normal drawing */ + PCHAN_COLOR_SOLID, /* specific case where "solid" color is needed */ + PCHAN_COLOR_CONSTS, /* "constraint" colors (which may/may-not be suppressed) */ + + PCHAN_COLOR_SPHEREBONE_BASE, /* for the 'stick' of sphere (envelope) bones */ + PCHAN_COLOR_SPHEREBONE_END, /* for the ends of sphere (envelope) bones */ + PCHAN_COLOR_LINEBONE /* for the middle of line-bones */ }; /* This function sets the color-set for coloring a certain bone */ -static void set_pchan_colorset (Object *ob, bPoseChannel *pchan) +static void set_pchan_colorset(Object *ob, bPoseChannel *pchan) { - bPose *pose= (ob) ? ob->pose : NULL; - bArmature *arm= (ob) ? ob->data : NULL; - bActionGroup *grp= NULL; - short color_index= 0; + bPose *pose = (ob) ? ob->pose : NULL; + bArmature *arm = (ob) ? ob->data : NULL; + bActionGroup *grp = NULL; + short color_index = 0; /* sanity check */ if (ELEM4(NULL, ob, arm, pose, pchan)) { - bcolor= NULL; + bcolor = NULL; return; } @@ -105,9 +105,9 @@ static void set_pchan_colorset (Object *ob, bPoseChannel *pchan) * has been set to use one */ if (pchan->agrp_index) { - grp= (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); + grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); if (grp) - color_index= grp->customCol; + color_index = grp->customCol; } } @@ -115,181 +115,181 @@ static void set_pchan_colorset (Object *ob, bPoseChannel *pchan) * color set (based on the theme colors for 3d-view) is used. */ if (color_index > 0) { - bTheme *btheme= UI_GetTheme(); - bcolor= &btheme->tarm[(color_index - 1)]; + bTheme *btheme = UI_GetTheme(); + bcolor = &btheme->tarm[(color_index - 1)]; } else if (color_index == -1) { /* use the group's own custom color set */ - bcolor= (grp)? &grp->cs : NULL; + bcolor = (grp) ? &grp->cs : NULL; } else - bcolor= NULL; + bcolor = NULL; } /* This function is for brightening/darkening a given color (like UI_ThemeColorShade()) */ -static void cp_shade_color3ub (unsigned char cp[3], const int offset) +static void cp_shade_color3ub(unsigned char cp[3], const int offset) { int r, g, b; - r= offset + (int) cp[0]; + r = offset + (int) cp[0]; CLAMP(r, 0, 255); - g= offset + (int) cp[1]; + g = offset + (int) cp[1]; CLAMP(g, 0, 255); - b= offset + (int) cp[2]; + b = offset + (int) cp[2]; CLAMP(b, 0, 255); - cp[0]= r; - cp[1]= g; - cp[2]= b; + cp[0] = r; + cp[1] = g; + cp[2] = b; } /* This function sets the gl-color for coloring a certain bone (based on bcolor) */ -static short set_pchan_glColor (short colCode, int boneflag, short constflag) +static short set_pchan_glColor(short colCode, int boneflag, short constflag) { switch (colCode) { - case PCHAN_COLOR_NORMAL: - { - if (bcolor) { - unsigned char cp[3]; + case PCHAN_COLOR_NORMAL: + { + if (bcolor) { + unsigned char cp[3]; - if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); - if (!(boneflag & BONE_SELECTED)) { - cp_shade_color3ub(cp, -80); + if (boneflag & BONE_DRAW_ACTIVE) { + copy_v3_v3_char((char *)cp, bcolor->active); + if (!(boneflag & BONE_SELECTED)) { + cp_shade_color3ub(cp, -80); + } + } + else if (boneflag & BONE_SELECTED) { + copy_v3_v3_char((char *)cp, bcolor->select); + } + else { + /* a bit darker than solid */ + copy_v3_v3_char((char *)cp, bcolor->solid); + cp_shade_color3ub(cp, -50); } - } - else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); - } - else { - /* a bit darker than solid */ - copy_v3_v3_char((char *)cp, bcolor->solid); - cp_shade_color3ub(cp, -50); - } - glColor3ubv(cp); - } - else { - if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) { - UI_ThemeColorShade(TH_BONE_POSE, 40); - } - else if (boneflag & BONE_DRAW_ACTIVE) { - UI_ThemeColorBlend(TH_WIRE, TH_BONE_POSE, 0.15f); /* unselected active */ - } - else if (boneflag & BONE_SELECTED) { - UI_ThemeColor(TH_BONE_POSE); + glColor3ubv(cp); } else { - UI_ThemeColor(TH_WIRE); + if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) { + UI_ThemeColorShade(TH_BONE_POSE, 40); + } + else if (boneflag & BONE_DRAW_ACTIVE) { + UI_ThemeColorBlend(TH_WIRE, TH_BONE_POSE, 0.15f); /* unselected active */ + } + else if (boneflag & BONE_SELECTED) { + UI_ThemeColor(TH_BONE_POSE); + } + else { + UI_ThemeColor(TH_WIRE); + } } - } - - return 1; - } - break; - case PCHAN_COLOR_SOLID: - { - if (bcolor) { - glColor3ubv((unsigned char *)bcolor->solid); + return 1; } - else - UI_ThemeColor(TH_BONE_SOLID); - - return 1; - } break; - case PCHAN_COLOR_CONSTS: - { - if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { - if (constflag & PCHAN_HAS_TARGET) glColor4ub(255, 150, 0, 80); - else if (constflag & PCHAN_HAS_IK) glColor4ub(255, 255, 0, 80); - else if (constflag & PCHAN_HAS_SPLINEIK) glColor4ub(200, 255, 0, 80); - else if (constflag & PCHAN_HAS_CONST) glColor4ub(0, 255, 120, 80); + case PCHAN_COLOR_SOLID: + { + if (bcolor) { + glColor3ubv((unsigned char *)bcolor->solid); + } + else + UI_ThemeColor(TH_BONE_SOLID); return 1; } - else - return 0; - } break; - case PCHAN_COLOR_SPHEREBONE_BASE: - { - if (bcolor) { - unsigned char cp[3]; + case PCHAN_COLOR_CONSTS: + { + if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { + if (constflag & PCHAN_HAS_TARGET) glColor4ub(255, 150, 0, 80); + else if (constflag & PCHAN_HAS_IK) glColor4ub(255, 255, 0, 80); + else if (constflag & PCHAN_HAS_SPLINEIK) glColor4ub(200, 255, 0, 80); + else if (constflag & PCHAN_HAS_CONST) glColor4ub(0, 255, 120, 80); - if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); + return 1; } - else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); + else + return 0; + } + break; + + case PCHAN_COLOR_SPHEREBONE_BASE: + { + if (bcolor) { + unsigned char cp[3]; + + if (boneflag & BONE_DRAW_ACTIVE) { + copy_v3_v3_char((char *)cp, bcolor->active); + } + else if (boneflag & BONE_SELECTED) { + copy_v3_v3_char((char *)cp, bcolor->select); + } + else { + copy_v3_v3_char((char *)cp, bcolor->solid); + } + + glColor3ubv(cp); } else { - copy_v3_v3_char((char *)cp, bcolor->solid); + if (boneflag & BONE_DRAW_ACTIVE) UI_ThemeColorShade(TH_BONE_POSE, 40); + else if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_BONE_POSE); + else UI_ThemeColor(TH_BONE_SOLID); } - glColor3ubv(cp); - } - else { - if (boneflag & BONE_DRAW_ACTIVE) UI_ThemeColorShade(TH_BONE_POSE, 40); - else if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_BONE_POSE); - else UI_ThemeColor(TH_BONE_SOLID); + return 1; } - - return 1; - } break; - case PCHAN_COLOR_SPHEREBONE_END: - { - if (bcolor) { - unsigned char cp[3]; + case PCHAN_COLOR_SPHEREBONE_END: + { + if (bcolor) { + unsigned char cp[3]; + + if (boneflag & BONE_DRAW_ACTIVE) { + copy_v3_v3_char((char *)cp, bcolor->active); + cp_shade_color3ub(cp, 10); + } + else if (boneflag & BONE_SELECTED) { + copy_v3_v3_char((char *)cp, bcolor->select); + cp_shade_color3ub(cp, -30); + } + else { + copy_v3_v3_char((char *)cp, bcolor->solid); + cp_shade_color3ub(cp, -30); + } - if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); - cp_shade_color3ub(cp, 10); - } - else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); - cp_shade_color3ub(cp, -30); + glColor3ubv(cp); } else { - copy_v3_v3_char((char *)cp, bcolor->solid); - cp_shade_color3ub(cp, -30); + if (boneflag & BONE_DRAW_ACTIVE) UI_ThemeColorShade(TH_BONE_POSE, 10); + else if (boneflag & BONE_SELECTED) UI_ThemeColorShade(TH_BONE_POSE, -30); + else UI_ThemeColorShade(TH_BONE_SOLID, -30); } - - glColor3ubv(cp); - } - else { - if (boneflag & BONE_DRAW_ACTIVE) UI_ThemeColorShade(TH_BONE_POSE, 10); - else if (boneflag & BONE_SELECTED) UI_ThemeColorShade(TH_BONE_POSE, -30); - else UI_ThemeColorShade(TH_BONE_SOLID, -30); } - } break; - case PCHAN_COLOR_LINEBONE: - { - /* inner part in background color or constraint */ - if ( (constflag) && ((bcolor==NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) ) { - if (constflag & PCHAN_HAS_TARGET) glColor3ub(255, 150, 0); - else if (constflag & PCHAN_HAS_IK) glColor3ub(255, 255, 0); - else if (constflag & PCHAN_HAS_SPLINEIK) glColor3ub(200, 255, 0); - else if (constflag & PCHAN_HAS_CONST) glColor3ub(0, 255, 120); - else if (constflag) UI_ThemeColor(TH_BONE_POSE); /* PCHAN_HAS_ACTION */ - } - else { - if (bcolor) { - char *cp= bcolor->solid; - glColor4ub(cp[0], cp[1], cp[2], 204); + case PCHAN_COLOR_LINEBONE: + { + /* inner part in background color or constraint */ + if ( (constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) ) { + if (constflag & PCHAN_HAS_TARGET) glColor3ub(255, 150, 0); + else if (constflag & PCHAN_HAS_IK) glColor3ub(255, 255, 0); + else if (constflag & PCHAN_HAS_SPLINEIK) glColor3ub(200, 255, 0); + else if (constflag & PCHAN_HAS_CONST) glColor3ub(0, 255, 120); + else if (constflag) UI_ThemeColor(TH_BONE_POSE); /* PCHAN_HAS_ACTION */ + } + else { + if (bcolor) { + char *cp = bcolor->solid; + glColor4ub(cp[0], cp[1], cp[2], 204); + } + else + UI_ThemeColorShade(TH_BACK, -30); } - else - UI_ThemeColorShade(TH_BACK, -30); - } - return 1; - } + return 1; + } break; } @@ -316,48 +316,48 @@ static void set_ebone_glColor(const unsigned int boneflag) /* half the cube, in Y */ static float cube[8][3] = { -{-1.0, 0.0, -1.0}, -{-1.0, 0.0, 1.0}, -{-1.0, 1.0, 1.0}, -{-1.0, 1.0, -1.0}, -{ 1.0, 0.0, -1.0}, -{ 1.0, 0.0, 1.0}, -{ 1.0, 1.0, 1.0}, -{ 1.0, 1.0, -1.0}, + {-1.0, 0.0, -1.0}, + {-1.0, 0.0, 1.0}, + {-1.0, 1.0, 1.0}, + {-1.0, 1.0, -1.0}, + { 1.0, 0.0, -1.0}, + { 1.0, 0.0, 1.0}, + { 1.0, 1.0, 1.0}, + { 1.0, 1.0, -1.0}, }; static void drawsolidcube_size(float xsize, float ysize, float zsize) { - static GLuint displist=0; - float n[3]= {0.0f}; + static GLuint displist = 0; + float n[3] = {0.0f}; glScalef(xsize, ysize, zsize); - if (displist==0) { - displist= glGenLists(1); + if (displist == 0) { + displist = glGenLists(1); glNewList(displist, GL_COMPILE); glBegin(GL_QUADS); - n[0]= -1.0; + n[0] = -1.0; glNormal3fv(n); glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); - n[0]=0; - n[1]= -1.0; + n[0] = 0; + n[1] = -1.0; glNormal3fv(n); glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[1]); - n[1]=0; - n[0]= 1.0; + n[1] = 0; + n[0] = 1.0; glNormal3fv(n); glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glVertex3fv(cube[5]); - n[0]=0; - n[1]= 1.0; + n[0] = 0; + n[1] = 1.0; glNormal3fv(n); glVertex3fv(cube[7]); glVertex3fv(cube[3]); glVertex3fv(cube[2]); glVertex3fv(cube[6]); - n[1]=0; - n[2]= 1.0; + n[1] = 0; + n[2] = 1.0; glNormal3fv(n); glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]); - n[2]= -1.0; + n[2] = -1.0; glNormal3fv(n); glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]); glEnd(); @@ -370,15 +370,15 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) static void drawcube_size(float xsize, float ysize, float zsize) { - static GLuint displist=0; + static GLuint displist = 0; if (displist == 0) { - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); glBegin(GL_LINE_STRIP); - glVertex3fv(cube[0]); glVertex3fv(cube[1]);glVertex3fv(cube[2]); glVertex3fv(cube[3]); - glVertex3fv(cube[0]); glVertex3fv(cube[4]);glVertex3fv(cube[5]); glVertex3fv(cube[6]); + glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); + glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[7]); glVertex3fv(cube[4]); glEnd(); @@ -399,17 +399,17 @@ static void drawcube_size(float xsize, float ysize, float zsize) static void draw_bonevert(void) { - static GLuint displist=0; + static GLuint displist = 0; if (displist == 0) { - GLUquadricObj *qobj; + GLUquadricObj *qobj; - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); glPushMatrix(); - qobj = gluNewQuadric(); + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0.0, 0.05, 16, 1); @@ -430,15 +430,15 @@ static void draw_bonevert(void) static void draw_bonevert_solid(void) { - static GLuint displist=0; + static GLuint displist = 0; if (displist == 0) { - GLUquadricObj *qobj; + GLUquadricObj *qobj; - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - qobj = gluNewQuadric(); + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); glShadeModel(GL_SMOOTH); gluSphere(qobj, 0.05, 8, 5); @@ -451,7 +451,7 @@ static void draw_bonevert_solid(void) glCallList(displist); } -static float bone_octahedral_verts[6][3]= { +static float bone_octahedral_verts[6][3] = { { 0.0f, 0.0f, 0.0f}, { 0.1f, 0.1f, 0.1f}, { 0.1f, 0.1f, -0.1f}, @@ -460,10 +460,10 @@ static float bone_octahedral_verts[6][3]= { { 0.0f, 1.0f, 0.0f} }; -static unsigned int bone_octahedral_wire_sides[8]= {0, 1, 5, 3, 0, 4, 5, 2}; -static unsigned int bone_octahedral_wire_square[8]= {1, 2, 3, 4, 1}; +static unsigned int bone_octahedral_wire_sides[8] = {0, 1, 5, 3, 0, 4, 5, 2}; +static unsigned int bone_octahedral_wire_square[8] = {1, 2, 3, 4, 1}; -static unsigned int bone_octahedral_solid_tris[8][3]= { +static unsigned int bone_octahedral_solid_tris[8][3] = { {2, 1, 0}, /* bottom */ {3, 2, 0}, {4, 3, 0}, @@ -476,7 +476,7 @@ static unsigned int bone_octahedral_solid_tris[8][3]= { }; /* aligned with bone_octahedral_solid_tris */ -static float bone_octahedral_solid_normals[8][3]= { +static float bone_octahedral_solid_normals[8][3] = { { 0.70710683f, -0.70710683f, 0.00000000f}, {-0.00000000f, -0.70710683f, -0.70710683f}, {-0.70710683f, -0.70710683f, 0.00000000f}, @@ -489,23 +489,23 @@ static float bone_octahedral_solid_normals[8][3]= { static void draw_bone_octahedral(void) { - static GLuint displist=0; + static GLuint displist = 0; if (displist == 0) { - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); /* Section 1, sides */ glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, bone_octahedral_verts); glDrawElements(GL_LINE_LOOP, - sizeof(bone_octahedral_wire_sides)/sizeof(*bone_octahedral_wire_sides), + sizeof(bone_octahedral_wire_sides) / sizeof(*bone_octahedral_wire_sides), GL_UNSIGNED_INT, bone_octahedral_wire_sides); /* Section 1, square */ glDrawElements(GL_LINE_LOOP, - sizeof(bone_octahedral_wire_square)/sizeof(*bone_octahedral_wire_square), + sizeof(bone_octahedral_wire_square) / sizeof(*bone_octahedral_wire_square), GL_UNSIGNED_INT, bone_octahedral_wire_square); glDisableClientState(GL_VERTEX_ARRAY); @@ -518,17 +518,17 @@ static void draw_bone_octahedral(void) static void draw_bone_solid_octahedral(void) { - static GLuint displist=0; + static GLuint displist = 0; if (displist == 0) { int i; - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); #if 1 glBegin(GL_TRIANGLES); - for (i= 0; i < 8; i++) { + for (i = 0; i < 8; i++) { glNormal3fv(bone_octahedral_solid_normals[i]); glVertex3fv(bone_octahedral_verts[bone_octahedral_solid_tris[i][0]]); glVertex3fv(bone_octahedral_verts[bone_octahedral_solid_tris[i][1]]); @@ -537,12 +537,12 @@ static void draw_bone_solid_octahedral(void) glEnd(); -#else /* not working because each vert needs a different normal */ +#else /* not working because each vert needs a different normal */ glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glNormalPointer(GL_FLOAT, 0, bone_octahedral_solid_normals); glVertexPointer(3, GL_FLOAT, 0, bone_octahedral_verts); - glDrawElements(GL_TRIANGLES, sizeof(bone_octahedral_solid_tris)/sizeof(unsigned int), + glDrawElements(GL_TRIANGLES, sizeof(bone_octahedral_solid_tris) / sizeof(unsigned int), GL_UNSIGNED_INT, bone_octahedral_solid_tris); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); @@ -560,7 +560,7 @@ static void draw_bone_solid_octahedral(void) static void draw_bone_points(int dt, int armflag, unsigned int boneflag, int id) { /* Draw root point if we are not connected */ - if ((boneflag & BONE_CONNECTED)==0) { + if ((boneflag & BONE_CONNECTED) == 0) { if (id != -1) glLoadName(id | BONESEL_ROOT); @@ -622,7 +622,7 @@ static float si[16] = { 0.10116832f }; /* 16 values of cos function (still same result!) */ -static float co[16] ={ +static float co[16] = { 1.00000000f, 0.97952994f, 0.91895781f, 0.82076344f, 0.68896691f, @@ -648,25 +648,25 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel ebone->length = len_v3v3(ebone->head, ebone->tail); /*length= ebone->length;*/ /*UNUSED*/ - tail= ebone->rad_tail; - dist= ebone->dist; + tail = ebone->rad_tail; + dist = ebone->dist; if (ebone->parent && (ebone->flag & BONE_CONNECTED)) - head= ebone->parent->rad_tail; + head = ebone->parent->rad_tail; else - head= ebone->rad_head; - headvec= ebone->head; - tailvec= ebone->tail; + head = ebone->rad_head; + headvec = ebone->head; + tailvec = ebone->tail; } else { /*length= pchan->bone->length;*/ /*UNUSED*/ - tail= pchan->bone->rad_tail; - dist= pchan->bone->dist; + tail = pchan->bone->rad_tail; + dist = pchan->bone->dist; if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) - head= pchan->parent->bone->rad_tail; + head = pchan->parent->bone->rad_tail; else - head= pchan->bone->rad_head; - headvec= pchan->pose_head; - tailvec= pchan->pose_tail; + head = pchan->bone->rad_head; + headvec = pchan->pose_head; + tailvec = pchan->pose_tail; } /* ***** draw it ***** */ @@ -675,24 +675,24 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel sub_v3_v3v3(dirvec, tailvec, headvec); mul_mat3_m4_v3(smat, dirvec); /* clear zcomp */ - dirvec[2]= 0.0f; + dirvec[2] = 0.0f; if (head != tail) { - /* correction when viewing along the bones axis - * it pops in and out but better then artifacts, [#23841] */ - float view_dist= len_v2(dirvec); + /* correction when viewing along the bones axis + * it pops in and out but better then artifacts, [#23841] */ + float view_dist = len_v2(dirvec); if (head - view_dist > tail) { - tailvec= headvec; + tailvec = headvec; tail = head; zero_v3(dirvec); - dirvec[0]= 0.00001; // XXX. weak but ok + dirvec[0] = 0.00001; // XXX. weak but ok } else if (tail - view_dist > head) { - headvec= tailvec; + headvec = tailvec; head = tail; zero_v3(dirvec); - dirvec[0]= 0.00001; // XXX. weak but ok + dirvec[0] = 0.00001; // XXX. weak but ok } } @@ -708,10 +708,10 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel glBegin(GL_QUAD_STRIP); - for (a=0; a<16; a++) { - vec[0]= - *(si+a) * dirvec[0] + *(co+a) * norvec[0]; - vec[1]= - *(si+a) * dirvec[1] + *(co+a) * norvec[1]; - vec[2]= - *(si+a) * dirvec[2] + *(co+a) * norvec[2]; + for (a = 0; a < 16; a++) { + vec[0] = -*(si + a) * dirvec[0] + *(co + a) * norvec[0]; + vec[1] = -*(si + a) * dirvec[1] + *(co + a) * norvec[1]; + vec[2] = -*(si + a) * dirvec[2] + *(co + a) * norvec[2]; madd_v3_v3v3fl(vec1, headvec, vec, head); madd_v3_v3v3fl(vec2, headvec, vec, head + dist); @@ -722,10 +722,10 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel glVertex3fv(vec2); } - for (a=15; a>=0; a--) { - vec[0]= *(si+a) * dirvec[0] + *(co+a) * norvec[0]; - vec[1]= *(si+a) * dirvec[1] + *(co+a) * norvec[1]; - vec[2]= *(si+a) * dirvec[2] + *(co+a) * norvec[2]; + for (a = 15; a >= 0; a--) { + vec[0] = *(si + a) * dirvec[0] + *(co + a) * norvec[0]; + vec[1] = *(si + a) * dirvec[1] + *(co + a) * norvec[1]; + vec[2] = *(si + a) * dirvec[2] + *(co + a) * norvec[2]; madd_v3_v3v3fl(vec1, tailvec, vec, tail); madd_v3_v3v3fl(vec2, tailvec, vec, tail + dist); @@ -737,9 +737,9 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel } /* make it cyclic... */ - vec[0]= - *(si) * dirvec[0] + *(co) * norvec[0]; - vec[1]= - *(si) * dirvec[1] + *(co) * norvec[1]; - vec[2]= - *(si) * dirvec[2] + *(co) * norvec[2]; + vec[0] = -*(si) * dirvec[0] + *(co) * norvec[0]; + vec[1] = -*(si) * dirvec[1] + *(co) * norvec[1]; + vec[2] = -*(si) * dirvec[2] + *(co) * norvec[2]; madd_v3_v3v3fl(vec1, headvec, vec, head); madd_v3_v3v3fl(vec2, headvec, vec, head + dist); @@ -768,23 +768,23 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], ebone->length = len_v3v3(ebone->head, ebone->tail); /*length= ebone->length;*/ /*UNUSED*/ - tail= ebone->rad_tail; + tail = ebone->rad_tail; if (ebone->parent && (boneflag & BONE_CONNECTED)) - head= ebone->parent->rad_tail; + head = ebone->parent->rad_tail; else - head= ebone->rad_head; - headvec= ebone->head; - tailvec= ebone->tail; + head = ebone->rad_head; + headvec = ebone->head; + tailvec = ebone->tail; } else { /*length= pchan->bone->length;*/ /*UNUSED*/ - tail= pchan->bone->rad_tail; + tail = pchan->bone->rad_tail; if ((pchan->parent) && (boneflag & BONE_CONNECTED)) - head= pchan->parent->bone->rad_tail; + head = pchan->parent->bone->rad_tail; else - head= pchan->bone->rad_head; - headvec= pchan->pose_head; - tailvec= pchan->pose_tail; + head = pchan->bone->rad_head; + headvec = pchan->pose_head; + tailvec = pchan->pose_tail; } /* sphere root color */ @@ -796,7 +796,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); /* Draw root point if we are not connected */ - if ((boneflag & BONE_CONNECTED)==0) { + if ((boneflag & BONE_CONNECTED) == 0) { if (id != -1) glLoadName(id | BONESEL_ROOT); @@ -825,7 +825,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], /* move vector to viewspace */ mul_mat3_m4_v3(smat, dirvec); /* clear zcomp */ - dirvec[2]= 0.0f; + dirvec[2] = 0.0f; /* move vector back */ mul_mat3_m4_v3(imat, dirvec); @@ -865,35 +865,35 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], static void draw_sphere_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone) { - GLUquadricObj *qobj; + GLUquadricObj *qobj; float head, tail, length; float fac1, fac2; glPushMatrix(); - qobj = gluNewQuadric(); + qobj = gluNewQuadric(); /* figure out the sizes of spheres */ if (ebone) { - length= ebone->length; - tail= ebone->rad_tail; + length = ebone->length; + tail = ebone->rad_tail; if (ebone->parent && (boneflag & BONE_CONNECTED)) - head= ebone->parent->rad_tail; + head = ebone->parent->rad_tail; else - head= ebone->rad_head; + head = ebone->rad_head; } else { - length= pchan->bone->length; - tail= pchan->bone->rad_tail; + length = pchan->bone->length; + tail = pchan->bone->rad_tail; if (pchan->parent && (boneflag & BONE_CONNECTED)) - head= pchan->parent->bone->rad_tail; + head = pchan->parent->bone->rad_tail; else - head= pchan->bone->rad_head; + head = pchan->bone->rad_head; } /* move to z-axis space */ glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); - if (dt==OB_SOLID) { + if (dt == OB_SOLID) { /* set up solid drawing */ glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); @@ -912,11 +912,11 @@ static void draw_sphere_bone(int dt, int armflag, int boneflag, short constflag, } else if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_SPHEREBONE_END, boneflag, constflag); - else if (dt==OB_SOLID) + else if (dt == OB_SOLID) UI_ThemeColorShade(TH_BONE_SOLID, -30); /* Draw root point if we are not connected */ - if ((boneflag & BONE_CONNECTED)==0) { + if ((boneflag & BONE_CONNECTED) == 0) { if (id != -1) glLoadName(id | BONESEL_ROOT); gluSphere(qobj, head, 16, 10); @@ -945,38 +945,38 @@ static void draw_sphere_bone(int dt, int armflag, int boneflag, short constflag, else if (dt == OB_SOLID) UI_ThemeColor(TH_BONE_SOLID); - fac1= (length-head)/length; - fac2= (length-tail)/length; + fac1 = (length - head) / length; + fac2 = (length - tail) / length; - if (length > (head+tail)) { + if (length > (head + tail)) { if (id != -1) - glLoadName (id | BONESEL_BONE); + glLoadName(id | BONESEL_BONE); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -1.0f); glTranslatef(0.0f, 0.0f, head); - gluCylinder(qobj, fac1*head + (1.0f-fac1)*tail, fac2*tail + (1.0f-fac2)*head, length-head-tail, 16, 1); + gluCylinder(qobj, fac1 * head + (1.0f - fac1) * tail, fac2 * tail + (1.0f - fac2) * head, length - head - tail, 16, 1); glTranslatef(0.0f, 0.0f, -head); glDisable(GL_POLYGON_OFFSET_FILL); /* draw sphere on extrema */ - glTranslatef(0.0f, 0.0f, length-tail); - gluSphere(qobj, fac2*tail + (1.0f-fac2)*head, 16, 10); - glTranslatef(0.0f, 0.0f, -length+tail); + glTranslatef(0.0f, 0.0f, length - tail); + gluSphere(qobj, fac2 * tail + (1.0f - fac2) * head, 16, 10); + glTranslatef(0.0f, 0.0f, -length + tail); glTranslatef(0.0f, 0.0f, head); - gluSphere(qobj, fac1*head + (1.0f-fac1)*tail, 16, 10); + gluSphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10); } else { /* 1 sphere in center */ - glTranslatef(0.0f, 0.0f, (head + length-tail)/2.0f); - gluSphere(qobj, fac1*head + (1.0f-fac1)*tail, 16, 10); + glTranslatef(0.0f, 0.0f, (head + length - tail) / 2.0f); + gluSphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10); } /* restore */ - if (dt==OB_SOLID) { + if (dt == OB_SOLID) { glShadeModel(GL_FLAT); glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); @@ -986,11 +986,11 @@ static void draw_sphere_bone(int dt, int armflag, int boneflag, short constflag, gluDeleteQuadric(qobj); } -static GLubyte bm_dot6[]= {0x0, 0x18, 0x3C, 0x7E, 0x7E, 0x3C, 0x18, 0x0}; -static GLubyte bm_dot8[]= {0x3C, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C}; +static GLubyte bm_dot6[] = {0x0, 0x18, 0x3C, 0x7E, 0x7E, 0x3C, 0x18, 0x0}; +static GLubyte bm_dot8[] = {0x3C, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C}; -static GLubyte bm_dot5[]= {0x0, 0x0, 0x10, 0x38, 0x7c, 0x38, 0x10, 0x0}; -static GLubyte bm_dot7[]= {0x0, 0x38, 0x7C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38}; +static GLubyte bm_dot5[] = {0x0, 0x0, 0x10, 0x38, 0x7c, 0x38, 0x10, 0x0}; +static GLubyte bm_dot7[] = {0x0, 0x38, 0x7C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38}; static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned int id, @@ -1001,15 +1001,15 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glPixelStorei(GL_UNPACK_ALIGNMENT, 1); if (pchan) - length= pchan->bone->length; + length = pchan->bone->length; else - length= ebone->length; + length = ebone->length; glPushMatrix(); glScalef(length, length, length); /* this chunk not in object mode */ - if (armflag & (ARM_EDITMODE|ARM_POSEMODE)) { + if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) { glLineWidth(4.0f); if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); @@ -1018,9 +1018,9 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned } /* Draw root point if we are not connected */ - if ((boneflag & BONE_CONNECTED)==0) { - if (G.f & G_PICKSEL) { // no bitmap in selection mode, crashes 3d cards... - glLoadName (id | BONESEL_ROOT); + if ((boneflag & BONE_CONNECTED) == 0) { + if (G.f & G_PICKSEL) { // no bitmap in selection mode, crashes 3d cards... + glLoadName(id | BONESEL_ROOT); glBegin(GL_POINTS); glVertex3f(0.0f, 0.0f, 0.0f); glEnd(); @@ -1032,7 +1032,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned } if (id != -1) - glLoadName((GLuint) id|BONESEL_BONE); + glLoadName((GLuint) id | BONESEL_BONE); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); @@ -1054,7 +1054,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned /* further we send no names */ if (id != -1) - glLoadName(id & 0xFFFF); /* object tag, for bordersel optim */ + glLoadName(id & 0xFFFF); /* object tag, for bordersel optim */ if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_LINEBONE, boneflag, constflag); @@ -1063,8 +1063,8 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glLineWidth(2.0); /*Draw root point if we are not connected */ - if ((boneflag & BONE_CONNECTED)==0) { - if ((G.f & G_PICKSEL)==0) { + if ((boneflag & BONE_CONNECTED) == 0) { + if ((G.f & G_PICKSEL) == 0) { /* no bitmap in selection mode, crashes 3d cards... */ if (armflag & ARM_EDITMODE) { if (boneflag & BONE_ROOTSEL) UI_ThemeColor(TH_VERTEX_SELECT); @@ -1085,7 +1085,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glEnd(); /* tip */ - if ((G.f & G_PICKSEL)==0) { + if ((G.f & G_PICKSEL) == 0) { /* no bitmap in selection mode, crashes 3d cards... */ if (armflag & ARM_EDITMODE) { if (boneflag & BONE_TIPSEL) UI_ThemeColor(TH_VERTEX_SELECT); @@ -1102,27 +1102,27 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned static void draw_b_bone_boxes(int dt, bPoseChannel *pchan, float xwidth, float length, float zwidth) { - int segments= 0; + int segments = 0; if (pchan) - segments= pchan->bone->segments; + segments = pchan->bone->segments; if ((segments > 1) && (pchan)) { - float dlen= length/(float)segments; - Mat4 *bbone= b_bone_spline_setup(pchan, 0); + float dlen = length / (float)segments; + Mat4 *bbone = b_bone_spline_setup(pchan, 0); int a; - for (a=0; a<segments; a++, bbone++) { + for (a = 0; a < segments; a++, bbone++) { glPushMatrix(); glMultMatrixf(bbone->mat); - if (dt==OB_SOLID) drawsolidcube_size(xwidth, dlen, zwidth); + if (dt == OB_SOLID) drawsolidcube_size(xwidth, dlen, zwidth); else drawcube_size(xwidth, dlen, zwidth); glPopMatrix(); } } else { glPushMatrix(); - if (dt==OB_SOLID) drawsolidcube_size(xwidth, length, zwidth); + if (dt == OB_SOLID) drawsolidcube_size(xwidth, length, zwidth); else drawcube_size(xwidth, length, zwidth); glPopMatrix(); } @@ -1134,14 +1134,14 @@ static void draw_b_bone(int dt, int armflag, int boneflag, short constflag, unsi float xwidth, length, zwidth; if (pchan) { - xwidth= pchan->bone->xwidth; - length= pchan->bone->length; - zwidth= pchan->bone->zwidth; + xwidth = pchan->bone->xwidth; + length = pchan->bone->length; + zwidth = pchan->bone->zwidth; } else { - xwidth= ebone->xwidth; - length= ebone->length; - zwidth= ebone->zwidth; + xwidth = ebone->xwidth; + length = ebone->length; + zwidth = ebone->zwidth; } /* draw points only if... */ @@ -1151,7 +1151,7 @@ static void draw_b_bone(int dt, int armflag, int boneflag, short constflag, unsi glScalef(length, length, length); draw_bone_points(dt, armflag, boneflag, id); glPopMatrix(); - length*= 0.95f; // make vertices visible + length *= 0.95f; // make vertices visible } /* colors for modes */ @@ -1162,7 +1162,7 @@ static void draw_b_bone(int dt, int armflag, int boneflag, short constflag, unsi set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag); } else if (armflag & ARM_EDITMODE) { - if (dt==OB_WIRE) { + if (dt == OB_WIRE) { set_ebone_glColor(boneflag); } else @@ -1170,7 +1170,7 @@ static void draw_b_bone(int dt, int armflag, int boneflag, short constflag, unsi } if (id != -1) { - glLoadName ((GLuint) id|BONESEL_BONE); + glLoadName((GLuint) id | BONESEL_BONE); } /* set up solid drawing */ @@ -1214,11 +1214,11 @@ static void draw_b_bone(int dt, int armflag, int boneflag, short constflag, unsi static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float length, int segments) { if ((segments > 1) && (pchan)) { - float dlen= length/(float)segments; + float dlen = length / (float)segments; Mat4 *bbone = bbones; int a; - for (a=0; a<segments; a++, bbone++) { + for (a = 0; a < segments; a++, bbone++) { glPushMatrix(); glMultMatrixf(bbone->mat); @@ -1250,14 +1250,14 @@ static void draw_wire_bone(int dt, int armflag, int boneflag, short constflag, u float length; if (pchan) { - segments= pchan->bone->segments; - length= pchan->bone->length; + segments = pchan->bone->segments; + length = pchan->bone->length; if (segments > 1) bbones = b_bone_spline_setup(pchan, 0); } else - length= ebone->length; + length = ebone->length; /* draw points only if... */ if (armflag & ARM_EDITMODE) { @@ -1266,19 +1266,19 @@ static void draw_wire_bone(int dt, int armflag, int boneflag, short constflag, u glScalef(length, length, length); draw_bone_points(dt, armflag, boneflag, id); glPopMatrix(); - length *= 0.95f; // make vertices visible + length *= 0.95f; // make vertices visible } /* this chunk not in object mode */ - if (armflag & (ARM_EDITMODE|ARM_POSEMODE)) { + if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) { if (id != -1) - glLoadName((GLuint) id|BONESEL_BONE); + glLoadName((GLuint) id | BONESEL_BONE); draw_wire_bone_segments(pchan, bbones, length, segments); /* further we send no names */ if (id != -1) - glLoadName(id & 0xFFFF); /* object tag, for bordersel optim */ + glLoadName(id & 0xFFFF); /* object tag, for bordersel optim */ } /* colors for modes */ @@ -1321,7 +1321,7 @@ static void draw_bone(int dt, int armflag, int boneflag, short constflag, unsign /* now draw the bone itself */ if (id != -1) { - glLoadName((GLuint) id|BONESEL_BONE); + glLoadName((GLuint) id | BONESEL_BONE); } /* wire? */ @@ -1366,7 +1366,7 @@ static void draw_bone(int dt, int armflag, int boneflag, short constflag, unsign static void draw_custom_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int dt, int armflag, int boneflag, unsigned int id, float length) { - if (ob==NULL) return; + if (ob == NULL) return; glScalef(length, length, length); @@ -1376,7 +1376,7 @@ static void draw_custom_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obje } if (id != -1) { - glLoadName((GLuint) id|BONESEL_BONE); + glLoadName((GLuint) id | BONESEL_BONE); } draw_object_instance(scene, v3d, rv3d, ob, dt, armflag & ARM_POSEMODE); @@ -1388,15 +1388,15 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) bConstraint *con; bPoseChannel *parchan; - for (con= pchan->constraints.first; con; con= con->next) { + for (con = pchan->constraints.first; con; con = con->next) { if (con->enforce == 0.0f) continue; switch (con->type) { case CONSTRAINT_TYPE_KINEMATIC: { - bKinematicConstraint *data = (bKinematicConstraint*)con->data; - int segcount= 0; + bKinematicConstraint *data = (bKinematicConstraint *)con->data; + int segcount = 0; /* if only_temp, only draw if it is a temporary ik-chain */ if ((only_temp) && !(data->flag & CONSTRAINT_IK_TEMP)) @@ -1406,18 +1406,18 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) glBegin(GL_LINES); /* exclude tip from chain? */ - if ((data->flag & CONSTRAINT_IK_TIP)==0) - parchan= pchan->parent; + if ((data->flag & CONSTRAINT_IK_TIP) == 0) + parchan = pchan->parent; else - parchan= pchan; + parchan = pchan; glVertex3fv(parchan->pose_tail); /* Find the chain's root */ while (parchan->parent) { segcount++; - if (segcount==data->rootbone || segcount>255) break; // 255 is weak - parchan= parchan->parent; + if (segcount == data->rootbone || segcount > 255) break; // 255 is weak + parchan = parchan->parent; } if (parchan) glVertex3fv(parchan->pose_head); @@ -1425,24 +1425,24 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) glEnd(); setlinestyle(0); } - break; + break; case CONSTRAINT_TYPE_SPLINEIK: { - bSplineIKConstraint *data = (bSplineIKConstraint*)con->data; - int segcount= 0; + bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; + int segcount = 0; setlinestyle(3); glBegin(GL_LINES); - parchan= pchan; + parchan = pchan; glVertex3fv(parchan->pose_tail); /* Find the chain's root */ while (parchan->parent) { segcount++; // FIXME: revise the breaking conditions - if (segcount==data->chainlen || segcount>255) break; // 255 is weak - parchan= parchan->parent; + if (segcount == data->chainlen || segcount > 255) break; // 255 is weak + parchan = parchan->parent; } if (parchan) // XXX revise the breaking conditions to only stop at the tail? glVertex3fv(parchan->pose_head); @@ -1450,7 +1450,7 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) glEnd(); setlinestyle(0); } - break; + break; } } } @@ -1459,12 +1459,12 @@ static void bgl_sphere_project(float ax, float az) { float dir[3], sine, q3; - sine= 1.0f - ax*ax - az*az; - q3= (sine < 0.0f)? 0.0f: (float)(2.0*sqrt(sine)); + sine = 1.0f - ax * ax - az * az; + q3 = (sine < 0.0f) ? 0.0f : (float)(2.0 * sqrt(sine)); - dir[0]= -az*q3; - dir[1]= 1.0f - 2.0f*sine; - dir[2]= ax*q3; + dir[0] = -az * q3; + dir[1] = 1.0f - 2.0f * sine; + dir[2] = ax * q3; glVertex3fv(dir); } @@ -1479,7 +1479,7 @@ static void draw_dof_ellipse(float ax, float az) 0.994521895368f, 1.0f }; - int i, j, n=16; + int i, j, n = 16; float x, z, px, pz; glEnable(GL_BLEND); @@ -1488,33 +1488,33 @@ static void draw_dof_ellipse(float ax, float az) glColor4ub(70, 70, 70, 50); glBegin(GL_QUADS); - pz= 0.0f; - for (i=1; i<n; i++) { - z= staticSine[i]; + pz = 0.0f; + for (i = 1; i < n; i++) { + z = staticSine[i]; - px= 0.0f; - for (j=1; j<n-i+1; j++) { + px = 0.0f; + for (j = 1; j < n - i + 1; j++) { x = staticSine[j]; - if (j == n-i) { + if (j == n - i) { glEnd(); glBegin(GL_TRIANGLES); - bgl_sphere_project(ax*px, az*z); - bgl_sphere_project(ax*px, az*pz); - bgl_sphere_project(ax*x, az*pz); + bgl_sphere_project(ax * px, az * z); + bgl_sphere_project(ax * px, az * pz); + bgl_sphere_project(ax * x, az * pz); glEnd(); glBegin(GL_QUADS); } else { - bgl_sphere_project(ax*x, az*z); - bgl_sphere_project(ax*x, az*pz); - bgl_sphere_project(ax*px, az*pz); - bgl_sphere_project(ax*px, az*z); + bgl_sphere_project(ax * x, az * z); + bgl_sphere_project(ax * x, az * pz); + bgl_sphere_project(ax * px, az * pz); + bgl_sphere_project(ax * px, az * z); } - px= x; + px = x; } - pz= z; + pz = z; } glEnd(); @@ -1524,27 +1524,27 @@ static void draw_dof_ellipse(float ax, float az) glColor3ub(0, 0, 0); glBegin(GL_LINE_STRIP); - for (i=0; i<n; i++) - bgl_sphere_project(staticSine[n-i-1]*ax, staticSine[i]*az); + for (i = 0; i < n; i++) + bgl_sphere_project(staticSine[n - i - 1] * ax, staticSine[i] * az); glEnd(); } static void draw_pose_dofs(Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; Bone *bone; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - bone= pchan->bone; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + bone = pchan->bone; - if ( (bone) && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) { + if ( (bone) && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) { if (bone->flag & BONE_SELECTED) { if (bone->layer & arm->layer) { - if (pchan->ikflag & (BONE_IK_XLIMIT|BONE_IK_ZLIMIT)) { + if (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ZLIMIT)) { if (ED_pose_channel_in_IK_chain(ob, pchan)) { float corner[4][3], posetrans[3], mat[4][4]; - float phi=0.0f, theta=0.0f, scale; + float phi = 0.0f, theta = 0.0f, scale; int a, i; /* in parent-bone pose, but own restspace */ @@ -1555,24 +1555,24 @@ static void draw_pose_dofs(Object *ob) if (pchan->parent) { copy_m4_m4(mat, pchan->parent->pose_mat); - mat[3][0]= mat[3][1]= mat[3][2]= 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; glMultMatrixf(mat); } copy_m4_m3(mat, pchan->bone->bone_mat); glMultMatrixf(mat); - scale= bone->length*pchan->size[1]; + scale = bone->length * pchan->size[1]; glScalef(scale, scale, scale); if (pchan->ikflag & BONE_IK_XLIMIT) { if (pchan->ikflag & BONE_IK_ZLIMIT) { float amin[3], amax[3]; - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ - amin[i]= (float)sin(pchan->limitmin[i]*0.5f); - amax[i]= (float)sin(pchan->limitmax[i]*0.5f); + amin[i] = (float)sin(pchan->limitmin[i] * 0.5f); + amax[i] = (float)sin(pchan->limitmax[i] * 0.5f); } glScalef(1.0f, -1.0f, 1.0f); @@ -1591,21 +1591,21 @@ static void draw_pose_dofs(Object *ob) /* arcs */ if (pchan->ikflag & BONE_IK_ZLIMIT) { /* OpenGL requires rotations in degrees; so we're taking the average angle here */ - theta= RAD2DEGF(0.5f * (pchan->limitmin[2]+pchan->limitmax[2])); + theta = RAD2DEGF(0.5f * (pchan->limitmin[2] + pchan->limitmax[2])); glRotatef(theta, 0.0f, 0.0f, 1.0f); - glColor3ub(50, 50, 255); // blue, Z axis limit + glColor3ub(50, 50, 255); // blue, Z axis limit glBegin(GL_LINE_STRIP); - for (a=-16; a<=16; a++) { + for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ - float fac= ((float)a)/16.0f * 0.5f; + float fac = ((float)a) / 16.0f * 0.5f; - phi= fac * (pchan->limitmax[2] - pchan->limitmin[2]); + phi = fac * (pchan->limitmax[2] - pchan->limitmin[2]); - i= (a == -16) ? 0 : 1; - corner[i][0]= (float)sin(phi); - corner[i][1]= (float)cos(phi); - corner[i][2]= 0.0f; + i = (a == -16) ? 0 : 1; + corner[i][0] = (float)sin(phi); + corner[i][1] = (float)cos(phi); + corner[i][2] = 0.0f; glVertex3fv(corner[i]); } glEnd(); @@ -1615,20 +1615,20 @@ static void draw_pose_dofs(Object *ob) if (pchan->ikflag & BONE_IK_XLIMIT) { /* OpenGL requires rotations in degrees; so we're taking the average angle here */ - theta= RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0])); + theta = RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0])); glRotatef(theta, 1.0f, 0.0f, 0.0f); - glColor3ub(255, 50, 50); // Red, X axis limit + glColor3ub(255, 50, 50); // Red, X axis limit glBegin(GL_LINE_STRIP); - for (a=-16; a<=16; a++) { + for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ - float fac= ((float)a)/16.0f * 0.5f; - phi= (float)(0.5*M_PI) + fac * (pchan->limitmax[0] - pchan->limitmin[0]); + float fac = ((float)a) / 16.0f * 0.5f; + phi = (float)(0.5 * M_PI) + fac * (pchan->limitmax[0] - pchan->limitmin[0]); - i= (a == -16) ? 2 : 3; - corner[i][0]= 0.0f; - corner[i][1]= (float)sin(phi); - corner[i][2]= (float)cos(phi); + i = (a == -16) ? 2 : 3; + corner[i][0] = 0.0f; + corner[i][1] = (float)sin(phi); + corner[i][2] = (float)cos(phi); glVertex3fv(corner[i]); } glEnd(); @@ -1659,19 +1659,19 @@ static void bone_matrix_translate_y(float mat[][4], float y) static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, const short is_ghost, const short is_outline) { - RegionView3D *rv3d= ar->regiondata; - Object *ob= base->object; - bArmature *arm= ob->data; + RegionView3D *rv3d = ar->regiondata; + Object *ob = base->object; + bArmature *arm = ob->data; bPoseChannel *pchan; Bone *bone; GLfloat tmp; float smat[4][4], imat[4][4], bmat[4][4]; - int index= -1; - short do_dashed= 3, draw_wire= 0; + int index = -1; + short do_dashed = 3, draw_wire = 0; int flag; /* being set below */ - arm->layer_used= 0; + arm->layer_used = 0; /* hacky... prevent outline select from drawing dashed helplines */ glGetFloatv(GL_LINE_WIDTH, &tmp); @@ -1679,10 +1679,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (v3d->flag & V3D_HIDE_HELPLINES) do_dashed &= ~2; /* precalc inverse matrix for drawing screen aligned */ - if (arm->drawtype==ARM_ENVELOPE) { + if (arm->drawtype == ARM_ENVELOPE) { /* precalc inverse matrix for drawing screen aligned */ copy_m4_m4(smat, rv3d->viewmatob); - mul_mat3_m4_fl(smat, 1.0f/len_v3(ob->obmat[0])); + mul_mat3_m4_fl(smat, 1.0f / len_v3(ob->obmat[0])); invert_m4_m4(imat, smat); /* and draw blended distances */ @@ -1692,14 +1692,14 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - bone= pchan->bone; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + bone = pchan->bone; if (bone) { /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] * NOTE: this is the only case with NO_DEFORM==0 flag, as this is for envelope influence drawing */ - if ( (bone->flag & (BONE_HIDDEN_P|BONE_NO_DEFORM|BONE_HIDDEN_PG))==0 && - ((G.f & G_PICKSEL)==0 || (bone->flag & BONE_UNSELECTABLE)==0) ) + if ( (bone->flag & (BONE_HIDDEN_P | BONE_NO_DEFORM | BONE_HIDDEN_PG)) == 0 && + ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0) ) { if (bone->flag & (BONE_SELECTED)) { if (bone->layer & arm->layer) @@ -1722,15 +1722,15 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* if solid we draw that first, with selection codes, but without names, axes etc */ if (dt > OB_WIRE) { if (arm->flag & ARM_POSEMODE) - index= base->selcol; + index = base->selcol; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - bone= pchan->bone; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + bone = pchan->bone; arm->layer_used |= bone->layer; /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ - if ( (bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))==0 && - ((G.f & G_PICKSEL)==0 || (bone->flag & BONE_UNSELECTABLE)==0) ) + if ( (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0 && + ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0) ) { if (bone->layer & arm->layer) { int use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM); @@ -1744,8 +1744,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } /* catch exception for bone with hidden parent */ - flag= bone->flag; - if ( (bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG)) ) + flag = bone->flag; + if ( (bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) ) flag &= ~BONE_CONNECTED; /* set temporary flag for drawing bone as active, but only if selected */ @@ -1758,7 +1758,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (use_custom) { /* if drawwire, don't try to draw in solid */ if (pchan->bone->flag & BONE_DRAWWIRE) { - draw_wire= 1; + draw_wire = 1; } else { draw_custom_bone(scene, v3d, rv3d, pchan->custom, @@ -1785,34 +1785,34 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } } - if (index!= -1) - index+= 0x10000; // pose bones count in higher 2 bytes only + if (index != -1) + index += 0x10000; // pose bones count in higher 2 bytes only } /* very very confusing... but in object mode, solid draw, we cannot do glLoadName yet, * stick bones and/or wire custom-shapes are drawn in next loop */ - if (ELEM(arm->drawtype,ARM_LINE,ARM_WIRE)==0 && (draw_wire == 0)) { + if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && (draw_wire == 0)) { /* object tag, for bordersel optim */ glLoadName(index & 0xFFFF); - index= -1; + index = -1; } } /* draw custom bone shapes as wireframes */ - if ( !(arm->flag & ARM_NO_CUSTOM) && - ((draw_wire) || (dt <= OB_WIRE)) ) + if (!(arm->flag & ARM_NO_CUSTOM) && + ((draw_wire) || (dt <= OB_WIRE)) ) { if (arm->flag & ARM_POSEMODE) - index= base->selcol; + index = base->selcol; /* only draw custom bone shapes that need to be drawn as wires */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - bone= pchan->bone; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + bone = pchan->bone; /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ - if ( (bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))==0 && - ((G.f & G_PICKSEL)==0 || (bone->flag & BONE_UNSELECTABLE)==0) ) + if ( (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0 && + ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0) ) { if (bone->layer & arm->layer) { if (pchan->custom) { @@ -1833,19 +1833,19 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, else if (arm->flag & ARM_POSEMODE) set_pchan_colorset(ob, pchan); else { - if ((scene->basact)==base) { - if (base->flag & (SELECT+BA_WAS_SEL)) UI_ThemeColor(TH_ACTIVE); + if ((scene->basact) == base) { + if (base->flag & (SELECT + BA_WAS_SEL)) UI_ThemeColor(TH_ACTIVE); else UI_ThemeColor(TH_WIRE); } else { - if (base->flag & (SELECT+BA_WAS_SEL)) UI_ThemeColor(TH_SELECT); + if (base->flag & (SELECT + BA_WAS_SEL)) UI_ThemeColor(TH_SELECT); else UI_ThemeColor(TH_WIRE); } } /* catch exception for bone with hidden parent */ - flag= bone->flag; - if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) + flag = bone->flag; + if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) flag &= ~BONE_CONNECTED; /* set temporary flag for drawing bone as active, but only if selected */ @@ -1862,13 +1862,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } if (index != -1) - index+= 0x10000; // pose bones count in higher 2 bytes only + index += 0x10000; // pose bones count in higher 2 bytes only } /* stick or wire bones have not been drawn yet so don't clear object selection in this case */ - if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)==0 && draw_wire) { + if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && draw_wire) { /* object tag, for bordersel optim */ glLoadName(index & 0xFFFF); - index= -1; + index = -1; } } @@ -1877,7 +1877,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* draw line check first. we do selection indices */ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { if (arm->flag & ARM_POSEMODE) - index= base->selcol; + index = base->selcol; } /* if solid && posemode, we draw again with polygonoffset */ else if ((dt > OB_WIRE) && (arm->flag & ARM_POSEMODE)) { @@ -1886,26 +1886,26 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, else { /* and we use selection indices if not done yet */ if (arm->flag & ARM_POSEMODE) - index= base->selcol; + index = base->selcol; } - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - bone= pchan->bone; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + bone = pchan->bone; arm->layer_used |= bone->layer; /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ - if ( (bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))==0 && - ((G.f & G_PICKSEL)==0 || (bone->flag & BONE_UNSELECTABLE)==0) ) + if ( (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0 && + ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0) ) { if (bone->layer & arm->layer) { - const short constflag= pchan->constflag; + const short constflag = pchan->constflag; if ((do_dashed & 1) && (pchan->parent)) { /* Draw a line from our root to the parent's tip * - only if V3D_HIDE_HELPLINES is enabled... */ - if ( (do_dashed & 2) && ((bone->flag & BONE_CONNECTED)==0) ) { + if ( (do_dashed & 2) && ((bone->flag & BONE_CONNECTED) == 0) ) { if (arm->flag & ARM_POSEMODE) { - glLoadName(index & 0xFFFF); // object tag, for bordersel optim + glLoadName(index & 0xFFFF); // object tag, for bordersel optim UI_ThemeColor(TH_WIRE); } setlinestyle(3); @@ -1917,13 +1917,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } /* Draw a line to IK root bone - * - only if temporary chain (i.e. "autoik") + * - only if temporary chain (i.e. "autoik") */ if (arm->flag & ARM_POSEMODE) { if (constflag & PCHAN_HAS_IK) { if (bone->flag & BONE_SELECTED) { if (constflag & PCHAN_HAS_TARGET) glColor3ub(200, 120, 0); - else glColor3ub(200, 200, 50); // add theme! + else glColor3ub(200, 200, 50); // add theme! glLoadName(index & 0xFFFF); pchan_draw_IK_root_lines(pchan, !(do_dashed & 2)); @@ -1931,7 +1931,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } else if (constflag & PCHAN_HAS_SPLINEIK) { if (bone->flag & BONE_SELECTED) { - glColor3ub(150, 200, 50); // add theme! + glColor3ub(150, 200, 50); // add theme! glLoadName(index & 0xFFFF); pchan_draw_IK_root_lines(pchan, !(do_dashed & 2)); @@ -1945,8 +1945,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glMultMatrixf(pchan->pose_mat); /* catch exception for bone with hidden parent */ - flag= bone->flag; - if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) + flag = bone->flag; + if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) flag &= ~BONE_CONNECTED; /* set temporary flag for drawing bone as active, but only if selected */ @@ -1961,15 +1961,15 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) { /* custom bone shapes should not be drawn here! */ } - else if (arm->drawtype==ARM_ENVELOPE) { + else if (arm->drawtype == ARM_ENVELOPE) { if (dt < OB_SOLID) draw_sphere_bone_wire(smat, imat, arm->flag, flag, constflag, index, pchan, NULL); } - else if (arm->drawtype==ARM_LINE) + else if (arm->drawtype == ARM_LINE) draw_line_bone(arm->flag, flag, constflag, index, pchan, NULL); - else if (arm->drawtype==ARM_WIRE) + else if (arm->drawtype == ARM_WIRE) draw_wire_bone(dt, arm->flag, flag, constflag, index, pchan, NULL); - else if (arm->drawtype==ARM_B_BONE) + else if (arm->drawtype == ARM_B_BONE) draw_b_bone(OB_WIRE, arm->flag, flag, constflag, index, pchan, NULL); else draw_bone(OB_WIRE, arm->flag, flag, constflag, index, bone->length); @@ -1980,10 +1980,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* pose bones count in higher 2 bytes only */ if (index != -1) - index+= 0x10000; + index += 0x10000; } /* restore things */ - if (!ELEM(arm->drawtype, ARM_WIRE, ARM_LINE) && (dt>OB_WIRE) && (arm->flag & ARM_POSEMODE)) + if (!ELEM(arm->drawtype, ARM_WIRE, ARM_LINE) && (dt > OB_WIRE) && (arm->flag & ARM_POSEMODE)) bglPolygonOffset(rv3d->dist, 0.0); } @@ -1995,7 +1995,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, draw_pose_dofs(ob); /* finally names and axes */ - if ((arm->flag & (ARM_DRAWNAMES|ARM_DRAWAXES)) && (is_outline == 0)) { + if ((arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) && (is_outline == 0)) { /* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */ if ((G.f & G_PICKSEL) == 0) { float vec[3]; @@ -2004,22 +2004,22 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, float col_f[4]; glGetFloatv(GL_CURRENT_COLOR, col_f); /* in case this is not set below */ rgb_float_to_uchar(col, col_f); - col[3]= 255; + col[3] = 255; if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { - if ((pchan->bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))==0) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + if ((pchan->bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) { if (pchan->bone->layer & arm->layer) { - if (arm->flag & (ARM_EDITMODE|ARM_POSEMODE)) { - bone= pchan->bone; + if (arm->flag & (ARM_EDITMODE | ARM_POSEMODE)) { + bone = pchan->bone; UI_GetThemeColor3ubv((bone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, col); } else if (dt > OB_WIRE) { UI_GetThemeColor3ubv(TH_TEXT, col); } - /* Draw names of bone */ + /* Draw names of bone */ if (arm->flag & ARM_DRAWNAMES) { mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail); view3d_cached_text_draw_add(vec, pchan->name, 10, 0, col); @@ -2033,7 +2033,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glMultMatrixf(bmat); glColor3ubv(col); - drawaxes(pchan->bone->length*0.25f, OB_ARROWS); + drawaxes(pchan->bone->length * 0.25f, OB_ARROWS); glPopMatrix(); } @@ -2049,13 +2049,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* in editmode, we don't store the bone matrix... */ static void get_matrix_editbone(EditBone *eBone, float bmat[][4]) { - float delta[3]; - float mat[3][3]; + float delta[3]; + float mat[3][3]; /* Compose the parent transforms (i.e. their translations) */ sub_v3_v3v3(delta, eBone->tail, eBone->head); - eBone->length = (float)sqrt(delta[0]*delta[0] + delta[1]*delta[1] +delta[2]*delta[2]); + eBone->length = (float)sqrt(delta[0] * delta[0] + delta[1] * delta[1] + delta[2] * delta[2]); vec_roll_to_mat3(delta, eBone->roll, mat); copy_m4_m3(bmat, mat); @@ -2065,21 +2065,21 @@ static void get_matrix_editbone(EditBone *eBone, float bmat[][4]) static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; EditBone *eBone; - bArmature *arm= ob->data; + bArmature *arm = ob->data; float smat[4][4], imat[4][4], bmat[4][4]; unsigned int index; int flag; /* being set in code below */ - arm->layer_used= 0; + arm->layer_used = 0; /* envelope (deform distance) */ - if (arm->drawtype==ARM_ENVELOPE) { + if (arm->drawtype == ARM_ENVELOPE) { /* precalc inverse matrix for drawing screen aligned */ copy_m4_m4(smat, rv3d->viewmatob); - mul_mat3_m4_fl(smat, 1.0f/len_v3(ob->obmat[0])); + mul_mat3_m4_fl(smat, 1.0f / len_v3(ob->obmat[0])); invert_m4_m4(imat, smat); /* and draw blended distances */ @@ -2088,10 +2088,10 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { if (eBone->layer & arm->layer) { - if ((eBone->flag & (BONE_HIDDEN_A|BONE_NO_DEFORM))==0) { - if (eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL)) + if ((eBone->flag & (BONE_HIDDEN_A | BONE_NO_DEFORM)) == 0) { + if (eBone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) draw_sphere_bone_dist(smat, imat, NULL, eBone); } } @@ -2104,15 +2104,15 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) /* if solid we draw it first */ if ((dt > OB_WIRE) && (arm->drawtype != ARM_LINE)) { - for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) { + for (eBone = arm->edbo->first, index = 0; eBone; eBone = eBone->next, index++) { if (eBone->layer & arm->layer) { - if ((eBone->flag & BONE_HIDDEN_A)==0) { + if ((eBone->flag & BONE_HIDDEN_A) == 0) { glPushMatrix(); get_matrix_editbone(eBone, bmat); glMultMatrixf(bmat); /* catch exception for bone with hidden parent */ - flag= eBone->flag; + flag = eBone->flag; if ( (eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) flag &= ~BONE_CONNECTED; @@ -2120,11 +2120,11 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) if (eBone == arm->act_edbone) flag |= BONE_DRAW_ACTIVE; - if (arm->drawtype==ARM_ENVELOPE) + if (arm->drawtype == ARM_ENVELOPE) draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone); - else if (arm->drawtype==ARM_B_BONE) + else if (arm->drawtype == ARM_B_BONE) draw_b_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone); - else if (arm->drawtype==ARM_WIRE) + else if (arm->drawtype == ARM_WIRE) draw_wire_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone); else { draw_bone(OB_SOLID, arm->flag, flag, 0, index, eBone->length); @@ -2137,24 +2137,24 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) } /* if wire over solid, set offset */ - index= -1; + index = -1; glLoadName(-1); if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { if (G.f & G_PICKSEL) - index= 0; + index = 0; } else if (dt > OB_WIRE) bglPolygonOffset(rv3d->dist, 1.0f); else if (arm->flag & ARM_EDITMODE) - index= 0; /* do selection codes */ + index = 0; /* do selection codes */ - for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { arm->layer_used |= eBone->layer; if (eBone->layer & arm->layer) { - if ((eBone->flag & BONE_HIDDEN_A)==0) { + if ((eBone->flag & BONE_HIDDEN_A) == 0) { /* catch exception for bone with hidden parent */ - flag= eBone->flag; + flag = eBone->flag; if ( (eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) flag &= ~BONE_CONNECTED; @@ -2173,7 +2173,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) if (arm->drawtype == ARM_LINE) draw_line_bone(arm->flag, flag, 0, index, NULL, eBone); - else if (arm->drawtype==ARM_WIRE) + else if (arm->drawtype == ARM_WIRE) draw_wire_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone); else if (arm->drawtype == ARM_B_BONE) draw_b_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone); @@ -2186,7 +2186,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) /* offset to parent */ if (eBone->parent) { UI_ThemeColor(TH_WIRE); - glLoadName (-1); // -1 here is OK! + glLoadName(-1); // -1 here is OK! setlinestyle(3); glBegin(GL_LINES); @@ -2198,27 +2198,27 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) } } } - if (index!=-1) index++; + if (index != -1) index++; } /* restore */ - if (index!=-1) glLoadName(-1); - if (ELEM(arm->drawtype,ARM_LINE,ARM_WIRE)); - else if (dt>OB_WIRE) bglPolygonOffset(rv3d->dist, 0.0f); + if (index != -1) glLoadName(-1); + if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) ; + else if (dt > OB_WIRE) bglPolygonOffset(rv3d->dist, 0.0f); /* finally names and axes */ - if (arm->flag & (ARM_DRAWNAMES|ARM_DRAWAXES)) { + if (arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) { // patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing if ((G.f & G_PICKSEL) == 0) { float vec[3]; unsigned char col[4]; - col[3]= 255; + col[3] = 255; if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { if (eBone->layer & arm->layer) { - if ((eBone->flag & BONE_HIDDEN_A)==0) { + if ((eBone->flag & BONE_HIDDEN_A) == 0) { UI_GetThemeColor3ubv((eBone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, col); @@ -2236,7 +2236,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) glMultMatrixf(bmat); glColor3ubv(col); - drawaxes(eBone->length*0.25f, OB_ARROWS); + drawaxes(eBone->length * 0.25f, OB_ARROWS); glPopMatrix(); } @@ -2259,15 +2259,15 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) */ static void draw_pose_paths(Scene *scene, View3D *v3d, ARegion *ar, Object *ob) { - bAnimVizSettings *avs= &ob->pose->avs; - bArmature *arm= ob->data; + bAnimVizSettings *avs = &ob->pose->avs; + bArmature *arm = ob->data; bPoseChannel *pchan; /* setup drawing environment for paths */ draw_motion_paths_init(v3d, ar); /* draw paths where they exist and they releated bone is visible */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone->layer & arm->layer) && (pchan->mpath)) draw_motion_path_instance(scene, ob, pchan, avs, pchan->mpath); } @@ -2284,16 +2284,16 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, ARegion *ar, Object *ob) */ static void ghost_poses_tag_unselected(Object *ob, short unset) { - bArmature *arm= ob->data; - bPose *pose= ob->pose; + bArmature *arm = ob->data; + bPose *pose = ob->pose; bPoseChannel *pchan; /* don't do anything if no hiding any bones */ - if ((arm->flag & ARM_GHOST_ONLYSEL)==0) + if ((arm->flag & ARM_GHOST_ONLYSEL) == 0) return; /* loop over all pchans, adding/removing tags as appropriate */ - for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone) && (arm->layer & pchan->bone->layer)) { if (unset) { /* remove tags from all pchans if cleaning up */ @@ -2301,7 +2301,7 @@ static void ghost_poses_tag_unselected(Object *ob, short unset) } else { /* set tags on unselected pchans only */ - if ((pchan->bone->flag & BONE_SELECTED)==0) + if ((pchan->bone->flag & BONE_SELECTED) == 0) pchan->bone->flag |= BONE_HIDDEN_PG; } } @@ -2309,13 +2309,13 @@ static void ghost_poses_tag_unselected(Object *ob, short unset) } /* draw ghosts that occur within a frame range - * note: object should be in posemode + * note: object should be in posemode */ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base *base) { - Object *ob= base->object; - AnimData *adt= BKE_animdata_from_id(&ob->id); - bArmature *arm= ob->data; + Object *ob = base->object; + AnimData *adt = BKE_animdata_from_id(&ob->id); + bArmature *arm = ob->data; bPose *posen, *poseo; float start, end, stepsize, range, colfac; int cfrao, flago, ipoflago; @@ -2325,31 +2325,31 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base if (end <= start) return; - stepsize= (float)(arm->ghostsize); - range= (float)(end - start); + stepsize = (float)(arm->ghostsize); + range = (float)(end - start); /* store values */ ob->mode &= ~OB_MODE_POSE; - cfrao= CFRA; - flago= arm->flag; - arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); - ipoflago= ob->ipoflag; + cfrao = CFRA; + flago = arm->flag; + arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES); + ipoflago = ob->ipoflag; ob->ipoflag |= OB_DISABLE_PATH; /* copy the pose */ - poseo= ob->pose; + poseo = ob->pose; copy_pose(&posen, ob->pose, 1); - ob->pose= posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ - ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ + ob->pose = posen; + armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); if (v3d->zbuf) glDisable(GL_DEPTH_TEST); /* draw from first frame of range to last */ - for (CFRA= (int)start; CFRA < end; CFRA += (int)stepsize) { + for (CFRA = (int)start; CFRA < end; CFRA += (int)stepsize) { colfac = (end - (float)CFRA) / range; - UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac))); + UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0 * sqrt(colfac))); BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); where_is_pose(scene, ob); @@ -2358,16 +2358,16 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); - ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ + ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ free_pose(posen); /* restore */ - CFRA= cfrao; - ob->pose= poseo; - arm->flag= flago; + CFRA = cfrao; + ob->pose = poseo; + arm->flag = flago; armature_rebuild_pose(ob, ob->data); ob->mode |= OB_MODE_POSE; - ob->ipoflag= ipoflago; + ob->ipoflag = ipoflago; } /* draw ghosts on keyframes in action within range @@ -2375,10 +2375,10 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base */ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base *base) { - Object *ob= base->object; - AnimData *adt= BKE_animdata_from_id(&ob->id); - bAction *act= (adt) ? adt->action : NULL; - bArmature *arm= ob->data; + Object *ob = base->object; + AnimData *adt = BKE_animdata_from_id(&ob->id); + bAction *act = (adt) ? adt->action : NULL; + bArmature *arm = ob->data; bPose *posen, *poseo; DLRBT_Tree keys; ActKeyColumn *ak, *akn; @@ -2395,9 +2395,9 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * action_to_keylist(adt, act, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); - range= 0; - for (ak= keys.first; ak; ak= akn) { - akn= ak->next; + range = 0; + for (ak = keys.first; ak; ak = akn) { + akn = ak->next; if ((ak->cfra < start) || (ak->cfra > end)) BLI_freelinkN((ListBase *)&keys, ak); @@ -2408,27 +2408,27 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * /* store values */ ob->mode &= ~OB_MODE_POSE; - cfrao= CFRA; - flago= arm->flag; - arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); + cfrao = CFRA; + flago = arm->flag; + arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES); ob->ipoflag |= OB_DISABLE_PATH; /* copy the pose */ - poseo= ob->pose; + poseo = ob->pose; copy_pose(&posen, ob->pose, 1); - ob->pose= posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ - ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ + ob->pose = posen; + armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); if (v3d->zbuf) glDisable(GL_DEPTH_TEST); /* draw from first frame of range to last */ - for (ak=keys.first, i=0; ak; ak=ak->next, i++) { - colfac = i/range; - UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac))); + for (ak = keys.first, i = 0; ak; ak = ak->next, i++) { + colfac = i / range; + UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0 * sqrt(colfac))); - CFRA= (int)ak->cfra; + CFRA = (int)ak->cfra; BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); where_is_pose(scene, ob); @@ -2437,26 +2437,26 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); - ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ + ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ BLI_dlrbTree_free(&keys); free_pose(posen); /* restore */ - CFRA= cfrao; - ob->pose= poseo; - arm->flag= flago; + CFRA = cfrao; + ob->pose = poseo; + arm->flag = flago; armature_rebuild_pose(ob, ob->data); ob->mode |= OB_MODE_POSE; } /* draw ghosts around current frame - * - object is supposed to be armature in posemode + * - object is supposed to be armature in posemode */ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) { - Object *ob= base->object; - AnimData *adt= BKE_animdata_from_id(&ob->id); - bArmature *arm= ob->data; + Object *ob = base->object; + AnimData *adt = BKE_animdata_from_id(&ob->id); + bArmature *arm = ob->data; bPose *posen, *poseo; float cur, start, end, stepsize, range, colfac, actframe, ctime; int cfrao, flago; @@ -2469,35 +2469,35 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (start == end) return; - stepsize= (float)(arm->ghostsize); - range= (float)(arm->ghostep)*stepsize + 0.5f; /* plus half to make the for loop end correct */ + stepsize = (float)(arm->ghostsize); + range = (float)(arm->ghostep) * stepsize + 0.5f; /* plus half to make the for loop end correct */ /* store values */ ob->mode &= ~OB_MODE_POSE; - cfrao= CFRA; - actframe= BKE_nla_tweakedit_remap(adt, (float)CFRA, 0); - flago= arm->flag; - arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); + cfrao = CFRA; + actframe = BKE_nla_tweakedit_remap(adt, (float)CFRA, 0); + flago = arm->flag; + arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES); /* copy the pose */ - poseo= ob->pose; + poseo = ob->pose; copy_pose(&posen, ob->pose, 1); - ob->pose= posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ - ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ + ob->pose = posen; + armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); if (v3d->zbuf) glDisable(GL_DEPTH_TEST); /* draw from darkest blend to lowest */ - for (cur= stepsize; cur<range; cur+=stepsize) { - ctime= cur - (float)fmod(cfrao, stepsize); /* ensures consistent stepping */ - colfac= ctime/range; - UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac))); + for (cur = stepsize; cur < range; cur += stepsize) { + ctime = cur - (float)fmod(cfrao, stepsize); /* ensures consistent stepping */ + colfac = ctime / range; + UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0 * sqrt(colfac))); /* only within action range */ - if (actframe+ctime >= start && actframe+ctime <= end) { - CFRA= (int)BKE_nla_tweakedit_remap(adt, actframe+ctime, NLATIME_CONVERT_MAP); + if (actframe + ctime >= start && actframe + ctime <= end) { + CFRA = (int)BKE_nla_tweakedit_remap(adt, actframe + ctime, NLATIME_CONVERT_MAP); if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); @@ -2506,13 +2506,13 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) } } - ctime= cur + (float)fmod((float)cfrao, stepsize) - stepsize+1.0f; /* ensures consistent stepping */ - colfac= ctime/range; - UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac))); + ctime = cur + (float)fmod((float)cfrao, stepsize) - stepsize + 1.0f; /* ensures consistent stepping */ + colfac = ctime / range; + UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0 * sqrt(colfac))); /* only within action range */ - if ((actframe-ctime >= start) && (actframe-ctime <= end)) { - CFRA= (int)BKE_nla_tweakedit_remap(adt, actframe-ctime, NLATIME_CONVERT_MAP); + if ((actframe - ctime >= start) && (actframe - ctime <= end)) { + CFRA = (int)BKE_nla_tweakedit_remap(adt, actframe - ctime, NLATIME_CONVERT_MAP); if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); @@ -2524,13 +2524,13 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); - ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ + ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ free_pose(posen); /* restore */ - CFRA= cfrao; - ob->pose= poseo; - arm->flag= flago; + CFRA = cfrao; + ob->pose = poseo; + arm->flag = flago; armature_rebuild_pose(ob, ob->data); ob->mode |= OB_MODE_POSE; } @@ -2540,22 +2540,22 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) /* called from drawobject.c, return 1 if nothing was drawn */ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline) { - Object *ob= base->object; - bArmature *arm= ob->data; - int retval= 0; + Object *ob = base->object; + bArmature *arm = ob->data; + int retval = 0; if (v3d->flag2 & V3D_RENDER_OVERRIDE) return 1; - if (dt>OB_WIRE && !ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { + if (dt > OB_WIRE && !ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { /* we use color for solid lighting */ glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); glEnable(GL_COLOR_MATERIAL); - glColor3ub(255,255,255); // clear spec + glColor3ub(255, 255, 255); // clear spec glDisable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); // only for lighting... + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); // only for lighting... } /* arm->flag is being used to detect mode... */ @@ -2571,9 +2571,10 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in /* drawing posemode selection indices or colors only in these cases */ if (!(base->flag & OB_FROMDUPLI)) { if (G.f & G_PICKSEL) { -#if 0 /* nifty but actually confusing to allow bone selection out of posemode */ +#if 0 + /* nifty but actually confusing to allow bone selection out of posemode */ if (OBACT && (OBACT->mode & OB_MODE_WEIGHT_PAINT)) { - if (ob==modifiers_isDeformedByArmature(OBACT)) + if (ob == modifiers_isDeformedByArmature(OBACT)) arm->flag |= ARM_POSEMODE; } else @@ -2593,11 +2594,11 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in if (arm->ghostep) draw_ghost_poses(scene, v3d, ar, base); } - if ((flag & DRAW_SCENESET)==0) { - if (ob==OBACT) + if ((flag & DRAW_SCENESET) == 0) { + if (ob == OBACT) arm->flag |= ARM_POSEMODE; else if (OBACT && (OBACT->mode & OB_MODE_WEIGHT_PAINT)) { - if (ob==modifiers_isDeformedByArmature(OBACT)) + if (ob == modifiers_isDeformedByArmature(OBACT)) arm->flag |= ARM_POSEMODE; } draw_pose_paths(scene, v3d, ar, ob); @@ -2608,9 +2609,11 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in arm->flag &= ~ARM_POSEMODE; if (ob->mode & OB_MODE_POSE) - UI_ThemeColor(TH_WIRE); /* restore, for extra draw stuff */ + UI_ThemeColor(TH_WIRE); /* restore, for extra draw stuff */ + } + else { + retval = 1; } - else retval= 1; } /* restore */ glFrontFace(GL_CCW); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 0ec9e9664f6..211104e60f0 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -71,7 +71,7 @@ #include "ED_mesh.h" #include "ED_uvedit.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include /* user data structures for derived mesh callbacks */ typedef struct drawMeshFaceSelect_userData { @@ -96,8 +96,8 @@ typedef struct drawTFace_userData { /* Flags for marked edges */ enum { - eEdge_Visible = (1<<0), - eEdge_Select = (1<<1), + eEdge_Visible = (1 << 0), + eEdge_Select = (1 << 1), }; /* Creates a hash of edges to flags indicating selected/visible */ @@ -108,7 +108,7 @@ static void get_marked_edge_info__orFlags(EdgeHash *eh, int v0, int v1, int flag if (!BLI_edgehash_haskey(eh, v0, v1)) BLI_edgehash_insert(eh, v0, v1, NULL); - flags_p = (int*) BLI_edgehash_lookup_p(eh, v0, v1); + flags_p = (int *) BLI_edgehash_lookup_p(eh, v0, v1); *flags_p |= flags; } @@ -120,7 +120,7 @@ static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me) MLoop *ml_next; int i, j; - for (i=0; i<me->totpoly; i++) { + for (i = 0; i < me->totpoly; i++) { mp = &me->mpoly[i]; if (!(mp->flag & ME_HIDE)) { @@ -128,7 +128,7 @@ static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me) if (mp->flag & ME_FACE_SEL) flags |= eEdge_Select; ml = me->mloop + mp->loopstart; - for (j=0; j<mp->totloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { ml_next = ME_POLY_LOOP_NEXT(me->mloop, mp, j); get_marked_edge_info__orFlags(eh, ml->v, ml_next->v, flags); } @@ -142,7 +142,7 @@ static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me) static DMDrawOption draw_mesh_face_select__setHiddenOpts(void *userData, int index) { drawMeshFaceSelect_userData *data = userData; - Mesh *me= data->me; + Mesh *me = data->me; MEdge *med = &me->medge[index]; uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2); @@ -170,11 +170,11 @@ static DMDrawOption draw_mesh_face_select__setSelectOpts(void *userData, int ind /* draws unselected */ static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int index) { - Mesh *me = (Mesh*)userData; + Mesh *me = (Mesh *)userData; MPoly *mface = &me->mpoly[index]; - if (!(mface->flag&ME_HIDE) && !(mface->flag&ME_FACE_SEL)) - return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ + if (!(mface->flag & ME_HIDE) && !(mface->flag & ME_FACE_SEL)) + return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ else return DM_DRAW_OPTION_SKIP; } @@ -202,20 +202,20 @@ static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* dull unselected faces so as not to get in the way of seeing color */ glColor4ub(96, 96, 96, 64); - dm->drawMappedFacesTex(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, (void*)me); + dm->drawMappedFacesTex(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, (void *)me); glDisable(GL_BLEND); } bglPolygonOffset(rv3d->dist, 1.0); - /* Draw Stippled Outline for selected faces */ + /* Draw Stippled Outline for selected faces */ glColor3ub(255, 255, 255); setlinestyle(1); dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data); setlinestyle(0); - bglPolygonOffset(rv3d->dist, 0.0); // resets correctly now, even after calling accumulated offsets + bglPolygonOffset(rv3d->dist, 0.0); // resets correctly now, even after calling accumulated offsets BLI_edgehash_free(data.eh, NULL); } @@ -224,10 +224,10 @@ static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) static Material *give_current_material_or_def(Object *ob, int matnr) { - extern Material defmaterial; // render module abuse... - Material *ma= give_current_material(ob, matnr); + extern Material defmaterial; // render module abuse... + Material *ma = give_current_material(ob, matnr); - return ma?ma:&defmaterial; + return ma ? ma : &defmaterial; } /* Icky globals, fix with userdata parameter */ @@ -255,9 +255,9 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m int lit = 0; if (clearcache) { - c_textured= c_lit= c_backculled= -1; - c_texface= (MTFace*) -1; - c_badtex= 0; + c_textured = c_lit = c_backculled = -1; + c_texface = (MTFace *) -1; + c_badtex = 0; } else { textured = gtexdraw.istex; @@ -284,35 +284,35 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m else textured = 0; - if (backculled!=c_backculled) { + if (backculled != c_backculled) { if (backculled) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); - c_backculled= backculled; + c_backculled = backculled; } - if (textured!=c_textured || texface!=c_texface) { - if (textured ) { - c_badtex= !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT), alphablend); + if (textured != c_textured || texface != c_texface) { + if (textured) { + c_badtex = !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT), alphablend); } else { GPU_set_tpage(NULL, 0, 0); - c_badtex= 0; + c_badtex = 0; } - c_textured= textured; - c_texface= texface; + c_textured = textured; + c_texface = texface; } - if (c_badtex) lit= 0; - if (lit!=c_lit || ma!=c_ma) { + if (c_badtex) lit = 0; + if (lit != c_lit || ma != c_ma) { if (lit) { float spec[4]; - if (!ma)ma= give_current_material_or_def(NULL, 0); //default material + if (!ma) ma = give_current_material_or_def(NULL, 0); //default material - spec[0]= ma->spec*ma->specr; - spec[1]= ma->spec*ma->specg; - spec[2]= ma->spec*ma->specb; - spec[3]= 1.0; + spec[0] = ma->spec * ma->specr; + spec[1] = ma->spec * ma->specg; + spec[2] = ma->spec * ma->specb; + spec[3] = 1.0; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); @@ -324,7 +324,7 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); } - c_lit= lit; + c_lit = lit; } return c_badtex; @@ -340,25 +340,25 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O /* texture draw is abused for mask selection mode, do this so wire draw * with face selection in weight paint is not lit. */ if ((v3d->drawtype <= OB_WIRE) && (ob->mode & OB_MODE_WEIGHT_PAINT)) { - solidtex= FALSE; - Gtexdraw.islit= 0; + solidtex = FALSE; + Gtexdraw.islit = 0; } - else if (v3d->drawtype==OB_SOLID || ((ob->mode & OB_MODE_EDIT) && v3d->drawtype!=OB_TEXTURE)) { + else if (v3d->drawtype == OB_SOLID || ((ob->mode & OB_MODE_EDIT) && v3d->drawtype != OB_TEXTURE)) { /* draw with default lights in solid draw mode and edit mode */ - solidtex= TRUE; - Gtexdraw.islit= -1; + solidtex = TRUE; + Gtexdraw.islit = -1; } else { /* draw with lights in the scene otherwise */ - solidtex= FALSE; - Gtexdraw.islit= GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp); + solidtex = FALSE; + Gtexdraw.islit = GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp); } rgba_float_to_uchar(obcol, ob->col); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); - if (solidtex || v3d->drawtype==OB_TEXTURE) istex= 1; - else istex= 0; + if (solidtex || v3d->drawtype == OB_TEXTURE) istex = 1; + else istex = 0; Gtexdraw.ob = ob; Gtexdraw.istex = istex; @@ -393,8 +393,8 @@ static void draw_textured_end(void) static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr) { - Material *ma= give_current_material(Gtexdraw.ob, matnr+1); - int validtexture=0; + Material *ma = give_current_material(Gtexdraw.ob, matnr + 1); + int validtexture = 0; if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return DM_DRAW_OPTION_SKIP; @@ -405,7 +405,7 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int glColor3ub(0xFF, 0x00, 0xFF); return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ } - else if (ma && (ma->shade_flag&MA_OBCOLOR)) { + else if (ma && (ma->shade_flag & MA_OBCOLOR)) { glColor3ubv(Gtexdraw.obcol); return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ } @@ -438,7 +438,7 @@ static DMDrawOption draw_mcol__set_draw_legacy(MTFace *UNUSED(tface), int has_mc static DMDrawOption draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr) { - Material *ma= give_current_material(Gtexdraw.ob, matnr+1); + Material *ma = give_current_material(Gtexdraw.ob, matnr + 1); if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return 0; @@ -461,78 +461,78 @@ static void add_tface_color_layer(DerivedMesh *dm) MTFace *tface = DM_get_poly_data_layer(dm, CD_MTFACE); MFace *mface = dm->getTessFaceArray(dm); MCol *finalCol; - int i,j; + int i, j; MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL); if (!mcol) mcol = dm->getTessFaceDataArray(dm, CD_MCOL); - finalCol = MEM_mallocN(sizeof(MCol)*4*dm->getNumTessFaces(dm),"add_tface_color_layer"); - for (i=0;i<dm->getNumTessFaces(dm);i++) { - Material *ma= give_current_material(Gtexdraw.ob, mface[i].mat_nr+1); + finalCol = MEM_mallocN(sizeof(MCol) * 4 * dm->getNumTessFaces(dm), "add_tface_color_layer"); + for (i = 0; i < dm->getNumTessFaces(dm); i++) { + Material *ma = give_current_material(Gtexdraw.ob, mface[i].mat_nr + 1); - if (ma && (ma->game.flag&GEMAT_INVISIBLE)) { - if ( mcol ) - memcpy(&finalCol[i*4],&mcol[i*4],sizeof(MCol)*4); + if (ma && (ma->game.flag & GEMAT_INVISIBLE)) { + if (mcol) + memcpy(&finalCol[i * 4], &mcol[i * 4], sizeof(MCol) * 4); else - for (j=0;j<4;j++) { - finalCol[i*4+j].b = 255; - finalCol[i*4+j].g = 255; - finalCol[i*4+j].r = 255; + for (j = 0; j < 4; j++) { + finalCol[i * 4 + j].b = 255; + finalCol[i * 4 + j].g = 255; + finalCol[i * 4 + j].r = 255; } } else if (tface && mface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) { - for (j=0;j<4;j++) { - finalCol[i*4+j].b = 255; - finalCol[i*4+j].g = 0; - finalCol[i*4+j].r = 255; + for (j = 0; j < 4; j++) { + finalCol[i * 4 + j].b = 255; + finalCol[i * 4 + j].g = 0; + finalCol[i * 4 + j].r = 255; } } else if (tface && (tface->mode & TF_OBCOL)) { - for (j=0;j<4;j++) { - finalCol[i*4+j].b = FTOCHAR(Gtexdraw.obcol[0]); - finalCol[i*4+j].g = FTOCHAR(Gtexdraw.obcol[1]); - finalCol[i*4+j].r = FTOCHAR(Gtexdraw.obcol[2]); + for (j = 0; j < 4; j++) { + finalCol[i * 4 + j].b = FTOCHAR(Gtexdraw.obcol[0]); + finalCol[i * 4 + j].g = FTOCHAR(Gtexdraw.obcol[1]); + finalCol[i * 4 + j].r = FTOCHAR(Gtexdraw.obcol[2]); } } else if (!mcol) { if (tface) { - for (j=0;j<4;j++) { - finalCol[i*4+j].b = 255; - finalCol[i*4+j].g = 255; - finalCol[i*4+j].r = 255; + for (j = 0; j < 4; j++) { + finalCol[i * 4 + j].b = 255; + finalCol[i * 4 + j].g = 255; + finalCol[i * 4 + j].r = 255; } } else { float col[3]; - Material *ma= give_current_material(Gtexdraw.ob, mface[i].mat_nr+1); + Material *ma = give_current_material(Gtexdraw.ob, mface[i].mat_nr + 1); if (ma) { if (Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r); else copy_v3_v3(col, &ma->r); - for (j=0;j<4;j++) { - finalCol[i*4+j].b = FTOCHAR(col[0]); - finalCol[i*4+j].g = FTOCHAR(col[1]); - finalCol[i*4+j].r = FTOCHAR(col[2]); + for (j = 0; j < 4; j++) { + finalCol[i * 4 + j].b = FTOCHAR(col[0]); + finalCol[i * 4 + j].g = FTOCHAR(col[1]); + finalCol[i * 4 + j].r = FTOCHAR(col[2]); } } else - for (j=0;j<4;j++) { - finalCol[i*4+j].b = 255; - finalCol[i*4+j].g = 255; - finalCol[i*4+j].r = 255; + for (j = 0; j < 4; j++) { + finalCol[i * 4 + j].b = 255; + finalCol[i * 4 + j].g = 255; + finalCol[i * 4 + j].r = 255; } } } else { - for (j=0;j<4;j++) { - finalCol[i*4+j].r = mcol[i*4+j].r; - finalCol[i*4+j].g = mcol[i*4+j].g; - finalCol[i*4+j].b = mcol[i*4+j].b; + for (j = 0; j < 4; j++) { + finalCol[i * 4 + j].r = mcol[i * 4 + j].r; + finalCol[i * 4 + j].g = mcol[i * 4 + j].g; + finalCol[i * 4 + j].b = mcol[i * 4 + j].b; } } } - CustomData_add_layer( &dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData ); + CustomData_add_layer(&dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData); } static DMDrawOption draw_tface_mapped__set_draw(void *userData, int index) @@ -549,7 +549,7 @@ static DMDrawOption draw_tface_mapped__set_draw(void *userData, int index) } else { MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[index] : NULL; - MTFace mtf= {{{0}}}; + MTFace mtf = {{{0}}}; int matnr = mpoly->mat_nr; if (tpoly) { @@ -564,13 +564,13 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index) { drawEMTFMapped_userData *data = userData; BMEditMesh *em = data->em; - BMFace *efa= EDBM_get_face_for_index(em, index); + BMFace *efa = EDBM_get_face_for_index(em, index); - if (efa==NULL || BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { + if (efa == NULL || BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { return DM_DRAW_OPTION_SKIP; } else { - MTFace mtf= {{{0}}}; + MTFace mtf = {{{0}}}; int matnr = efa->mat_nr; if (data->has_mtface) { @@ -579,16 +579,16 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index) } return draw_tface__set_draw_legacy(data->has_mtface ? &mtf : NULL, - data->has_mcol, matnr); + data->has_mcol, matnr); } } static DMDrawOption wpaint__setSolidDrawOptions_material(void *userData, int index) { - Mesh *me = (Mesh*)userData; + Mesh *me = (Mesh *)userData; if (me->mat && me->mpoly) { - Material *ma= me->mat[me->mpoly[index].mat_nr]; + Material *ma = me->mat[me->mpoly[index].mat_nr]; if (ma && (ma->game.flag & GEMAT_INVISIBLE)) { return DM_DRAW_OPTION_SKIP; } @@ -600,7 +600,7 @@ static DMDrawOption wpaint__setSolidDrawOptions_material(void *userData, int ind /* when face select is on, use face hidden flag */ static DMDrawOption wpaint__setSolidDrawOptions_facemask(void *userData, int index) { - Mesh *me = (Mesh*)userData; + Mesh *me = (Mesh *)userData; MPoly *mp = &me->mpoly[index]; if (mp->flag & ME_HIDE) return DM_DRAW_OPTION_SKIP; @@ -615,7 +615,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) MTexPoly *mtpoly = me->mtpoly; MLoopUV *mloopuv = me->mloopuv; MLoopUV *luv; - MLoopCol *mloopcol = me->mloopcol; /* why does mcol exist? */ + MLoopCol *mloopcol = me->mloopcol; /* why does mcol exist? */ MLoopCol *lcol; bProperty *prop = get_ob_property(ob, "Text"); @@ -623,7 +623,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) int a, totpoly = me->totpoly; /* fake values to pass to GPU_render_text() */ - MCol tmp_mcol[4] = {{0}}; + MCol tmp_mcol[4] = {{0}}; MCol *tmp_mcol_pt = mloopcol ? tmp_mcol : NULL; MTFace tmp_tf = {{{0}}}; @@ -634,33 +634,33 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) /* don't draw when editing */ if (ob->mode & OB_MODE_EDIT) return; - else if (ob==OBACT) + else if (ob == OBACT) if (paint_facesel_test(ob) || paint_vertsel_test(ob)) return; ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); - for (a=0, mp=mface; a<totpoly ; a++, mtpoly++, mp++) { - short matnr= mp->mat_nr; - int mf_smooth= mp->flag & ME_SMOOTH; + for (a = 0, mp = mface; a < totpoly; a++, mtpoly++, mp++) { + short matnr = mp->mat_nr; + int mf_smooth = mp->flag & ME_SMOOTH; Material *mat = me->mat[matnr]; - int mode= mat->game.flag; + int mode = mat->game.flag; - if (!(mode&GEMAT_INVISIBLE) && (mode&GEMAT_TEXT) && mp->totloop >= 3) { + if (!(mode & GEMAT_INVISIBLE) && (mode & GEMAT_TEXT) && mp->totloop >= 3) { /* get the polygon as a tri/quad */ int mp_vi[4]; float v1[3], v2[3], v3[3], v4[3]; char string[MAX_PROPSTRING]; - int characters, i, glattrib= -1, badtex= 0; + int characters, i, glattrib = -1, badtex = 0; /* TEXFACE */ ME_MTEXFACE_CPY(&tmp_tf, mtpoly); if (glsl) { - GPU_enable_material(matnr+1, &gattribs); + GPU_enable_material(matnr + 1, &gattribs); - for (i=0; i<gattribs.totlayer; i++) { + for (i = 0; i < gattribs.totlayer; i++) { if (gattribs.layer[i].type == CD_MTFACE) { glattrib = gattribs.layer[i].glindex; break; @@ -675,9 +675,9 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) } mp_vi[0] = me->mloop[mp->loopstart + 0].v; - mp_vi[1] = me->mloop[mp->loopstart + 1].v; - mp_vi[2] = me->mloop[mp->loopstart + 2].v; - mp_vi[3] = (mp->totloop >= 4) ? me->mloop[mp->loopstart + 3].v : 0; + mp_vi[1] = me->mloop[mp->loopstart + 1].v; + mp_vi[2] = me->mloop[mp->loopstart + 2].v; + mp_vi[3] = (mp->totloop >= 4) ? me->mloop[mp->loopstart + 3].v : 0; /* UV */ luv = &mloopuv[mp->loopstart]; @@ -721,13 +721,13 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) if (!mf_smooth) { float nor[3]; - normal_tri_v3( nor,v1, v2, v3); + normal_tri_v3(nor, v1, v2, v3); glNormal3fv(nor); } GPU_render_text(&tmp_tf, mode, string, characters, - (unsigned int*)tmp_mcol_pt, v1, v2, v3, (mp->totloop >= 4 ? v4: NULL), glattrib); + (unsigned int *)tmp_mcol_pt, v1, v2, v3, (mp->totloop >= 4 ? v4 : NULL), glattrib); } } @@ -749,7 +749,7 @@ static int compareDrawOptions(void *userData, int cur_index, int next_index) static int compareDrawOptionsEm(void *userData, int cur_index, int next_index) { - drawEMTFMapped_userData *data= userData; + drawEMTFMapped_userData *data = userData; if (data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr) return 0; @@ -762,7 +762,7 @@ static int compareDrawOptionsEm(void *userData, int cur_index, int next_index) void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) { - Mesh *me= ob->data; + Mesh *me = ob->data; /* correct for negative scale */ if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW); @@ -771,23 +771,23 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec /* draw the textured mesh */ draw_textured_begin(scene, v3d, rv3d, ob); - glColor4f(1.0f,1.0f,1.0f,1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if (ob->mode & OB_MODE_EDIT) { drawEMTFMapped_userData data; - data.em= me->edit_btmesh; - data.has_mcol= CustomData_has_layer(&me->edit_btmesh->bm->ldata, CD_MLOOPCOL); - data.has_mtface= CustomData_has_layer(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY); - data.mf= DM_get_tessface_data_layer(dm, CD_MFACE); - data.tf= DM_get_tessface_data_layer(dm, CD_MTFACE); + data.em = me->edit_btmesh; + data.has_mcol = CustomData_has_layer(&me->edit_btmesh->bm->ldata, CD_MLOOPCOL); + data.has_mtface = CustomData_has_layer(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY); + data.mf = DM_get_tessface_data_layer(dm, CD_MFACE); + data.tf = DM_get_tessface_data_layer(dm, CD_MTFACE); dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, compareDrawOptionsEm, &data); } else if (draw_flags & DRAW_FACE_SELECT) { if (ob->mode & OB_MODE_WEIGHT_PAINT) dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); else dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me); } @@ -801,7 +801,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec else { drawTFace_userData userData; - if (!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL)) + if (!CustomData_has_layer(&dm->faceData, CD_TEXTURE_MCOL)) add_tface_color_layer(dm); userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE); @@ -849,22 +849,22 @@ static void tex_mat_set_material_cb(void *UNUSED(userData), int mat_nr, void *at static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs) { /* texture draw mode without GLSL */ - TexMatCallback *data= (TexMatCallback*)userData; + TexMatCallback *data = (TexMatCallback *)userData; GPUVertexAttribs *gattribs = attribs; Image *ima; ImageUser *iuser; bNode *node; - int texture_set= 0; + int texture_set = 0; /* draw image texture if we find one */ if (ED_object_get_active_image(data->ob, mat_nr, &ima, &iuser, &node)) { /* get openl texture */ - int mipmap= 1; - int bindcode= (ima)? GPU_verify_image(ima, iuser, 0, 0, mipmap): 0; + int mipmap = 1; + int bindcode = (ima) ? GPU_verify_image(ima, iuser, 0, 0, mipmap) : 0; float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; if (bindcode) { - NodeTexBase *texbase= node->storage; + NodeTexBase *texbase = node->storage; /* disable existing material */ GPU_disable_material(); @@ -886,12 +886,12 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs) /* use active UV texture layer */ memset(gattribs, 0, sizeof(*gattribs)); - gattribs->layer[0].type= CD_MTFACE; - gattribs->layer[0].name[0]= '\0'; - gattribs->layer[0].gltexco= 1; - gattribs->totlayer= 1; + gattribs->layer[0].type = CD_MTFACE; + gattribs->layer[0].name[0] = '\0'; + gattribs->layer[0].gltexco = 1; + gattribs->totlayer = 1; - texture_set= 1; + texture_set = 1; } } @@ -912,8 +912,8 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs) static int tex_mat_set_face_mesh_cb(void *userData, int index) { /* faceselect mode face hiding */ - TexMatCallback *data= (TexMatCallback*)userData; - Mesh *me = (Mesh*)data->me; + TexMatCallback *data = (TexMatCallback *)userData; + Mesh *me = (Mesh *)data->me; MPoly *mp = &me->mpoly[index]; return !(mp->flag & ME_HIDE); @@ -922,9 +922,9 @@ static int tex_mat_set_face_mesh_cb(void *userData, int index) static int tex_mat_set_face_editmesh_cb(void *userData, int index) { /* editmode face hiding */ - TexMatCallback *data= (TexMatCallback*)userData; - Mesh *me = (Mesh*)data->me; - BMFace *efa= EDBM_get_face_for_index(me->edit_btmesh, index); + TexMatCallback *data = (TexMatCallback *)userData; + Mesh *me = (Mesh *)data->me; + BMFace *efa = EDBM_get_face_for_index(me->edit_btmesh, index); return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN); } @@ -945,32 +945,32 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o if (ob->mode & OB_MODE_WEIGHT_PAINT) { /* weight paint mode exception */ dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_material, - GPU_enable_material, NULL, ob->data, DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + GPU_enable_material, NULL, ob->data, DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); } else { - Mesh *me= ob->data; + Mesh *me = ob->data; TexMatCallback data = {scene, ob, me, dm}; - int (*set_face_cb)(void*, int); + int (*set_face_cb)(void *, int); int glsl; /* face hiding callback depending on mode */ if (ob == scene->obedit) - set_face_cb= tex_mat_set_face_editmesh_cb; + set_face_cb = tex_mat_set_face_editmesh_cb; else if (draw_flags & DRAW_FACE_SELECT) - set_face_cb= tex_mat_set_face_mesh_cb; + set_face_cb = tex_mat_set_face_mesh_cb; else - set_face_cb= NULL; + set_face_cb = NULL; /* test if we can use glsl */ - glsl= (v3d->drawtype == OB_MATERIAL) && GPU_glsl_support(); + glsl = (v3d->drawtype == OB_MATERIAL) && GPU_glsl_support(); GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); if (glsl) { /* draw glsl */ dm->drawMappedFacesMat(dm, - tex_mat_set_material_cb, - set_face_cb, &data); + tex_mat_set_material_cb, + set_face_cb, &data); } else { float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; @@ -981,8 +981,8 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0); dm->drawMappedFacesMat(dm, - tex_mat_set_texture_cb, - set_face_cb, &data); + tex_mat_set_texture_cb, + set_face_cb, &data); } GPU_end_object_materials(); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b78d5b23e3f..0332bd0bdb7 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -55,7 +55,7 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" -#include "BKE_anim.h" //for the where_on_path function +#include "BKE_anim.h" //for the where_on_path function #include "BKE_armature.h" #include "BKE_camera.h" #include "BKE_constraint.h" // for the get_constraint_target function @@ -107,18 +107,18 @@ #include "wm_subwindow.h" #include "BLF_api.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include /* this condition has been made more complex since editmode can draw textures */ #define CHECK_OB_DRAWTEXTURE(vd, dt) \ - ((ELEM(vd->drawtype, OB_TEXTURE, OB_MATERIAL) && dt>OB_SOLID) || \ - (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX)) + ((ELEM(vd->drawtype, OB_TEXTURE, OB_MATERIAL) && dt > OB_SOLID) || \ + (vd->drawtype == OB_SOLID && vd->flag2 & V3D_SOLID_TEX)) typedef enum eWireDrawMode { - OBDRAW_WIRE_OFF= 0, - OBDRAW_WIRE_ON= 1, - OBDRAW_WIRE_ON_DEPTH= 2 + OBDRAW_WIRE_OFF = 0, + OBDRAW_WIRE_ON = 1, + OBDRAW_WIRE_ON_DEPTH = 2 } eWireDrawMode; /* user data structures for derived mesh callbacks */ @@ -195,7 +195,7 @@ static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) return 1; /* if its drawing textures with zbuf sel, then don't draw dots */ - if (dt==OB_TEXTURE && vd->drawtype==OB_TEXTURE) + if (dt == OB_TEXTURE && vd->drawtype == OB_TEXTURE) return 0; if ((vd->drawtype >= OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX)) @@ -209,10 +209,10 @@ static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) * */ static void view3d_project_short_clip(ARegion *ar, const float vec[3], short adr[2], int is_local) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; - adr[0]= IS_CLIPPED; + adr[0] = IS_CLIPPED; /* clipplanes in eye space */ if (rv3d->rflag & RV3D_CLIPPING) { @@ -221,21 +221,21 @@ static void view3d_project_short_clip(ARegion *ar, const float vec[3], short adr } copy_v3_v3(vec4, vec); - vec4[3]= 1.0; + vec4[3] = 1.0; mul_m4_v4(rv3d->persmatob, vec4); /* clipplanes in window space */ - if ( vec4[3] > (float)BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ - fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); + if (vec4[3] > (float)BL_NEAR_CLIP) { /* is the NEAR clipping cutoff for picking */ + fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); - if ( fx>0 && fx<ar->winx) { + if (fx > 0 && fx < ar->winx) { - fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); + fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); if (fy > 0.0f && fy < (float)ar->winy) { - adr[0]= (short)floorf(fx); - adr[1]= (short)floorf(fy); + adr[0] = (short)floorf(fx); + adr[1] = (short)floorf(fy); } } } @@ -244,28 +244,28 @@ static void view3d_project_short_clip(ARegion *ar, const float vec[3], short adr /* BMESH NOTE: this function is unused in bmesh only */ /* only use while object drawing */ -static void UNUSED_FUNCTION(view3d_project_short_noclip)(ARegion *ar, const float vec[3], short adr[2]) +static void UNUSED_FUNCTION(view3d_project_short_noclip) (ARegion * ar, const float vec[3], short adr[2]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; - adr[0]= IS_CLIPPED; + adr[0] = IS_CLIPPED; copy_v3_v3(vec4, vec); - vec4[3]= 1.0; + vec4[3] = 1.0; mul_m4_v4(rv3d->persmatob, vec4); - if ( vec4[3] > (float)BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ - fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); + if (vec4[3] > (float)BL_NEAR_CLIP) { /* is the NEAR clipping cutoff for picking */ + fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); - if ( fx>-32700 && fx<32700) { + if (fx > -32700 && fx < 32700) { - fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); + fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); if (fy > -32700.0f && fy < 32700.0f) { - adr[0]= (short)floorf(fx); - adr[1]= (short)floorf(fy); + adr[0] = (short)floorf(fx); + adr[1] = (short)floorf(fy); } } } @@ -274,10 +274,10 @@ static void UNUSED_FUNCTION(view3d_project_short_noclip)(ARegion *ar, const floa /* same as view3d_project_short_clip but use persmat instead of persmatob for projection */ static void view3d_project_short_clip_persmat(ARegion *ar, const float vec[3], short adr[2], int is_local) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; - adr[0]= IS_CLIPPED; + adr[0] = IS_CLIPPED; /* clipplanes in eye space */ if (rv3d->rflag & RV3D_CLIPPING) { @@ -286,21 +286,21 @@ static void view3d_project_short_clip_persmat(ARegion *ar, const float vec[3], s } copy_v3_v3(vec4, vec); - vec4[3]= 1.0; + vec4[3] = 1.0; mul_m4_v4(rv3d->persmat, vec4); /* clipplanes in window space */ - if ( vec4[3] > (float)BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ - fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); + if (vec4[3] > (float)BL_NEAR_CLIP) { /* is the NEAR clipping cutoff for picking */ + fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); - if ( fx>0 && fx<ar->winx) { + if (fx > 0 && fx < ar->winx) { - fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); + fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); if (fy > 0.0f && fy < (float)ar->winy) { - adr[0]= (short)floorf(fx); - adr[1]= (short)floorf(fy); + adr[0] = (short)floorf(fx); + adr[1] = (short)floorf(fy); } } } @@ -317,7 +317,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if (!CHECK_OB_DRAWTEXTURE(v3d, dt)) return 0; - if (ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) + if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; if (scene_use_new_shading_nodes(scene)) return 0; @@ -336,14 +336,13 @@ static int check_alpha_pass(Base *base) return (base->object->dtx & OB_DRAWTRANSP); } - /***/ -static unsigned int colortab[24]= - {0x0, 0xFF88FF, 0xFFBBFF, - 0x403000, 0xFFFF88, 0xFFFFBB, - 0x104040, 0x66CCCC, 0x77CCCC, - 0x104010, 0x55BB55, 0x66FF66, - 0xFFFFFF -}; +/***/ +static unsigned int colortab[24] = +{0x0, 0xFF88FF, 0xFFBBFF, + 0x403000, 0xFFFF88, 0xFFFFBB, + 0x104040, 0x66CCCC, 0x77CCCC, + 0x104010, 0x55BB55, 0x66FF66, + 0xFFFFFF}; static float cube[8][3] = { @@ -434,16 +433,16 @@ static const float cosval[CIRCLE_RESOL] = { static void draw_xyz_wire(const float c[3], float size, int axis) { - float v1[3]= {0.f, 0.f, 0.f}, v2[3] = {0.f, 0.f, 0.f}; + float v1[3] = {0.f, 0.f, 0.f}, v2[3] = {0.f, 0.f, 0.f}; float dim = size * 0.1f; float dx[3], dy[3], dz[3]; - dx[0]=dim; dx[1]=0.f; dx[2]=0.f; - dy[0]=0.f; dy[1]=dim; dy[2]=0.f; - dz[0]=0.f; dz[1]=0.f; dz[2]=dim; + dx[0] = dim; dx[1] = 0.f; dx[2] = 0.f; + dy[0] = 0.f; dy[1] = dim; dy[2] = 0.f; + dz[0] = 0.f; dz[1] = 0.f; dz[2] = dim; - switch(axis) { - case 0: /* x axis */ + switch (axis) { + case 0: /* x axis */ glBegin(GL_LINES); /* bottom left to top right */ @@ -465,7 +464,7 @@ static void draw_xyz_wire(const float c[3], float size, int axis) glEnd(); break; - case 1: /* y axis */ + case 1: /* y axis */ glBegin(GL_LINES); /* bottom left to top right */ @@ -488,7 +487,7 @@ static void draw_xyz_wire(const float c[3], float size, int axis) glEnd(); break; - case 2: /* z axis */ + case 2: /* z axis */ glBegin(GL_LINE_STRIP); /* start at top left */ @@ -521,23 +520,23 @@ static void draw_xyz_wire(const float c[3], float size, int axis) void drawaxes(float size, char drawtype) { int axis; - float v1[3]= {0.0, 0.0, 0.0}; - float v2[3]= {0.0, 0.0, 0.0}; - float v3[3]= {0.0, 0.0, 0.0}; + float v1[3] = {0.0, 0.0, 0.0}; + float v2[3] = {0.0, 0.0, 0.0}; + float v3[3] = {0.0, 0.0, 0.0}; - switch(drawtype) { + switch (drawtype) { case OB_PLAINAXES: - for (axis=0; axis<3; axis++) { + for (axis = 0; axis < 3; axis++) { glBegin(GL_LINES); - v1[axis]= size; - v2[axis]= -size; + v1[axis] = size; + v2[axis] = -size; glVertex3fv(v1); glVertex3fv(v2); /* reset v1 & v2 to zero */ - v1[axis]= v2[axis]= 0.0f; + v1[axis] = v2[axis] = 0.0f; glEnd(); } @@ -546,7 +545,7 @@ void drawaxes(float size, char drawtype) glBegin(GL_LINES); /* in positive z direction only */ - v1[2]= size; + v1[2] = size; glVertex3fv(v1); glVertex3fv(v2); glEnd(); @@ -554,11 +553,11 @@ void drawaxes(float size, char drawtype) /* square pyramid */ glBegin(GL_TRIANGLES); - v2[0]= size * 0.035f; v2[1] = size * 0.035f; - v3[0]= size * -0.035f; v3[1] = size * 0.035f; - v2[2]= v3[2]= size * 0.75f; + v2[0] = size * 0.035f; v2[1] = size * 0.035f; + v3[0] = size * -0.035f; v3[1] = size * 0.035f; + v2[2] = v3[2] = size * 0.75f; - for (axis=0; axis<4; axis++) { + for (axis = 0; axis < 4; axis++) { if (axis % 2 == 1) { v2[0] = -v2[0]; v3[1] = -v3[1]; @@ -595,33 +594,33 @@ void drawaxes(float size, char drawtype) case OB_ARROWS: default: { - for (axis=0; axis<3; axis++) { - const int arrow_axis= (axis==0) ? 1:0; + for (axis = 0; axis < 3; axis++) { + const int arrow_axis = (axis == 0) ? 1 : 0; glBegin(GL_LINES); - v2[axis]= size; + v2[axis] = size; glVertex3fv(v1); glVertex3fv(v2); - v1[axis]= size*0.85f; - v1[arrow_axis]= -size*0.08f; + v1[axis] = size * 0.85f; + v1[arrow_axis] = -size * 0.08f; glVertex3fv(v1); glVertex3fv(v2); - v1[arrow_axis]= size*0.08f; + v1[arrow_axis] = size * 0.08f; glVertex3fv(v1); glVertex3fv(v2); glEnd(); - v2[axis]+= size*0.125f; + v2[axis] += size * 0.125f; draw_xyz_wire(v2, size, axis); /* reset v1 & v2 to zero */ - v1[arrow_axis]= v1[axis]= v2[axis]= 0.0f; + v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f; } break; } @@ -632,7 +631,7 @@ void drawaxes(float size, char drawtype) /* Function to draw an Image on a empty Object */ static void draw_empty_image(Object *ob) { - Image *ima = (Image*)ob->data; + Image *ima = (Image *)ob->data; ImBuf *ibuf = ima ? BKE_image_get_ibuf(ima, NULL) : NULL; float scale, ofs_x, ofs_y, sca_x, sca_y; @@ -644,37 +643,37 @@ static void draw_empty_image(Object *ob) /* Get the buffer dimensions so we can fallback to fake ones */ if (ibuf && ibuf->rect) { - ima_x= ibuf->x; - ima_y= ibuf->y; + ima_x = ibuf->x; + ima_y = ibuf->y; } else { - ima_x= 1; - ima_y= 1; + ima_x = 1; + ima_y = 1; } /* Get the image aspect even if the buffer is invalid */ if (ima) { if (ima->aspx > ima->aspy) { - sca_x= 1.0f; - sca_y= ima->aspy / ima->aspx; + sca_x = 1.0f; + sca_y = ima->aspy / ima->aspx; } else if (ima->aspx < ima->aspy) { - sca_x= ima->aspx / ima->aspy; - sca_y= 1.0f; + sca_x = ima->aspx / ima->aspy; + sca_y = 1.0f; } else { - sca_x= 1.0f; - sca_y= 1.0f; + sca_x = 1.0f; + sca_y = 1.0f; } } else { - sca_x= 1.0f; - sca_y= 1.0f; + sca_x = 1.0f; + sca_y = 1.0f; } /* Calculate the scale center based on objects origin */ - ofs_x= ob->ima_ofs[0] * ima_x; - ofs_y= ob->ima_ofs[1] * ima_y; + ofs_x = ob->ima_ofs[0] * ima_x; + ofs_y = ob->ima_ofs[1] * ima_y; glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -683,7 +682,7 @@ static void draw_empty_image(Object *ob) glTranslatef(0.0f, 0.0f, 0.0f); /* Calculate Image scale */ - scale= (ob->empty_drawsize / (float)MAX2(ima_x * sca_x, ima_y * sca_y)); + scale = (ob->empty_drawsize / (float)MAX2(ima_x * sca_x, ima_y * sca_y)); /* Set the object scale */ glScalef(scale * sca_x, scale * sca_y, 1.0f); @@ -721,16 +720,16 @@ static void draw_empty_image(Object *ob) static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, float tmat[][4]) { float vx[3], vy[3]; - float *viter= (float *)verts; + float *viter = (float *)verts; unsigned int a; mul_v3_v3fl(vx, tmat[0], rad); mul_v3_v3fl(vy, tmat[1], rad); - for (a=0; a < CIRCLE_RESOL; a++, viter += 3) { - viter[0]= cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0]; - viter[1]= cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1]; - viter[2]= cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2]; + for (a = 0; a < CIRCLE_RESOL; a++, viter += 3) { + viter[0] = cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0]; + viter[1] = cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1]; + viter[2] = cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2]; } } @@ -749,16 +748,16 @@ void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]) /* circle for object centers, special_color is for library or ob users */ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], int selstate, int special_color) { - const float size= ED_view3d_pixel_size(rv3d, co) * (float)U.obcenter_dia * 0.5f; + const float size = ED_view3d_pixel_size(rv3d, co) * (float)U.obcenter_dia * 0.5f; float verts[CIRCLE_RESOL][3]; /* using gldepthfunc guarantees that it does write z values, * but not checks for it, so centers remain visible independent order of drawing */ - if (v3d->zbuf) glDepthFunc(GL_ALWAYS); + if (v3d->zbuf) glDepthFunc(GL_ALWAYS); glEnable(GL_BLEND); if (special_color) { - if (selstate==ACTIVE || selstate==SELECT) glColor4ub(0x88, 0xFF, 0xFF, 155); + if (selstate == ACTIVE || selstate == SELECT) glColor4ub(0x88, 0xFF, 0xFF, 155); else glColor4ub(0x55, 0xCC, 0xCC, 155); } @@ -786,12 +785,12 @@ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], glDisable(GL_BLEND); - if (v3d->zbuf) glDepthFunc(GL_LEQUAL); + if (v3d->zbuf) glDepthFunc(GL_LEQUAL); } /* *********** text drawing for object/particles/armature ************* */ static ListBase CachedText[3]; -static int CachedTextLevel= 0; +static int CachedTextLevel = 0; typedef struct ViewCachedString { struct ViewCachedString *next, *prev; @@ -809,8 +808,8 @@ typedef struct ViewCachedString { void view3d_cached_text_draw_begin(void) { - ListBase *strings= &CachedText[CachedTextLevel]; - strings->first= strings->last= NULL; + ListBase *strings = &CachedText[CachedTextLevel]; + strings->first = strings->last = NULL; CachedTextLevel++; } @@ -819,17 +818,17 @@ void view3d_cached_text_draw_add(const float co[3], short xoffs, short flag, const unsigned char col[4]) { - int alloc_len= strlen(str) + 1; - ListBase *strings= &CachedText[CachedTextLevel-1]; + int alloc_len = strlen(str) + 1; + ListBase *strings = &CachedText[CachedTextLevel - 1]; /* TODO, replace with more efficient malloc, perhaps memarena per draw? */ - ViewCachedString *vos= MEM_callocN(sizeof(ViewCachedString) + alloc_len, "ViewCachedString"); + ViewCachedString *vos = MEM_callocN(sizeof(ViewCachedString) + alloc_len, "ViewCachedString"); BLI_addtail(strings, vos); copy_v3_v3(vos->vec, co); - vos->col.pack= *((int *)col); - vos->xoffs= xoffs; - vos->flag= flag; - vos->str_len= alloc_len-1; + vos->col.pack = *((int *)col); + vos->xoffs = xoffs; + vos->flag = flag; + vos->str_len = alloc_len - 1; /* allocate past the end */ memcpy(++vos, str, alloc_len); @@ -837,13 +836,13 @@ void view3d_cached_text_draw_add(const float co[3], void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, float mat[][4]) { - RegionView3D *rv3d= ar->regiondata; - ListBase *strings= &CachedText[CachedTextLevel-1]; + RegionView3D *rv3d = ar->regiondata; + ListBase *strings = &CachedText[CachedTextLevel - 1]; ViewCachedString *vos; - int tot= 0; + int tot = 0; /* project first and test */ - for (vos= strings->first; vos; vos= vos->next) { + for (vos = strings->first; vos; vos = vos->next) { if (mat && !(vos->flag & V3D_CACHE_TEXT_WORLDSPACE)) mul_m4_v3(mat, vos->vec); @@ -852,12 +851,12 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa else view3d_project_short_clip(ar, vos->vec, vos->sco, (vos->flag & V3D_CACHE_TEXT_LOCALCLIP) != 0); - if (vos->sco[0]!=IS_CLIPPED) + if (vos->sco[0] != IS_CLIPPED) tot++; } if (tot) { - int col_pack_prev= 0; + int col_pack_prev = 0; #if 0 bglMats mats; /* ZBuffer depth vars */ @@ -884,34 +883,34 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa glDepthMask(0); } - for (vos= strings->first; vos; vos= vos->next) { + for (vos = strings->first; vos; vos = vos->next) { /* too slow, reading opengl info while drawing is very bad, * better to see if we can use the zbuffer while in pixel space - campbell */ #if 0 if (v3d->zbuf && (vos->flag & V3D_CACHE_TEXT_ZBUF)) { gluProject(vos->vec[0], vos->vec[1], vos->vec[2], mats.modelview, mats.projection, (GLint *)mats.viewport, &ux, &uy, &uz); - glReadPixels(ar->winrct.xmin+vos->mval[0]+vos->xoffs, ar->winrct.ymin+vos->mval[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); + glReadPixels(ar->winrct.xmin + vos->mval[0] + vos->xoffs, ar->winrct.ymin + vos->mval[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); if (uz > depth) continue; } #endif - if (vos->sco[0]!=IS_CLIPPED) { - const char *str= (char *)(vos+1); + if (vos->sco[0] != IS_CLIPPED) { + const char *str = (char *)(vos + 1); if (col_pack_prev != vos->col.pack) { glColor3ubv(vos->col.ub); - col_pack_prev= vos->col.pack; + col_pack_prev = vos->col.pack; } ((vos->flag & V3D_CACHE_TEXT_ASCII) ? - BLF_draw_default_ascii : - BLF_draw_default - ) ( (float)vos->sco[0] + vos->xoffs, - (float)vos->sco[1], - (depth_write) ? 0.0f: 2.0f, - str, - vos->str_len); + BLF_draw_default_ascii : + BLF_draw_default + )( (float)vos->sco[0] + vos->xoffs, + (float)vos->sco[1], + (depth_write) ? 0.0f : 2.0f, + str, + vos->str_len); } } @@ -942,8 +941,8 @@ static void drawcube(void) { glBegin(GL_LINE_STRIP); - glVertex3fv(cube[0]); glVertex3fv(cube[1]);glVertex3fv(cube[2]); glVertex3fv(cube[3]); - glVertex3fv(cube[0]); glVertex3fv(cube[4]);glVertex3fv(cube[5]); glVertex3fv(cube[6]); + glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); + glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[7]); glVertex3fv(cube[4]); glEnd(); @@ -966,25 +965,25 @@ static void drawcube(void) static void drawcube_size(float size) { glBegin(GL_LINE_STRIP); - glVertex3f(-size,-size,-size); glVertex3f(-size,-size,size); - glVertex3f(-size,size,size); glVertex3f(-size,size,-size); + glVertex3f(-size, -size, -size); glVertex3f(-size, -size, size); + glVertex3f(-size, size, size); glVertex3f(-size, size, -size); - glVertex3f(-size,-size,-size); glVertex3f(size,-size,-size); - glVertex3f(size,-size,size); glVertex3f(size,size,size); + glVertex3f(-size, -size, -size); glVertex3f(size, -size, -size); + glVertex3f(size, -size, size); glVertex3f(size, size, size); - glVertex3f(size,size,-size); glVertex3f(size,-size,-size); + glVertex3f(size, size, -size); glVertex3f(size, -size, -size); glEnd(); glBegin(GL_LINE_STRIP); - glVertex3f(-size,-size,size); glVertex3f(size,-size,size); + glVertex3f(-size, -size, size); glVertex3f(size, -size, size); glEnd(); glBegin(GL_LINE_STRIP); - glVertex3f(-size,size,size); glVertex3f(size,size,size); + glVertex3f(-size, size, size); glVertex3f(size, size, size); glEnd(); glBegin(GL_LINE_STRIP); - glVertex3f(-size,size,-size); glVertex3f(size,size,-size); + glVertex3f(-size, size, -size); glVertex3f(size, size, -size); glEnd(); } @@ -998,8 +997,8 @@ static void drawcube_size(const float size[3]) glBegin(GL_LINE_STRIP); - glVertex3fv(cube[0]); glVertex3fv(cube[1]);glVertex3fv(cube[2]); glVertex3fv(cube[3]); - glVertex3fv(cube[0]); glVertex3fv(cube[4]);glVertex3fv(cube[5]); glVertex3fv(cube[6]); + glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); + glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[7]); glVertex3fv(cube[4]); glEnd(); @@ -1047,17 +1046,17 @@ static void drawshadbuflimits(Lamp *la, float mat[][4]) static void spotvolume(float lvec[3], float vvec[3], const float inp) { /* camera is at 0,0,0 */ - float temp[3],plane[3],mat1[3][3],mat2[3][3],mat3[3][3],mat4[3][3],q[4],co,si,angle; + float temp[3], plane[3], mat1[3][3], mat2[3][3], mat3[3][3], mat4[3][3], q[4], co, si, angle; normalize_v3(lvec); - normalize_v3(vvec); /* is this the correct vector ? */ + normalize_v3(vvec); /* is this the correct vector ? */ - cross_v3_v3v3(temp,vvec,lvec); /* equation for a plane through vvec en lvec */ - cross_v3_v3v3(plane,lvec,temp); /* a plane perpendicular to this, parrallel with lvec */ + cross_v3_v3v3(temp, vvec, lvec); /* equation for a plane through vvec en lvec */ + cross_v3_v3v3(plane, lvec, temp); /* a plane perpendicular to this, parrallel with lvec */ /* vectors are exactly aligned, use the X axis, this is arbitrary */ if (normalize_v3(plane) == 0.0f) - plane[1]= 1.0f; + plane[1] = 1.0f; /* now we've got two equations: one of a cone and one of a plane, but we have * three unknowns. We remove one unknown by rotating the plane to z=0 (the plane normal) */ @@ -1072,46 +1071,46 @@ static void spotvolume(float lvec[3], float vvec[3], const float inp) q[3] = 0; normalize_v3(&q[1]); - angle = saacos(plane[2])/2.0f; + angle = saacos(plane[2]) / 2.0f; co = cosf(angle); - si = sqrtf(1-co*co); + si = sqrtf(1 - co * co); q[0] = co; q[1] *= si; q[2] *= si; q[3] = 0; - quat_to_mat3(mat1,q); + quat_to_mat3(mat1, q); /* rotate lamp vector now over acos(inp) degrees */ copy_v3_v3(vvec, lvec); unit_m3(mat2); co = inp; - si = sqrtf(1.0f-inp*inp); + si = sqrtf(1.0f - inp * inp); mat2[0][0] = co; mat2[1][0] = -si; mat2[0][1] = si; mat2[1][1] = co; - mul_m3_m3m3(mat3,mat2,mat1); + mul_m3_m3m3(mat3, mat2, mat1); mat2[1][0] = si; mat2[0][1] = -si; - mul_m3_m3m3(mat4,mat2,mat1); + mul_m3_m3m3(mat4, mat2, mat1); transpose_m3(mat1); - mul_m3_m3m3(mat2,mat1,mat3); - mul_m3_v3(mat2,lvec); - mul_m3_m3m3(mat2,mat1,mat4); - mul_m3_v3(mat2,vvec); + mul_m3_m3m3(mat2, mat1, mat3); + mul_m3_v3(mat2, lvec); + mul_m3_m3m3(mat2, mat1, mat4); + mul_m3_v3(mat2, vvec); return; } static void draw_spot_cone(Lamp *la, float x, float z) { - z= fabs(z); + z = fabs(z); glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0f, 0.0f, -x); @@ -1127,9 +1126,9 @@ static void draw_spot_cone(Lamp *la, float x, float z) float angle; int a; - for (a=0; a<33; a++) { - angle= a*M_PI*2/(33-1); - glVertex3f(z*cosf(angle), z*sinf(angle), 0); + for (a = 0; a < 33; a++) { + angle = a * M_PI * 2 / (33 - 1); + glVertex3f(z * cosf(angle), z * sinf(angle), 0); } } @@ -1168,22 +1167,22 @@ static void draw_transp_spot_volume(Lamp *la, float x, float z) static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag) { - Object *ob= base->object; - const float pixsize= ED_view3d_pixel_size(rv3d, ob->obmat[3]); - Lamp *la= ob->data; - float vec[3], lvec[3], vvec[3], circrad, x,y,z; + Object *ob = base->object; + const float pixsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]); + Lamp *la = ob->data; + float vec[3], lvec[3], vvec[3], circrad, x, y, z; float lampsize; float imat[4][4], curcol[4]; unsigned char col[4]; /* cone can't be drawn for duplicated lamps, because duplilist would be freed to */ /* the moment of view3d_draw_transp() call */ - const short is_view= (rv3d->persp==RV3D_CAMOB && v3d->camera == base->object); - const short drawcone= ((dt > OB_WIRE) && - !(G.f & G_PICKSEL) && - (la->type == LA_SPOT) && - (la->mode & LA_SHOW_CONE) && - !(base->flag & OB_FROMDUPLI) && - !is_view); + const short is_view = (rv3d->persp == RV3D_CAMOB && v3d->camera == base->object); + const short drawcone = ((dt > OB_WIRE) && + !(G.f & G_PICKSEL) && + (la->type == LA_SPOT) && + (la->mode & LA_SHOW_CONE) && + !(base->flag & OB_FROMDUPLI) && + !is_view); if (drawcone && !v3d->transp) { /* in this case we need to draw delayed */ @@ -1196,7 +1195,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glLoadMatrixf(rv3d->viewmat); /* lets calculate the scale: */ - lampsize= pixsize*((float)U.obcenter_dia*0.5f); + lampsize = pixsize * ((float)U.obcenter_dia * 0.5f); /* and view aligned matrix: */ copy_m4_m4(imat, rv3d->viewinv); @@ -1208,13 +1207,13 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* for AA effects */ glGetFloatv(GL_CURRENT_COLOR, curcol); - curcol[3]= 0.6; + curcol[3] = 0.6; glColor4fv(curcol); if (lampsize > 0.0f) { - if (ob->id.us>1) { - if (ob==OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155); + if (ob->id.us > 1) { + if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155); else glColor4ub(0x77, 0xCC, 0xCC, 155); } @@ -1225,19 +1224,19 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, drawcircball(GL_POLYGON, vec, lampsize, imat); /* restore */ - if (ob->id.us>1) + if (ob->id.us > 1) glColor4fv(curcol); /* Outer circle */ - circrad = 3.0f*lampsize; + circrad = 3.0f * lampsize; setlinestyle(3); drawcircball(GL_LINE_LOOP, vec, circrad, imat); /* draw dashed outer circle if shadow is on. remember some lamps can't have certain shadows! */ - if (la->type!=LA_HEMI) { + if (la->type != LA_HEMI) { if ((la->mode & LA_SHAD_RAY) || ((la->mode & LA_SHAD_BUF) && (la->type == LA_SPOT))) { - drawcircball(GL_LINE_LOOP, vec, circrad + 3.0f*pixsize, imat); + drawcircball(GL_LINE_LOOP, vec, circrad + 3.0f * pixsize, imat); } } } @@ -1247,12 +1246,12 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } /* draw the pretty sun rays */ - if (la->type==LA_SUN) { + if (la->type == LA_SUN) { float v1[3], v2[3], mat[3][3]; short axis; /* setup a 45 degree rotation matrix */ - vec_rot_to_mat3(mat, imat[2], (float)M_PI/4.0f); + vec_rot_to_mat3(mat, imat[2], (float)M_PI / 4.0f); /* vectors */ mul_v3_v3fl(v1, imat[0], circrad * 1.2f); @@ -1264,7 +1263,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, setlinestyle(3); glBegin(GL_LINES); - for (axis=0; axis<8; axis++) { + for (axis = 0; axis < 8; axis++) { glVertex3fv(v1); glVertex3fv(v2); mul_m3_v3(mat, v1); @@ -1276,30 +1275,30 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } - if (la->type==LA_LOCAL) { + if (la->type == LA_LOCAL) { if (la->mode & LA_SPHERE) { drawcircball(GL_LINE_LOOP, vec, la->dist, imat); } /* yafray: for photonlight also draw lightcone as for spot */ } - glPopMatrix(); /* back in object space */ + glPopMatrix(); /* back in object space */ zero_v3(vec); if (is_view) { /* skip drawing extra info */ } - else if ((la->type==LA_SPOT) || (la->type==LA_YF_PHOTON)) { - lvec[0]=lvec[1]= 0.0; + else if ((la->type == LA_SPOT) || (la->type == LA_YF_PHOTON)) { + lvec[0] = lvec[1] = 0.0; lvec[2] = 1.0; x = rv3d->persmat[0][2]; y = rv3d->persmat[1][2]; z = rv3d->persmat[2][2]; - vvec[0]= x*ob->obmat[0][0] + y*ob->obmat[0][1] + z*ob->obmat[0][2]; - vvec[1]= x*ob->obmat[1][0] + y*ob->obmat[1][1] + z*ob->obmat[1][2]; - vvec[2]= x*ob->obmat[2][0] + y*ob->obmat[2][1] + z*ob->obmat[2][2]; + vvec[0] = x * ob->obmat[0][0] + y * ob->obmat[0][1] + z * ob->obmat[0][2]; + vvec[1] = x * ob->obmat[1][0] + y * ob->obmat[1][1] + z * ob->obmat[1][2]; + vvec[2] = x * ob->obmat[2][0] + y * ob->obmat[2][1] + z * ob->obmat[2][2]; - y = cosf(la->spotsize*(float)(M_PI/360.0)); + y = cosf(la->spotsize * (float)(M_PI / 360.0)); spotvolume(lvec, vvec, y); x = -la->dist; mul_v3_fl(lvec, x); @@ -1312,33 +1311,33 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glVertex3fv(lvec); glEnd(); - z = x*sqrtf(1.0f - y*y); + z = x * sqrtf(1.0f - y * y); x *= y; /* draw the circle/square at the end of the cone */ - glTranslatef(0.0, 0.0 , x); + glTranslatef(0.0, 0.0, x); if (la->mode & LA_SQUARE) { float tvec[3]; - float z_abs= fabs(z); + float z_abs = fabs(z); - tvec[0]= tvec[1]= z_abs; - tvec[2]= 0.0; + tvec[0] = tvec[1] = z_abs; + tvec[2] = 0.0; glBegin(GL_LINE_LOOP); glVertex3fv(tvec); - tvec[1]= -z_abs; /* neg */ + tvec[1] = -z_abs; /* neg */ glVertex3fv(tvec); - tvec[0]= -z_abs; /* neg */ + tvec[0] = -z_abs; /* neg */ glVertex3fv(tvec); - tvec[1]= z_abs; /* pos */ + tvec[1] = z_abs; /* pos */ glVertex3fv(tvec); glEnd(); } else circ(0.0, 0.0, fabsf(z)); /* draw the circle/square representing spotbl */ - if (la->type==LA_SPOT) { - float spotblcirc = fabs(z)*(1 - pow(la->spotblend, 2)); + if (la->type == LA_SPOT) { + float spotblcirc = fabs(z) * (1 - pow(la->spotblend, 2)); /* hide line if it is zero size or overlaps with outer border, * previously it adjusted to always to show it but that seems * confusing because it doesn't show the actual blend size */ @@ -1350,11 +1349,11 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, draw_transp_spot_volume(la, x, z); /* draw clip start, useful for wide cones where its not obvious where the start is */ - glTranslatef(0.0, 0.0 , -x); /* reverse translation above */ - if (la->type==LA_SPOT && (la->mode & LA_SHAD_BUF) ) { + glTranslatef(0.0, 0.0, -x); /* reverse translation above */ + if (la->type == LA_SPOT && (la->mode & LA_SHAD_BUF) ) { float lvec_clip[3]; float vvec_clip[3]; - float clipsta_fac= la->clipsta / -x; + float clipsta_fac = la->clipsta / -x; interp_v3_v3v3(lvec_clip, vec, lvec, clipsta_fac); interp_v3_v3v3(vvec_clip, vec, vvec, clipsta_fac); @@ -1371,11 +1370,11 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glBegin(GL_LINE_STRIP); vec[2] = -circrad; glVertex3fv(vec); - vec[2]= -la->dist; + vec[2] = -la->dist; glVertex3fv(vec); glEnd(); - if (la->type==LA_HEMI) { + if (la->type == LA_HEMI) { /* draw the hemisphere curves */ short axis, steps, dir; float outdist, zdist, mul; @@ -1384,24 +1383,24 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, setlinestyle(4); /* loop over the 4 compass points, and draw each arc as a LINE_STRIP */ - for (axis=0; axis<4; axis++) { - float v[3]= {0.0, 0.0, 0.0}; + for (axis = 0; axis < 4; axis++) { + float v[3] = {0.0, 0.0, 0.0}; zdist = 0.02; glBegin(GL_LINE_STRIP); - for (steps=0; steps<6; steps++) { - if (axis == 0 || axis == 1) { /* x axis up, x axis down */ + for (steps = 0; steps < 6; steps++) { + if (axis == 0 || axis == 1) { /* x axis up, x axis down */ /* make the arcs start at the edge of the energy circle */ - if (steps == 0) v[0] = dir*circrad; - else v[0] = v[0] + dir*(steps*outdist); + if (steps == 0) v[0] = dir * circrad; + else v[0] = v[0] + dir * (steps * outdist); } - else if (axis == 2 || axis == 3) { /* y axis up, y axis down */ + else if (axis == 2 || axis == 3) { /* y axis up, y axis down */ /* make the arcs start at the edge of the energy circle */ v[1] = (steps == 0) ? (dir * circrad) : (v[1] + dir * (steps * outdist)); } - v[2] = v[2] - steps*zdist; + v[2] = v[2] - steps * zdist; glVertex3fv(v); @@ -1414,16 +1413,16 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } } } - else if (la->type==LA_AREA) { + else if (la->type == LA_AREA) { setlinestyle(3); - if (la->area_shape==LA_AREA_SQUARE) - fdrawbox(-la->area_size*0.5f, -la->area_size*0.5f, la->area_size*0.5f, la->area_size*0.5f); - else if (la->area_shape==LA_AREA_RECT) - fdrawbox(-la->area_size*0.5f, -la->area_sizey*0.5f, la->area_size*0.5f, la->area_sizey*0.5f); + if (la->area_shape == LA_AREA_SQUARE) + fdrawbox(-la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f); + else if (la->area_shape == LA_AREA_RECT) + fdrawbox(-la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f); glBegin(GL_LINE_STRIP); - glVertex3f(0.0,0.0,-circrad); - glVertex3f(0.0,0.0,-la->dist); + glVertex3f(0.0, 0.0, -circrad); + glVertex3f(0.0, 0.0, -la->dist); glEnd(); } @@ -1442,12 +1441,12 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glEnable(GL_BLEND); - if (vec[2]>0) vec[2] -= circrad; + if (vec[2] > 0) vec[2] -= circrad; else vec[2] += circrad; glBegin(GL_LINE_STRIP); glVertex3fv(vec); - vec[2]= 0; + vec[2] = 0; glVertex3fv(vec); glEnd(); @@ -1495,22 +1494,22 @@ static void draw_focus_cross(float dist, float size) #ifdef VIEW3D_CAMERA_BORDER_HACK float view3d_camera_border_hack_col[4]; -short view3d_camera_border_hack_test= FALSE; +short view3d_camera_border_hack_test = FALSE; #endif /* ****************** draw clip data *************** */ static void draw_bundle_sphere(void) { - static GLuint displist= 0; + static GLuint displist = 0; if (displist == 0) { GLUquadricObj *qobj; - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - qobj= gluNewQuadric(); + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); glShadeModel(GL_SMOOTH); gluSphere(qobj, 0.05, 8, 8); @@ -1527,12 +1526,12 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D MovieClip *clip, MovieTrackingObject *tracking_object, int flag, int *global_track_index, int draw_selected) { - MovieTracking *tracking= &clip->tracking; + MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; float mat[4][4], imat[4][4]; unsigned char col[4], scol[4]; - int tracknr= *global_track_index; - ListBase *tracksbase= BKE_tracking_object_tracks(tracking, tracking_object); + int tracknr = *global_track_index; + ListBase *tracksbase = BKE_tracking_object_tracks(tracking, tracking_object); UI_GetThemeColor4ubv(TH_TEXT, col); UI_GetThemeColor4ubv(TH_SELECT, scol); @@ -1559,31 +1558,31 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glMultMatrixf(imat); } - for (track= tracksbase->first; track; track= track->next) { - int selected= TRACK_SELECTED(track); + for (track = tracksbase->first; track; track = track->next) { + int selected = TRACK_SELECTED(track); if (draw_selected && !selected) continue; - if ((track->flag&TRACK_HAS_BUNDLE)==0) + if ((track->flag & TRACK_HAS_BUNDLE) == 0) continue; - if (flag&DRAW_PICKING) - glLoadName(base->selcol + (tracknr<<16)); + if (flag & DRAW_PICKING) + glLoadName(base->selcol + (tracknr << 16)); glPushMatrix(); glTranslatef(track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]); - glScalef(v3d->bundle_size/0.05f, v3d->bundle_size/0.05f, v3d->bundle_size/0.05f); + glScalef(v3d->bundle_size / 0.05f, v3d->bundle_size / 0.05f, v3d->bundle_size / 0.05f); - if (v3d->drawtype==OB_WIRE) { + if (v3d->drawtype == OB_WIRE) { glDisable(GL_LIGHTING); if (selected) { - if (base==BASACT) UI_ThemeColor(TH_ACTIVE); + if (base == BASACT) UI_ThemeColor(TH_ACTIVE); else UI_ThemeColor(TH_SELECT); } else { - if (track->flag&TRACK_CUSTOMCOLOR) glColor3fv(track->color); + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); else UI_ThemeColor(TH_WIRE); } @@ -1591,11 +1590,11 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glEnable(GL_LIGHTING); } - else if (v3d->drawtype>OB_WIRE) { - if (v3d->bundle_drawtype==OB_EMPTY_SPHERE) { + else if (v3d->drawtype > OB_WIRE) { + if (v3d->bundle_drawtype == OB_EMPTY_SPHERE) { /* selection outline */ if (selected) { - if (base==BASACT) UI_ThemeColor(TH_ACTIVE); + if (base == BASACT) UI_ThemeColor(TH_ACTIVE); else UI_ThemeColor(TH_SELECT); glLineWidth(2.f); @@ -1609,7 +1608,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glLineWidth(1.f); } - if (track->flag&TRACK_CUSTOMCOLOR) glColor3fv(track->color); + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); else UI_ThemeColor(TH_BUNDLE_SOLID); draw_bundle_sphere(); @@ -1618,11 +1617,11 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glDisable(GL_LIGHTING); if (selected) { - if (base==BASACT) UI_ThemeColor(TH_ACTIVE); + if (base == BASACT) UI_ThemeColor(TH_ACTIVE); else UI_ThemeColor(TH_SELECT); } else { - if (track->flag&TRACK_CUSTOMCOLOR) glColor3fv(track->color); + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); else UI_ThemeColor(TH_WIRE); } @@ -1634,7 +1633,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glPopMatrix(); - if ((flag & DRAW_PICKING)==0 && (v3d->flag2&V3D_SHOW_BUNDLENAME)) { + if ((flag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) { float pos[3]; unsigned char tcol[4]; @@ -1648,21 +1647,21 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D tracknr++; } - if ((flag & DRAW_PICKING)==0) { - if ((v3d->flag2&V3D_SHOW_CAMERAPATH) && (tracking_object->flag&TRACKING_OBJECT_CAMERA)) { + if ((flag & DRAW_PICKING) == 0) { + if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA)) { MovieTrackingReconstruction *reconstruction; - reconstruction= BKE_tracking_object_reconstruction(tracking, tracking_object); + reconstruction = BKE_tracking_object_reconstruction(tracking, tracking_object); if (reconstruction->camnr) { - MovieReconstructedCamera *camera= reconstruction->cameras; - int a= 0; + MovieReconstructedCamera *camera = reconstruction->cameras; + int a = 0; glDisable(GL_LIGHTING); UI_ThemeColor(TH_CAMERA_PATH); glLineWidth(2.0f); glBegin(GL_LINE_STRIP); - for (a= 0; a<reconstruction->camnr; a++, camera++) { + for (a = 0; a < reconstruction->camnr; a++, camera++) { glVertex3fv(camera->mat[3]); } glEnd(); @@ -1675,21 +1674,21 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glPopMatrix(); - *global_track_index= tracknr; + *global_track_index = tracknr; } static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip, int flag, int draw_selected) { - MovieTracking *tracking= &clip->tracking; + MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; float curcol[4]; - int global_track_index= 1; + int global_track_index = 1; - if ((v3d->flag2&V3D_SHOW_RECONSTRUCTION)==0) + if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) == 0) return; - if (v3d->flag2&V3D_RENDER_OVERRIDE) + if (v3d->flag2 & V3D_RENDER_OVERRIDE) return; glGetFloatv(GL_CURRENT_COLOR, curcol); @@ -1699,12 +1698,12 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, glEnable(GL_COLOR_MATERIAL); glShadeModel(GL_SMOOTH); - tracking_object= tracking->objects.first; + tracking_object = tracking->objects.first; while (tracking_object) { draw_viewport_object_reconstruction(scene, base, v3d, clip, tracking_object, flag, &global_track_index, draw_selected); - tracking_object= tracking_object->next; + tracking_object = tracking_object->next; } /* restore */ @@ -1714,7 +1713,7 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, glColor4fv(curcol); - if (flag&DRAW_PICKING) + if (flag & DRAW_PICKING) glLoadName(base->selcol); } @@ -1723,13 +1722,13 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base { /* a standing up pyramid with (0,0,0) as top */ Camera *cam; - Object *ob= base->object; + Object *ob = base->object; float tvec[3]; float vec[4][3], asp[2], shift[2], scale[3]; int i; float drawsize; - const short is_view= (rv3d->persp==RV3D_CAMOB && ob==v3d->camera); - MovieClip *clip= object_get_movieclip(scene, base->object, 0); + const short is_view = (rv3d->persp == RV3D_CAMOB && ob == v3d->camera); + MovieClip *clip = object_get_movieclip(scene, base->object, 0); /* draw data for movie clip set as active for scene */ if (clip) { @@ -1740,16 +1739,16 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base #ifdef VIEW3D_CAMERA_BORDER_HACK if (is_view && !(G.f & G_PICKSEL)) { glGetFloatv(GL_CURRENT_COLOR, view3d_camera_border_hack_col); - view3d_camera_border_hack_test= TRUE; + view3d_camera_border_hack_test = TRUE; return; } #endif - cam= ob->data; + cam = ob->data; - scale[0]= 1.0f / len_v3(ob->obmat[0]); - scale[1]= 1.0f / len_v3(ob->obmat[1]); - scale[2]= 1.0f / len_v3(ob->obmat[2]); + scale[0] = 1.0f / len_v3(ob->obmat[0]); + scale[1] = 1.0f / len_v3(ob->obmat[1]); + scale[2] = 1.0f / len_v3(ob->obmat[2]); camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale, asp, shift, &drawsize, vec); @@ -1782,33 +1781,33 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base /* arrow on top */ - tvec[2]= vec[1][2]; /* copy the depth */ + tvec[2] = vec[1][2]; /* copy the depth */ /* draw an outline arrow for inactive cameras and filled * for active cameras. We actually draw both outline+filled * for active cameras so the wire can be seen side-on */ - for (i=0;i<2;i++) { - if (i==0) glBegin(GL_LINE_LOOP); - else if (i==1 && (ob == v3d->camera)) glBegin(GL_TRIANGLES); + for (i = 0; i < 2; i++) { + if (i == 0) glBegin(GL_LINE_LOOP); + else if (i == 1 && (ob == v3d->camera)) glBegin(GL_TRIANGLES); else break; - tvec[0]= shift[0] + ((-0.7f * drawsize) * scale[0]); - tvec[1]= shift[1] + ((drawsize * (asp[1] + 0.1f)) * scale[1]); + tvec[0] = shift[0] + ((-0.7f * drawsize) * scale[0]); + tvec[1] = shift[1] + ((drawsize * (asp[1] + 0.1f)) * scale[1]); glVertex3fv(tvec); /* left */ - tvec[0]= shift[0] + ((0.7f * drawsize) * scale[0]); + tvec[0] = shift[0] + ((0.7f * drawsize) * scale[0]); glVertex3fv(tvec); /* right */ - tvec[0]= shift[0]; - tvec[1]= shift[1] + ((1.1f * drawsize * (asp[1] + 0.7f)) * scale[1]); + tvec[0] = shift[0]; + tvec[1] = shift[1] + ((1.1f * drawsize * (asp[1] + 0.7f)) * scale[1]); glVertex3fv(tvec); /* top */ glEnd(); } - if (flag==0) { - if (cam->flag & (CAM_SHOWLIMITS+CAM_SHOWMIST)) { + if (flag == 0) { + if (cam->flag & (CAM_SHOWLIMITS + CAM_SHOWMIST)) { float nobmat[4][4]; World *wrld; @@ -1826,9 +1825,9 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base draw_focus_cross(object_camera_dof_distance(ob), cam->drawsize); } - wrld= scene->world; + wrld = scene->world; if (cam->flag & CAM_SHOWMIST) - if (wrld) draw_limit_line(wrld->miststa, wrld->miststa+wrld->mistdist, 0xFFFFFF); + if (wrld) draw_limit_line(wrld->miststa, wrld->miststa + wrld->mistdist, 0xFFFFFF); glPopMatrix(); } @@ -1847,7 +1846,7 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D glEnable(GL_BLEND); for (j = 0; j < 3; j++) { - vec[2] = 0.25f * j -0.125f; + vec[2] = 0.25f * j - 0.125f; glBegin(GL_LINE_LOOP); for (i = 0; i < 16; i++) { @@ -1868,7 +1867,7 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D vec[1] *= 0.5f; } - vec[2] = 0.25f * i -0.125f; + vec[2] = 0.25f * i - 0.125f; glVertex3fv(vec); } glEnd(); @@ -1880,23 +1879,23 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel) { BPoint *bp = lt->def; - float *co = dl?dl->verts:NULL; + float *co = dl ? dl->verts : NULL; int u, v, w; - UI_ThemeColor(sel?TH_VERTEX_SELECT:TH_VERTEX); + UI_ThemeColor(sel ? TH_VERTEX_SELECT : TH_VERTEX); glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); bglBegin(GL_POINTS); - for (w=0; w<lt->pntsw; w++) { - int wxt = (w==0 || w==lt->pntsw-1); - for (v=0; v<lt->pntsv; v++) { - int vxt = (v==0 || v==lt->pntsv-1); - for (u=0; u<lt->pntsu; u++, bp++, co+=3) { - int uxt = (u==0 || u==lt->pntsu-1); + for (w = 0; w < lt->pntsw; w++) { + int wxt = (w == 0 || w == lt->pntsw - 1); + for (v = 0; v < lt->pntsv; v++) { + int vxt = (v == 0 || v == lt->pntsv - 1); + for (u = 0; u < lt->pntsu; u++, bp++, co += 3) { + int uxt = (u == 0 || u == lt->pntsu - 1); if (!(lt->flag & LT_OUTSIDE) || uxt || vxt || wxt) { - if (bp->hide==0) { - if ((bp->f1 & SELECT)==sel) { - bglVertex3fv(dl?co:bp->vec); + if (bp->hide == 0) { + if ((bp->f1 & SELECT) == sel) { + bglVertex3fv(dl ? co : bp->vec); } } } @@ -1910,19 +1909,19 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel) void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPoint *bp, int x, int y), void *userData) { - Object *obedit= vc->obedit; - Lattice *lt= obedit->data; + Object *obedit = vc->obedit; + Lattice *lt = obedit->data; BPoint *bp = lt->editlatt->latt->def; DispList *dl = find_displist(&obedit->disp, DL_VERTS); - float *co = dl?dl->verts:NULL; - int i, N = lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; + float *co = dl ? dl->verts : NULL; + int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; short s[2] = {IS_CLIPPED, 0}; ED_view3d_clipping_local(vc->rv3d, obedit->obmat); /* for local clipping lookups */ - for (i=0; i<N; i++, bp++, co+=3) { - if (bp->hide==0) { - view3d_project_short_clip(vc->ar, dl?co:bp->vec, s, TRUE); + for (i = 0; i < N; i++, bp++, co += 3) { + if (bp->hide == 0) { + view3d_project_short_clip(vc->ar, dl ? co : bp->vec, s, TRUE); if (s[0] != IS_CLIPPED) func(userData, bp, s[0], s[1]); } @@ -1931,19 +1930,19 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, int use_wcol) { - int index = ((w*lt->pntsv + v)*lt->pntsu) + u; + int index = ((w * lt->pntsv + v) * lt->pntsu) + u; if (use_wcol) { float col[3]; - MDeformWeight *mdw= defvert_find_index (lt->dvert+index, use_wcol-1); + MDeformWeight *mdw = defvert_find_index(lt->dvert + index, use_wcol - 1); - weight_to_rgb(col, mdw?mdw->weight:0.0f); + weight_to_rgb(col, mdw ? mdw->weight : 0.0f); glColor3fv(col); } if (dl) { - glVertex3fv(&dl->verts[index*3]); + glVertex3fv(&dl->verts[index * 3]); } else { glVertex3fv(lt->def[index].vec); @@ -1953,45 +1952,45 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i /* lattice color is hardcoded, now also shows weightgroup values in edit mode */ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; DispList *dl; int u, v, w; - int use_wcol= 0, is_edit= (lt->editlatt != NULL); + int use_wcol = 0, is_edit = (lt->editlatt != NULL); /* now we default make displist, this will modifiers work for non animated case */ - if (ob->disp.first==NULL) + if (ob->disp.first == NULL) lattice_calc_modifiers(scene, ob); - dl= find_displist(&ob->disp, DL_VERTS); + dl = find_displist(&ob->disp, DL_VERTS); if (is_edit) { - lt= lt->editlatt->latt; + lt = lt->editlatt->latt; cpack(0x004000); if (ob->defbase.first && lt->dvert) { - use_wcol= ob->actdef; + use_wcol = ob->actdef; glShadeModel(GL_SMOOTH); } } glBegin(GL_LINES); - for (w=0; w<lt->pntsw; w++) { - int wxt = (w==0 || w==lt->pntsw-1); - for (v=0; v<lt->pntsv; v++) { - int vxt = (v==0 || v==lt->pntsv-1); - for (u=0; u<lt->pntsu; u++) { - int uxt = (u==0 || u==lt->pntsu-1); + for (w = 0; w < lt->pntsw; w++) { + int wxt = (w == 0 || w == lt->pntsw - 1); + for (v = 0; v < lt->pntsv; v++) { + int vxt = (v == 0 || v == lt->pntsv - 1); + for (u = 0; u < lt->pntsu; u++) { + int uxt = (u == 0 || u == lt->pntsu - 1); if (w && ((uxt || vxt) || !(lt->flag & LT_OUTSIDE))) { - drawlattice__point(lt, dl, u, v, w-1, use_wcol); + drawlattice__point(lt, dl, u, v, w - 1, use_wcol); drawlattice__point(lt, dl, u, v, w, use_wcol); } if (v && ((uxt || wxt) || !(lt->flag & LT_OUTSIDE))) { - drawlattice__point(lt, dl, u, v-1, w, use_wcol); + drawlattice__point(lt, dl, u, v - 1, w, use_wcol); drawlattice__point(lt, dl, u, v, w, use_wcol); } if (u && ((vxt || wxt) || !(lt->flag & LT_OUTSIDE))) { - drawlattice__point(lt, dl, u-1, v, w, use_wcol); + drawlattice__point(lt, dl, u - 1, v, w, use_wcol); drawlattice__point(lt, dl, u, v, w, use_wcol); } } @@ -2025,7 +2024,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, float *co BMVert *eve = EDBM_get_vert_for_index(data->vc.em, index); if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - short s[2]= {IS_CLIPPED, 0}; + short s[2] = {IS_CLIPPED, 0}; if (data->clipVerts != V3D_CLIP_TEST_OFF) { view3d_project_short_clip(data->vc.ar, co, s, TRUE); @@ -2036,26 +2035,26 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, float *co project_short_noclip(data->vc.ar, co2, s); } - if (s[0]!=IS_CLIPPED) + if (s[0] != IS_CLIPPED) data->func(data->userData, eve, s[0], s[1], index); } } void mesh_foreachScreenVert( - ViewContext *vc, - void (*func)(void *userData, BMVert *eve, int x, int y, int index), - void *userData, eV3DClipTest clipVerts) + ViewContext *vc, + void (*func)(void *userData, BMVert *eve, int x, int y, int index), + void *userData, eV3DClipTest clipVerts) { foreachScreenVert_userData data; DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH); - data.vc= *vc; + data.vc = *vc; data.func = func; data.userData = userData; data.clipVerts = clipVerts; if (clipVerts != V3D_CLIP_TEST_OFF) - ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ EDBM_init_index_arrays(vc->em, 1, 0, 0); dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data); @@ -2070,7 +2069,7 @@ static void drawSelectedVertices__mapFunc(void *userData, int index, float *co, MVert *mv = &((MVert *)userData)[index]; if (!(mv->flag & ME_HIDE)) { - const char sel= mv->flag & SELECT; + const char sel = mv->flag & SELECT; // TODO define selected color if (sel) { @@ -2120,8 +2119,8 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0 project_short_noclip(data->vc.ar, v2_co, s[1]); if (data->clipVerts == V3D_CLIP_TEST_REGION) { - if ( !is_co_in_region(data->vc.ar, s[0]) && - !is_co_in_region(data->vc.ar, s[1])) + if (!is_co_in_region(data->vc.ar, s[0]) && + !is_co_in_region(data->vc.ar, s[1])) { return; } @@ -2133,20 +2132,20 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0 } void mesh_foreachScreenEdge( - ViewContext *vc, - void (*func)(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index), - void *userData, eV3DClipTest clipVerts) + ViewContext *vc, + void (*func)(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index), + void *userData, eV3DClipTest clipVerts) { foreachScreenEdge_userData data; DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH); - data.vc= *vc; + data.vc = *vc; data.func = func; data.userData = userData; data.clipVerts = clipVerts; if (clipVerts != V3D_CLIP_TEST_OFF) - ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ EDBM_init_index_arrays(vc->em, 0, 1, 0); dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data); @@ -2174,14 +2173,14 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, float *ce } void mesh_foreachScreenFace( - ViewContext *vc, - void (*func)(void *userData, BMFace *efa, int x, int y, int index), - void *userData) + ViewContext *vc, + void (*func)(void *userData, BMFace *efa, int x, int y, int index), + void *userData) { foreachScreenFace_userData data; DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH); - data.vc= *vc; + data.vc = *vc; data.func = func; data.userData = userData; @@ -2196,24 +2195,24 @@ void mesh_foreachScreenFace( } void nurbs_foreachScreenVert( - ViewContext *vc, - void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), - void *userData) + ViewContext *vc, + void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), + void *userData) { - Curve *cu= vc->obedit->data; + Curve *cu = vc->obedit->data; short s[2] = {IS_CLIPPED, 0}; Nurb *nu; int i; - ListBase *nurbs= curve_editnurbs(cu); + ListBase *nurbs = curve_editnurbs(cu); ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ - for (nu= nurbs->first; nu; nu=nu->next) { + for (nu = nurbs->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - for (i=0; i<nu->pntsu; i++) { + for (i = 0; i < nu->pntsu; i++) { BezTriple *bezt = &nu->bezt[i]; - if (bezt->hide==0) { + if (bezt->hide == 0) { if (cu->drawflag & CU_HIDE_HANDLES) { view3d_project_short_clip(vc->ar, bezt->vec[1], s, TRUE); @@ -2235,10 +2234,10 @@ void nurbs_foreachScreenVert( } } else { - for (i=0; i<nu->pntsu*nu->pntsv; i++) { + for (i = 0; i < nu->pntsu * nu->pntsv; i++) { BPoint *bp = &nu->bp[i]; - if (bp->hide==0) { + if (bp->hide == 0) { view3d_project_short_clip(vc->ar, bp->vec, s, TRUE); if (s[0] != IS_CLIPPED) func(userData, nu, bp, NULL, -1, s[0], s[1]); @@ -2288,7 +2287,7 @@ static void draw_dm_face_centers__mapFunc(void *userData, int index, float *cent BMFace *efa = EDBM_get_face_for_index(((void **)userData)[0], index); int sel = *(((int **)userData)[1]); - if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)==sel) { + if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT) == sel) { bglVertex3fv(cent); } } @@ -2336,12 +2335,12 @@ static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, DerivedMesh *dm) /* Draw verts with color set based on selection */ static void draw_dm_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s)) { - drawDMVerts_userData * data = userData; + drawDMVerts_userData *data = userData; BMVert *eve = EDBM_get_vert_for_index(data->em, index); - if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT)==data->sel) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT) == data->sel) { /* draw active larger - need to stop/start point drawing for this :/ */ - if (eve==data->eve_act) { + if (eve == data->eve_act) { float size = UI_GetThemeValuef(TH_VERTEX_SIZE); UI_ThemeColor4(TH_EDITMESH_ACTIVE); @@ -2352,7 +2351,7 @@ static void draw_dm_verts__mapFunc(void *userData, int index, float *co, float * bglVertex3fv(co); bglEnd(); - UI_ThemeColor4(data->sel?TH_VERTEX_SELECT:TH_VERTEX); + UI_ThemeColor4(data->sel ? TH_VERTEX_SELECT : TH_VERTEX); glPointSize(size); bglBegin(GL_POINTS); } @@ -2379,13 +2378,13 @@ static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index) { BMEdge *eed; //unsigned char **cols = userData, *col; - drawDMEdgesSel_userData * data = userData; + drawDMEdgesSel_userData *data = userData; unsigned char *col; eed = EDBM_get_edge_for_index(data->em, index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - if (eed==data->eed_act) { + if (eed == data->eed_act) { glColor4ubv(data->actCol); } else { @@ -2396,7 +2395,7 @@ static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index) col = data->baseCol; } /* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */ - if (col[3]==0) + if (col[3] == 0) return DM_DRAW_OPTION_SKIP; glColor4ubv(col); @@ -2437,17 +2436,17 @@ static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm) /* Draw edges with color interpolated based on selection */ static DMDrawOption draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index) { - if (BM_elem_flag_test(EDBM_get_edge_for_index(((void**)userData)[0], index), BM_ELEM_HIDDEN)) + if (BM_elem_flag_test(EDBM_get_edge_for_index(((void **)userData)[0], index), BM_ELEM_HIDDEN)) return DM_DRAW_OPTION_SKIP; else return DM_DRAW_OPTION_NORMAL; } static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t) { - BMEdge *eed = EDBM_get_edge_for_index(((void**)userData)[0], index); + BMEdge *eed = EDBM_get_edge_for_index(((void **)userData)[0], index); unsigned char **cols = userData; - unsigned char *col0 = cols[(BM_elem_flag_test(eed->v1, BM_ELEM_SELECT))?2:1]; - unsigned char *col1 = cols[(BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))?2:1]; + unsigned char *col0 = cols[(BM_elem_flag_test(eed->v1, BM_ELEM_SELECT)) ? 2 : 1]; + unsigned char *col1 = cols[(BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1]; glColor4ub(col0[0] + (col1[0] - col0[0]) * t, col0[1] + (col1[1] - col0[1]) * t, @@ -2496,10 +2495,10 @@ static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) /* Draw faces with color set based on selection - * return 2 for the active face so it renders with stipple enabled */ + * return 2 for the active face so it renders with stipple enabled */ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) { - drawDMFacesSel_userData * data = userData; + drawDMFacesSel_userData *data = userData; BMFace *efa = EDBM_get_face_for_index(data->em, index); unsigned char *col; @@ -2512,8 +2511,8 @@ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) return DM_DRAW_OPTION_STIPPLE; } else { - col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT)?1:0]; - if (col[3]==0) + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0]; + if (col[3] == 0) return DM_DRAW_OPTION_SKIP; glColor4ubv(col); return DM_DRAW_OPTION_NORMAL; @@ -2534,8 +2533,8 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int if (!data->orig_index) return 0; - efa= EDBM_get_face_for_index(data->em, data->orig_index[index]); - next_efa= EDBM_get_face_for_index(data->em, data->orig_index[next_index]); + efa = EDBM_get_face_for_index(data->em, data->orig_index[index]); + next_efa = EDBM_get_face_for_index(data->em, data->orig_index[next_index]); if (efa == next_efa) return 1; @@ -2543,10 +2542,10 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int if (efa == data->efa_act || next_efa == data->efa_act) return 0; - col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT)?1:0]; - next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT)?1:0]; + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0]; + next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : 0]; - if (col[3]==0 || next_col[3]==0) + if (col[3] == 0 || next_col[3] == 0) return 0; return col == next_col; @@ -2557,7 +2556,7 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba unsigned char *selCol, unsigned char *actCol, BMFace *efa_act) { drawDMFacesSel_userData data; - data.dm= dm; + data.dm = dm; data.cols[0] = baseCol; data.em = em; data.cols[1] = selCol; @@ -2577,7 +2576,7 @@ static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index) if (!crease) return DM_DRAW_OPTION_SKIP; - if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *crease!=0.0f) { + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *crease != 0.0f) { UI_ThemeColorBlend(TH_WIRE, TH_EDGE_CREASE, *crease); return DM_DRAW_OPTION_NORMAL; } @@ -2601,7 +2600,7 @@ static DMDrawOption draw_dm_bweights__setDrawOptions(void *userData, int index) if (!bweight) return DM_DRAW_OPTION_SKIP; - if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *bweight!=0.0f) { + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *bweight != 0.0f) { UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, *bweight); return DM_DRAW_OPTION_NORMAL; } @@ -2618,14 +2617,14 @@ static void draw_dm_bweights__mapFunc(void *userData, int index, float *co, floa if (!bweight) return; - if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && *bweight!=0.0f) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && *bweight != 0.0f) { UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, *bweight); bglVertex3fv(co); } } static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm) { - ToolSettings *ts= scene->toolsettings; + ToolSettings *ts = scene->toolsettings; if (ts->selectmode & SCE_SELECT_VERTEX) { glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) + 2); @@ -2652,24 +2651,24 @@ static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm) static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, BMEditMesh *em, DerivedMesh *cageDM, BMVert *eve_act) { - ToolSettings *ts= scene->toolsettings; + ToolSettings *ts = scene->toolsettings; int sel; - if (v3d->zbuf) glDepthMask(0); // disable write in zbuffer, zbuf select + if (v3d->zbuf) glDepthMask(0); // disable write in zbuffer, zbuf select - for (sel=0; sel<2; sel++) { + for (sel = 0; sel < 2; sel++) { unsigned char col[4], fcol[4]; int pass; - UI_GetThemeColor3ubv(sel?TH_VERTEX_SELECT:TH_VERTEX, col); - UI_GetThemeColor3ubv(sel?TH_FACE_DOT:TH_WIRE, fcol); + UI_GetThemeColor3ubv(sel ? TH_VERTEX_SELECT : TH_VERTEX, col); + UI_GetThemeColor3ubv(sel ? TH_FACE_DOT : TH_WIRE, fcol); - for (pass=0; pass<2; pass++) { + for (pass = 0; pass < 2; pass++) { float size = UI_GetThemeValuef(TH_VERTEX_SIZE); float fsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); - if (pass==0) { - if (v3d->zbuf && !(v3d->flag&V3D_ZBUF_SELECT)) { + if (pass == 0) { + if (v3d->zbuf && !(v3d->flag & V3D_ZBUF_SELECT)) { glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -2678,8 +2677,8 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, continue; } - size = (size > 2.1f ? size/2.0f:size); - fsize = (fsize > 2.1f ? fsize/2.0f:fsize); + size = (size > 2.1f ? size / 2.0f : size); + fsize = (fsize > 2.1f ? fsize / 2.0f : fsize); col[3] = fcol[3] = 100; } else { @@ -2698,7 +2697,7 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, draw_dm_face_centers(em, cageDM, sel); } - if (pass==0) { + if (pass == 0) { glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); } @@ -2713,7 +2712,7 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, Mesh *me, DerivedMesh *cageDM, short sel_only, BMEdge *eed_act) { - ToolSettings *ts= scene->toolsettings; + ToolSettings *ts = scene->toolsettings; int pass; unsigned char wireCol[4], selCol[4], actCol[4]; @@ -2727,10 +2726,10 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, if (sel_only) wireCol[3] = 0; - for (pass=0; pass<2; pass++) { + for (pass = 0; pass < 2; pass++) { /* show wires in transparant when no zbuf clipping for select */ - if (pass==0) { - if (v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT)==0) { + if (pass == 0) { + if (v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT) == 0) { glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); selCol[3] = 85; @@ -2765,7 +2764,7 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, } } - if (pass==0) { + if (pass == 0) { glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); } @@ -2775,27 +2774,27 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitSettings *unit) { const short txt_flag = V3D_CACHE_TEXT_ASCII | V3D_CACHE_TEXT_LOCALCLIP; - Mesh *me= ob->data; + Mesh *me = ob->data; float v1[3], v2[3], v3[3], vmid[3], fvec[3]; char numstr[32]; /* Stores the measurement display text here */ const char *conv_float; /* Use a float conversion matching the grid size */ - unsigned char col[4]= {0, 0, 0, 255}; /* color of the text to draw */ + unsigned char col[4] = {0, 0, 0, 255}; /* color of the text to draw */ float area; /* area of the face */ - float grid= unit->system ? unit->scale_length : v3d->grid; - const int do_split= unit->flag & USER_UNIT_OPT_SPLIT; - const int do_global= v3d->flag & V3D_GLOBAL_STATS; - const int do_moving= G.moving; + float grid = unit->system ? unit->scale_length : v3d->grid; + const int do_split = unit->flag & USER_UNIT_OPT_SPLIT; + const int do_global = v3d->flag & V3D_GLOBAL_STATS; + const int do_moving = G.moving; BMIter iter; int i; /* make the precision of the pronted value proportionate to the gridsize */ - if (grid < 0.01f) conv_float= "%.6g"; - else if (grid < 0.1f) conv_float= "%.5g"; - else if (grid < 1.0f) conv_float= "%.4g"; - else if (grid < 10.0f) conv_float= "%.3g"; - else conv_float= "%.2g"; + if (grid < 0.01f) conv_float = "%.6g"; + else if (grid < 0.1f) conv_float = "%.5g"; + else if (grid < 1.0f) conv_float = "%.4g"; + else if (grid < 10.0f) conv_float = "%.3g"; + else conv_float = "%.2g"; if (me->drawflag & ME_DRAWEXTRA_EDGELEN) { BMEdge *eed; @@ -2803,7 +2802,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL); - for (; eed; eed=BM_iter_step(&iter)) { + for (; eed; eed = BM_iter_step(&iter)) { /* draw selected edges, or edges next to selected verts while draging */ if (BM_elem_flag_test(eed, BM_ELEM_SELECT) || (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || @@ -2839,16 +2838,16 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS BMFace *f; int n; -#define DRAW_EM_MEASURE_STATS_FACEAREA() \ - if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { \ - mul_v3_fl(vmid, 1.0/n); \ - if (unit->system) \ - bUnit_AsString(numstr, sizeof(numstr), area*unit->scale_length, \ - 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ - else \ - BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ - view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col); \ - } +#define DRAW_EM_MEASURE_STATS_FACEAREA() \ + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { \ + mul_v3_fl(vmid, 1.0 / n); \ + if (unit->system) \ + bUnit_AsString(numstr, sizeof(numstr), area * unit->scale_length, \ + 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ + else \ + BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ + view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col); \ + } UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); @@ -2894,7 +2893,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS for (efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL); - efa; efa=BM_iter_step(&iter)) + efa; efa = BM_iter_step(&iter)) { BMIter liter; BMLoop *loop; @@ -2940,10 +2939,10 @@ static void draw_em_indices(BMEditMesh *em) unsigned char col[4]; BMIter iter; - BMesh *bm= em->bm; + BMesh *bm = em->bm; /* For now, reuse appropriate theme colors from stats text colors */ - i= 0; + i = 0; if (em->selectmode & SCE_SELECT_VERTEX) { UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { @@ -2956,7 +2955,7 @@ static void draw_em_indices(BMEditMesh *em) } if (em->selectmode & SCE_SELECT_EDGE) { - i= 0; + i = 0; UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { @@ -2969,7 +2968,7 @@ static void draw_em_indices(BMEditMesh *em) } if (em->selectmode & SCE_SELECT_FACE) { - i= 0; + i = 0; UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { @@ -2987,7 +2986,7 @@ static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index) BMFace *efa = EDBM_get_face_for_index(userData, index); if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { - GPU_enable_material(efa->mat_nr+1, NULL); + GPU_enable_material(efa->mat_nr + 1, NULL); return DM_DRAW_OPTION_NORMAL; } else @@ -3014,28 +3013,28 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, BMVert *eve_act = NULL; if (em->bm->selected.last) { - BMEditSelection *ese= em->bm->selected.last; + BMEditSelection *ese = em->bm->selected.last; /* face is handeled above */ #if 0 - if (ese->type == BM_FACE ) { + if (ese->type == BM_FACE) { efa_act = (BMFace *)ese->data; } else #endif - if ( ese->htype == BM_EDGE ) { + if (ese->htype == BM_EDGE) { eed_act = (BMEdge *)ese->ele; } - else if ( ese->htype == BM_VERT ) { + else if (ese->htype == BM_VERT) { eve_act = (BMVert *)ese->ele; } } EDBM_init_index_arrays(em, 1, 1, 1); - if (dt>OB_WIRE) { + if (dt > OB_WIRE) { if (CHECK_OB_DRAWTEXTURE(v3d, dt)) { if (draw_glsl_material(scene, ob, v3d, dt)) { - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material, draw_em_fancy__setGLSLFaceOpts, em); @@ -3053,7 +3052,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE); glEnable(GL_LIGHTING); - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, GPU_enable_material, NULL, me->edit_btmesh, 0); glFrontFace(GL_CCW); @@ -3069,13 +3068,13 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, glDepthMask(0); } else { - if (cageDM!=finalDM) { + if (cageDM != finalDM) { UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7); finalDM->drawEdges(finalDM, 1, 0); } } - if (me->drawflag & ME_DRAWFACES) { /* transp faces */ + if (me->drawflag & ME_DRAWFACES) { /* transp faces */ unsigned char col1[4], col2[4], col3[4]; UI_GetThemeColor4ubv(TH_FACE, col1); @@ -3083,7 +3082,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3); glEnable(GL_BLEND); - glDepthMask(0); // disable write in zbuffer, needed for nice transp + glDepthMask(0); // disable write in zbuffer, needed for nice transp /* don't draw unselected faces, only selected, this is MUCH nicer when texturing */ if (CHECK_OB_DRAWTEXTURE(v3d, dt)) @@ -3092,7 +3091,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); glDisable(GL_BLEND); - glDepthMask(1); // restore write in zbuffer + glDepthMask(1); // restore write in zbuffer } else if (efa_act) { /* even if draw faces is off it would be nice to draw the stipple face @@ -3103,17 +3102,17 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3); glEnable(GL_BLEND); - glDepthMask(0); // disable write in zbuffer, needed for nice transp + glDepthMask(0); // disable write in zbuffer, needed for nice transp draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); glDisable(GL_BLEND); - glDepthMask(1); // restore write in zbuffer + glDepthMask(1); // restore write in zbuffer } /* here starts all fancy draw-extra over */ - if ((me->drawflag & ME_DRAWEDGES)==0 && CHECK_OB_DRAWTEXTURE(v3d, dt)) { + if ((me->drawflag & ME_DRAWEDGES) == 0 && CHECK_OB_DRAWTEXTURE(v3d, dt)) { /* we are drawing textures and 'ME_DRAWEDGES' is disabled, don't draw any edges */ /* only draw selected edges otherwise there is no way of telling if a face is selected */ @@ -3127,7 +3126,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, draw_dm_edges_seams(em, cageDM); - glColor3ub(0,0,0); + glColor3ub(0, 0, 0); glLineWidth(1); } @@ -3137,7 +3136,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, draw_dm_edges_sharp(em, cageDM); - glColor3ub(0,0,0); + glColor3ub(0, 0, 0); glLineWidth(1); } @@ -3162,7 +3161,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, draw_dm_vert_normals(em, scene, cageDM); } - if ( (me->drawflag & (ME_DRAWEXTRA_EDGELEN|ME_DRAWEXTRA_FACEAREA|ME_DRAWEXTRA_FACEANG)) && + if ( (me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_FACEAREA | ME_DRAWEXTRA_FACEANG)) && !(v3d->flag2 & V3D_RENDER_OVERRIDE)) { draw_em_measure_stats(v3d, ob, em, &scene->unit); @@ -3174,7 +3173,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, } } - if (dt>OB_WIRE) { + if (dt > OB_WIRE) { glDepthMask(1); bglPolygonOffset(rv3d->dist, 0.0); GPU_disable_material(); @@ -3213,14 +3212,14 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag) { - Object *ob= base->object; + Object *ob = base->object; Mesh *me = ob->data; - Material *ma= give_current_material(ob, 1); + Material *ma = give_current_material(ob, 1); const short hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO)); - eWireDrawMode draw_wire= OBDRAW_WIRE_OFF; + eWireDrawMode draw_wire = OBDRAW_WIRE_OFF; int /* totvert,*/ totedge, totface; - DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); - const short is_obact= (ob == OBACT); + DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); + const short is_obact = (ob == OBACT); int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0; if (!dm) @@ -3233,10 +3232,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* Unwanted combination */ if (draw_flags & DRAW_FACE_SELECT) { - draw_wire= OBDRAW_WIRE_OFF; + draw_wire = OBDRAW_WIRE_OFF; } else if (ob->dtx & OB_DRAWWIRE) { - draw_wire= OBDRAW_WIRE_ON_DEPTH; /* draw wire after solid using zoffset and depth buffer adjusment */ + draw_wire = OBDRAW_WIRE_ON_DEPTH; /* draw wire after solid using zoffset and depth buffer adjusment */ } /* totvert = dm->getNumVerts(dm); */ /*UNUSED*/ @@ -3244,25 +3243,25 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D totface = dm->getNumTessFaces(dm); /* vertexpaint, faceselect wants this, but it doesnt work for shaded? */ - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if (dt==OB_BOUNDBOX) { - if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE)==0) + if (dt == OB_BOUNDBOX) { + if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0) draw_bounding_volume(scene, ob, ob->boundtype); } - else if (hasHaloMat || (totface==0 && totedge==0)) { + else if (hasHaloMat || (totface == 0 && totedge == 0)) { glPointSize(1.5); dm->drawVerts(dm); glPointSize(1.0); } - else if (dt==OB_WIRE || totface==0) { - draw_wire= OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */ + else if (dt == OB_WIRE || totface == 0) { + draw_wire = OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */ } else if ( (draw_flags & DRAW_FACE_SELECT || (is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) || CHECK_OB_DRAWTEXTURE(v3d, dt)) { if ( (v3d->flag & V3D_SELECT_OUTLINE) && - ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && + ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && (base->flag & SELECT) && !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && (draw_wire == OBDRAW_WIRE_OFF)) @@ -3271,7 +3270,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } if (draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); dm->drawFacesGLSL(dm, GPU_enable_material); // if (get_ob_property(ob, "Text")) @@ -3290,11 +3289,11 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D else UI_ThemeColor(TH_WIRE); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) dm->drawLooseEdges(dm); } } - else if (dt==OB_SOLID) { + else if (dt == OB_SOLID) { if (is_obact && ob->mode & OB_MODE_WEIGHT_PAINT) { /* weight paint in solid mode, special case. focus on making the weights clear * rather than the shading, this is also forced in wire view */ @@ -3303,7 +3302,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better + glDepthMask(0); // disable write in zbuffer, selected edge wires show better glEnable(GL_BLEND); glColor4ub(255, 255, 255, 96); @@ -3320,17 +3319,17 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D GPU_disable_material(); /* since we already draw wire as wp guide, don't draw over the top */ - draw_wire= OBDRAW_WIRE_OFF; + draw_wire = OBDRAW_WIRE_OFF; } else if (draw_flags & DRAW_MODIFIERS_PREVIEW) { /* for object selection draws no shade */ - if (flag & (DRAW_PICKING|DRAW_CONSTCOLOR)) { + if (flag & (DRAW_PICKING | DRAW_CONSTCOLOR)) { dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); } else { /* draw outline */ if ( (v3d->flag & V3D_SELECT_OUTLINE) && - ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && + ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && (base->flag & SELECT) && (draw_wire == OBDRAW_WIRE_OFF) && (ob->sculpt == NULL)) @@ -3345,7 +3344,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* set default spec */ glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ + glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ glColor3ub(120, 120, 120); glDisable(GL_COLOR_MATERIAL); /* diffuse */ @@ -3364,7 +3363,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D Paint *p; if ( (v3d->flag & V3D_SELECT_OUTLINE) && - ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && + ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && (base->flag & SELECT) && (draw_wire == OBDRAW_WIRE_OFF) && (ob->sculpt == NULL)) @@ -3375,12 +3374,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE); glEnable(GL_LIGHTING); - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if (ob->sculpt && (p=paint_get_active(scene))) { + if (ob->sculpt && (p = paint_get_active(scene))) { float planes[4][4]; float (*fpl)[4] = NULL; - int fast= (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); + int fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); if (ob->sculpt->partial_redraw) { if (ar->do_draw & RGN_DRAW_PARTIAL) { @@ -3408,11 +3407,11 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D else { UI_ThemeColor(TH_WIRE); } - if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) + if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) dm->drawLooseEdges(dm); } } - else if (dt==OB_PAINT) { + else if (dt == OB_PAINT) { if (is_obact) { if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* enforce default material settings */ @@ -3420,7 +3419,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* but set default spec */ glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ + glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ glColor3ub(120, 120, 120); glDisable(GL_COLOR_MATERIAL); /* diffuse */ @@ -3435,7 +3434,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D GPU_disable_material(); } - else if (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_TEXTURE_PAINT)) { + else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT)) { if (me->mloopcol) dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, NULL, DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); @@ -3449,23 +3448,23 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } /* set default draw color back for wire or for draw-extra later on */ - if (dt!=OB_WIRE) { + if (dt != OB_WIRE) { if (base->flag & SELECT) { if (is_obact && ob->flag & OB_FROMGROUP) UI_ThemeColor(TH_GROUP_ACTIVE); else if (ob->flag & OB_FROMGROUP) UI_ThemeColorShade(TH_GROUP_ACTIVE, -16); - else if (flag!=DRAW_CONSTCOLOR) + else if (flag != DRAW_CONSTCOLOR) UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT); else - glColor3ub(80,80,80); + glColor3ub(80, 80, 80); } else { if (ob->flag & OB_FROMGROUP) UI_ThemeColor(TH_GROUP); else { - if (ob->dtx & OB_DRAWWIRE && flag==DRAW_CONSTCOLOR) - glColor3ub(80,80,80); + if (ob->dtx & OB_DRAWWIRE && flag == DRAW_CONSTCOLOR) + glColor3ub(80, 80, 80); else UI_ThemeColor(TH_WIRE); } @@ -3494,15 +3493,15 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D * if draw wire is 1 then just drawing wire, no need for depth buffer stuff, * otherwise this wire is to overlay solid mode faces so do some depth buffer tricks. */ - if (dt!=OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { + if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better + glDepthMask(0); // disable write in zbuffer, selected edge wires show better } - if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID)==0) - dm->drawEdges(dm, (dt==OB_WIRE || totface==0), me->drawflag & ME_ALLEDGES); + if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0) + dm->drawEdges(dm, (dt == OB_WIRE || totface == 0), me->drawflag & ME_ALLEDGES); - if (dt!=OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { + if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { glDepthMask(1); bglPolygonOffset(rv3d->dist, 0.0); } @@ -3523,39 +3522,39 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* returns 1 if nothing was drawn, for detecting to draw an object center */ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag) { - Object *ob= base->object; - Object *obedit= scene->obedit; - Mesh *me= ob->data; - BMEditMesh *em= me->edit_btmesh; - int do_alpha_after= 0, drawlinked= 0, retval= 0, glsl, check_alpha, i; + Object *ob = base->object; + Object *obedit = scene->obedit; + Mesh *me = ob->data; + BMEditMesh *em = me->edit_btmesh; + int do_alpha_after = 0, drawlinked = 0, retval = 0, glsl, check_alpha, i; /* If we are drawing shadows and any of the materials don't cast a shadow, * then don't draw the object */ if (v3d->flag2 & V3D_RENDER_SHADOW) { - for (i=0; i<ob->totcol; ++i) { - Material *ma= give_current_material(ob, i); + for (i = 0; i < ob->totcol; ++i) { + Material *ma = give_current_material(ob, i); if (ma && !(ma->mode & MA_SHADBUF)) { return 1; } } } - if (obedit && ob!=obedit && ob->data==obedit->data) { + if (obedit && ob != obedit && ob->data == obedit->data) { if (ob_get_key(ob) || ob_get_key(obedit)) {} else if (ob->modifiers.first || obedit->modifiers.first) {} - else drawlinked= 1; + else drawlinked = 1; } - if (ob==obedit || drawlinked) { + if (ob == obedit || drawlinked) { DerivedMesh *finalDM, *cageDM; - if (obedit!=ob) + if (obedit != ob) finalDM = cageDM = editbmesh_get_derived_base(ob, em); else cageDM = editbmesh_get_derived_cage_and_final(scene, ob, em, &finalDM, scene->customdata_mask); - if (dt>OB_WIRE) { + if (dt > OB_WIRE) { glsl = draw_glsl_material(scene, ob, v3d, dt); GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); @@ -3565,25 +3564,25 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D GPU_end_object_materials(); - if (obedit!=ob && finalDM) + if (obedit != ob && finalDM) finalDM->release(finalDM); } else { /* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */ - if (me->totpoly <= 4 || ED_view3d_boundbox_clip(rv3d, ob->obmat, (ob->bb)? ob->bb: me->bb)) { + if (me->totpoly <= 4 || ED_view3d_boundbox_clip(rv3d, ob->obmat, (ob->bb) ? ob->bb : me->bb)) { glsl = draw_glsl_material(scene, ob, v3d, dt); check_alpha = check_alpha_pass(base); - if (dt==OB_SOLID || glsl) { + if (dt == OB_SOLID || glsl) { GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, - (check_alpha)? &do_alpha_after: NULL); + (check_alpha) ? &do_alpha_after : NULL); } draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, flag); GPU_end_object_materials(); - if (me->totvert==0) retval= 1; + if (me->totvert == 0) retval = 1; } } @@ -3608,8 +3607,8 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* ************** DRAW DISPLIST ****************** */ -static int draw_index_wire= 1; -static int index3_nors_incr= 1; +static int draw_index_wire = 1; +static int index3_nors_incr = 1; /* returns 1 when nothing was drawn */ static int drawDispListwire(ListBase *dlbase) @@ -3618,57 +3617,57 @@ static int drawDispListwire(ListBase *dlbase) int parts, nr; float *data; - if (dlbase==NULL) return 1; + if (dlbase == NULL) return 1; glEnableClientState(GL_VERTEX_ARRAY); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - for (dl= dlbase->first; dl; dl= dl->next) { - if (dl->parts==0 || dl->nr==0) + for (dl = dlbase->first; dl; dl = dl->next) { + if (dl->parts == 0 || dl->nr == 0) continue; - data= dl->verts; + data = dl->verts; - switch(dl->type) { + switch (dl->type) { case DL_SEGM: glVertexPointer(3, GL_FLOAT, 0, data); - for (parts=0; parts<dl->parts; parts++) - glDrawArrays(GL_LINE_STRIP, parts*dl->nr, dl->nr); + for (parts = 0; parts < dl->parts; parts++) + glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr); break; case DL_POLY: glVertexPointer(3, GL_FLOAT, 0, data); - for (parts=0; parts<dl->parts; parts++) - glDrawArrays(GL_LINE_LOOP, parts*dl->nr, dl->nr); + for (parts = 0; parts < dl->parts; parts++) + glDrawArrays(GL_LINE_LOOP, parts * dl->nr, dl->nr); break; case DL_SURF: glVertexPointer(3, GL_FLOAT, 0, data); - for (parts=0; parts<dl->parts; parts++) { + for (parts = 0; parts < dl->parts; parts++) { if (dl->flag & DL_CYCL_U) - glDrawArrays(GL_LINE_LOOP, parts*dl->nr, dl->nr); + glDrawArrays(GL_LINE_LOOP, parts * dl->nr, dl->nr); else - glDrawArrays(GL_LINE_STRIP, parts*dl->nr, dl->nr); + glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr); } - for (nr=0; nr<dl->nr; nr++) { - int ofs= 3*dl->nr; + for (nr = 0; nr < dl->nr; nr++) { + int ofs = 3 * dl->nr; - data= ( dl->verts )+3*nr; - parts= dl->parts; + data = (dl->verts) + 3 * nr; + parts = dl->parts; if (dl->flag & DL_CYCL_V) glBegin(GL_LINE_LOOP); else glBegin(GL_LINE_STRIP); while (parts--) { glVertex3fv(data); - data+=ofs; + data += ofs; } glEnd(); @@ -3684,14 +3683,14 @@ static int drawDispListwire(ListBase *dlbase) case DL_INDEX3: if (draw_index_wire) { glVertexPointer(3, GL_FLOAT, 0, dl->verts); - glDrawElements(GL_TRIANGLES, 3*dl->parts, GL_UNSIGNED_INT, dl->index); + glDrawElements(GL_TRIANGLES, 3 * dl->parts, GL_UNSIGNED_INT, dl->index); } break; case DL_INDEX4: if (draw_index_wire) { glVertexPointer(3, GL_FLOAT, 0, dl->verts); - glDrawElements(GL_QUADS, 4*dl->parts, GL_UNSIGNED_INT, dl->index); + glDrawElements(GL_QUADS, 4 * dl->parts, GL_UNSIGNED_INT, dl->index); } break; } @@ -3710,7 +3709,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) float *data, curcol[4]; float *ndata; - if (lb==NULL) return; + if (lb == NULL) return; /* for drawing wire */ glGetFloatv(GL_CURRENT_COLOR, curcol); @@ -3721,18 +3720,18 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW); else glFrontFace(GL_CCW); - if (ob->type==OB_MBALL) { // mball always smooth shaded + if (ob->type == OB_MBALL) { // mball always smooth shaded glShadeModel(GL_SMOOTH); } - dl= lb->first; + dl = lb->first; while (dl) { - data= dl->verts; - ndata= dl->nors; + data = dl->verts; + ndata = dl->nors; - switch(dl->type) { + switch (dl->type) { case DL_SEGM: - if (ob->type==OB_SURF) { + if (ob->type == OB_SURF) { int nr; glDisable(GL_LIGHTING); @@ -3742,7 +3741,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) // glDrawArrays(GL_LINE_STRIP, 0, dl->nr); glBegin(GL_LINE_STRIP); - for (nr= dl->nr; nr; nr--, data+=3) + for (nr = dl->nr; nr; nr--, data += 3) glVertex3fv(data); glEnd(); @@ -3750,7 +3749,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) } break; case DL_POLY: - if (ob->type==OB_SURF) { + if (ob->type == OB_SURF) { int nr; glDisable(GL_LIGHTING); @@ -3760,7 +3759,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) //glDrawArrays(GL_LINE_LOOP, 0, dl->nr); glBegin(GL_LINE_LOOP); - for (nr= dl->nr; nr; nr--, data+=3) + for (nr = dl->nr; nr; nr--, data += 3) glVertex3fv(data); glEnd(); @@ -3770,7 +3769,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) case DL_SURF: if (dl->index) { - GPU_enable_material(dl->col+1, (glsl)? &gattribs: NULL); + GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL); if (dl->rt & CU_SMOOTH) glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); @@ -3778,13 +3777,13 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) glEnableClientState(GL_NORMAL_ARRAY); glVertexPointer(3, GL_FLOAT, 0, dl->verts); glNormalPointer(GL_FLOAT, 0, dl->nors); - glDrawElements(GL_QUADS, 4*dl->totindex, GL_UNSIGNED_INT, dl->index); + glDrawElements(GL_QUADS, 4 * dl->totindex, GL_UNSIGNED_INT, dl->index); glDisableClientState(GL_NORMAL_ARRAY); } break; case DL_INDEX3: - GPU_enable_material(dl->col+1, (glsl)? &gattribs: NULL); + GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL); glVertexPointer(3, GL_FLOAT, 0, dl->verts); @@ -3796,7 +3795,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) else glNormal3fv(ndata); - glDrawElements(GL_TRIANGLES, 3*dl->parts, GL_UNSIGNED_INT, dl->index); + glDrawElements(GL_TRIANGLES, 3 * dl->parts, GL_UNSIGNED_INT, dl->index); if (index3_nors_incr) glDisableClientState(GL_NORMAL_ARRAY); @@ -3804,17 +3803,17 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) break; case DL_INDEX4: - GPU_enable_material(dl->col+1, (glsl)? &gattribs: NULL); + GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL); glEnableClientState(GL_NORMAL_ARRAY); glVertexPointer(3, GL_FLOAT, 0, dl->verts); glNormalPointer(GL_FLOAT, 0, dl->nors); - glDrawElements(GL_QUADS, 4*dl->parts, GL_UNSIGNED_INT, dl->index); + glDrawElements(GL_QUADS, 4 * dl->parts, GL_UNSIGNED_INT, dl->index); glDisableClientState(GL_NORMAL_ARRAY); break; } - dl= dl->next; + dl = dl->next; } glDisableClientState(GL_VERTEX_ARRAY); @@ -3826,20 +3825,20 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) static void drawCurveDMWired(Object *ob) { DerivedMesh *dm = ob->derivedFinal; - dm->drawEdges (dm, 1, 0); + dm->drawEdges(dm, 1, 0); } /* return 1 when nothing was drawn */ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt) { - Object *ob= base->object; + Object *ob = base->object; DerivedMesh *dm = ob->derivedFinal; if (!dm) { return 1; } - if (dt>OB_WIRE && dm->getNumTessFaces(dm)) { + if (dt > OB_WIRE && dm->getNumTessFaces(dm)) { int glsl = draw_glsl_material(scene, ob, v3d, dt); GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); @@ -3854,8 +3853,8 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B GPU_end_object_materials(); } else { - if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID)==0) - drawCurveDMWired (ob); + if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0) + drawCurveDMWired(ob); } return 0; @@ -3864,37 +3863,37 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B /* returns 1 when nothing was drawn */ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt) { - Object *ob= base->object; - ListBase *lb=NULL; + Object *ob = base->object; + ListBase *lb = NULL; DispList *dl; Curve *cu; - const short render_only= (v3d->flag2 & V3D_RENDER_OVERRIDE); - const short solid= (dt > OB_WIRE); - int retval= 0; + const short render_only = (v3d->flag2 & V3D_RENDER_OVERRIDE); + const short solid = (dt > OB_WIRE); + int retval = 0; if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == 0) { return 0; } - switch(ob->type) { + switch (ob->type) { case OB_FONT: case OB_CURVE: - cu= ob->data; + cu = ob->data; - lb= &ob->disp; + lb = &ob->disp; if (solid) { - dl= lb->first; - if (dl==NULL) return 1; + dl = lb->first; + if (dl == NULL) return 1; - if (dl->nors==NULL) addnormalsDispList(lb); - index3_nors_incr= 0; + if (dl->nors == NULL) addnormalsDispList(lb); + index3_nors_incr = 0; - if ( displist_has_faces(lb)==0) { + if (displist_has_faces(lb) == 0) { if (!render_only) { - draw_index_wire= 0; + draw_index_wire = 0; drawDispListwire(lb); - draw_index_wire= 1; + draw_index_wire = 1; } } else { @@ -3908,32 +3907,32 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas drawDispListsolid(lb, ob, 0); GPU_end_object_materials(); } - if (cu->editnurb && cu->bevobj==NULL && cu->taperobj==NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) { + if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) { cpack(0); - draw_index_wire= 0; + draw_index_wire = 0; drawDispListwire(lb); - draw_index_wire= 1; + draw_index_wire = 1; } } - index3_nors_incr= 1; + index3_nors_incr = 1; } else { if (!render_only || (render_only && displist_has_faces(lb))) { - draw_index_wire= 0; - retval= drawDispListwire(lb); - draw_index_wire= 1; + draw_index_wire = 0; + retval = drawDispListwire(lb); + draw_index_wire = 1; } } break; case OB_SURF: - lb= &ob->disp; + lb = &ob->disp; if (solid) { - dl= lb->first; - if (dl==NULL) return 1; + dl = lb->first; + if (dl == NULL) return 1; - if (dl->nors==NULL) addnormalsDispList(lb); + if (dl->nors == NULL) addnormalsDispList(lb); if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); @@ -3947,15 +3946,15 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas } } else { - retval= drawDispListwire(lb); + retval = drawDispListwire(lb); } break; case OB_MBALL: - if ( is_basis_mball(ob)) { - lb= &ob->disp; - if (lb->first==NULL) makeDispListMBall(scene, ob); - if (lb->first==NULL) return 1; + if (is_basis_mball(ob)) { + lb = &ob->disp; + if (lb->first == NULL) makeDispListMBall(scene, ob); + if (lb->first == NULL) return 1; if (solid) { @@ -3972,7 +3971,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas } else { /* MetaBalls use DL_INDEX4 type of DispList */ - retval= drawDispListwire(lb); + retval = drawDispListwire(lb); } } break; @@ -3985,21 +3984,21 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int select) { /* draw created data arrays */ - switch(draw_as) { + switch (draw_as) { case PART_DRAW_AXIS: case PART_DRAW_CROSS: - glDrawArrays(GL_LINES, 0, 6*totpoint); + glDrawArrays(GL_LINES, 0, 6 * totpoint); break; case PART_DRAW_LINE: - glDrawArrays(GL_LINES, 0, 2*totpoint); + glDrawArrays(GL_LINES, 0, 2 * totpoint); break; case PART_DRAW_BB: - if (ob_dt<=OB_WIRE || select) - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); + if (ob_dt <= OB_WIRE || select) + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glDrawArrays(GL_QUADS, 0, 4*totpoint); + glDrawArrays(GL_QUADS, 0, 4 * totpoint); break; default: glDrawArrays(GL_POINTS, 0, totpoint); @@ -4012,7 +4011,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix float vec[3], vec2[3]; float *vd = NULL; float *cd = NULL; - float ma_col[3]= {0.0f, 0.0f, 0.0f}; + float ma_col[3] = {0.0f, 0.0f, 0.0f}; /* null only for PART_DRAW_CIRC */ if (pdd) { @@ -4024,90 +4023,90 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix } } - switch(draw_as) { + switch (draw_as) { case PART_DRAW_DOT: { if (vd) { - copy_v3_v3(vd,state->co); pdd->vd+=3; + copy_v3_v3(vd, state->co); pdd->vd += 3; } if (cd) { copy_v3_v3(cd, pdd->ma_col); - pdd->cd+=3; + pdd->cd += 3; } break; } case PART_DRAW_CROSS: case PART_DRAW_AXIS: { - vec[0]=2.0f*pixsize; - vec[1]=vec[2]=0.0; - mul_qt_v3(state->rot,vec); - if (draw_as==PART_DRAW_AXIS) { + vec[0] = 2.0f * pixsize; + vec[1] = vec[2] = 0.0; + mul_qt_v3(state->rot, vec); + if (draw_as == PART_DRAW_AXIS) { if (cd) { - cd[1]=cd[2]=cd[4]=cd[5]=0.0; - cd[0]=cd[3]=1.0; - cd[6]=cd[8]=cd[9]=cd[11]=0.0; - cd[7]=cd[10]=1.0; - cd[13]=cd[12]=cd[15]=cd[16]=0.0; - cd[14]=cd[17]=1.0; - pdd->cd+=18; + cd[1] = cd[2] = cd[4] = cd[5] = 0.0; + cd[0] = cd[3] = 1.0; + cd[6] = cd[8] = cd[9] = cd[11] = 0.0; + cd[7] = cd[10] = 1.0; + cd[13] = cd[12] = cd[15] = cd[16] = 0.0; + cd[14] = cd[17] = 1.0; + pdd->cd += 18; } - copy_v3_v3(vec2,state->co); + copy_v3_v3(vec2, state->co); } else { if (cd) { - cd[0]=cd[3]=cd[6]=cd[ 9]=cd[12]=cd[15]= ma_col[0]; - cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]= ma_col[1]; - cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]= ma_col[2]; - pdd->cd+=18; + cd[0] = cd[3] = cd[6] = cd[9] = cd[12] = cd[15] = ma_col[0]; + cd[1] = cd[4] = cd[7] = cd[10] = cd[13] = cd[16] = ma_col[1]; + cd[2] = cd[5] = cd[8] = cd[11] = cd[14] = cd[17] = ma_col[2]; + pdd->cd += 18; } sub_v3_v3v3(vec2, state->co, vec); } add_v3_v3(vec, state->co); - copy_v3_v3(pdd->vd,vec); pdd->vd+=3; - copy_v3_v3(pdd->vd,vec2); pdd->vd+=3; + copy_v3_v3(pdd->vd, vec); pdd->vd += 3; + copy_v3_v3(pdd->vd, vec2); pdd->vd += 3; - vec[1]=2.0f*pixsize; - vec[0]=vec[2]=0.0; - mul_qt_v3(state->rot,vec); - if (draw_as==PART_DRAW_AXIS) { - copy_v3_v3(vec2,state->co); + vec[1] = 2.0f * pixsize; + vec[0] = vec[2] = 0.0; + mul_qt_v3(state->rot, vec); + if (draw_as == PART_DRAW_AXIS) { + copy_v3_v3(vec2, state->co); } else sub_v3_v3v3(vec2, state->co, vec); add_v3_v3(vec, state->co); - copy_v3_v3(pdd->vd,vec); pdd->vd+=3; - copy_v3_v3(pdd->vd,vec2); pdd->vd+=3; + copy_v3_v3(pdd->vd, vec); pdd->vd += 3; + copy_v3_v3(pdd->vd, vec2); pdd->vd += 3; - vec[2]=2.0f*pixsize; - vec[0]=vec[1]=0.0; - mul_qt_v3(state->rot,vec); - if (draw_as==PART_DRAW_AXIS) { - copy_v3_v3(vec2,state->co); + vec[2] = 2.0f * pixsize; + vec[0] = vec[1] = 0.0; + mul_qt_v3(state->rot, vec); + if (draw_as == PART_DRAW_AXIS) { + copy_v3_v3(vec2, state->co); } else sub_v3_v3v3(vec2, state->co, vec); add_v3_v3(vec, state->co); - copy_v3_v3(pdd->vd,vec); pdd->vd+=3; - copy_v3_v3(pdd->vd,vec2); pdd->vd+=3; + copy_v3_v3(pdd->vd, vec); pdd->vd += 3; + copy_v3_v3(pdd->vd, vec2); pdd->vd += 3; break; } case PART_DRAW_LINE: { - copy_v3_v3(vec,state->vel); + copy_v3_v3(vec, state->vel); normalize_v3(vec); if (draw & PART_DRAW_VEL_LENGTH) - mul_v3_fl(vec,len_v3(state->vel)); - madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd+=3; - madd_v3_v3v3fl(pdd->vd, state->co, vec, draw_line[1]); pdd->vd+=3; + mul_v3_fl(vec, len_v3(state->vel)); + madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd += 3; + madd_v3_v3v3fl(pdd->vd, state->co, vec, draw_line[1]); pdd->vd += 3; if (cd) { - cd[0]=cd[3]= ma_col[0]; - cd[1]=cd[4]= ma_col[1]; - cd[2]=cd[5]= ma_col[2]; - pdd->cd+=6; + cd[0] = cd[3] = ma_col[0]; + cd[1] = cd[4] = ma_col[1]; + cd[2] = cd[5] = ma_col[2]; + pdd->cd += 6; } break; } @@ -4120,10 +4119,10 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix { float xvec[3], yvec[3], zvec[3], bb_center[3]; if (cd) { - cd[0]=cd[3]=cd[6]=cd[ 9]= ma_col[0]; - cd[1]=cd[4]=cd[7]=cd[10]= ma_col[1]; - cd[2]=cd[5]=cd[8]=cd[11]= ma_col[2]; - pdd->cd+=12; + cd[0] = cd[3] = cd[6] = cd[9] = ma_col[0]; + cd[1] = cd[4] = cd[7] = cd[10] = ma_col[1]; + cd[2] = cd[5] = cd[8] = cd[11] = ma_col[2]; + pdd->cd += 12; } @@ -4133,21 +4132,21 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix psys_make_billboard(bb, xvec, yvec, zvec, bb_center); add_v3_v3v3(pdd->vd, bb_center, xvec); - add_v3_v3(pdd->vd, yvec); pdd->vd+=3; + add_v3_v3(pdd->vd, yvec); pdd->vd += 3; sub_v3_v3v3(pdd->vd, bb_center, xvec); - add_v3_v3(pdd->vd, yvec); pdd->vd+=3; + add_v3_v3(pdd->vd, yvec); pdd->vd += 3; sub_v3_v3v3(pdd->vd, bb_center, xvec); - sub_v3_v3v3(pdd->vd, pdd->vd,yvec); pdd->vd+=3; + sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3; add_v3_v3v3(pdd->vd, bb_center, xvec); - sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd+=3; + sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3; - copy_v3_v3(pdd->nd, zvec); pdd->nd+=3; - copy_v3_v3(pdd->nd, zvec); pdd->nd+=3; - copy_v3_v3(pdd->nd, zvec); pdd->nd+=3; - copy_v3_v3(pdd->nd, zvec); pdd->nd+=3; + copy_v3_v3(pdd->nd, zvec); pdd->nd += 3; + copy_v3_v3(pdd->nd, zvec); pdd->nd += 3; + copy_v3_v3(pdd->nd, zvec); pdd->nd += 3; + copy_v3_v3(pdd->nd, zvec); pdd->nd += 3; break; } } @@ -4165,35 +4164,35 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, ParticleSystem *psys, int ob_dt) { - Object *ob=base->object; + Object *ob = base->object; ParticleEditSettings *pset = PE_settings(scene); ParticleSettings *part = psys->part; ParticleData *pars = psys->particles; ParticleData *pa; - ParticleKey state, *states=NULL; + ParticleKey state, *states = NULL; ParticleBillboardData bb; - ParticleSimulationData sim= {NULL}; + ParticleSimulationData sim = {NULL}; ParticleDrawData *pdd = psys->pdd; Material *ma; float vel[3], imat[4][4]; float timestep, pixsize_scale, pa_size, r_tilt, r_length; float pa_time, pa_birthtime, pa_dietime, pa_health, intensity; float cfra; - float ma_col[3]= {0.0f, 0.0f, 0.0f}; - int a, totpart, totpoint=0, totve=0, drawn, draw_as, totchild=0; - int select=ob->flag&SELECT, create_cdata=0, need_v=0; + float ma_col[3] = {0.0f, 0.0f, 0.0f}; + int a, totpart, totpoint = 0, totve = 0, drawn, draw_as, totchild = 0; + int select = ob->flag & SELECT, create_cdata = 0, need_v = 0; GLint polygonmode[2]; char numstr[32]; - unsigned char tcol[4]= {0, 0, 0, 255}; + unsigned char tcol[4] = {0, 0, 0, 255}; /* 1. */ - if (part==NULL || !psys_check_enabled(ob, psys)) + if (part == NULL || !psys_check_enabled(ob, psys)) return; - if (pars==NULL) return; + if (pars == NULL) return; /* don't draw normal paths in edit mode */ - if (psys_in_edit_mode(scene, psys) && (pset->flag & PE_DRAW_PART)==0) + if (psys_in_edit_mode(scene, psys) && (pset->flag & PE_DRAW_PART) == 0) return; if (part->draw_as == PART_DRAW_REND) @@ -4205,33 +4204,33 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv return; /* 2. */ - sim.scene= scene; - sim.ob= ob; - sim.psys= psys; - sim.psmd = psys_get_modifier(ob,psys); + sim.scene = scene; + sim.ob = ob; + sim.psys = psys; + sim.psmd = psys_get_modifier(ob, psys); - if (part->phystype==PART_PHYS_KEYED) { - if (psys->flag&PSYS_KEYED) { + if (part->phystype == PART_PHYS_KEYED) { + if (psys->flag & PSYS_KEYED) { psys_count_keyed_targets(&sim); - if (psys->totkeyed==0) + if (psys->totkeyed == 0) return; } } if (select) { - select=0; - if (psys_get_current(ob)==psys) - select=1; + select = 0; + if (psys_get_current(ob) == psys) + select = 1; } - psys->flag|=PSYS_DRAWING; + psys->flag |= PSYS_DRAWING; - if (part->type==PART_HAIR && !psys->childcache) - totchild=0; + if (part->type == PART_HAIR && !psys->childcache) + totchild = 0; else - totchild=psys->totchild*part->disp/100; + totchild = psys->totchild * part->disp / 100; - ma= give_current_material(ob,part->omat); + ma = give_current_material(ob, part->omat); if (v3d->zbuf) glDepthMask(1); @@ -4242,7 +4241,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glColor3ubv(tcol); - timestep= psys_get_timestep(&sim); + timestep = psys_get_timestep(&sim); if ( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) { float mat[4][4]; @@ -4253,27 +4252,27 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv /* needed for text display */ invert_m4_m4(ob->imat, ob->obmat); - totpart=psys->totpart; + totpart = psys->totpart; - cfra= BKE_curframe(scene); + cfra = BKE_curframe(scene); - if (draw_as==PART_DRAW_PATH && psys->pathcache==NULL && psys->childcache==NULL) - draw_as=PART_DRAW_DOT; + if (draw_as == PART_DRAW_PATH && psys->pathcache == NULL && psys->childcache == NULL) + draw_as = PART_DRAW_DOT; /* 3. */ - switch(draw_as) { + switch (draw_as) { case PART_DRAW_DOT: if (part->draw_size) glPointSize(part->draw_size); else - glPointSize(2.0); /* default dot size */ + glPointSize(2.0); /* default dot size */ break; case PART_DRAW_CIRC: /* calculate view aligned matrix: */ copy_m4_m4(imat, rv3d->viewinv); normalize_v3(imat[0]); normalize_v3(imat[1]); - /* no break! */ + /* no break! */ case PART_DRAW_CROSS: case PART_DRAW_AXIS: /* lets calculate the scale: */ @@ -4283,36 +4282,36 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv else pixsize_scale = part->draw_size; - if (draw_as==PART_DRAW_AXIS) + if (draw_as == PART_DRAW_AXIS) create_cdata = 1; break; case PART_DRAW_OB: - if (part->dup_ob==NULL) - draw_as=PART_DRAW_DOT; + if (part->dup_ob == NULL) + draw_as = PART_DRAW_DOT; else - draw_as=0; + draw_as = 0; break; case PART_DRAW_GR: - if (part->dup_group==NULL) - draw_as=PART_DRAW_DOT; + if (part->dup_group == NULL) + draw_as = PART_DRAW_DOT; else - draw_as=0; + draw_as = 0; break; case PART_DRAW_BB: - if (v3d->camera==NULL && part->bb_ob==NULL) { + if (v3d->camera == NULL && part->bb_ob == NULL) { printf("Billboards need an active camera or a target object!\n"); - draw_as=part->draw_as=PART_DRAW_DOT; + draw_as = part->draw_as = PART_DRAW_DOT; if (part->draw_size) glPointSize(part->draw_size); else - glPointSize(2.0); /* default dot size */ + glPointSize(2.0); /* default dot size */ } else if (part->bb_ob) - bb.ob=part->bb_ob; + bb.ob = part->bb_ob; else - bb.ob=v3d->camera; + bb.ob = v3d->camera; bb.align = part->bb_align; bb.anim = part->bb_anim; @@ -4321,10 +4320,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv case PART_DRAW_PATH: break; case PART_DRAW_LINE: - need_v=1; + need_v = 1; break; } - if (part->draw & PART_DRAW_SIZE && part->draw_as!=PART_DRAW_CIRC) { + if (part->draw & PART_DRAW_SIZE && part->draw_as != PART_DRAW_CIRC) { copy_m4_m4(imat, rv3d->viewinv); normalize_v3(imat[0]); normalize_v3(imat[1]); @@ -4342,7 +4341,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } /* 4. */ - if (draw_as && ELEM(draw_as, PART_DRAW_PATH, PART_DRAW_CIRC)==0) { + if (draw_as && ELEM(draw_as, PART_DRAW_PATH, PART_DRAW_CIRC) == 0) { int tot_vec_size = (totpart + totchild) * 3 * sizeof(float); int create_ndata = 0; @@ -4354,7 +4353,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv psys_make_temp_pointcache(ob, psys); } - switch(draw_as) { + switch (draw_as) { case PART_DRAW_AXIS: case PART_DRAW_CROSS: tot_vec_size *= 6; @@ -4389,14 +4388,14 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv else if (pdd->vedata) { /* velocity data not needed, so free it */ MEM_freeN(pdd->vedata); - pdd->vedata= NULL; + pdd->vedata = NULL; } - pdd->vd= pdd->vdata; - pdd->ved= pdd->vedata; - pdd->cd= pdd->cdata; - pdd->nd= pdd->ndata; - pdd->tot_vec_size= tot_vec_size; + pdd->vd = pdd->vdata; + pdd->ved = pdd->vedata; + pdd->cd = pdd->cdata; + pdd->nd = pdd->ndata; + pdd->tot_vec_size = tot_vec_size; } else if (psys->pdd) { psys_free_pdd(psys); @@ -4405,62 +4404,62 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } if (pdd) { - pdd->ma_col= ma_col; + pdd->ma_col = ma_col; } - psys->lattice= psys_get_lattice(&sim); + psys->lattice = psys_get_lattice(&sim); /* circles don't use drawdata, so have to add a special case here */ - if ((pdd || draw_as==PART_DRAW_CIRC) && draw_as!=PART_DRAW_PATH) { + if ((pdd || draw_as == PART_DRAW_CIRC) && draw_as != PART_DRAW_PATH) { /* 5. */ if (pdd && (pdd->flag & PARTICLE_DRAW_DATA_UPDATED) && - (pdd->vedata || part->draw & (PART_DRAW_SIZE|PART_DRAW_NUM|PART_DRAW_HEALTH))==0) + (pdd->vedata || part->draw & (PART_DRAW_SIZE | PART_DRAW_NUM | PART_DRAW_HEALTH)) == 0) { totpoint = pdd->totpoint; /* draw data is up to date */ } else { - for (a=0,pa=pars; a<totpart+totchild; a++, pa++) { + for (a = 0, pa = pars; a < totpart + totchild; a++, pa++) { /* setup per particle individual stuff */ - if (a<totpart) { - if (totchild && (part->draw&PART_DRAW_PARENT)==0) continue; + if (a < totpart) { + if (totchild && (part->draw & PART_DRAW_PARENT) == 0) continue; if (pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) continue; - pa_time=(cfra-pa->time)/pa->lifetime; - pa_birthtime=pa->time; + pa_time = (cfra - pa->time) / pa->lifetime; + pa_birthtime = pa->time; pa_dietime = pa->dietime; - pa_size=pa->size; - if (part->phystype==PART_PHYS_BOIDS) + pa_size = pa->size; + if (part->phystype == PART_PHYS_BOIDS) pa_health = pa->boid->data.health; else pa_health = -1.0; - r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f); + r_tilt = 2.0f * (PSYS_FRAND(a + 21) - 0.5f); r_length = PSYS_FRAND(a + 22); if (part->draw_col > PART_DRAW_COL_MAT) { - switch(part->draw_col) { + switch (part->draw_col) { case PART_DRAW_COL_VEL: - intensity = len_v3(pa->state.vel)/part->color_vec_max; + intensity = len_v3(pa->state.vel) / part->color_vec_max; break; case PART_DRAW_COL_ACC: intensity = len_v3v3(pa->state.vel, pa->prev_state.vel) / ((pa->state.time - pa->prev_state.time) * part->color_vec_max); break; default: - intensity= 1.0f; /* should never happen */ + intensity = 1.0f; /* should never happen */ } CLAMP(intensity, 0.f, 1.f); weight_to_rgb(ma_col, intensity); } } else { - ChildParticle *cpa= &psys->child[a-totpart]; + ChildParticle *cpa = &psys->child[a - totpart]; - pa_time=psys_get_child_time(psys,cpa,cfra,&pa_birthtime,&pa_dietime); - pa_size=psys_get_child_size(psys,cpa,cfra,NULL); + pa_time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime); + pa_size = psys_get_child_size(psys, cpa, cfra, NULL); pa_health = -1.0; - r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f); + r_tilt = 2.0f * (PSYS_FRAND(a + 21) - 0.5f); r_length = PSYS_FRAND(a + 22); } @@ -4470,10 +4469,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv int trail_count = part->trail_count * (1.0f - part->randlength * r_length); float ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length; float dt = length / (trail_count ? (float)trail_count : 1.0f); - int i=0; + int i = 0; - ct+=dt; - for (i=0; i < trail_count; i++, ct += dt) { + ct += dt; + for (i = 0; i < trail_count; i++, ct += dt) { float pixsize; if (part->draw & PART_ABS_PATH_TIME) { @@ -4484,7 +4483,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv continue; state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : -(pa_birthtime + ct * (pa_dietime - pa_birthtime)); - psys_get_particle_on_path(&sim,a,&state,need_v); + psys_get_particle_on_path(&sim, a, &state, need_v); if (psys->parent) mul_m4_v3(psys->parent->obmat, state.co); @@ -4494,14 +4493,14 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv bb.offset[0] = part->bb_offset[0]; bb.offset[1] = part->bb_offset[1]; bb.size[0] = part->bb_size[0] * pa_size; - if (part->bb_align==PART_BB_VEL) { + if (part->bb_align == PART_BB_VEL) { float pa_vel = len_v3(state.vel); - float head = part->bb_vel_head*pa_vel; - float tail = part->bb_vel_tail*pa_vel; - bb.size[1] = part->bb_size[1]*pa_size + head + tail; + float head = part->bb_vel_head * pa_vel; + float tail = part->bb_vel_tail * pa_vel; + bb.size[1] = part->bb_size[1] * pa_size + head + tail; /* use offset to adjust the particle center. this is relative to size, so need to divide! */ if (bb.size[1] > 0.0f) - bb.offset[1] += (head-tail) / bb.size[1]; + bb.offset[1] += (head - tail) / bb.size[1]; } else bb.size[1] = part->bb_size[1] * pa_size; @@ -4518,8 +4517,8 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } } else { - state.time=cfra; - if (psys_get_particle_state(&sim,a,&state,0)) { + state.time = cfra; + if (psys_get_particle_state(&sim, a, &state, 0)) { float pixsize; if (psys->parent) @@ -4530,14 +4529,14 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv bb.offset[0] = part->bb_offset[0]; bb.offset[1] = part->bb_offset[1]; bb.size[0] = part->bb_size[0] * pa_size; - if (part->bb_align==PART_BB_VEL) { + if (part->bb_align == PART_BB_VEL) { float pa_vel = len_v3(state.vel); - float head = part->bb_vel_head*pa_vel; - float tail = part->bb_vel_tail*pa_vel; - bb.size[1] = part->bb_size[1]*pa_size + head + tail; + float head = part->bb_vel_head * pa_vel; + float tail = part->bb_vel_tail * pa_vel; + bb.size[1] = part->bb_size[1] * pa_size + head + tail; /* use offset to adjust the particle center. this is relative to size, so need to divide! */ if (bb.size[1] > 0.0f) - bb.offset[1] += (head-tail) / bb.size[1]; + bb.offset[1] += (head - tail) / bb.size[1]; } else bb.size[1] = part->bb_size[1] * pa_size; @@ -4558,11 +4557,11 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv /* additional things to draw for each particle */ /* (velocity, size and number) */ if ((part->draw & PART_DRAW_VEL) && pdd && pdd->vedata) { - copy_v3_v3(pdd->ved,state.co); + copy_v3_v3(pdd->ved, state.co); pdd->ved += 3; mul_v3_v3fl(vel, state.vel, timestep); add_v3_v3v3(pdd->ved, state.co, vel); - pdd->ved+=3; + pdd->ved += 3; totve++; } @@ -4578,11 +4577,11 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { float vec_txt[3]; - char *val_pos= numstr; - numstr[0]= '\0'; + char *val_pos = numstr; + numstr[0] = '\0'; - if (part->draw&PART_DRAW_NUM) { - if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype==PART_PHYS_BOIDS)) { + if (part->draw & PART_DRAW_NUM) { + if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) { sprintf(val_pos, "%d:%.2f", a, pa_health); } else { @@ -4590,7 +4589,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } } else { - if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype==PART_PHYS_BOIDS)) { + if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) { sprintf(val_pos, "%.2f", pa_health); } } @@ -4598,7 +4597,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv /* in path drawing state.co is the end point */ /* use worldspace beause object matrix is already applied */ mul_v3_m4v3(vec_txt, ob->imat, state.co); - view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); + view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol); } } } @@ -4609,9 +4608,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glGetIntegerv(GL_POLYGON_MODE, polygonmode); glEnableClientState(GL_VERTEX_ARRAY); - if (draw_as==PART_DRAW_PATH) { + if (draw_as == PART_DRAW_PATH) { ParticleCacheKey **cache, *path; - float /* *cd2=NULL, */ /* UNUSED */ *cdata2=NULL; + float /* *cd2=NULL, */ /* UNUSED */ *cdata2 = NULL; /* setup gl flags */ if (1) { //ob_dt > OB_WIRE) { @@ -4634,15 +4633,15 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } #endif - if (totchild && (part->draw&PART_DRAW_PARENT)==0) - totpart=0; - else if (psys->pathcache==NULL) - totpart=0; + if (totchild && (part->draw & PART_DRAW_PARENT) == 0) + totpart = 0; + else if (psys->pathcache == NULL) + totpart = 0; /* draw actual/parent particles */ - cache=psys->pathcache; - for (a=0, pa=psys->particles; a<totpart; a++, pa++) { - path=cache[a]; + cache = psys->pathcache; + for (a = 0, pa = psys->particles; a < totpart; a++, pa++) { + path = cache[a]; if (path->steps > 0) { glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co); @@ -4657,9 +4656,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } /* draw child particles */ - cache=psys->childcache; - for (a=0; a<totchild; a++) { - path=cache[a]; + cache = psys->childcache; + for (a = 0; a < totchild; a++) { + path = cache[a]; glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co); if (1) { //ob_dt > OB_WIRE) { @@ -4681,23 +4680,23 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if (cdata2) MEM_freeN(cdata2); - /* cd2= */ /* UNUSED */ cdata2=NULL; + /* cd2= */ /* UNUSED */ cdata2 = NULL; glLineWidth(1.0f); - if ((part->draw & PART_DRAW_NUM) && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { - cache=psys->pathcache; + if ((part->draw & PART_DRAW_NUM) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + cache = psys->pathcache; - for (a=0, pa=psys->particles; a<totpart; a++, pa++) { + for (a = 0, pa = psys->particles; a < totpart; a++, pa++) { float vec_txt[3]; BLI_snprintf(numstr, sizeof(numstr), "%i", a); /* use worldspace beause object matrix is already applied */ mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co); - view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); + view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol); } } } - else if (pdd && ELEM(draw_as, 0, PART_DRAW_CIRC)==0) { + else if (pdd && ELEM(draw_as, 0, PART_DRAW_CIRC) == 0) { glDisableClientState(GL_COLOR_ARRAY); /* enable point data array */ @@ -4729,7 +4728,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv /* enable other data arrays */ /* billboards are drawn this way */ - if (pdd->ndata && ob_dt>OB_WIRE) { + if (pdd->ndata && ob_dt > OB_WIRE) { glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, pdd->ndata); glEnable(GL_LIGHTING); @@ -4756,7 +4755,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glVertexPointer(3, GL_FLOAT, 0, pdd->vedata); - glDrawArrays(GL_LINES, 0, 2*totve); + glDrawArrays(GL_LINES, 0, 2 * totve); } glPolygonMode(GL_FRONT, polygonmode[0]); @@ -4782,12 +4781,12 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if (psys->lattice) { end_latt_deform(psys->lattice); - psys->lattice= NULL; + psys->lattice = NULL; } if (pdd) { /* drop references to stack memory */ - pdd->ma_col= NULL; + pdd->ma_col = NULL; } if ( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) { @@ -4812,7 +4811,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) PTCacheEditKey *key; ParticleEditSettings *pset = PE_settings(scene); int i, k, totpoint = edit->totpoint, timed = pset->flag & PE_FADE_TIME ? pset->fade_frames : 0; - int steps=1; + int steps = 1; float sel_col[3]; float nosel_col[3]; float *pathcol = NULL, *pcol; @@ -4823,7 +4822,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) PE_hide_keys_time(scene, edit, CFRA); /* opengl setup */ - if ((v3d->flag & V3D_ZBUF_SELECT)==0) + if ((v3d->flag & V3D_ZBUF_SELECT) == 0) glDisable(GL_DEPTH_TEST); /* get selection theme colors */ @@ -4834,7 +4833,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) if (timed) { glEnable(GL_BLEND); steps = (*edit->pathcache)->steps + 1; - pathcol = MEM_callocN(steps*4*sizeof(float), "particle path color data"); + pathcol = MEM_callocN(steps * 4 * sizeof(float), "particle path color data"); } glEnableClientState(GL_VERTEX_ARRAY); @@ -4849,18 +4848,18 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) glDisable(GL_LIGHTING); } - cache=edit->pathcache; - for (i=0; i<totpoint; i++) { + cache = edit->pathcache; + for (i = 0; i < totpoint; i++) { path = cache[i]; glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co); if (timed) { - for (k=0, pcol=pathcol, pkey=path; k<steps; k++, pkey++, pcol+=4) { + for (k = 0, pcol = pathcol, pkey = path; k < steps; k++, pkey++, pcol += 4) { copy_v3_v3(pcol, pkey->col); - pcol[3] = 1.0f - fabsf((float)(CFRA) - pkey->time)/(float)pset->fade_frames; + pcol[3] = 1.0f - fabsf((float)(CFRA) -pkey->time) / (float)pset->fade_frames; } - glColorPointer(4, GL_FLOAT, 4*sizeof(float), pathcol); + glColorPointer(4, GL_FLOAT, 4 * sizeof(float), pathcol); } else glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col); @@ -4872,69 +4871,69 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) /* draw edit vertices */ - if (pset->selectmode!=SCE_SELECT_PATH) { + if (pset->selectmode != SCE_SELECT_PATH) { glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); - if (pset->selectmode==SCE_SELECT_POINT) { - float *pd=NULL,*pdata=NULL; - float *cd=NULL,*cdata=NULL; + if (pset->selectmode == SCE_SELECT_POINT) { + float *pd = NULL, *pdata = NULL; + float *cd = NULL, *cdata = NULL; int totkeys = 0; - for (i=0, point=edit->points; i<totpoint; i++, point++) + for (i = 0, point = edit->points; i < totpoint; i++, point++) if (!(point->flag & PEP_HIDE)) totkeys += point->totkey; if (edit->points && !(edit->points->keys->flag & PEK_USE_WCO)) - pd=pdata=MEM_callocN(totkeys*3*sizeof(float), "particle edit point data"); - cd=cdata=MEM_callocN(totkeys*(timed?4:3)*sizeof(float), "particle edit color data"); + pd = pdata = MEM_callocN(totkeys * 3 * sizeof(float), "particle edit point data"); + cd = cdata = MEM_callocN(totkeys * (timed ? 4 : 3) * sizeof(float), "particle edit color data"); - for (i=0, point=edit->points; i<totpoint; i++, point++) { + for (i = 0, point = edit->points; i < totpoint; i++, point++) { if (point->flag & PEP_HIDE) continue; - for (k=0, key=point->keys; k<point->totkey; k++, key++) { + for (k = 0, key = point->keys; k < point->totkey; k++, key++) { if (pd) { copy_v3_v3(pd, key->co); pd += 3; } - if (key->flag&PEK_SELECT) { - copy_v3_v3(cd,sel_col); + if (key->flag & PEK_SELECT) { + copy_v3_v3(cd, sel_col); } else { - copy_v3_v3(cd,nosel_col); + copy_v3_v3(cd, nosel_col); } if (timed) - *(cd+3) = 1.0f - fabsf((float)CFRA - *key->time)/(float)pset->fade_frames; + *(cd + 3) = 1.0f - fabsf((float)CFRA - *key->time) / (float)pset->fade_frames; - cd += (timed?4:3); + cd += (timed ? 4 : 3); } } - cd=cdata; - pd=pdata; - for (i=0, point=edit->points; i<totpoint; i++, point++) { + cd = cdata; + pd = pdata; + for (i = 0, point = edit->points; i < totpoint; i++, point++) { if (point->flag & PEP_HIDE || point->totkey == 0) continue; if (point->keys->flag & PEK_USE_WCO) glVertexPointer(3, GL_FLOAT, sizeof(PTCacheEditKey), point->keys->world_co); else - glVertexPointer(3, GL_FLOAT, 3*sizeof(float), pd); + glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), pd); - glColorPointer((timed?4:3), GL_FLOAT, (timed?4:3)*sizeof(float), cd); + glColorPointer((timed ? 4 : 3), GL_FLOAT, (timed ? 4 : 3) * sizeof(float), cd); glDrawArrays(GL_POINTS, 0, point->totkey); pd += pd ? 3 * point->totkey : 0; - cd += (timed?4:3) * point->totkey; + cd += (timed ? 4 : 3) * point->totkey; } - if (pdata) { MEM_freeN(pdata); pd=pdata=NULL; } - if (cdata) { MEM_freeN(cdata); cd=cdata=NULL; } + if (pdata) { MEM_freeN(pdata); pd = pdata = NULL; } + if (cdata) { MEM_freeN(cdata); cd = cdata = NULL; } } else if (pset->selectmode == SCE_SELECT_END) { - for (i=0, point=edit->points; i<totpoint; i++, point++) { - if ((point->flag & PEP_HIDE)==0 && point->totkey) { + for (i = 0, point = edit->points; i < totpoint; i++, point++) { + if ((point->flag & PEP_HIDE) == 0 && point->totkey) { key = point->keys + point->totkey - 1; if (key->flag & PEK_SELECT) glColor3fv(sel_col); @@ -4961,13 +4960,13 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) glPointSize(1.0); } //static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float tw,float th) -static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float ith,float drw_size) +static void ob_draw_RE_motion(float com[3], float rotscale[3][3], float itw, float ith, float drw_size) { float tr[3][3]; - float root[3],tip[3]; - float tw,th; + float root[3], tip[3]; + float tw, th; /* take a copy for not spoiling original */ - copy_m3_m3(tr,rotscale); + copy_m3_m3(tr, rotscale); tw = itw * drw_size; th = ith * drw_size; @@ -4975,29 +4974,29 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float glBegin(GL_LINES); root[1] = root[2] = 0.0f; root[0] = -drw_size; - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); tip[1] = tip[2] = 0.0f; tip[0] = drw_size; - mul_m3_v3(tr,tip); + mul_m3_v3(tr, tip); add_v3_v3(tip, com); glVertex3fv(tip); glEnd(); - root[1] =0.0f; root[2] = tw; + root[1] = 0.0f; root[2] = tw; root[0] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); - root[1] =0.0f; root[2] = -tw; + root[1] = 0.0f; root[2] = -tw; root[0] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); @@ -5006,16 +5005,16 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[1] = tw; root[2] = 0.0f; root[0] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); - root[1] =-tw; root[2] = 0.0f; + root[1] = -tw; root[2] = 0.0f; root[0] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); @@ -5026,20 +5025,20 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float glBegin(GL_LINES); root[0] = root[2] = 0.0f; root[1] = -drw_size; - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); tip[0] = tip[2] = 0.0f; tip[1] = drw_size; - mul_m3_v3(tr,tip); + mul_m3_v3(tr, tip); add_v3_v3(tip, com); glVertex3fv(tip); glEnd(); - root[0] =0.0f; root[2] = tw; + root[0] = 0.0f; root[2] = tw; root[1] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); @@ -5048,7 +5047,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = 0.0f; root[2] = -tw; root[1] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); @@ -5057,16 +5056,16 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = tw; root[2] = 0.0f; root[1] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); - root[0] =-tw; root[2] = 0.0f; + root[0] = -tw; root[2] = 0.0f; root[1] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); @@ -5076,29 +5075,29 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float glBegin(GL_LINES); root[0] = root[1] = 0.0f; root[2] = -drw_size; - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); tip[0] = tip[1] = 0.0f; tip[2] = drw_size; - mul_m3_v3(tr,tip); + mul_m3_v3(tr, tip); add_v3_v3(tip, com); glVertex3fv(tip); glEnd(); - root[0] =0.0f; root[1] = tw; + root[0] = 0.0f; root[1] = tw; root[2] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); glEnd(); - root[0] =0.0f; root[1] = -tw; + root[0] = 0.0f; root[1] = -tw; root[2] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); @@ -5107,7 +5106,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = tw; root[1] = 0.0f; root[2] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); @@ -5116,7 +5115,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float root[0] = -tw; root[1] = 0.0f; root[2] = th; glBegin(GL_LINES); - mul_m3_v3(tr,root); + mul_m3_v3(tr, root); add_v3_v3(root, com); glVertex3fv(root); glVertex3fv(tip); @@ -5140,40 +5139,40 @@ static void tekenhandlesN(Nurb *nu, short sel, short hide_handles) #define TH_HANDLE_COL_TOT ((TH_HANDLE_SEL_FREE - TH_HANDLE_FREE) + 1) /* use MIN2 when indexing to ensure newer files don't read outside the array */ unsigned char handle_cols[TH_HANDLE_COL_TOT][3]; - const int basecol= sel ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE; + const int basecol = sel ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE; - for (a=0; a < TH_HANDLE_COL_TOT; a++) { + for (a = 0; a < TH_HANDLE_COL_TOT; a++) { UI_GetThemeColor3ubv(basecol + a, handle_cols[a]); } - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (bezt->hide==0) { - if ( (bezt->f2 & SELECT)==sel) { - fp= bezt->vec[0]; + if (bezt->hide == 0) { + if ( (bezt->f2 & SELECT) == sel) { + fp = bezt->vec[0]; - glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]); + glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]); glVertex3fv(fp); - glVertex3fv(fp+3); + glVertex3fv(fp + 3); - glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]); - glVertex3fv(fp+3); - glVertex3fv(fp+6); + glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]); + glVertex3fv(fp + 3); + glVertex3fv(fp + 6); } - else if ( (bezt->f1 & SELECT)==sel) { - fp= bezt->vec[0]; + else if ( (bezt->f1 & SELECT) == sel) { + fp = bezt->vec[0]; - glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]); + glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]); glVertex3fv(fp); - glVertex3fv(fp+3); + glVertex3fv(fp + 3); } - else if ( (bezt->f3 & SELECT)==sel) { - fp= bezt->vec[1]; + else if ( (bezt->f3 & SELECT) == sel) { + fp = bezt->vec[1]; - glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]); + glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]); glVertex3fv(fp); - glVertex3fv(fp+3); + glVertex3fv(fp + 3); } } bezt++; @@ -5199,24 +5198,24 @@ static void tekenhandlesN_active(Nurb *nu) glBegin(GL_LINES); if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (bezt->hide==0) { - fp= bezt->vec[0]; + if (bezt->hide == 0) { + fp = bezt->vec[0]; glVertex3fv(fp); - glVertex3fv(fp+3); + glVertex3fv(fp + 3); - glVertex3fv(fp+3); - glVertex3fv(fp+6); + glVertex3fv(fp + 3); + glVertex3fv(fp + 6); } bezt++; } } glEnd(); - glColor3ub(0,0,0); + glColor3ub(0, 0, 0); glLineWidth(1); } @@ -5229,22 +5228,22 @@ static void tekenvertsN(Nurb *nu, short sel, short hide_handles, void *lastsel) if (nu->hide) return; - if (sel) color= TH_VERTEX_SELECT; - else color= TH_VERTEX; + if (sel) color = TH_VERTEX_SELECT; + else color = TH_VERTEX; UI_ThemeColor(color); - size= UI_GetThemeValuef(TH_VERTEX_SIZE); + size = UI_GetThemeValuef(TH_VERTEX_SIZE); glPointSize(size); bglBegin(GL_POINTS); if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (bezt->hide==0) { + if (bezt->hide == 0) { if (sel == 1 && bezt == lastsel) { UI_ThemeColor(TH_LASTSEL_POINT); bglVertex3fv(bezt->vec[1]); @@ -5257,29 +5256,29 @@ static void tekenvertsN(Nurb *nu, short sel, short hide_handles, void *lastsel) UI_ThemeColor(color); } else if (hide_handles) { - if ((bezt->f2 & SELECT)==sel) bglVertex3fv(bezt->vec[1]); + if ((bezt->f2 & SELECT) == sel) bglVertex3fv(bezt->vec[1]); } else { - if ((bezt->f1 & SELECT)==sel) bglVertex3fv(bezt->vec[0]); - if ((bezt->f2 & SELECT)==sel) bglVertex3fv(bezt->vec[1]); - if ((bezt->f3 & SELECT)==sel) bglVertex3fv(bezt->vec[2]); + if ((bezt->f1 & SELECT) == sel) bglVertex3fv(bezt->vec[0]); + if ((bezt->f2 & SELECT) == sel) bglVertex3fv(bezt->vec[1]); + if ((bezt->f3 & SELECT) == sel) bglVertex3fv(bezt->vec[2]); } } bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if (bp->hide==0) { + if (bp->hide == 0) { if (bp == lastsel) { UI_ThemeColor(TH_LASTSEL_POINT); bglVertex3fv(bp->vec); UI_ThemeColor(color); } else { - if ((bp->f1 & SELECT)==sel) bglVertex3fv(bp->vec); + if ((bp->f1 & SELECT) == sel) bglVertex3fv(bp->vec); } } bp++; @@ -5298,19 +5297,19 @@ static void editnurb_draw_active_poly(Nurb *nu) UI_ThemeColor(TH_ACTIVE_SPLINE); glLineWidth(2); - bp= nu->bp; - for (b=0; b<nu->pntsv; b++) { + bp = nu->bp; + for (b = 0; b < nu->pntsv; b++) { if (nu->flagu & 1) glBegin(GL_LINE_LOOP); else glBegin(GL_LINE_STRIP); - for (a=0; a<nu->pntsu; a++, bp++) { + for (a = 0; a < nu->pntsu; a++, bp++) { glVertex3fv(bp->vec); } glEnd(); } - glColor3ub(0,0,0); + glColor3ub(0, 0, 0); glLineWidth(1); } @@ -5323,39 +5322,39 @@ static void editnurb_draw_active_nurbs(Nurb *nu) glLineWidth(2); glBegin(GL_LINES); - bp= nu->bp; - for (b=0; b<nu->pntsv; b++) { - bp1= bp; + bp = nu->bp; + for (b = 0; b < nu->pntsv; b++) { + bp1 = bp; bp++; - for (a=nu->pntsu-1; a>0; a--, bp++) { - if (bp->hide==0 && bp1->hide==0) { + for (a = nu->pntsu - 1; a > 0; a--, bp++) { + if (bp->hide == 0 && bp1->hide == 0) { glVertex3fv(bp->vec); glVertex3fv(bp1->vec); } - bp1= bp; + bp1 = bp; } } - if (nu->pntsv > 1) { /* surface */ + if (nu->pntsv > 1) { /* surface */ - ofs= nu->pntsu; - for (b=0; b<nu->pntsu; b++) { - bp1= nu->bp+b; - bp= bp1+ofs; - for (a=nu->pntsv-1; a>0; a--, bp+=ofs) { - if (bp->hide==0 && bp1->hide==0) { + ofs = nu->pntsu; + for (b = 0; b < nu->pntsu; b++) { + bp1 = nu->bp + b; + bp = bp1 + ofs; + for (a = nu->pntsv - 1; a > 0; a--, bp += ofs) { + if (bp->hide == 0 && bp1->hide == 0) { glVertex3fv(bp->vec); glVertex3fv(bp1->vec); } - bp1= bp; + bp1 = bp; } } } glEnd(); - glColor3ub(0,0,0); + glColor3ub(0, 0, 0); glLineWidth(1); } @@ -5364,26 +5363,26 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) Nurb *nu; BPoint *bp, *bp1; int a, b, ofs, index; - Curve *cu= (Curve*)ob->data; + Curve *cu = (Curve *)ob->data; - index= 0; - nu= nurb; + index = 0; + nu = nurb; while (nu) { - if (nu->hide==0) { - switch(nu->type) { + if (nu->hide == 0) { + switch (nu->type) { case CU_POLY: - if (!sel && index== cu->actnu) { + if (!sel && index == cu->actnu) { /* we should draw active spline highlight below everything */ editnurb_draw_active_poly(nu); } UI_ThemeColor(TH_NURB_ULINE); - bp= nu->bp; - for (b=0; b<nu->pntsv; b++) { + bp = nu->bp; + for (b = 0; b < nu->pntsv; b++) { if (nu->flagu & 1) glBegin(GL_LINE_LOOP); else glBegin(GL_LINE_STRIP); - for (a=0; a<nu->pntsu; a++, bp++) { + for (a = 0; a < nu->pntsu; a++, bp++) { glVertex3fv(bp->vec); } @@ -5391,19 +5390,19 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) } break; case CU_NURBS: - if (!sel && index== cu->actnu) { + if (!sel && index == cu->actnu) { /* we should draw active spline highlight below everything */ editnurb_draw_active_nurbs(nu); } - bp= nu->bp; - for (b=0; b<nu->pntsv; b++) { - bp1= bp; + bp = nu->bp; + for (b = 0; b < nu->pntsv; b++) { + bp1 = bp; bp++; - for (a=nu->pntsu-1; a>0; a--, bp++) { - if (bp->hide==0 && bp1->hide==0) { + for (a = nu->pntsu - 1; a > 0; a--, bp++) { + if (bp->hide == 0 && bp1->hide == 0) { if (sel) { - if ( (bp->f1 & SELECT) && ( bp1->f1 & SELECT ) ) { + if ( (bp->f1 & SELECT) && (bp1->f1 & SELECT) ) { UI_ThemeColor(TH_NURB_SEL_ULINE); glBegin(GL_LINE_STRIP); @@ -5426,19 +5425,19 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) } } } - bp1= bp; + bp1 = bp; } } - if (nu->pntsv > 1) { /* surface */ - - ofs= nu->pntsu; - for (b=0; b<nu->pntsu; b++) { - bp1= nu->bp+b; - bp= bp1+ofs; - for (a=nu->pntsv-1; a>0; a--, bp+=ofs) { - if (bp->hide==0 && bp1->hide==0) { + if (nu->pntsv > 1) { /* surface */ + + ofs = nu->pntsu; + for (b = 0; b < nu->pntsu; b++) { + bp1 = nu->bp + b; + bp = bp1 + ofs; + for (a = nu->pntsv - 1; a > 0; a--, bp += ofs) { + if (bp->hide == 0 && bp1->hide == 0) { if (sel) { - if ( (bp->f1 & SELECT) && ( bp1->f1 & SELECT) ) { + if ( (bp->f1 & SELECT) && (bp1->f1 & SELECT) ) { UI_ThemeColor(TH_NURB_SEL_VLINE); glBegin(GL_LINE_STRIP); @@ -5461,7 +5460,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) } } } - bp1= bp; + bp1 = bp; } } @@ -5471,14 +5470,14 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) } ++index; - nu= nu->next; + nu = nu->next; } } static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb, int dt) { - ToolSettings *ts= scene->toolsettings; - Object *ob= base->object; + ToolSettings *ts = scene->toolsettings; + Object *ob = base->object; Curve *cu = ob->data; Nurb *nu; BevList *bl; @@ -5492,8 +5491,8 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, if (v3d->zbuf) glDisable(GL_DEPTH_TEST); /* first non-selected and active handles */ - index= 0; - for (nu=nurb; nu; nu=nu->next) { + index = 0; + for (nu = nurb; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { if (index == cu->actnu && !hide_handles) tekenhandlesN_active(nu); @@ -5504,8 +5503,8 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, draw_editnurb(ob, nurb, 0); draw_editnurb(ob, nurb, 1); /* selected handles */ - for (nu=nurb; nu; nu=nu->next) { - if (nu->type == CU_BEZIER && (cu->drawflag & CU_HIDE_HANDLES)==0) + for (nu = nurb; nu; nu = nu->next) { + if (nu->type == CU_BEZIER && (cu->drawflag & CU_HIDE_HANDLES) == 0) tekenhandlesN(nu, 1, hide_handles); tekenvertsN(nu, 0, hide_handles, NULL); } @@ -5514,26 +5513,26 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* direction vectors for 3d curve paths * when at its lowest, don't render normals */ - if ((cu->flag & CU_3D) && (ts->normalsize > 0.0015f) && (cu->drawflag & CU_HIDE_NORMALS)==0) { + if ((cu->flag & CU_3D) && (ts->normalsize > 0.0015f) && (cu->drawflag & CU_HIDE_NORMALS) == 0) { UI_ThemeColor(TH_WIRE); - for (bl=cu->bev.first,nu=nurb; nu && bl; bl=bl->next,nu=nu->next) { - BevPoint *bevp= (BevPoint *)(bl + 1); - int nr= bl->nr; - int skip= nu->resolu/16; + for (bl = cu->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) { + BevPoint *bevp = (BevPoint *)(bl + 1); + int nr = bl->nr; + int skip = nu->resolu / 16; - while (nr-->0) { /* accounts for empty bevel lists */ - const float fac= bevp->radius * ts->normalsize; + while (nr-- > 0) { /* accounts for empty bevel lists */ + const float fac = bevp->radius * ts->normalsize; float vec_a[3]; // Offset perpendicular to the curve float vec_b[3]; // Delta along the curve - vec_a[0]= fac; - vec_a[1]= 0.0f; - vec_a[2]= 0.0f; + vec_a[0] = fac; + vec_a[1] = 0.0f; + vec_a[2] = 0.0f; - vec_b[0]= -fac; - vec_b[1]= 0.0f; - vec_b[2]= 0.0f; + vec_b[0] = -fac; + vec_b[1] = 0.0f; + vec_b[2] = 0.0f; mul_qt_v3(bevp->quat, vec_a); mul_qt_v3(bevp->quat, vec_b); @@ -5549,7 +5548,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glVertex3fv(vec_b); glEnd(); - bevp += skip+1; + bevp += skip + 1; nr -= skip; } } @@ -5557,7 +5556,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - for (nu=nurb; nu; nu=nu->next) { + for (nu = nurb; nu; nu = nu->next) { tekenvertsN(nu, 1, hide_handles, cu->lastsel); } @@ -5565,14 +5564,14 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } /* draw a sphere for use as an empty drawtype */ -static void draw_empty_sphere (float size) +static void draw_empty_sphere(float size) { - static GLuint displist=0; + static GLuint displist = 0; if (displist == 0) { - GLUquadricObj *qobj; + GLUquadricObj *qobj; - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); glPushMatrix(); @@ -5595,13 +5594,13 @@ static void draw_empty_sphere (float size) glScalef(size, size, size); glCallList(displist); - glScalef(1.0f/size, 1.0f/size, 1.0f/size); + glScalef(1.0f / size, 1.0f / size, 1.0f / size); } /* draw a cone for use as an empty drawtype */ -static void draw_empty_cone (float size) +static void draw_empty_cone(float size) { - float cent=0; + float cent = 0; float radius; GLUquadricObj *qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); @@ -5610,7 +5609,7 @@ static void draw_empty_cone (float size) glPushMatrix(); radius = size; - glTranslatef(cent,cent, cent); + glTranslatef(cent, cent, cent); glScalef(radius, size * 2.0f, radius); glRotatef(-90., 1.0, 0.0, 0.0); gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1); @@ -5624,25 +5623,25 @@ static void draw_empty_cone (float size) #if 0 // XXX old animation system stuff static void curve_draw_speed(Scene *scene, Object *ob) { - Curve *cu= ob->data; + Curve *cu = ob->data; IpoCurve *icu; BezTriple *bezt; float loc[4], dir[3]; int a; - if (cu->ipo==NULL) + if (cu->ipo == NULL) return; - icu= cu->ipo->curve.first; - if (icu==NULL || icu->totvert<2) + icu = cu->ipo->curve.first; + if (icu == NULL || icu->totvert < 2) return; - glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) ); + glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) ); bglBegin(GL_POINTS); - for (a=0, bezt= icu->bezt; a<icu->totvert; a++, bezt++) { - if ( where_on_path(ob, bezt->vec[1][1], loc, dir)) { - UI_ThemeColor((bezt->f2 & SELECT) && ob==OBACT?TH_VERTEX_SELECT:TH_VERTEX); + for (a = 0, bezt = icu->bezt; a < icu->totvert; a++, bezt++) { + if (where_on_path(ob, bezt->vec[1][1], loc, dir)) { + UI_ThemeColor((bezt->f2 & SELECT) && ob == OBACT ? TH_VERTEX_SELECT : TH_VERTEX); bglVertex3fv(loc); } } @@ -5670,14 +5669,14 @@ static void draw_textcurs(float textcurs[4][2]) static void drawspiral(const float cent[3], float rad, float tmat[][4], int start) { float vec[3], vx[3], vy[3]; - const float tot_inv= (1.0f / (float)CIRCLE_RESOL); + const float tot_inv = (1.0f / (float)CIRCLE_RESOL); int a; - char inverse= FALSE; + char inverse = FALSE; float x, y, fac; if (start < 0) { inverse = TRUE; - start= -start; + start = -start; } mul_v3_v3fl(vx, tmat[0], rad); @@ -5685,47 +5684,47 @@ static void drawspiral(const float cent[3], float rad, float tmat[][4], int star glBegin(GL_LINE_STRIP); - if (inverse==0) { + if (inverse == 0) { copy_v3_v3(vec, cent); glVertex3fv(vec); - for (a=0; a<CIRCLE_RESOL; a++) { - if (a+start>=CIRCLE_RESOL) - start=-a + 1; + for (a = 0; a < CIRCLE_RESOL; a++) { + if (a + start >= CIRCLE_RESOL) + start = -a + 1; - fac= (float)a * tot_inv; - x= sinval[a+start] * fac; - y= cosval[a+start] * fac; + fac = (float)a * tot_inv; + x = sinval[a + start] * fac; + y = cosval[a + start] * fac; - vec[0]= cent[0] + (x * vx[0] + y * vy[0]); - vec[1]= cent[1] + (x * vx[1] + y * vy[1]); - vec[2]= cent[2] + (x * vx[2] + y * vy[2]); + vec[0] = cent[0] + (x * vx[0] + y * vy[0]); + vec[1] = cent[1] + (x * vx[1] + y * vy[1]); + vec[2] = cent[2] + (x * vx[2] + y * vy[2]); glVertex3fv(vec); } } else { - fac= (float)(CIRCLE_RESOL-1) * tot_inv; - x= sinval[start] * fac; - y= cosval[start] * fac; + fac = (float)(CIRCLE_RESOL - 1) * tot_inv; + x = sinval[start] * fac; + y = cosval[start] * fac; - vec[0]= cent[0] + (x * vx[0] + y * vy[0]); - vec[1]= cent[1] + (x * vx[1] + y * vy[1]); - vec[2]= cent[2] + (x * vx[2] + y * vy[2]); + vec[0] = cent[0] + (x * vx[0] + y * vy[0]); + vec[1] = cent[1] + (x * vx[1] + y * vy[1]); + vec[2] = cent[2] + (x * vx[2] + y * vy[2]); glVertex3fv(vec); - for (a=0; a<CIRCLE_RESOL; a++) { - if (a+start>=CIRCLE_RESOL) - start=-a + 1; + for (a = 0; a < CIRCLE_RESOL; a++) { + if (a + start >= CIRCLE_RESOL) + start = -a + 1; - fac= (float)(-a+(CIRCLE_RESOL-1)) * tot_inv; - x= sinval[a+start] * fac; - y= cosval[a+start] * fac; + fac = (float)(-a + (CIRCLE_RESOL - 1)) * tot_inv; + x = sinval[a + start] * fac; + y = cosval[a + start] * fac; - vec[0]= cent[0] + (x * vx[0] + y * vy[0]); - vec[1]= cent[1] + (x * vx[1] + y * vy[1]); - vec[2]= cent[2] + (x * vx[2] + y * vy[2]); + vec[0] = cent[0] + (x * vx[0] + y * vy[0]); + vec[1] = cent[1] + (x * vx[1] + y * vy[1]); + vec[2] = cent[2] + (x * vx[2] + y * vy[2]); glVertex3fv(vec); } } @@ -5744,11 +5743,11 @@ static void drawcircle_size(float size) glBegin(GL_LINE_LOOP); /* coordinates are: cos(degrees*11.25)=x, sin(degrees*11.25)=y, 0.0f=z */ - for (degrees=0; degrees<CIRCLE_RESOL; degrees++) { - x= cosval[degrees]; - y= sinval[degrees]; + for (degrees = 0; degrees < CIRCLE_RESOL; degrees++) { + x = cosval[degrees]; + y = sinval[degrees]; - glVertex3f(x*size, 0.0f, y*size); + glVertex3f(x * size, 0.0f, y * size); } glEnd(); @@ -5761,20 +5760,20 @@ static void drawtube(const float vec[3], float radius, float height, float tmat[ float cur[3]; drawcircball(GL_LINE_LOOP, vec, radius, tmat); - copy_v3_v3(cur,vec); - cur[2]+=height; + copy_v3_v3(cur, vec); + cur[2] += height; drawcircball(GL_LINE_LOOP, cur, radius, tmat); glBegin(GL_LINES); - glVertex3f(vec[0]+radius,vec[1],vec[2]); - glVertex3f(cur[0]+radius,cur[1],cur[2]); - glVertex3f(vec[0]-radius,vec[1],vec[2]); - glVertex3f(cur[0]-radius,cur[1],cur[2]); - glVertex3f(vec[0],vec[1]+radius,vec[2]); - glVertex3f(cur[0],cur[1]+radius,cur[2]); - glVertex3f(vec[0],vec[1]-radius,vec[2]); - glVertex3f(cur[0],cur[1]-radius,cur[2]); + glVertex3f(vec[0] + radius, vec[1], vec[2]); + glVertex3f(cur[0] + radius, cur[1], cur[2]); + glVertex3f(vec[0] - radius, vec[1], vec[2]); + glVertex3f(cur[0] - radius, cur[1], cur[2]); + glVertex3f(vec[0], vec[1] + radius, vec[2]); + glVertex3f(cur[0], cur[1] + radius, cur[2]); + glVertex3f(vec[0], vec[1] - radius, vec[2]); + glVertex3f(cur[0], cur[1] - radius, cur[2]); glEnd(); } /* needs fixing if non-identity matrice used */ @@ -5782,51 +5781,51 @@ static void drawcone(const float vec[3], float radius, float height, float tmat[ { float cur[3]; - copy_v3_v3(cur,vec); - cur[2]+=height; + copy_v3_v3(cur, vec); + cur[2] += height; drawcircball(GL_LINE_LOOP, cur, radius, tmat); glBegin(GL_LINES); - glVertex3f(vec[0],vec[1],vec[2]); - glVertex3f(cur[0]+radius,cur[1],cur[2]); - glVertex3f(vec[0],vec[1],vec[2]); - glVertex3f(cur[0]-radius,cur[1],cur[2]); - glVertex3f(vec[0],vec[1],vec[2]); - glVertex3f(cur[0],cur[1]+radius,cur[2]); - glVertex3f(vec[0],vec[1],vec[2]); - glVertex3f(cur[0],cur[1]-radius,cur[2]); + glVertex3f(vec[0], vec[1], vec[2]); + glVertex3f(cur[0] + radius, cur[1], cur[2]); + glVertex3f(vec[0], vec[1], vec[2]); + glVertex3f(cur[0] - radius, cur[1], cur[2]); + glVertex3f(vec[0], vec[1], vec[2]); + glVertex3f(cur[0], cur[1] + radius, cur[2]); + glVertex3f(vec[0], vec[1], vec[2]); + glVertex3f(cur[0], cur[1] - radius, cur[2]); glEnd(); } /* return 1 if nothing was drawn */ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt) { - Object *ob= base->object; + Object *ob = base->object; MetaBall *mb; MetaElem *ml; float imat[4][4]; - int code= 1; + int code = 1; - mb= ob->data; + mb = ob->data; if (mb->editelems) { UI_ThemeColor(TH_WIRE); - if ((G.f & G_PICKSEL)==0 ) drawDispList(scene, v3d, rv3d, base, dt); - ml= mb->editelems->first; + if ((G.f & G_PICKSEL) == 0) drawDispList(scene, v3d, rv3d, base, dt); + ml = mb->editelems->first; } else { - if ((base->flag & OB_FROMDUPLI)==0) + if ((base->flag & OB_FROMDUPLI) == 0) drawDispList(scene, v3d, rv3d, base, dt); - ml= mb->elems.first; + ml = mb->elems.first; } - if (ml==NULL) return 1; + if (ml == NULL) return 1; if (v3d->flag2 & V3D_RENDER_OVERRIDE) return 0; /* in case solid draw, reset wire colors */ if (ob->flag & SELECT) { - if (ob==OBACT) UI_ThemeColor(TH_ACTIVE); + if (ob == OBACT) UI_ThemeColor(TH_ACTIVE); else UI_ThemeColor(TH_SELECT); } else UI_ThemeColor(TH_WIRE); @@ -5843,7 +5842,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, else cpack(0x3030A0); if (G.f & G_PICKSEL) { - ml->selcol1= code; + ml->selcol1 = code; glLoadName(code++); } } @@ -5855,31 +5854,31 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, else cpack(0x30A030); if (G.f & G_PICKSEL) { - ml->selcol2= code; + ml->selcol2 = code; glLoadName(code++); } - drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad*atanf(ml->s)/(float)M_PI_2, imat); + drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad * atanf(ml->s) / (float)M_PI_2, imat); } - ml= ml->next; + ml = ml->next; } return 0; } static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) { - PartDeflect *pd= ob->pd; + PartDeflect *pd = ob->pd; float imat[4][4], tmat[4][4]; - float vec[3]= {0.0, 0.0, 0.0}; + float vec[3] = {0.0, 0.0, 0.0}; int curcol; float size; /* XXX why? */ - if (ob!=scene->obedit && (ob->flag & SELECT)) { - if (ob==OBACT) curcol= TH_ACTIVE; - else curcol= TH_SELECT; + if (ob != scene->obedit && (ob->flag & SELECT)) { + if (ob == OBACT) curcol = TH_ACTIVE; + else curcol = TH_SELECT; } - else curcol= TH_EMPTY; + else curcol = TH_EMPTY; /* scale size of circle etc with the empty drawsize */ if (ob->type == OB_EMPTY) size = ob->empty_drawsize; @@ -5904,11 +5903,11 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) } force_val *= 0.1f; drawcircball(GL_LINE_LOOP, vec, size, tmat); - vec[2]= 0.5f * force_val; + vec[2] = 0.5f * force_val; drawcircball(GL_LINE_LOOP, vec, size, tmat); - vec[2]= 1.0f * force_val; + vec[2] = 1.0f * force_val; drawcircball(GL_LINE_LOOP, vec, size, tmat); - vec[2]= 1.5f * force_val; + vec[2] = 1.5f * force_val; drawcircball(GL_LINE_LOOP, vec, size, tmat); vec[2] = 0.0f; /* reset vec for max dist circle */ @@ -5928,7 +5927,7 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val)); drawcircball(GL_LINE_LOOP, vec, size * 1.5f, imat); UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val)); - drawcircball(GL_LINE_LOOP, vec, size*2.0f, imat); + drawcircball(GL_LINE_LOOP, vec, size * 2.0f, imat); } else if (pd->forcefield == PFIELD_VORTEX) { float /*ffall_val,*/ force_val; @@ -5956,8 +5955,8 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) drawspiral(vec, size, tmat, -16); } } - else if (pd->forcefield == PFIELD_GUIDE && ob->type==OB_CURVE) { - Curve *cu= ob->data; + else if (pd->forcefield == PFIELD_GUIDE && ob->type == OB_CURVE) { + Curve *cu = ob->data; if ((cu->flag & CU_PATH) && cu->path && cu->path->data) { float mindist, guidevec1[4], guidevec2[3]; @@ -5980,14 +5979,14 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) UI_ThemeColorBlend(curcol, TH_BACK, 0.5); drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat); - copy_v3_v3(vec, guidevec1); /* max center */ + copy_v3_v3(vec, guidevec1); /* max center */ } } setlinestyle(3); UI_ThemeColorBlend(curcol, TH_BACK, 0.5); - if (pd->falloff==PFIELD_FALL_SPHERE) { + if (pd->falloff == PFIELD_FALL_SPHERE) { /* as last, guide curve alters it */ if (pd->flag & PFIELD_USEMAX) drawcircball(GL_LINE_LOOP, vec, pd->maxdist, imat); @@ -5995,48 +5994,48 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) if (pd->flag & PFIELD_USEMIN) drawcircball(GL_LINE_LOOP, vec, pd->mindist, imat); } - else if (pd->falloff==PFIELD_FALL_TUBE) { - float radius,distance; + else if (pd->falloff == PFIELD_FALL_TUBE) { + float radius, distance; unit_m4(tmat); - vec[0]=vec[1]=0.0f; - radius=(pd->flag&PFIELD_USEMAXR)?pd->maxrad:1.0f; - distance=(pd->flag&PFIELD_USEMAX)?pd->maxdist:0.0f; - vec[2]=distance; - distance=(pd->flag&PFIELD_POSZ)?-distance:-2.0f*distance; + vec[0] = vec[1] = 0.0f; + radius = (pd->flag & PFIELD_USEMAXR) ? pd->maxrad : 1.0f; + distance = (pd->flag & PFIELD_USEMAX) ? pd->maxdist : 0.0f; + vec[2] = distance; + distance = (pd->flag & PFIELD_POSZ) ? -distance : -2.0f * distance; - if (pd->flag & (PFIELD_USEMAX|PFIELD_USEMAXR)) - drawtube(vec,radius,distance,tmat); + if (pd->flag & (PFIELD_USEMAX | PFIELD_USEMAXR)) + drawtube(vec, radius, distance, tmat); - radius=(pd->flag&PFIELD_USEMINR)?pd->minrad:1.0f; - distance=(pd->flag&PFIELD_USEMIN)?pd->mindist:0.0f; - vec[2]=distance; - distance=(pd->flag&PFIELD_POSZ)?-distance:-2.0f*distance; + radius = (pd->flag & PFIELD_USEMINR) ? pd->minrad : 1.0f; + distance = (pd->flag & PFIELD_USEMIN) ? pd->mindist : 0.0f; + vec[2] = distance; + distance = (pd->flag & PFIELD_POSZ) ? -distance : -2.0f * distance; - if (pd->flag & (PFIELD_USEMIN|PFIELD_USEMINR)) - drawtube(vec,radius,distance,tmat); + if (pd->flag & (PFIELD_USEMIN | PFIELD_USEMINR)) + drawtube(vec, radius, distance, tmat); } - else if (pd->falloff==PFIELD_FALL_CONE) { - float radius,distance; + else if (pd->falloff == PFIELD_FALL_CONE) { + float radius, distance; unit_m4(tmat); - radius= DEG2RADF((pd->flag&PFIELD_USEMAXR) ? pd->maxrad : 1.0f); - distance=(pd->flag&PFIELD_USEMAX)?pd->maxdist:0.0f; + radius = DEG2RADF((pd->flag & PFIELD_USEMAXR) ? pd->maxrad : 1.0f); + distance = (pd->flag & PFIELD_USEMAX) ? pd->maxdist : 0.0f; - if (pd->flag & (PFIELD_USEMAX|PFIELD_USEMAXR)) { - drawcone(vec, distance * sinf(radius),distance * cosf(radius), tmat); - if ((pd->flag & PFIELD_POSZ)==0) - drawcone(vec, distance * sinf(radius),-distance * cosf(radius),tmat); + if (pd->flag & (PFIELD_USEMAX | PFIELD_USEMAXR)) { + drawcone(vec, distance * sinf(radius), distance * cosf(radius), tmat); + if ((pd->flag & PFIELD_POSZ) == 0) + drawcone(vec, distance * sinf(radius), -distance * cosf(radius), tmat); } - radius= DEG2RADF((pd->flag&PFIELD_USEMINR) ? pd->minrad : 1.0f); - distance=(pd->flag&PFIELD_USEMIN)?pd->mindist:0.0f; + radius = DEG2RADF((pd->flag & PFIELD_USEMINR) ? pd->minrad : 1.0f); + distance = (pd->flag & PFIELD_USEMIN) ? pd->mindist : 0.0f; - if (pd->flag & (PFIELD_USEMIN|PFIELD_USEMINR)) { - drawcone(vec,distance*sinf(radius),distance*cosf(radius),tmat); - if ((pd->flag & PFIELD_POSZ)==0) + if (pd->flag & (PFIELD_USEMIN | PFIELD_USEMINR)) { + drawcone(vec, distance * sinf(radius), distance * cosf(radius), tmat); + if ((pd->flag & PFIELD_POSZ) == 0) drawcone(vec, distance * sinf(radius), -distance * cosf(radius), tmat); } } @@ -6046,8 +6045,8 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) static void draw_box(float vec[8][3]) { glBegin(GL_LINE_STRIP); - glVertex3fv(vec[0]); glVertex3fv(vec[1]);glVertex3fv(vec[2]); glVertex3fv(vec[3]); - glVertex3fv(vec[0]); glVertex3fv(vec[4]);glVertex3fv(vec[5]); glVertex3fv(vec[6]); + glVertex3fv(vec[0]); glVertex3fv(vec[1]); glVertex3fv(vec[2]); glVertex3fv(vec[3]); + glVertex3fv(vec[0]); glVertex3fv(vec[4]); glVertex3fv(vec[5]); glVertex3fv(vec[6]); glVertex3fv(vec[7]); glVertex3fv(vec[4]); glEnd(); @@ -6062,20 +6061,20 @@ static void draw_box(float vec[8][3]) #if 0 static void get_local_bounds(Object *ob, float center[3], float size[3]) { - BoundBox *bb= object_get_boundbox(ob); + BoundBox *bb = object_get_boundbox(ob); - if (bb==NULL) { + if (bb == NULL) { zero_v3(center); copy_v3_v3(size, ob->size); } else { - size[0]= 0.5*fabs(bb->vec[0][0] - bb->vec[4][0]); - size[1]= 0.5*fabs(bb->vec[0][1] - bb->vec[2][1]); - size[2]= 0.5*fabs(bb->vec[0][2] - bb->vec[1][2]); - - center[0]= (bb->vec[0][0] + bb->vec[4][0])/2.0; - center[1]= (bb->vec[0][1] + bb->vec[2][1])/2.0; - center[2]= (bb->vec[0][2] + bb->vec[1][2])/2.0; + size[0] = 0.5 * fabs(bb->vec[0][0] - bb->vec[4][0]); + size[1] = 0.5 * fabs(bb->vec[0][1] - bb->vec[2][1]); + size[2] = 0.5 * fabs(bb->vec[0][2] - bb->vec[1][2]); + + center[0] = (bb->vec[0][0] + bb->vec[4][0]) / 2.0; + center[1] = (bb->vec[0][1] + bb->vec[2][1]) / 2.0; + center[2] = (bb->vec[0][2] + bb->vec[1][2]) / 2.0; } } #endif @@ -6087,29 +6086,29 @@ static void draw_bb_quadric(BoundBox *bb, char type) gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); - size[0]= 0.5f*fabsf(bb->vec[0][0] - bb->vec[4][0]); - size[1]= 0.5f*fabsf(bb->vec[0][1] - bb->vec[2][1]); - size[2]= 0.5f*fabsf(bb->vec[0][2] - bb->vec[1][2]); - - cent[0]= 0.5f*(bb->vec[0][0] + bb->vec[4][0]); - cent[1]= 0.5f*(bb->vec[0][1] + bb->vec[2][1]); - cent[2]= 0.5f*(bb->vec[0][2] + bb->vec[1][2]); + size[0] = 0.5f * fabsf(bb->vec[0][0] - bb->vec[4][0]); + size[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]); + size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]); + + cent[0] = 0.5f * (bb->vec[0][0] + bb->vec[4][0]); + cent[1] = 0.5f * (bb->vec[0][1] + bb->vec[2][1]); + cent[2] = 0.5f * (bb->vec[0][2] + bb->vec[1][2]); glPushMatrix(); - if (type==OB_BOUND_SPHERE) { + if (type == OB_BOUND_SPHERE) { glTranslatef(cent[0], cent[1], cent[2]); glScalef(size[0], size[1], size[2]); gluSphere(qobj, 1.0, 8, 5); } - else if (type==OB_BOUND_CYLINDER) { + else if (type == OB_BOUND_CYLINDER) { float radius = size[0] > size[1] ? size[0] : size[1]; - glTranslatef(cent[0], cent[1], cent[2]-size[2]); + glTranslatef(cent[0], cent[1], cent[2] - size[2]); glScalef(radius, radius, 2.0f * size[2]); gluCylinder(qobj, 1.0, 1.0, 1.0, 8, 1); } - else if (type==OB_BOUND_CONE) { + else if (type == OB_BOUND_CONE) { float radius = size[0] > size[1] ? size[0] : size[1]; - glTranslatef(cent[0], cent[1], cent[2]-size[2]); + glTranslatef(cent[0], cent[1], cent[2] - size[2]); glScalef(radius, radius, 2.0f * size[2]); gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1); } @@ -6120,20 +6119,20 @@ static void draw_bb_quadric(BoundBox *bb, char type) static void draw_bounding_volume(Scene *scene, Object *ob, char type) { - BoundBox *bb= NULL; + BoundBox *bb = NULL; - if (ob->type==OB_MESH) { - bb= mesh_get_bb(ob); + if (ob->type == OB_MESH) { + bb = mesh_get_bb(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - bb= ob->bb ? ob->bb : ( (Curve *)ob->data )->bb; + bb = ob->bb ? ob->bb : ( (Curve *)ob->data)->bb; } - else if (ob->type==OB_MBALL) { + else if (ob->type == OB_MBALL) { if (is_basis_mball(ob)) { - bb= ob->bb; - if (bb==NULL) { + bb = ob->bb; + if (bb == NULL) { makeDispListMBall(scene, ob); - bb= ob->bb; + bb = ob->bb; } } } @@ -6145,9 +6144,9 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) return; } - if (bb==NULL) return; + if (bb == NULL) return; - if (type==OB_BOUND_BOX) draw_box(bb->vec); + if (type == OB_BOUND_BOX) draw_box(bb->vec); else draw_bb_quadric(bb, type); } @@ -6156,29 +6155,29 @@ static void drawtexspace(Object *ob) { float vec[8][3], loc[3], size[3]; - if (ob->type==OB_MESH) { + if (ob->type == OB_MESH) { mesh_get_texspace(ob->data, loc, NULL, size); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - Curve *cu= ob->data; + Curve *cu = ob->data; copy_v3_v3(size, cu->size); copy_v3_v3(loc, cu->loc); } - else if (ob->type==OB_MBALL) { - MetaBall *mb= ob->data; + else if (ob->type == OB_MBALL) { + MetaBall *mb = ob->data; copy_v3_v3(size, mb->size); copy_v3_v3(loc, mb->loc); } else return; - vec[0][0]=vec[1][0]=vec[2][0]=vec[3][0]= loc[0]-size[0]; - vec[4][0]=vec[5][0]=vec[6][0]=vec[7][0]= loc[0]+size[0]; + vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = loc[0] - size[0]; + vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = loc[0] + size[0]; - vec[0][1]=vec[1][1]=vec[4][1]=vec[5][1]= loc[1]-size[1]; - vec[2][1]=vec[3][1]=vec[6][1]=vec[7][1]= loc[1]+size[1]; + vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = loc[1] - size[1]; + vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = loc[1] + size[1]; - vec[0][2]=vec[3][2]=vec[4][2]=vec[7][2]= loc[2]-size[2]; - vec[1][2]=vec[2][2]=vec[5][2]=vec[6][2]= loc[2]+size[2]; + vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = loc[2] - size[2]; + vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = loc[2] + size[2]; setlinestyle(2); @@ -6190,42 +6189,42 @@ static void drawtexspace(Object *ob) /* draws wire outline */ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) { - RegionView3D *rv3d= ar->regiondata; - Object *ob= base->object; + RegionView3D *rv3d = ar->regiondata; + Object *ob = base->object; glLineWidth(2.0); glDepthMask(0); - if (ELEM3(ob->type, OB_FONT,OB_CURVE, OB_SURF)) { + if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { Curve *cu = ob->data; DerivedMesh *dm = ob->derivedFinal; - int hasfaces= 0; + int hasfaces = 0; if (dm) { - hasfaces= dm->getNumTessFaces(dm); + hasfaces = dm->getNumTessFaces(dm); } else { - hasfaces= displist_has_faces(&ob->disp); + hasfaces = displist_has_faces(&ob->disp); } if (hasfaces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - draw_index_wire= 0; + draw_index_wire = 0; if (dm) { draw_mesh_object_outline(v3d, ob, dm); } else { drawDispListwire(&ob->disp); } - draw_index_wire= 1; + draw_index_wire = 1; } } - else if (ob->type==OB_MBALL) { + else if (ob->type == OB_MBALL) { if (is_basis_mball(ob)) { - if ((base->flag & OB_FROMDUPLI)==0) + if ((base->flag & OB_FROMDUPLI) == 0) drawDispListwire(&ob->disp); } } - else if (ob->type==OB_ARMATURE) { + else if (ob->type == OB_ARMATURE) { if (!(ob->mode & OB_MODE_POSE && base == scene->basact)) draw_armature(scene, v3d, ar, base, OB_WIRE, FALSE, TRUE); } @@ -6236,8 +6235,8 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) { - if (ob!=scene->obedit && (ob->flag & SELECT)) { - if (ob==OBACT) { + if (ob != scene->obedit && (ob->flag & SELECT)) { + if (ob == OBACT) { if (ob->flag & OB_FROMGROUP) UI_ThemeColor(TH_GROUP_ACTIVE); else UI_ThemeColor(TH_ACTIVE); } @@ -6251,7 +6250,7 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) UI_ThemeColor(TH_GROUP); else { if (ob->dtx & OB_DRAWWIRE) { - glColor3ub(80,80,80); + glColor3ub(80, 80, 80); } else { UI_ThemeColor(TH_WIRE); @@ -6260,13 +6259,13 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) } bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better + glDepthMask(0); // disable write in zbuffer, selected edge wires show better if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { Curve *cu = ob->data; if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - if (ob->type==OB_CURVE) - draw_index_wire= 0; + if (ob->type == OB_CURVE) + draw_index_wire = 0; if (ob->derivedFinal) { drawCurveDMWired(ob); @@ -6275,11 +6274,11 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) drawDispListwire(&ob->disp); } - if (ob->type==OB_CURVE) - draw_index_wire= 1; + if (ob->type == OB_CURVE) + draw_index_wire = 1; } } - else if (ob->type==OB_MBALL) { + else if (ob->type == OB_MBALL) { if (is_basis_mball(ob)) { drawDispListwire(&ob->disp); } @@ -6295,9 +6294,9 @@ static void draw_hooks(Object *ob) ModifierData *md; float vec[3]; - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Hook) { - HookModifierData *hmd = (HookModifierData*) md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Hook) { + HookModifierData *hmd = (HookModifierData *) md; mul_v3_m4v3(vec, ob->obmat, hmd->cent); @@ -6331,20 +6330,20 @@ static void drawRBpivot(bRigidBodyJointConstraint *data) glGetFloatv(GL_CURRENT_COLOR, curcol); rgb_float_to_uchar(tcol, curcol); - tcol[3]= 255; + tcol[3] = 255; - eul_to_mat4(mat,&data->axX); - glLineWidth (4.0f); + eul_to_mat4(mat, &data->axX); + glLineWidth(4.0f); setlinestyle(2); - for (axis=0; axis<3; axis++) { - float dir[3] = {0,0,0}; + for (axis = 0; axis < 3; axis++) { + float dir[3] = {0, 0, 0}; float v[3]; copy_v3_v3(v, &data->pivX); dir[axis] = 1.f; glBegin(GL_LINES); - mul_m4_v3(mat,dir); + mul_m4_v3(mat, dir); add_v3_v3(v, dir); glVertex3fv(&data->pivX); glVertex3fv(v); @@ -6352,29 +6351,29 @@ static void drawRBpivot(bRigidBodyJointConstraint *data) view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, tcol); } - glLineWidth (1.0f); + glLineWidth(1.0f); setlinestyle(0); } /* flag can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET */ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) { - static int warning_recursive= 0; + static int warning_recursive = 0; ModifierData *md = NULL; - Object *ob= base->object; + Object *ob = base->object; Curve *cu; - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float vec1[3], vec2[3]; - unsigned int col=0; - int /*sel, drawtype,*/ colindex= 0; - int i, selstart, selend, empty_object=0; - short dt, dtx, zbufoff= 0; - const short is_obact= (ob == OBACT); + unsigned int col = 0; + int /*sel, drawtype,*/ colindex = 0; + int i, selstart, selend, empty_object = 0; + short dt, dtx, zbufoff = 0; + const short is_obact = (ob == OBACT); /* only once set now, will be removed too, should become a global standard */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - if (ob!=scene->obedit) { + if (ob != scene->obedit) { if (ob->restrictflag & OB_RESTRICT_VIEW) { return; } @@ -6390,7 +6389,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) return; /* xray delay? */ - if ((flag & DRAW_PICKING)==0 && (base->flag & OB_FROMDUPLI)==0) { + if ((flag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0) { /* don't do xray in particle mode, need the z-buffer */ if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) { /* xray and transp are set when it is drawing the 2nd/3rd pass */ @@ -6408,8 +6407,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ /* draw motion paths (in view space) */ - if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { - bAnimVizSettings *avs= &ob->avs; + if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + bAnimVizSettings *avs = &ob->avs; /* setup drawing environment for paths */ draw_motion_paths_init(v3d, ar); @@ -6431,25 +6430,25 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id. * * note: no theme yet for 'colindex' */ - int theme_id= TH_WIRE; - int theme_shade= 0; + int theme_id = TH_WIRE; + int theme_shade = 0; project_short(ar, ob->obmat[3], &base->sx); if ((scene->obedit == NULL) && (G.moving & G_TRANSFORM_OBJ) && - (base->flag & (SELECT+BA_WAS_SEL))) + (base->flag & (SELECT + BA_WAS_SEL))) { - theme_id= TH_TRANSFORM; + theme_id = TH_TRANSFORM; } else { /* Sets the 'colindex' */ if (ob->id.lib) { - colindex= (base->flag & (SELECT+BA_WAS_SEL)) ? 4 : 3; + colindex = (base->flag & (SELECT + BA_WAS_SEL)) ? 4 : 3; } - else if (warning_recursive==1) { - if (base->flag & (SELECT+BA_WAS_SEL)) { - colindex= (scene->basact==base) ? 8 : 7; + else if (warning_recursive == 1) { + if (base->flag & (SELECT + BA_WAS_SEL)) { + colindex = (scene->basact == base) ? 8 : 7; } else { colindex = 6; @@ -6458,27 +6457,27 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* Sets the 'theme_id' or fallback to wire */ else { if (ob->flag & OB_FROMGROUP) { - if (base->flag & (SELECT+BA_WAS_SEL)) { + if (base->flag & (SELECT + BA_WAS_SEL)) { /* uses darker active color for non-active + selected*/ - theme_id= TH_GROUP_ACTIVE; + theme_id = TH_GROUP_ACTIVE; if (scene->basact != base) { - theme_shade= -16; + theme_shade = -16; } } else { - theme_id= TH_GROUP; + theme_id = TH_GROUP; } } else { - if (base->flag & (SELECT+BA_WAS_SEL)) { - theme_id= scene->basact == base ? TH_ACTIVE : TH_SELECT; + if (base->flag & (SELECT + BA_WAS_SEL)) { + theme_id = scene->basact == base ? TH_ACTIVE : TH_SELECT; } else { - if (ob->type==OB_LAMP) theme_id= TH_LAMP; - else if (ob->type==OB_SPEAKER) theme_id= TH_SPEAKER; - else if (ob->type==OB_CAMERA) theme_id= TH_CAMERA; - else if (ob->type==OB_EMPTY) theme_id= TH_EMPTY; + if (ob->type == OB_LAMP) theme_id = TH_LAMP; + else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER; + else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA; + else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY; /* fallback to TH_WIRE */ } } @@ -6488,56 +6487,56 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* finally set the color */ if (colindex == 0) { if (theme_shade == 0) UI_ThemeColor(theme_id); - else UI_ThemeColorShade(theme_id, theme_shade); + else UI_ThemeColorShade(theme_id, theme_shade); } else { - col= colortab[colindex]; + col = colortab[colindex]; cpack(col); } } /* maximum drawtype */ - dt= v3d->drawtype; - if (dt==OB_RENDER) dt= OB_SOLID; - dt= MIN2(dt, ob->dt); - if (v3d->zbuf==0 && dt>OB_WIRE) dt= OB_WIRE; - dtx= 0; + dt = v3d->drawtype; + if (dt == OB_RENDER) dt = OB_SOLID; + dt = MIN2(dt, ob->dt); + if (v3d->zbuf == 0 && dt > OB_WIRE) dt = OB_WIRE; + dtx = 0; /* faceselect exception: also draw solid when dt==wire, except in editmode */ - if (is_obact && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { - if (ob->type==OB_MESH) { + if (is_obact && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { + if (ob->type == OB_MESH) { if (ob->mode & OB_MODE_EDIT) { /* pass */ } else { - if (dt<OB_SOLID) { - zbufoff= 1; - dt= OB_SOLID; + if (dt < OB_SOLID) { + zbufoff = 1; + dt = OB_SOLID; } else { - dt= OB_PAINT; + dt = OB_PAINT; } glEnable(GL_DEPTH_TEST); } } else { - if (dt<OB_SOLID) { - dt= OB_SOLID; + if (dt < OB_SOLID) { + dt = OB_SOLID; glEnable(GL_DEPTH_TEST); - zbufoff= 1; + zbufoff = 1; } } } /* draw-extra supported for boundbox drawmode too */ - if (dt>=OB_BOUNDBOX ) { + if (dt >= OB_BOUNDBOX) { - dtx= ob->dtx; + dtx = ob->dtx; if (ob->mode & OB_MODE_EDIT) { // the only 2 extra drawtypes alowed in editmode - dtx= dtx & (OB_DRAWWIRE|OB_TEXSPACE); + dtx = dtx & (OB_DRAWWIRE | OB_TEXSPACE); } } @@ -6545,27 +6544,27 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* bad exception, solve this! otherwise outline shows too late */ if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */ - if (ob->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0); + if (ob->disp.first == NULL) makeDispListCurveTypes(scene, ob, 0); } /* draw outline for selected objects, mesh does itself */ - if ((v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && ob->type!=OB_MESH) { - if (dt>OB_WIRE && (ob->mode & OB_MODE_EDIT)==0 && (flag & DRAW_SCENESET)==0) { - if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(flag&DRAW_PICKING)) { + if ((v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && ob->type != OB_MESH) { + if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (flag & DRAW_SCENESET) == 0) { + if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(flag & DRAW_PICKING)) { drawObjectSelect(scene, v3d, ar, base); } } } - switch( ob->type) { + switch (ob->type) { case OB_MESH: - empty_object= draw_mesh_object(scene, ar, v3d, rv3d, base, dt, flag); - if (flag!=DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself + empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, flag); + if (flag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself break; case OB_FONT: - cu= ob->data; + cu = ob->data; if (cu->editfont) { draw_textcurs(cu->editfont->textcurs); @@ -6596,9 +6595,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } setlinestyle(3); - for (i=0; i<cu->totbox; i++) { + for (i = 0; i < cu->totbox; i++) { if (cu->tb[i].w != 0.0f) { - UI_ThemeColor(i == (cu->actbox-1) ? TH_ACTIVE : TH_WIRE); + UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE); vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x; vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize; vec1[2] = 0.001; @@ -6623,75 +6622,75 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) cpack(0xffffff); set_inverted_drawing(1); - for (i=0; i<(selend-selstart+1); i++) { + for (i = 0; i < (selend - selstart + 1); i++) { SelBox *sb = &(cu->selboxes[i]); - if (i<(selend-selstart)) { - if (cu->selboxes[i+1].y == sb->y) - selboxw= cu->selboxes[i+1].x - sb->x; + if (i < (selend - selstart)) { + if (cu->selboxes[i + 1].y == sb->y) + selboxw = cu->selboxes[i + 1].x - sb->x; else - selboxw= sb->w; + selboxw = sb->w; } else { - selboxw= sb->w; + selboxw = sb->w; } glBegin(GL_QUADS); glVertex3f(sb->x, sb->y, 0.001); - glVertex3f(sb->x+selboxw, sb->y, 0.001); - glVertex3f(sb->x+selboxw, sb->y+sb->h, 0.001); - glVertex3f(sb->x, sb->y+sb->h, 0.001); + glVertex3f(sb->x + selboxw, sb->y, 0.001); + glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001); + glVertex3f(sb->x, sb->y + sb->h, 0.001); glEnd(); } set_inverted_drawing(0); } } - else if (dt==OB_BOUNDBOX) { + else if (dt == OB_BOUNDBOX) { if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0) { draw_bounding_volume(scene, ob, ob->boundtype); } } else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - empty_object= drawDispList(scene, v3d, rv3d, base, dt); + empty_object = drawDispList(scene, v3d, rv3d, base, dt); } break; case OB_CURVE: case OB_SURF: - cu= ob->data; + cu = ob->data; if (cu->editnurb) { - ListBase *nurbs= curve_editnurbs(cu); + ListBase *nurbs = curve_editnurbs(cu); drawnurb(scene, v3d, rv3d, base, nurbs->first, dt); } - else if (dt==OB_BOUNDBOX) { + else if (dt == OB_BOUNDBOX) { if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) { draw_bounding_volume(scene, ob, ob->boundtype); } } else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - empty_object= drawDispList(scene, v3d, rv3d, base, dt); + empty_object = drawDispList(scene, v3d, rv3d, base, dt); //XXX old animsys if (cu->path) -// curve_draw_speed(scene, ob); +// curve_draw_speed(scene, ob); } break; case OB_MBALL: { - MetaBall *mb= ob->data; + MetaBall *mb = ob->data; if (mb->editelems) drawmball(scene, v3d, rv3d, base, dt); - else if (dt==OB_BOUNDBOX) { + else if (dt == OB_BOUNDBOX) { if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) { draw_bounding_volume(scene, ob, ob->boundtype); } } else - empty_object= drawmball(scene, v3d, rv3d, base, dt); + empty_object = drawmball(scene, v3d, rv3d, base, dt); break; } case OB_EMPTY: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { if (ob->empty_drawtype == OB_EMPTY_IMAGE) { draw_empty_image(ob); } @@ -6701,24 +6700,24 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } break; case OB_LAMP: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { drawlamp(scene, v3d, rv3d, base, dt, flag); if (dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat); } break; case OB_CAMERA: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0 || - (rv3d->persp==RV3D_CAMOB && v3d->camera==ob)) /* special exception for active camera */ + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0 || + (rv3d->persp == RV3D_CAMOB && v3d->camera == ob)) /* special exception for active camera */ { drawcamera(scene, v3d, rv3d, base, flag); break; } case OB_SPEAKER: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) drawspeaker(scene, v3d, rv3d, ob, flag); break; case OB_LATTICE: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { drawlattice(scene, v3d, ob); } break; @@ -6731,16 +6730,16 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) draw_bounding_volume(scene, ob, ob->boundtype); } else { - if (dt>OB_WIRE) - GPU_enable_material(0, NULL); /* we use default material */ + if (dt > OB_WIRE) + GPU_enable_material(0, NULL); /* we use default material */ empty_object = draw_armature(scene, v3d, ar, base, dt, flag, FALSE); - if (dt>OB_WIRE) + if (dt > OB_WIRE) GPU_disable_material(); } } break; default: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { drawaxes(1.0, OB_ARROWS); } } @@ -6748,17 +6747,17 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { if (ob->soft /*&& flag & OB_SBMOTION*/) { - float mrt[3][3],msc[3][3],mtr[3][3]; - SoftBody *sb= NULL; - float tipw = 0.5f, tiph = 0.5f,drawsize = 4.0f; - if ((sb= ob->soft)) { + float mrt[3][3], msc[3][3], mtr[3][3]; + SoftBody *sb = NULL; + float tipw = 0.5f, tiph = 0.5f, drawsize = 4.0f; + if ((sb = ob->soft)) { if (sb->solverflags & SBSO_ESTIMATEIPO) { glLoadMatrixf(rv3d->viewmat); - copy_m3_m3(msc,sb->lscale); - copy_m3_m3(mrt,sb->lrot); - mul_m3_m3m3(mtr,mrt,msc); - ob_draw_RE_motion(sb->lcom,mtr,tipw,tiph,drawsize); + copy_m3_m3(msc, sb->lscale); + copy_m3_m3(mrt, sb->lrot); + mul_m3_m3m3(mtr, mrt, msc); + ob_draw_RE_motion(sb->lcom, mtr, tipw, tiph, drawsize); glMultMatrixf(ob->obmat); } } @@ -6770,22 +6769,22 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* code for new particle system */ - if ((warning_recursive==0) && + if ((warning_recursive == 0) && (ob->particlesystem.first) && - (flag & DRAW_PICKING)==0 && - (ob!=scene->obedit) + (flag & DRAW_PICKING) == 0 && + (ob != scene->obedit) ) { ParticleSystem *psys; - if (col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */ + if (col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */ //glDepthMask(GL_FALSE); glLoadMatrixf(rv3d->viewmat); view3d_cached_text_draw_begin(); - for (psys=ob->particlesystem.first; psys; psys=psys->next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { /* run this so that possible child particles get cached */ if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) { PTCacheEdit *edit = PE_create_current(scene, ob); @@ -6805,8 +6804,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* draw edit particles last so that they can draw over child particles */ - if ( (warning_recursive==0) && - (flag & DRAW_PICKING)==0 && + if ( (warning_recursive == 0) && + (flag & DRAW_PICKING) == 0 && (!scene->obedit)) { @@ -6844,7 +6843,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for (i = 0; i < scs->numpoints; i++) { - bglVertex3fv(&scs->points[3*i]); + bglVertex3fv(&scs->points[3 * i]); } bglEnd(); @@ -6930,19 +6929,19 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } } - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { bConstraint *con; - for (con=ob->constraints.first; con; con= con->next) { - if (con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) { - bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint*)con->data; - if (data->flag&CONSTRAINT_DRAW_PIVOT) + for (con = ob->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) { + bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)con->data; + if (data->flag & CONSTRAINT_DRAW_PIVOT) drawRBpivot(data); } } if (ob->gameflag & OB_BOUNDS) { - if (ob->boundtype!=ob->collision_boundtype || (dtx & OB_BOUNDBOX)==0) { + if (ob->boundtype != ob->collision_boundtype || (dtx & OB_BOUNDBOX) == 0) { setlinestyle(2); draw_bounding_volume(scene, ob, ob->collision_boundtype); setlinestyle(0); @@ -6950,7 +6949,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* draw extra: after normal draw because of makeDispList */ - if (dtx && (G.f & G_RENDER_OGL)==0) { + if (dtx && (G.f & G_RENDER_OGL) == 0) { if (dtx & OB_AXIS) { drawaxes(1.0f, OB_ARROWS); @@ -6965,27 +6964,27 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */ /* but, we also don't draw names for sets or duplicators */ if (flag == 0) { - float zero[3]= {0,0,0}; + float zero[3] = {0, 0, 0}; float curcol[4]; unsigned char tcol[4]; glGetFloatv(GL_CURRENT_COLOR, curcol); rgb_float_to_uchar(tcol, curcol); - tcol[3]= 255; - view3d_cached_text_draw_add(zero, ob->id.name+2, 10, 0, tcol); + tcol[3] = 255; + view3d_cached_text_draw_add(zero, ob->id.name + 2, 10, 0, tcol); } } /*if (dtx & OB_DRAWIMAGE) drawDispListwire(&ob->disp);*/ - if ((dtx & OB_DRAWWIRE) && dt>=OB_SOLID) { + if ((dtx & OB_DRAWWIRE) && dt >= OB_SOLID) { drawWireExtra(scene, rv3d, ob); } } } - if (dt<=OB_SOLID && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if (dt <= OB_SOLID && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { if ((ob->gameflag & OB_DYNAMIC) || ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) { - float imat[4][4], vec[3]= {0.0f, 0.0f, 0.0f}; + float imat[4][4], vec[3] = {0.0f, 0.0f, 0.0f}; invert_m4_m4(imat, rv3d->viewmatob); @@ -7013,18 +7012,18 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */ - if (!is_obact || !(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { - int do_draw_center= -1; /* defines below are zero or positive... */ + if (!is_obact || !(ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { + int do_draw_center = -1; /* defines below are zero or positive... */ if (v3d->flag2 & V3D_RENDER_OVERRIDE) { /* don't draw */ } - else if ((scene->basact)==base) - do_draw_center= ACTIVE; + else if ((scene->basact) == base) + do_draw_center = ACTIVE; else if (base->flag & SELECT) - do_draw_center= SELECT; + do_draw_center = SELECT; else if (empty_object || (v3d->flag & V3D_DRAW_CENTERS)) - do_draw_center= DESELECT; + do_draw_center = DESELECT; if (do_draw_center != -1) { if (flag & DRAW_PICKING) { @@ -7033,25 +7032,25 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) glVertex3fv(ob->obmat[3]); glEnd(); } - else if ((flag & DRAW_CONSTCOLOR)==0) { + else if ((flag & DRAW_CONSTCOLOR) == 0) { /* we don't draw centers for duplicators and sets */ if (U.obcenter_dia > 0) { /* check > 0 otherwise grease pencil can draw into the circle select which is annoying. */ - drawcentercircle(v3d, rv3d, ob->obmat[3], do_draw_center, ob->id.lib || ob->id.us>1); + drawcentercircle(v3d, rv3d, ob->obmat[3], do_draw_center, ob->id.lib || ob->id.us > 1); } } } } /* not for sets, duplicators or picking */ - if (flag==0 && (v3d->flag & V3D_HIDE_HELPLINES)== 0 && (v3d->flag2 & V3D_RENDER_OVERRIDE)== 0) { + if (flag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { ListBase *list; /* draw hook center and offset line */ - if (ob!=scene->obedit) draw_hooks(ob); + if (ob != scene->obedit) draw_hooks(ob); /* help lines and so */ - if (ob!=scene->obedit && ob->parent && (ob->parent->lay & v3d->lay)) { + if (ob != scene->obedit && ob->parent && (ob->parent->lay & v3d->lay)) { setlinestyle(3); glBegin(GL_LINES); glVertex3fv(ob->obmat[3]); @@ -7072,10 +7071,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) UI_make_axis_color(col1, col2, 'Z'); glColor3ubv(col2); - cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); - for (curcon = list->first; curcon; curcon=curcon->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon); + for (curcon = list->first; curcon; curcon = curcon->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -7084,17 +7083,17 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) * constraint targets properly (design limitation -- scene is needed for their target * but it can't be accessed from get_targets callvack) */ - Object *camob= NULL; + Object *camob = NULL; - if (cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) { - bFollowTrackConstraint *data= (bFollowTrackConstraint *)curcon->data; + if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) { + bFollowTrackConstraint *data = (bFollowTrackConstraint *)curcon->data; - camob= data->camera ? data->camera : scene->camera; + camob = data->camera ? data->camera : scene->camera; } - else if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { - bObjectSolverConstraint *data= (bObjectSolverConstraint *)curcon->data; + else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) { + bObjectSolverConstraint *data = (bObjectSolverConstraint *)curcon->data; - camob= data->camera ? data->camera : scene->camera; + camob = data->camera ? data->camera : scene->camera; } if (camob) { @@ -7109,7 +7108,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) else if ((curcon->flag & CONSTRAINT_EXPAND) && (cti) && (cti->get_constraint_targets)) { cti->get_constraint_targets(curcon, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { /* calculate target's matrix */ if (cti->get_target_matrix) cti->get_target_matrix(curcon, cob, ct, BKE_curframe(scene)); @@ -7145,7 +7144,7 @@ static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, float *co, int offset = (intptr_t) data->offset; if (!(mv->flag & ME_HIDE)) { - WM_set_framebuffer_index_color(offset+index); + WM_set_framebuffer_index_color(offset + index); bglVertex3fv(co); } } @@ -7156,8 +7155,8 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset) Mesh *me = ob->data; MVert *mvert = me->mvert; data.mvert = mvert; - data.offset = (void*)(intptr_t) offset; - glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) ); + data.offset = (void *)(intptr_t) offset; + glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) ); bglBegin(GL_POINTS); dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data); bglEnd(); @@ -7171,15 +7170,15 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, float *co, float BMVert *eve = EDBM_get_vert_for_index(ptrs[1], index); if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - WM_set_framebuffer_index_color(offset+index); + WM_set_framebuffer_index_color(offset + index); bglVertex3fv(co); } } static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset) { - void *ptrs[2] = {(void*)(intptr_t) offset, em}; + void *ptrs[2] = {(void *)(intptr_t) offset, em}; - glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) ); + glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) ); bglBegin(GL_POINTS); dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, ptrs); bglEnd(); @@ -7193,7 +7192,7 @@ static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index) BMEdge *eed = EDBM_get_edge_for_index(ptrs[1], index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - WM_set_framebuffer_index_color(offset+index); + WM_set_framebuffer_index_color(offset + index); return DM_DRAW_OPTION_NORMAL; } else { @@ -7202,17 +7201,17 @@ static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index) } static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) { - void *ptrs[2] = {(void*)(intptr_t) offset, em}; + void *ptrs[2] = {(void *)(intptr_t) offset, em}; dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, ptrs); } static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int index) { - BMFace *efa = EDBM_get_face_for_index(((void**)userData)[0], index); + BMFace *efa = EDBM_get_face_for_index(((void **)userData)[0], index); if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { - if (((void**)userData)[1]) { - WM_set_framebuffer_index_color(index+1); + if (((void **)userData)[1]) { + WM_set_framebuffer_index_color(index + 1); } return DM_DRAW_OPTION_NORMAL; } @@ -7223,10 +7222,10 @@ static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int inde static void bbs_mesh_solid__drawCenter(void *userData, int index, float *cent, float *UNUSED(no)) { - BMFace *efa = EDBM_get_face_for_index(((void**)userData)[0], index); + BMFace *efa = EDBM_get_face_for_index(((void **)userData)[0], index); if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { - WM_set_framebuffer_index_color(index+1); + WM_set_framebuffer_index_color(index + 1); bglVertex3fv(cent); } @@ -7240,7 +7239,7 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d, cpack(0); if (facecol) { - ptrs[1] = (void*)(intptr_t) 1; + ptrs[1] = (void *)(intptr_t) 1; dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, GPU_enable_material, NULL, ptrs, 0); if (check_ob_drawface_dot(scene, v3d, ob->dt)) { @@ -7259,7 +7258,7 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d, static DMDrawOption bbs_mesh_solid__setDrawOpts(void *UNUSED(userData), int index) { - WM_set_framebuffer_index_color(index+1); + WM_set_framebuffer_index_color(index + 1); return DM_DRAW_OPTION_NORMAL; } @@ -7267,8 +7266,8 @@ static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index) { Mesh *me = userData; - if (!(me->mpoly[index].flag&ME_HIDE)) { - WM_set_framebuffer_index_color(index+1); + if (!(me->mpoly[index].flag & ME_HIDE)) { + WM_set_framebuffer_index_color(index + 1); return DM_DRAW_OPTION_NORMAL; } else { @@ -7291,7 +7290,7 @@ static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index) static void bbs_mesh_solid(Scene *scene, Object *ob) { DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); - Mesh *me = (Mesh*)ob->data; + Mesh *me = (Mesh *)ob->data; glColor3ub(0, 0, 0); @@ -7305,18 +7304,18 @@ static void bbs_mesh_solid(Scene *scene, Object *ob) void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob) { - ToolSettings *ts= scene->toolsettings; + ToolSettings *ts = scene->toolsettings; glMultMatrixf(ob->obmat); glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); - switch( ob->type) { + switch (ob->type) { case OB_MESH: if (ob->mode & OB_MODE_EDIT) { - Mesh *me= ob->data; - BMEditMesh *em= me->edit_btmesh; + Mesh *me = ob->data; + BMEditMesh *em = me->edit_btmesh; DerivedMesh *dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH); @@ -7324,22 +7323,24 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec bbs_mesh_solid_EM(em, scene, v3d, ob, dm, ts->selectmode & SCE_SELECT_FACE); if (ts->selectmode & SCE_SELECT_FACE) - bm_solidoffs = 1+em->bm->totface; + bm_solidoffs = 1 + em->bm->totface; else - bm_solidoffs= 1; + bm_solidoffs = 1; bglPolygonOffset(rv3d->dist, 1.0); // we draw edges always, for loop (select) tools bbs_mesh_wire(em, dm, bm_solidoffs); - bm_wireoffs= bm_solidoffs + em->bm->totedge; + bm_wireoffs = bm_solidoffs + em->bm->totedge; // we draw verts if vert select mode or if in transform (for snap). if ((ts->selectmode & SCE_SELECT_VERTEX) || (G.moving & G_TRANSFORM_EDIT)) { bbs_mesh_verts(em, dm, bm_wireoffs); - bm_vertoffs= bm_wireoffs + em->bm->totvert; + bm_vertoffs = bm_wireoffs + em->bm->totvert; + } + else { + bm_vertoffs = bm_wireoffs; } - else bm_vertoffs= bm_wireoffs; bglPolygonOffset(rv3d->dist, 0.0); @@ -7348,10 +7349,10 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec EDBM_free_index_arrays(em); } else { - Mesh *me= ob->data; - if ( (me->editflag & ME_EDIT_VERT_SEL) && - /* currently vertex select only supports weight paint */ - (ob->mode & OB_MODE_WEIGHT_PAINT)) + Mesh *me = ob->data; + if ((me->editflag & ME_EDIT_VERT_SEL) && + /* currently vertex select only supports weight paint */ + (ob->mode & OB_MODE_WEIGHT_PAINT)) { DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); glColor3ub(0, 0, 0); @@ -7360,7 +7361,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec bbs_obmode_mesh_verts(ob, dm, 1); - bm_vertoffs = me->totvert+1; + bm_vertoffs = me->totvert + 1; dm->release(dm); } else { @@ -7384,16 +7385,16 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int dt, int outline) { - Mesh *me= ob->data; - DerivedMesh *dm=NULL, *edm=NULL; + Mesh *me = ob->data; + DerivedMesh *dm = NULL, *edm = NULL; int glsl; if (ob->mode & OB_MODE_EDIT) - edm= editbmesh_get_derived_base(ob, me->edit_btmesh); + edm = editbmesh_get_derived_base(ob, me->edit_btmesh); else dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - if (dt<=OB_WIRE) { + if (dt <= OB_WIRE) { if (dm) dm->drawEdges(dm, 1, 0); else if (edm) @@ -7401,7 +7402,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r } else { if (outline) - draw_mesh_object_outline(v3d, ob, dm?dm:edm); + draw_mesh_object_outline(v3d, ob, dm ? dm : edm); if (dm) { glsl = draw_glsl_material(scene, ob, v3d, dt); @@ -7413,7 +7414,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r glDisable(GL_COLOR_MATERIAL); } - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); glEnable(GL_LIGHTING); if (dm) { diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 52f432c2e7d..2289216c2a8 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -77,7 +77,7 @@ #include "BLF_api.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include #ifdef _WIN32 @@ -90,38 +90,38 @@ static LARGE_INTEGER liFrequency; static LARGE_INTEGER liStartTime; static LARGE_INTEGER liCurrentTime; -static void tstart ( void ) +static void tstart(void) { - QueryPerformanceFrequency ( &liFrequency ); - QueryPerformanceCounter ( &liStartTime ); + QueryPerformanceFrequency(&liFrequency); + QueryPerformanceCounter(&liStartTime); } -static void tend ( void ) +static void tend(void) { - QueryPerformanceCounter ( &liCurrentTime ); + QueryPerformanceCounter(&liCurrentTime); } -static double tval( void ) +static double tval(void) { - return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart)* (double)1000.0/(double)liFrequency.QuadPart )); + return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart) * (double)1000.0 / (double)liFrequency.QuadPart)); } #else #include <sys/time.h> static struct timeval _tstart, _tend; static struct timezone tz; -static void tstart ( void ) +static void tstart(void) { - gettimeofday ( &_tstart, &tz ); + gettimeofday(&_tstart, &tz); } -static void tend ( void ) +static void tend(void) { - gettimeofday ( &_tend,&tz ); + gettimeofday(&_tend, &tz); } #if 0 static double tval() { double t1, t2; - t1 = ( double ) _tstart.tv_sec*1000 + ( double ) _tstart.tv_usec/ ( 1000 ); - t2 = ( double ) _tend.tv_sec*1000 + ( double ) _tend.tv_usec/ ( 1000 ); - return t2-t1; + t1 = ( double ) _tstart.tv_sec * 1000 + ( double ) _tstart.tv_usec / (1000); + t2 = ( double ) _tend.tv_sec * 1000 + ( double ) _tend.tv_usec / (1000); + return t2 - t1; } #endif #endif @@ -134,13 +134,13 @@ static int intersect_edges(float *points, float a, float b, float c, float d, fl float t; int numpoints = 0; - for (i=0; i<12; i++) { - t = -(a*edges[i][0][0] + b*edges[i][0][1] + c*edges[i][0][2] + d) - / (a*edges[i][1][0] + b*edges[i][1][1] + c*edges[i][1][2]); - if ((t>0)&&(t<1)) { - points[numpoints * 3 + 0] = edges[i][0][0] + edges[i][1][0]*t; - points[numpoints * 3 + 1] = edges[i][0][1] + edges[i][1][1]*t; - points[numpoints * 3 + 2] = edges[i][0][2] + edges[i][1][2]*t; + for (i = 0; i < 12; i++) { + t = -(a * edges[i][0][0] + b * edges[i][0][1] + c * edges[i][0][2] + d) / + (a * edges[i][1][0] + b * edges[i][1][1] + c * edges[i][1][2]); + if ((t > 0) && (t < 1)) { + points[numpoints * 3 + 0] = edges[i][0][0] + edges[i][1][0] * t; + points[numpoints * 3 + 1] = edges[i][0][1] + edges[i][1][1] * t; + points[numpoints * 3 + 2] = edges[i][0][2] + edges[i][1][2] * t; numpoints++; } } @@ -159,14 +159,14 @@ static int convex(float *p0, float *up, float *a, float *b) void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3], float dx, GPUTexture *tex_shadow) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float viewnormal[3]; int i, j, n, good_index; float d /*, d0 */ /* UNUSED */, dd, ds; float *points = NULL; int numpoints = 0; - float cor[3] = {1.,1.,1.}; + float cor[3] = {1., 1., 1.}; int gl_depth = 0, gl_blend = 0; /* draw slices of smoke is adapted from c++ code authored @@ -197,22 +197,22 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 /* Fragment program to calculate the view3d of smoke */ /* using 2 textures, density and shadow */ const char *text = "!!ARBfp1.0\n" - "PARAM dx = program.local[0];\n" - "PARAM darkness = program.local[1];\n" - "PARAM f = {1.442695041, 1.442695041, 1.442695041, 0.01};\n" - "TEMP temp, shadow, value;\n" - "TEX temp, fragment.texcoord[0], texture[0], 3D;\n" - "TEX shadow, fragment.texcoord[0], texture[1], 3D;\n" - "MUL value, temp, darkness;\n" - "MUL value, value, dx;\n" - "MUL value, value, f;\n" - "EX2 temp, -value.r;\n" - "SUB temp.a, 1.0, temp.r;\n" - "MUL temp.r, temp.r, shadow.r;\n" - "MUL temp.g, temp.g, shadow.r;\n" - "MUL temp.b, temp.b, shadow.r;\n" - "MOV result.color, temp;\n" - "END\n"; + "PARAM dx = program.local[0];\n" + "PARAM darkness = program.local[1];\n" + "PARAM f = {1.442695041, 1.442695041, 1.442695041, 0.01};\n" + "TEMP temp, shadow, value;\n" + "TEX temp, fragment.texcoord[0], texture[0], 3D;\n" + "TEX shadow, fragment.texcoord[0], texture[1], 3D;\n" + "MUL value, temp, darkness;\n" + "MUL value, value, dx;\n" + "MUL value, value, f;\n" + "EX2 temp, -value.r;\n" + "SUB temp.a, 1.0, temp.r;\n" + "MUL temp.r, temp.r, shadow.r;\n" + "MUL temp.g, temp.g, shadow.r;\n" + "MUL temp.b, temp.b, shadow.r;\n" + "MOV result.color, temp;\n" + "END\n"; GLuint prog; @@ -317,23 +317,24 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 normalize_v3(viewnormal); // find cube vertex that is closest to the viewer - for (i=0; i<8; i++) { - float x,y,z; + for (i = 0; i < 8; i++) { + float x, y, z; x = cv[i][0] - viewnormal[0]; y = cv[i][1] - viewnormal[1]; z = cv[i][2] - viewnormal[2]; - if ((x>=min[0])&&(x<=max[0]) - &&(y>=min[1])&&(y<=max[1]) - &&(z>=min[2])&&(z<=max[2])) { + if ((x >= min[0]) && (x <= max[0]) && + (y >= min[1]) && (y <= max[1]) && + (z >= min[2]) && (z <= max[2])) + { break; } } if (i >= 8) { /* fallback, avoid using buffer over-run */ - i= 0; + i = 0; } // printf("i: %d\n", i); @@ -347,9 +348,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(text), text); // cell spacing - glProgramLocalParameter4fARB (GL_FRAGMENT_PROGRAM_ARB, 0, dx, dx, dx, 1.0); + glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, dx, dx, dx, 1.0); // custom parameter for smoke style (higher = thicker) - glProgramLocalParameter4fARB (GL_FRAGMENT_PROGRAM_ARB, 1, 7.0, 7.0, 7.0, 1.0); + glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 7.0, 7.0, 7.0, 1.0); } else printf("Your gfx card does not support 3D View smoke drawing.\n"); @@ -361,9 +362,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 printf("No volume shadow\n"); if (!GPU_non_power_of_two_support()) { - cor[0] = (float)res[0]/(float)power_of_2_max_i(res[0]); - cor[1] = (float)res[1]/(float)power_of_2_max_i(res[1]); - cor[2] = (float)res[2]/(float)power_of_2_max_i(res[2]); + cor[0] = (float)res[0] / (float)power_of_2_max_i(res[0]); + cor[1] = (float)res[1] / (float)power_of_2_max_i(res[1]); + cor[2] = (float)res[2] / (float)power_of_2_max_i(res[2]); } // our slices are defined by the plane equation a*x + b*y +c*z + d = 0 @@ -372,24 +373,24 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 // inserting previously found vertex into the plane equation /* d0 = (viewnormal[0]*cv[i][0] + viewnormal[1]*cv[i][1] + viewnormal[2]*cv[i][2]); */ /* UNUSED */ - ds = (ABS(viewnormal[0])*size[0] + ABS(viewnormal[1])*size[1] + ABS(viewnormal[2])*size[2]); + ds = (ABS(viewnormal[0]) * size[0] + ABS(viewnormal[1]) * size[1] + ABS(viewnormal[2]) * size[2]); dd = 0.05; // ds/512.0f; n = 0; good_index = i; // printf("d0: %f, dd: %f, ds: %f\n\n", d0, dd, ds); - points = MEM_callocN(sizeof(float)*12*3, "smoke_points_preview"); + points = MEM_callocN(sizeof(float) * 12 * 3, "smoke_points_preview"); while (1) { float p0[3]; float tmp_point[3], tmp_point2[3]; - if (dd*(float)n > ds) + if (dd * (float)n > ds) break; copy_v3_v3(tmp_point, viewnormal); - mul_v3_fl(tmp_point, -dd*((ds/dd)-(float)n)); + mul_v3_fl(tmp_point, -dd * ((ds / dd) - (float)n)); add_v3_v3v3(tmp_point2, cv[good_index], tmp_point); d = dot_v3v3(tmp_point2, viewnormal); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 0d0d1bd3139..72b67c2a716 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -62,7 +62,7 @@ #include "UI_resources.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include /* ******************** manage regions ********************* */ @@ -70,20 +70,20 @@ ARegion *view3d_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; /* add subdiv level; after header */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if (ar==NULL) return NULL; + if (ar == NULL) return NULL; - arnew= MEM_callocN(sizeof(ARegion), "buttons for view3d"); + arnew = MEM_callocN(sizeof(ARegion), "buttons for view3d"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_RIGHT; + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; arnew->flag = RGN_FLAG_HIDDEN; @@ -92,42 +92,42 @@ ARegion *view3d_has_buttons_region(ScrArea *sa) ARegion *view3d_has_tools_region(ScrArea *sa) { - ARegion *ar, *artool=NULL, *arprops=NULL, *arhead; + ARegion *ar, *artool = NULL, *arprops = NULL, *arhead; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_TOOLS) - artool= ar; - if (ar->regiontype==RGN_TYPE_TOOL_PROPS) - arprops= ar; + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_TOOLS) + artool = ar; + if (ar->regiontype == RGN_TYPE_TOOL_PROPS) + arprops = ar; } /* tool region hide/unhide also hides props */ if (arprops && artool) return artool; - if (artool==NULL) { + if (artool == NULL) { /* add subdiv level; after header */ - for (arhead= sa->regionbase.first; arhead; arhead= arhead->next) - if (arhead->regiontype==RGN_TYPE_HEADER) + for (arhead = sa->regionbase.first; arhead; arhead = arhead->next) + if (arhead->regiontype == RGN_TYPE_HEADER) break; /* is error! */ - if (arhead==NULL) return NULL; + if (arhead == NULL) return NULL; - artool= MEM_callocN(sizeof(ARegion), "tools for view3d"); + artool = MEM_callocN(sizeof(ARegion), "tools for view3d"); BLI_insertlinkafter(&sa->regionbase, arhead, artool); - artool->regiontype= RGN_TYPE_TOOLS; - artool->alignment= RGN_ALIGN_LEFT; //RGN_OVERLAP_LEFT; + artool->regiontype = RGN_TYPE_TOOLS; + artool->alignment = RGN_ALIGN_LEFT; //RGN_OVERLAP_LEFT; artool->flag = RGN_FLAG_HIDDEN; } - if (arprops==NULL) { + if (arprops == NULL) { /* add extra subdivided region for tool properties */ - arprops= MEM_callocN(sizeof(ARegion), "tool props for view3d"); + arprops = MEM_callocN(sizeof(ARegion), "tool props for view3d"); BLI_insertlinkafter(&sa->regionbase, artool, arprops); - arprops->regiontype= RGN_TYPE_TOOL_PROPS; - arprops->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + arprops->regiontype = RGN_TYPE_TOOL_PROPS; + arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; } return artool; @@ -138,12 +138,12 @@ ARegion *view3d_has_tools_region(ScrArea *sa) /* function to always find a regionview3d context inside 3D window */ RegionView3D *ED_view3d_context_rv3d(bContext *C) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); - if (rv3d==NULL) { + if (rv3d == NULL) { ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacetype == SPACE_VIEW3D) { - ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar) { rv3d = ar->regiondata; } @@ -156,33 +156,33 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) * so return that, the caller can then access the ar->regiondata */ int ED_view3d_context_user_region(bContext *C, View3D **v3d_r, ARegion **ar_r) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); *v3d_r = NULL; *ar_r = NULL; - if (sa && sa->spacetype==SPACE_VIEW3D) { - ARegion *ar= CTX_wm_region(C); + if (sa && sa->spacetype == SPACE_VIEW3D) { + ARegion *ar = CTX_wm_region(C); View3D *v3d = (View3D *)sa->spacedata.first; if (ar) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; if (rv3d && rv3d->viewlock == 0) { *v3d_r = v3d; *ar_r = ar; return 1; } else { - ARegion *ar_unlock_user= NULL; - ARegion *ar_unlock= NULL; - for (ar= sa->regionbase.first; ar; ar= ar->next) { + ARegion *ar_unlock_user = NULL; + ARegion *ar_unlock = NULL; + for (ar = sa->regionbase.first; ar; ar = ar->next) { /* find the first unlocked rv3d */ if (ar->regiondata && ar->regiontype == RGN_TYPE_WINDOW) { - rv3d= ar->regiondata; + rv3d = ar->regiondata; if (rv3d->viewlock == 0) { - ar_unlock= ar; - if (rv3d->persp==RV3D_PERSP || rv3d->persp==RV3D_CAMOB) { - ar_unlock_user= ar; + ar_unlock = ar; + if (rv3d->persp == RV3D_PERSP || rv3d->persp == RV3D_CAMOB) { + ar_unlock_user = ar; break; } } @@ -243,24 +243,24 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d) static SpaceLink *view3d_new(const bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ARegion *ar; View3D *v3d; RegionView3D *rv3d; - v3d= MEM_callocN(sizeof(View3D), "initview3d"); - v3d->spacetype= SPACE_VIEW3D; - v3d->blockscale= 0.7f; - v3d->lay= v3d->layact= 1; + v3d = MEM_callocN(sizeof(View3D), "initview3d"); + v3d->spacetype = SPACE_VIEW3D; + v3d->blockscale = 0.7f; + v3d->lay = v3d->layact = 1; if (scene) { - v3d->lay= v3d->layact= scene->lay; - v3d->camera= scene->camera; + v3d->lay = v3d->layact = scene->lay; + v3d->camera = scene->camera; } - v3d->scenelock= TRUE; - v3d->grid= 1.0f; - v3d->gridlines= 16; + v3d->scenelock = TRUE; + v3d->grid = 1.0f; + v3d->gridlines = 16; v3d->gridsubdiv = 10; - v3d->drawtype= OB_SOLID; + v3d->drawtype = OB_SOLID; v3d->gridflag |= V3D_SHOW_X; v3d->gridflag |= V3D_SHOW_Y; @@ -270,60 +270,60 @@ static SpaceLink *view3d_new(const bContext *C) v3d->flag |= V3D_SELECT_OUTLINE; v3d->flag2 |= V3D_SHOW_RECONSTRUCTION; - v3d->lens= 35.0f; - v3d->near= 0.01f; - v3d->far= 1000.0f; + v3d->lens = 35.0f; + v3d->near = 0.01f; + v3d->far = 1000.0f; v3d->twflag |= U.tw_flag & V3D_USE_MANIPULATOR; - v3d->twtype= V3D_MANIP_TRANSLATE; - v3d->around= V3D_CENTROID; + v3d->twtype = V3D_MANIP_TRANSLATE; + v3d->around = V3D_CENTROID; - v3d->bundle_size= 0.2f; - v3d->bundle_drawtype= OB_PLAINAXES; + v3d->bundle_size = 0.2f; + v3d->bundle_drawtype = OB_PLAINAXES; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for view3d"); + ar = MEM_callocN(sizeof(ARegion), "header for view3d"); BLI_addtail(&v3d->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* tool shelf */ - ar= MEM_callocN(sizeof(ARegion), "toolshelf for view3d"); + ar = MEM_callocN(sizeof(ARegion), "toolshelf for view3d"); BLI_addtail(&v3d->regionbase, ar); - ar->regiontype= RGN_TYPE_TOOLS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_TOOLS; + ar->alignment = RGN_ALIGN_LEFT; ar->flag = RGN_FLAG_HIDDEN; /* tool properties */ - ar= MEM_callocN(sizeof(ARegion), "tool properties for view3d"); + ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d"); BLI_addtail(&v3d->regionbase, ar); - ar->regiontype= RGN_TYPE_TOOL_PROPS; - ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + ar->regiontype = RGN_TYPE_TOOL_PROPS; + ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; ar->flag = RGN_FLAG_HIDDEN; /* buttons/list view */ - ar= MEM_callocN(sizeof(ARegion), "buttons for view3d"); + ar = MEM_callocN(sizeof(ARegion), "buttons for view3d"); BLI_addtail(&v3d->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for view3d"); + ar = MEM_callocN(sizeof(ARegion), "main area for view3d"); BLI_addtail(&v3d->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; - ar->regiondata= MEM_callocN(sizeof(RegionView3D), "region view3d"); - rv3d= ar->regiondata; - rv3d->viewquat[0]= 1.0f; - rv3d->persp= RV3D_PERSP; - rv3d->view= RV3D_VIEW_PERSPORTHO; - rv3d->dist= 10.0; + ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region view3d"); + rv3d = ar->regiondata; + rv3d->viewquat[0] = 1.0f; + rv3d->persp = RV3D_PERSP; + rv3d->view = RV3D_VIEW_PERSPORTHO; + rv3d->dist = 10.0; return (SpaceLink *)v3d; } @@ -331,7 +331,7 @@ static SpaceLink *view3d_new(const bContext *C) /* not spacelink itself */ static void view3d_free(SpaceLink *sl) { - View3D *vd= (View3D *) sl; + View3D *vd = (View3D *) sl; BLI_freelistN(&vd->bgpicbase); @@ -349,17 +349,17 @@ static void view3d_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *view3d_duplicate(SpaceLink *sl) { - View3D *v3do= (View3D *)sl; - View3D *v3dn= MEM_dupallocN(sl); + View3D *v3do = (View3D *)sl; + View3D *v3dn = MEM_dupallocN(sl); /* clear or remove stuff from old */ // XXX BIF_view3d_previewrender_free(v3do); if (v3do->localvd) { - v3do->localvd= NULL; - v3do->properties_storage= NULL; - v3do->lay= v3dn->localvd->lay; + v3do->localvd = NULL; + v3do->properties_storage = NULL; + v3do->lay = v3dn->localvd->lay; v3do->lay &= 0xFFFFFF; } @@ -370,7 +370,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) BLI_duplicatelist(&v3dn->bgpicbase, &v3do->bgpicbase); - v3dn->properties_storage= NULL; + v3dn->properties_storage = NULL; return (SpaceLink *)v3dn; } @@ -453,7 +453,7 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler(&ar->handlers, keymap); /* add drop boxes */ - lb= WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); + lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); WM_event_add_dropbox_handler(&ar->handlers, lb); @@ -461,9 +461,9 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar) static int view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if (drag->type==WM_DRAG_ID) { - ID *id= (ID *)drag->poin; - if ( GS(id->name)==ID_OB ) + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_OB) return 1; } return 0; @@ -471,9 +471,9 @@ static int view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSE static int view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if (drag->type==WM_DRAG_ID) { - ID *id= (ID *)drag->poin; - if ( GS(id->name)==ID_MA ) + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_MA) return 1; } return 0; @@ -481,13 +481,13 @@ static int view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUS static int view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if (drag->type==WM_DRAG_ID) { - ID *id= (ID *)drag->poin; - if ( GS(id->name)==ID_IM ) + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_IM) return 1; } - else if (drag->type==WM_DRAG_PATH) { - if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ + else if (drag->type == WM_DRAG_PATH) { + if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ return 1; } return 0; @@ -496,7 +496,7 @@ static int view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUS static int view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) { - if ( ED_view3d_give_base_under_cursor(C, event->mval) ) { + if (ED_view3d_give_base_under_cursor(C, event->mval) ) { return 0; } return view3d_ima_drop_poll(C, drag, event); @@ -504,7 +504,7 @@ static int view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) static int view3d_ima_ob_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) { - if ( ED_view3d_give_base_under_cursor(C, event->mval) ) { + if (ED_view3d_give_base_under_cursor(C, event->mval) ) { return view3d_ima_drop_poll(C, drag, event); } return 0; @@ -512,30 +512,30 @@ static int view3d_ima_ob_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) { - ID *id= (ID *)drag->poin; + ID *id = (ID *)drag->poin; PointerRNA ptr; /* need to put name in sub-operator in macro */ - ptr= RNA_pointer_get(drop->ptr, "OBJECT_OT_add_named"); + ptr = RNA_pointer_get(drop->ptr, "OBJECT_OT_add_named"); if (ptr.data) - RNA_string_set(&ptr, "name", id->name+2); + RNA_string_set(&ptr, "name", id->name + 2); else - RNA_string_set(drop->ptr, "name", id->name+2); + RNA_string_set(drop->ptr, "name", id->name + 2); } static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop) { - ID *id= (ID *)drag->poin; + ID *id = (ID *)drag->poin; - RNA_string_set(drop->ptr, "name", id->name+2); + RNA_string_set(drop->ptr, "name", id->name + 2); } static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) { - ID *id= (ID *)drag->poin; + ID *id = (ID *)drag->poin; if (id) - RNA_string_set(drop->ptr, "name", id->name+2); + RNA_string_set(drop->ptr, "name", id->name + 2); if (drag->path[0]) RNA_string_set(drop->ptr, "filepath", drag->path); } @@ -544,7 +544,7 @@ static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) /* region dropbox definition */ static void view3d_dropboxes(void) { - ListBase *lb= WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); + ListBase *lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); WM_dropbox_add(lb, "OBJECT_OT_add_named_cursor", view3d_ob_drop_poll, view3d_ob_drop_copy); WM_dropbox_add(lb, "OBJECT_OT_drop_named_material", view3d_mat_drop_poll, view3d_id_drop_copy); @@ -557,7 +557,7 @@ static void view3d_dropboxes(void) /* type callback, not region itself */ static void view3d_main_area_free(ARegion *ar) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; if (rv3d) { if (rv3d->localvd) MEM_freeN(rv3d->localvd); @@ -575,7 +575,7 @@ static void view3d_main_area_free(ARegion *ar) MEM_freeN(rv3d->depths); } MEM_freeN(rv3d); - ar->regiondata= NULL; + ar->regiondata = NULL; } } @@ -583,20 +583,20 @@ static void view3d_main_area_free(ARegion *ar) static void *view3d_main_area_duplicate(void *poin) { if (poin) { - RegionView3D *rv3d= poin, *new; + RegionView3D *rv3d = poin, *new; - new= MEM_dupallocN(rv3d); + new = MEM_dupallocN(rv3d); if (rv3d->localvd) - new->localvd= MEM_dupallocN(rv3d->localvd); + new->localvd = MEM_dupallocN(rv3d->localvd); if (rv3d->clipbb) - new->clipbb= MEM_dupallocN(rv3d->clipbb); + new->clipbb = MEM_dupallocN(rv3d->clipbb); - new->depths= NULL; - new->ri= NULL; - new->render_engine= NULL; - new->gpd= NULL; - new->sms= NULL; - new->smooth_timer= NULL; + new->depths = NULL; + new->ri = NULL; + new->render_engine = NULL; + new->gpd = NULL; + new->sms = NULL; + new->smooth_timer = NULL; return new; } @@ -605,28 +605,28 @@ static void *view3d_main_area_duplicate(void *poin) static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, Scene *scene) { - wmWindow *win= wmn->wm->winactive; + wmWindow *win = wmn->wm->winactive; ScrArea *sa; - unsigned int lay_used= 0; + unsigned int lay_used = 0; Base *base; if (!win) return; - base= scene->base.first; + base = scene->base.first; while (base) { - lay_used |= base->lay & ((1<<20)-1); /* ignore localview */ + lay_used |= base->lay & ((1 << 20) - 1); /* ignore localview */ - if (lay_used == (1<<20)-1) + if (lay_used == (1 << 20) - 1) break; - base= base->next; + base = base->next; } - for (sa= win->screen->areabase.first; sa; sa= sa->next) { + for (sa = win->screen->areabase.first; sa; sa = sa->next) { if (sa->spacetype == SPACE_VIEW3D) { if (BLI_findindex(&sa->regionbase, ar) != -1) { - View3D *v3d= sa->spacedata.first; - v3d->lay_used= lay_used; + View3D *v3d = sa->spacedata.first; + v3d->lay_used = lay_used; break; } } @@ -638,9 +638,9 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) bScreen *sc; /* context changes */ - switch(wmn->category) { + switch (wmn->category) { case NC_ANIMATION: - switch(wmn->data) { + switch (wmn->data) { case ND_KEYFRAME_PROP: case ND_NLA_ACTCHANGE: ED_region_tag_redraw(ar); @@ -657,7 +657,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_SCENE: - switch(wmn->data) { + switch (wmn->data) { case ND_LAYER_CONTENT: view3d_recalc_used_layers(ar, wmn, wmn->reference); ED_region_tag_redraw(ar); @@ -680,7 +680,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_OBJECT: - switch(wmn->data) { + switch (wmn->data) { case ND_BONE_ACTIVE: case ND_BONE_SELECT: case ND_TRANSFORM: @@ -693,20 +693,20 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; } - switch(wmn->action) { + switch (wmn->action) { case NA_ADDED: ED_region_tag_redraw(ar); break; } break; case NC_GEOM: - switch(wmn->data) { + switch (wmn->data) { case ND_DATA: case ND_SELECT: ED_region_tag_redraw(ar); break; } - switch(wmn->action) { + switch (wmn->action) { case NA_EDITED: ED_region_tag_redraw(ar); break; @@ -721,20 +721,20 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw_overlay(ar); break; case NC_MATERIAL: - switch(wmn->data) { + switch (wmn->data) { case ND_SHADING_DRAW: ED_region_tag_redraw(ar); break; } break; case NC_WORLD: - switch(wmn->data) { + switch (wmn->data) { case ND_WORLD_DRAW: /* handled by space_view3d_listener() for v3d access */ break; case ND_WORLD_STARS: { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; if (rv3d->persp == RV3D_CAMOB) { ED_region_tag_redraw(ar); } @@ -742,7 +742,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_LAMP: - switch(wmn->data) { + switch (wmn->data) { case ND_LIGHTING_DRAW: ED_region_tag_redraw(ar); break; @@ -758,13 +758,13 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_MOVIECLIP: - if (wmn->data==ND_DISPLAY) + if (wmn->data == ND_DISPLAY) ED_region_tag_redraw(ar); break; case NC_SPACE: if (wmn->data == ND_SPACE_VIEW3D) { if (wmn->subtype == NS_VIEW3D_GPU) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; rv3d->rflag |= RV3D_GPULIGHT_UPDATE; } ED_region_tag_redraw(ar); @@ -775,7 +775,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_SCREEN: - switch(wmn->data) { + switch (wmn->data) { case ND_GPENCIL: case ND_ANIMPLAY: case ND_SKETCH: @@ -786,7 +786,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) case ND_SCREENSET: /* screen was changed, need to update used layers due to NC_SCENE|ND_LAYER_CONTENT */ /* updates used layers only for View3D in active screen */ - sc= wmn->reference; + sc = wmn->reference; view3d_recalc_used_layers(ar, wmn, sc->scene); ED_region_tag_redraw(ar); break; @@ -799,7 +799,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) /* concept is to retrieve cursor type context-less */ static void view3d_main_area_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegion *UNUSED(ar)) { - Scene *scene= win->screen->scene; + Scene *scene = win->screen->scene; if (scene->obedit) { WM_cursor_set(win, CURSOR_EDIT); @@ -827,9 +827,9 @@ static void view3d_header_area_draw(const bContext *C, ARegion *ar) static void view3d_header_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ - switch(wmn->category) { + switch (wmn->category) { case NC_SCENE: - switch(wmn->data) { + switch (wmn->data) { case ND_FRAME: case ND_OB_ACTIVE: case ND_OB_SELECT: @@ -868,9 +868,9 @@ static void view3d_buttons_area_draw(const bContext *C, ARegion *ar) static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ - switch(wmn->category) { + switch (wmn->category) { case NC_ANIMATION: - switch(wmn->data) { + switch (wmn->data) { case ND_KEYFRAME_PROP: case ND_NLA_ACTCHANGE: ED_region_tag_redraw(ar); @@ -883,7 +883,7 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_SCENE: - switch(wmn->data) { + switch (wmn->data) { case ND_FRAME: case ND_OB_ACTIVE: case ND_OB_SELECT: @@ -895,14 +895,14 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; } - switch(wmn->action) { + switch (wmn->action) { case NA_EDITED: ED_region_tag_redraw(ar); break; } break; case NC_OBJECT: - switch(wmn->data) { + switch (wmn->data) { case ND_BONE_ACTIVE: case ND_BONE_SELECT: case ND_TRANSFORM: @@ -915,7 +915,7 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_GEOM: - switch(wmn->data) { + switch (wmn->data) { case ND_DATA: case ND_SELECT: ED_region_tag_redraw(ar); @@ -930,7 +930,7 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_BRUSH: - if (wmn->action==NA_EDITED) + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; case NC_SPACE: @@ -967,7 +967,7 @@ static void view3d_tools_area_draw(const bContext *C, ARegion *ar) static void view3d_props_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ - switch(wmn->category) { + switch (wmn->category) { case NC_WM: if (wmn->data == ND_HISTORY) ED_region_tag_redraw(ar); @@ -989,9 +989,9 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) View3D *v3d = sa->spacedata.first; /* context changes */ - switch(wmn->category) { + switch (wmn->category) { case NC_SCENE: - switch(wmn->data) { + switch (wmn->data) { case ND_WORLD: if (v3d->flag2 & V3D_RENDER_OVERRIDE) ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); @@ -999,7 +999,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) } break; case NC_WORLD: - switch(wmn->data) { + switch (wmn->data) { case ND_WORLD_DRAW: if (v3d->flag2 & V3D_RENDER_OVERRIDE) ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); @@ -1007,7 +1007,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) } break; case NC_MATERIAL: - switch(wmn->data) { + switch (wmn->data) { case ND_NODES: if (v3d->drawtype == OB_TEXTURE) ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); @@ -1035,25 +1035,26 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) const char *view3d_context_dir[] = { "selected_objects", "selected_bases", "selected_editable_objects", "selected_editable_bases", "visible_objects", "visible_bases", "selectable_objects", "selectable_bases", - "active_base", "active_object", NULL}; + "active_base", "active_object", NULL +}; static int view3d_context(const bContext *C, const char *member, bContextDataResult *result) { - View3D *v3d= CTX_wm_view3d(C); - Scene *scene= CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); Base *base; /* fallback to the scene layer, allows duplicate and other object operators to run outside the 3d view */ - unsigned int lay = v3d ? v3d->lay:scene->lay; + unsigned int lay = v3d ? v3d->lay : scene->lay; if (CTX_data_dir(member)) { CTX_data_dir_set(result, view3d_context_dir); } else if (CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) { - int selected_objects= CTX_data_equals(member, "selected_objects"); + int selected_objects = CTX_data_equals(member, "selected_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & lay)) { - if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { if (selected_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -1065,12 +1066,12 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes return 1; } else if (CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) { - int selected_editable_objects= CTX_data_equals(member, "selected_editable_objects"); + int selected_editable_objects = CTX_data_equals(member, "selected_editable_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & lay)) { - if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { - if (0==object_is_libdata(base->object)) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { + if (0 == object_is_libdata(base->object)) { if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -1083,11 +1084,11 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes return 1; } else if (CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) { - int visible_objects= CTX_data_equals(member, "visible_objects"); + int visible_objects = CTX_data_equals(member, "visible_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & lay) { - if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { if (visible_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -1099,11 +1100,11 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes return 1; } else if (CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) { - int selectable_objects= CTX_data_equals(member, "selectable_objects"); + int selectable_objects = CTX_data_equals(member, "selectable_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & lay) { - if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0 && (base->object->restrictflag & OB_RESTRICT_SELECT)==0) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0 && (base->object->restrictflag & OB_RESTRICT_SELECT) == 0) { if (selectable_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -1116,14 +1117,14 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes } else if (CTX_data_equals(member, "active_base")) { if (scene->basact && (scene->basact->lay & lay)) - if ((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0) + if ((scene->basact->object->restrictflag & OB_RESTRICT_VIEW) == 0) CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, scene->basact); return 1; } else if (CTX_data_equals(member, "active_object")) { if (scene->basact && (scene->basact->lay & lay)) - if ((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0) + if ((scene->basact->object->restrictflag & OB_RESTRICT_VIEW) == 0) CTX_data_id_pointer_set(result, &scene->basact->object->id); return 1; @@ -1139,56 +1140,56 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes /* only called once, from space/spacetypes.c */ void ED_spacetype_view3d(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype view3d"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype view3d"); ARegionType *art; - st->spaceid= SPACE_VIEW3D; + st->spaceid = SPACE_VIEW3D; strncpy(st->name, "View3D", BKE_ST_MAXNAME); - st->new= view3d_new; - st->free= view3d_free; - st->init= view3d_init; + st->new = view3d_new; + st->free = view3d_free; + st->init = view3d_init; st->listener = space_view3d_listener; - st->duplicate= view3d_duplicate; - st->operatortypes= view3d_operatortypes; - st->keymap= view3d_keymap; - st->dropboxes= view3d_dropboxes; - st->context= view3d_context; + st->duplicate = view3d_duplicate; + st->operatortypes = view3d_operatortypes; + st->keymap = view3d_keymap; + st->dropboxes = view3d_dropboxes; + st->context = view3d_context; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d main region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype view3d main region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_GPENCIL; - art->draw= view3d_main_area_draw; - art->init= view3d_main_area_init; - art->free= view3d_main_area_free; - art->duplicate= view3d_main_area_duplicate; - art->listener= view3d_main_area_listener; - art->cursor= view3d_main_area_cursor; - art->lock= 1; /* can become flag, see BKE_spacedata_draw_locks */ + art->keymapflag = ED_KEYMAP_GPENCIL; + art->draw = view3d_main_area_draw; + art->init = view3d_main_area_init; + art->free = view3d_main_area_free; + art->duplicate = view3d_main_area_duplicate; + art->listener = view3d_main_area_listener; + art->cursor = view3d_main_area_cursor; + art->lock = 1; /* can become flag, see BKE_spacedata_draw_locks */ BLI_addhead(&st->regiontypes, art); /* regions: listview/buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d buttons region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype view3d buttons region"); art->regionid = RGN_TYPE_UI; - art->prefsizex= 180; // XXX - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; - art->listener= view3d_buttons_area_listener; - art->init= view3d_buttons_area_init; - art->draw= view3d_buttons_area_draw; + art->prefsizex = 180; // XXX + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; + art->listener = view3d_buttons_area_listener; + art->init = view3d_buttons_area_init; + art->draw = view3d_buttons_area_draw; BLI_addhead(&st->regiontypes, art); view3d_buttons_register(art); /* regions: tool(bar) */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d tools region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; - art->prefsizex= 160; // XXX - art->prefsizey= 50; // XXX - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; - art->listener= view3d_buttons_area_listener; - art->init= view3d_tools_area_init; - art->draw= view3d_tools_area_draw; + art->prefsizex = 160; // XXX + art->prefsizey = 50; // XXX + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; + art->listener = view3d_buttons_area_listener; + art->init = view3d_tools_area_init; + art->draw = view3d_tools_area_draw; BLI_addhead(&st->regiontypes, art); #if 0 @@ -1197,27 +1198,27 @@ void ED_spacetype_view3d(void) #endif /* regions: tool properties */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d tool properties region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tool properties region"); art->regionid = RGN_TYPE_TOOL_PROPS; - art->prefsizex= 0; - art->prefsizey= 120; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; - art->listener= view3d_props_area_listener; - art->init= view3d_tools_area_init; - art->draw= view3d_tools_area_draw; + art->prefsizex = 0; + art->prefsizey = 120; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; + art->listener = view3d_props_area_listener; + art->init = view3d_tools_area_init; + art->draw = view3d_tools_area_draw; BLI_addhead(&st->regiontypes, art); view3d_tool_props_register(art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d header region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; - art->listener= view3d_header_area_listener; - art->init= view3d_header_area_init; - art->draw= view3d_header_area_draw; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; + art->listener = view3d_header_area_listener; + art->init = view3d_header_area_init; + art->draw = view3d_header_area_draw; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 953f22a2b65..f714260ed41 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -83,44 +83,44 @@ /* ******************* view3d space & buttons ************** */ -#define B_NOP 1 -#define B_REDR 2 -#define B_OBJECTPANELROT 1007 +#define B_NOP 1 +#define B_REDR 2 +#define B_OBJECTPANELROT 1007 #define B_OBJECTPANELMEDIAN 1008 -#define B_ARMATUREPANEL1 1009 -#define B_ARMATUREPANEL2 1010 +#define B_ARMATUREPANEL1 1009 +#define B_ARMATUREPANEL2 1010 #define B_OBJECTPANELPARENT 1011 -#define B_OBJECTPANEL 1012 -#define B_ARMATUREPANEL3 1013 -#define B_OBJECTPANELSCALE 1014 -#define B_OBJECTPANELDIMS 1015 -#define B_TRANSFORMSPACEADD 1016 -#define B_TRANSFORMSPACECLEAR 1017 -#define B_SETPT_AUTO 2125 -#define B_SETPT_VECTOR 2126 -#define B_SETPT_ALIGN 2127 -#define B_SETPT_FREE 2128 -#define B_RECALCMBALL 2501 - -#define B_WEIGHT0_0 2840 -#define B_WEIGHT1_4 2841 -#define B_WEIGHT1_2 2842 -#define B_WEIGHT3_4 2843 -#define B_WEIGHT1_0 2844 - -#define B_OPA1_8 2845 -#define B_OPA1_4 2846 -#define B_OPA1_2 2847 -#define B_OPA3_4 2848 -#define B_OPA1_0 2849 - -#define B_CLR_WPAINT 2850 - -#define B_RV3D_LOCKED 2900 -#define B_RV3D_BOXVIEW 2901 -#define B_RV3D_BOXCLIP 2902 - -#define B_IDNAME 3000 +#define B_OBJECTPANEL 1012 +#define B_ARMATUREPANEL3 1013 +#define B_OBJECTPANELSCALE 1014 +#define B_OBJECTPANELDIMS 1015 +#define B_TRANSFORMSPACEADD 1016 +#define B_TRANSFORMSPACECLEAR 1017 +#define B_SETPT_AUTO 2125 +#define B_SETPT_VECTOR 2126 +#define B_SETPT_ALIGN 2127 +#define B_SETPT_FREE 2128 +#define B_RECALCMBALL 2501 + +#define B_WEIGHT0_0 2840 +#define B_WEIGHT1_4 2841 +#define B_WEIGHT1_2 2842 +#define B_WEIGHT3_4 2843 +#define B_WEIGHT1_0 2844 + +#define B_OPA1_8 2845 +#define B_OPA1_4 2846 +#define B_OPA1_2 2847 +#define B_OPA3_4 2848 +#define B_OPA1_0 2849 + +#define B_CLR_WPAINT 2850 + +#define B_RV3D_LOCKED 2900 +#define B_RV3D_BOXVIEW 2901 +#define B_RV3D_BOXCLIP 2902 + +#define B_IDNAME 3000 /* temporary struct for storing transform properties */ typedef struct { @@ -167,8 +167,8 @@ static float compute_scale_factor(const float ve_median, const float median) /* is used for both read and write... */ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float lim) { - uiBlock *block = (layout)? uiLayoutAbsoluteBlock(layout): NULL; - MDeformVert *dvert =NULL; + uiBlock *block = (layout) ? uiLayoutAbsoluteBlock(layout) : NULL; + MDeformVert *dvert = NULL; TransformProperties *tfp; float median[7], ve_median[7]; int tot, totw, totweight, totedge, totradius; @@ -221,8 +221,8 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float int i, max = 1, init = 1; char str[320]; - for (i = 0; i<dvert->totweight; i++) { - dg = BLI_findlink (&ob->defbase, dvert->dw[i].def_nr); + for (i = 0; i < dvert->totweight; i++) { + dg = BLI_findlink(&ob->defbase, dvert->dw[i].def_nr); if (dg) { max += BLI_snprintf(str, sizeof(str), "%s %%x%d|", dg->name, dvert->dw[i].def_nr); if (max < sizeof(str)) strcat(defstr, str); @@ -281,7 +281,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } else { bp = nu->bp; - a = nu->pntsu*nu->pntsv; + a = nu->pntsu * nu->pntsv; while (a--) { if (bp->f1 & SELECT) { add_v3_v3(median, bp->vec); @@ -405,7 +405,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Bevel Weight:"), 0, 20, 200, 20, &(tfp->ve_median[6]), 0.0, 1.0, 1, 3, TIP_("Weight used by Bevel modifier")); } - else if (totedge>1) { + else if (totedge > 1) { uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Crease:"), 0, 40, 200, 20, &(tfp->ve_median[3]), 0.0, 1.0, 1, 3, TIP_("Weight used by SubSurf modifier")); uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Bevel Weight:"), 0, 20, 200, 20, @@ -571,7 +571,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } else { bp = nu->bp; - a = nu->pntsu*nu->pntsv; + a = nu->pntsu * nu->pntsv; while (a--) { if (bp->f1 & SELECT) { add_v3_v3(bp->vec, median); @@ -605,7 +605,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float int a; const float scale_w = compute_scale_factor(ve_median[4], median[4]); - a = lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; bp = lt->editlatt->latt->def; while (a--) { if (bp->f1 & SELECT) { @@ -820,7 +820,7 @@ static void do_view3d_vgroup_buttons(bContext *C, void *UNUSED(arg), int event) /* default for now */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); } static int view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt)) @@ -862,7 +862,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) uiBlockBeginAlign(block); for (i = dv->totweight; i != 0; i--, dw++) { - dg = BLI_findlink (&ob->defbase, dw->def_nr); + dg = BLI_findlink(&ob->defbase, dw->def_nr); if (dg) { uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + dw->def_nr, dg->name, 0, yco, 180, 20, &dw->weight, 0.0, 1.0, 1, 3, ""); @@ -912,7 +912,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, 1); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) - uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", ICON_NONE); + uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE + UI_ITEM_R_ICON_ONLY, "", ICON_NONE); else uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -970,7 +970,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) /* row = uiLayoutRow(layout, 0); */ - if (!pchan) { + if (!pchan) { uiItemL(layout, IFACE_("No Bone Active"), ICON_NONE); return; } @@ -991,57 +991,57 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) float quat[4]; /* convert to euler, passing through quats... */ axis_angle_to_quat(quat, pchan->rotAxis, pchan->rotAngle); - quat_to_eul( tfp->ob_eul,quat); + quat_to_eul(tfp->ob_eul, quat); } else if (pchan->rotmode == ROT_MODE_QUAT) - quat_to_eul( tfp->ob_eul,pchan->quat); + quat_to_eul(tfp->ob_eul, pchan->quat); else copy_v3_v3(tfp->ob_eul, pchan->eul); - tfp->ob_eul[0]*= RAD2DEGF(1.0f); - tfp->ob_eul[1]*= RAD2DEGF(1.0f); - tfp->ob_eul[2]*= RAD2DEGF(1.0f); + tfp->ob_eul[0] *= RAD2DEGF(1.0f); + tfp->ob_eul[1] *= RAD2DEGF(1.0f); + tfp->ob_eul[2] *= RAD2DEGF(1.0f); uiDefBut(block, LABEL, 0, "Location:", 0, 240, 100, 20, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); - but = uiDefButF(block, NUM, B_ARMATUREPANEL2, "X:", 0, 220, 120, 19, pchan->loc, -lim, lim, 100, 3, ""); + but = uiDefButF(block, NUM, B_ARMATUREPANEL2, "X:", 0, 220, 120, 19, pchan->loc, -lim, lim, 100, 3, ""); uiButSetUnitType(but, PROP_UNIT_LENGTH); - but = uiDefButF(block, NUM, B_ARMATUREPANEL2, "Y:", 0, 200, 120, 19, pchan->loc+1, -lim, lim, 100, 3, ""); + but = uiDefButF(block, NUM, B_ARMATUREPANEL2, "Y:", 0, 200, 120, 19, pchan->loc + 1, -lim, lim, 100, 3, ""); uiButSetUnitType(but, PROP_UNIT_LENGTH); - but = uiDefButF(block, NUM, B_ARMATUREPANEL2, "Z:", 0, 180, 120, 19, pchan->loc+2, -lim, lim, 100, 3, ""); + but = uiDefButF(block, NUM, B_ARMATUREPANEL2, "Z:", 0, 180, 120, 19, pchan->loc + 2, -lim, lim, 100, 3, ""); uiButSetUnitType(but, PROP_UNIT_LENGTH); uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCX, B_REDR, ICON_UNLOCKED, 125, 220, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects X Location value from being Transformed"); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCY, B_REDR, ICON_UNLOCKED, 125, 200, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Y Location value from being Transformed"); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCZ, B_REDR, ICON_UNLOCKED, 125, 180, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Z Location value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCX, B_REDR, ICON_UNLOCKED, 125, 220, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects X Location value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCY, B_REDR, ICON_UNLOCKED, 125, 200, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Y Location value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCZ, B_REDR, ICON_UNLOCKED, 125, 180, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Z Location value from being Transformed"); uiBlockEndAlign(block); - uiDefBut(block, LABEL, 0, "Rotation:", 0, 160, 100, 20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Rotation:", 0, 160, 100, 20, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_ARMATUREPANEL3, "X:", 0, 140, 120, 19, tfp->ob_eul, -1000.0, 1000.0, 100, 3, ""); - uiDefButF(block, NUM, B_ARMATUREPANEL3, "Y:", 0, 120, 120, 19, tfp->ob_eul+1, -1000.0, 1000.0, 100, 3, ""); - uiDefButF(block, NUM, B_ARMATUREPANEL3, "Z:", 0, 100, 120, 19, tfp->ob_eul+2, -1000.0, 1000.0, 100, 3, ""); + uiDefButF(block, NUM, B_ARMATUREPANEL3, "X:", 0, 140, 120, 19, tfp->ob_eul, -1000.0, 1000.0, 100, 3, ""); + uiDefButF(block, NUM, B_ARMATUREPANEL3, "Y:", 0, 120, 120, 19, tfp->ob_eul + 1, -1000.0, 1000.0, 100, 3, ""); + uiDefButF(block, NUM, B_ARMATUREPANEL3, "Z:", 0, 100, 120, 19, tfp->ob_eul + 2, -1000.0, 1000.0, 100, 3, ""); uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTX, B_REDR, ICON_UNLOCKED, 125, 140, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects X Rotation value from being Transformed"); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTY, B_REDR, ICON_UNLOCKED, 125, 120, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Y Rotation value from being Transformed"); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTZ, B_REDR, ICON_UNLOCKED, 125, 100, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Z Rotation value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTX, B_REDR, ICON_UNLOCKED, 125, 140, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects X Rotation value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTY, B_REDR, ICON_UNLOCKED, 125, 120, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Y Rotation value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTZ, B_REDR, ICON_UNLOCKED, 125, 100, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Z Rotation value from being Transformed"); uiBlockEndAlign(block); - uiDefBut(block, LABEL, 0, "Scale:", 0, 80, 100, 20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Scale:", 0, 80, 100, 20, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_ARMATUREPANEL2, "X:", 0, 60, 120, 19, pchan->size, -lim, lim, 10, 3, ""); - uiDefButF(block, NUM, B_ARMATUREPANEL2, "Y:", 0, 40, 120, 19, pchan->size+1, -lim, lim, 10, 3, ""); - uiDefButF(block, NUM, B_ARMATUREPANEL2, "Z:", 0, 20, 120, 19, pchan->size+2, -lim, lim, 10, 3, ""); + uiDefButF(block, NUM, B_ARMATUREPANEL2, "X:", 0, 60, 120, 19, pchan->size, -lim, lim, 10, 3, ""); + uiDefButF(block, NUM, B_ARMATUREPANEL2, "Y:", 0, 40, 120, 19, pchan->size + 1, -lim, lim, 10, 3, ""); + uiDefButF(block, NUM, B_ARMATUREPANEL2, "Z:", 0, 20, 120, 19, pchan->size + 2, -lim, lim, 10, 3, ""); uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEX, B_REDR, ICON_UNLOCKED, 125, 60, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects X Scale value from being Transformed"); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEY, B_REDR, ICON_UNLOCKED, 125, 40, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Y Scale value from being Transformed"); - uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEZ, B_REDR, ICON_UNLOCKED, 125, 20, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects z Scale value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEX, B_REDR, ICON_UNLOCKED, 125, 60, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects X Scale value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEY, B_REDR, ICON_UNLOCKED, 125, 40, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects Y Scale value from being Transformed"); + uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEZ, B_REDR, ICON_UNLOCKED, 125, 20, 25, 19, &(pchan->protectflag), 0, 0, 0, 0, "Protects z Scale value from being Transformed"); uiBlockEndAlign(block); #endif } @@ -1085,7 +1085,7 @@ static void v3d_editarmature_buts(uiLayout *layout, Object *ob) col = uiLayoutColumn(layout, 0); uiItemR(col, &eboneptr, "head", 0, NULL, ICON_NONE); - if (ebone->parent && ebone->flag & BONE_CONNECTED ) { + if (ebone->parent && ebone->flag & BONE_CONNECTED) { PointerRNA parptr = RNA_pointer_get(&eboneptr, "parent"); uiItemR(col, &parptr, "tail_radius", 0, IFACE_("Radius (Parent)"), ICON_NONE); } @@ -1164,34 +1164,34 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event switch (event) { - case B_REDR: - ED_area_tag_redraw(CTX_wm_area(C)); - return; /* no notifier! */ + case B_REDR: + ED_area_tag_redraw(CTX_wm_area(C)); + return; /* no notifier! */ - case B_OBJECTPANEL: - DAG_id_tag_update(&ob->id, OB_RECALC_OB); - break; + case B_OBJECTPANEL: + DAG_id_tag_update(&ob->id, OB_RECALC_OB); + break; - case B_OBJECTPANELMEDIAN: - if (ob) { - v3d_editvertex_buts(NULL, v3d, ob, 1.0); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - break; + case B_OBJECTPANELMEDIAN: + if (ob) { + v3d_editvertex_buts(NULL, v3d, ob, 1.0); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + break; /* note; this case also used for parbone */ - case B_OBJECTPANELPARENT: - if (ob) { - if (ob->id.lib || BKE_object_parent_loop_check(ob->parent, ob)) - ob->parent = NULL; - else { - DAG_scene_sort(bmain, scene); - DAG_id_tag_update(&ob->id, OB_RECALC_OB); + case B_OBJECTPANELPARENT: + if (ob) { + if (ob->id.lib || BKE_object_parent_loop_check(ob->parent, ob)) + ob->parent = NULL; + else { + DAG_scene_sort(bmain, scene); + DAG_id_tag_update(&ob->id, OB_RECALC_OB); + } } - } - break; + break; - case B_ARMATUREPANEL3: /* rotate button on channel */ + case B_ARMATUREPANEL3: /* rotate button on channel */ { bPoseChannel *pchan; float eul[3]; @@ -1218,73 +1218,73 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event } /* no break, pass on */ - case B_ARMATUREPANEL2: - ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - break; + case B_ARMATUREPANEL2: + ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + break; - case B_TRANSFORMSPACEADD: + case B_TRANSFORMSPACEADD: { char names[sizeof(((TransformOrientation *)NULL)->name)] = ""; BIF_createTransformOrientation(C, NULL, names, 1, 0); } break; - case B_TRANSFORMSPACECLEAR: - BIF_clearTransformOrientation(C); - break; + case B_TRANSFORMSPACECLEAR: + BIF_clearTransformOrientation(C); + break; #if 0 /* XXX */ - case B_WEIGHT0_0: - wpaint->weight = 0.0f; - break; + case B_WEIGHT0_0: + wpaint->weight = 0.0f; + break; - case B_WEIGHT1_4: - wpaint->weight = 0.25f; - break; - case B_WEIGHT1_2: - wpaint->weight = 0.5f; - break; - case B_WEIGHT3_4: - wpaint->weight = 0.75f; - break; - case B_WEIGHT1_0: - wpaint->weight = 1.0f; - break; + case B_WEIGHT1_4: + wpaint->weight = 0.25f; + break; + case B_WEIGHT1_2: + wpaint->weight = 0.5f; + break; + case B_WEIGHT3_4: + wpaint->weight = 0.75f; + break; + case B_WEIGHT1_0: + wpaint->weight = 1.0f; + break; - case B_OPA1_8: - wpaint->a = 0.125f; - break; - case B_OPA1_4: - wpaint->a = 0.25f; - break; - case B_OPA1_2: - wpaint->a = 0.5f; - break; - case B_OPA3_4: - wpaint->a = 0.75f; - break; - case B_OPA1_0: - wpaint->a = 1.0f; - break; + case B_OPA1_8: + wpaint->a = 0.125f; + break; + case B_OPA1_4: + wpaint->a = 0.25f; + break; + case B_OPA1_2: + wpaint->a = 0.5f; + break; + case B_OPA3_4: + wpaint->a = 0.75f; + break; + case B_OPA1_0: + wpaint->a = 1.0f; + break; #endif - case B_CLR_WPAINT: + case B_CLR_WPAINT: /* if (!multires_level1_test()) { */ { - bDeformGroup *defGroup = BLI_findlink(&ob->defbase, ob->actdef-1); + bDeformGroup *defGroup = BLI_findlink(&ob->defbase, ob->actdef - 1); if (defGroup) { Mesh *me = ob->data; int a; for (a = 0; a < me->totvert; a++) - ED_vgroup_vert_remove (ob, defGroup, a); + ED_vgroup_vert_remove(ob, defGroup, a); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } } break; - case B_RV3D_LOCKED: - case B_RV3D_BOXVIEW: - case B_RV3D_BOXCLIP: + case B_RV3D_LOCKED: + case B_RV3D_BOXVIEW: + case B_RV3D_BOXCLIP: { ScrArea *sa = CTX_wm_area(C); ARegion *ar = sa->regionbase.last; @@ -1316,7 +1316,7 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event } /* default for now */ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); } static void view3d_panel_object(const bContext *C, Panel *pa) @@ -1343,7 +1343,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa) /* XXX uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); */ - if (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) { + if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) { } else { if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) { @@ -1388,8 +1388,8 @@ static void view3d_panel_preview(bContext *C, ARegion *ar, short cntrl) /* VIEW3 uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl); uiSetPanelHandler(VIEW3D_HANDLER_PREVIEW); /* for close and esc */ - ofsx = -150 + (sa->winx/2) / v3d->blockscale; - ofsy = -100 + (sa->winy/2) / v3d->blockscale; + ofsx = -150 + (sa->winx / 2) / v3d->blockscale; + ofsy = -100 + (sa->winy / 2) / v3d->blockscale; if (uiNewPanel(C, ar, block, "Preview", "View3d", ofsx, ofsy, 300, 200) == 0) return; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 1f6ec45f908..b6ed8f65c68 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -65,7 +65,7 @@ #include "BKE_movieclip.h" #include "RE_engine.h" -#include "RE_pipeline.h" // make_stars +#include "RE_pipeline.h" // make_stars #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -92,7 +92,7 @@ #include "GPU_material.h" #include "GPU_extensions.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include @@ -102,7 +102,7 @@ static void star_stuff_init_func(void) glPointSize(1.0); glBegin(GL_POINTS); } -static void star_stuff_vertex_func(float* i) +static void star_stuff_vertex_func(float*i) { glVertex3fv(i); } @@ -121,7 +121,7 @@ void circf(float x, float y, float rad) glTranslatef(x, y, 0.); - gluDisk( qobj, 0.0, rad, 32, 1); + gluDisk(qobj, 0.0, rad, 32, 1); glPopMatrix(); @@ -138,7 +138,7 @@ void circ(float x, float y, float rad) glTranslatef(x, y, 0.); - gluDisk( qobj, 0.0, rad, 32, 1); + gluDisk(qobj, 0.0, rad, 32, 1); glPopMatrix(); @@ -150,21 +150,21 @@ void circ(float x, float y, float rad) static void view3d_draw_clipping(RegionView3D *rv3d) { - BoundBox *bb= rv3d->clipbb; + BoundBox *bb = rv3d->clipbb; if (bb) { - static unsigned int clipping_index[6][4]= {{0, 1, 2, 3}, - {0, 4, 5, 1}, - {4, 7, 6, 5}, - {7, 3, 2, 6}, - {1, 5, 6, 2}, - {7, 4, 0, 3}}; + static unsigned int clipping_index[6][4] = {{0, 1, 2, 3}, + {0, 4, 5, 1}, + {4, 7, 6, 5}, + {7, 3, 2, 6}, + {1, 5, 6, 2}, + {7, 4, 0, 3}}; UI_ThemeColorShade(TH_BACK, -8); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, bb->vec); - glDrawElements(GL_QUADS, sizeof(clipping_index)/sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index); + glDrawElements(GL_QUADS, sizeof(clipping_index) / sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index); glDisableClientState(GL_VERTEX_ARRAY); } @@ -229,15 +229,15 @@ static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, { double verts[2][2]; - x+= (wx); - y+= (wy); + x += (wx); + y += (wy); /* set fixed 'Y' */ - verts[0][1]= 0.0f; - verts[1][1]= (double)ar->winy; + verts[0][1] = 0.0f; + verts[1][1] = (double)ar->winy; /* iter over 'X' */ - verts[0][0] = verts[1][0] = x-dx*floor(x/dx); + verts[0][0] = verts[1][0] = x - dx *floor(x / dx); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_DOUBLE, 0, verts); @@ -247,11 +247,11 @@ static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, } /* set fixed 'X' */ - verts[0][0]= 0.0f; - verts[1][0]= (double)ar->winx; + verts[0][0] = 0.0f; + verts[1][0] = (double)ar->winx; /* iter over 'Y' */ - verts[0][1]= verts[1][1]= y-dx*floor(y/dx); + verts[0][1] = verts[1][1] = y - dx *floor(y / dx); while (verts[0][1] < ar->winy) { glDrawArrays(GL_LINES, 0, 2); verts[0][1] = verts[1][1] = verts[0][1] + dx; @@ -265,34 +265,34 @@ static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit) { /* extern short bgpicmode; */ - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; double wx, wy, x, y, fw, fx, fy, dx; double vec4[4]; unsigned char col[3], col2[3]; - fx= rv3d->persmat[3][0]; - fy= rv3d->persmat[3][1]; - fw= rv3d->persmat[3][3]; + fx = rv3d->persmat[3][0]; + fy = rv3d->persmat[3][1]; + fw = rv3d->persmat[3][3]; - wx= (ar->winx/2.0); /* because of rounding errors, grid at wrong location */ - wy= (ar->winy/2.0); + 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; + x = (wx) * fx / fw; + y = (wy) * fy / fw; - vec4[0]=vec4[1]= v3d->grid; + vec4[0] = vec4[1] = v3d->grid; - vec4[2]= 0.0; - vec4[3]= 1.0; + vec4[2] = 0.0; + vec4[3] = 1.0; mul_m4_v4d(rv3d->persmat, vec4); - fx= vec4[0]; - fy= vec4[1]; - fw= vec4[3]; + fx = vec4[0]; + fy = vec4[1]; + fw = vec4[3]; - dx= fabs(x-(wx)*fx/fw); - if (dx==0) dx= fabs(y-(wy)*fy/fw); + dx = fabs(x - (wx) * fx / fw); + if (dx == 0) dx = fabs(y - (wy) * fy / fw); - glDepthMask(0); // disable write in zbuffer + glDepthMask(0); // disable write in zbuffer /* check zoom out */ UI_ThemeColor(TH_GRID); @@ -308,23 +308,23 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** bUnit_GetSystem(&usys, &len, unit->system, B_UNIT_LENGTH); if (usys) { - i= len; + i = len; while (i--) { - double scalar= bUnit_GetScaler(usys, i); + double scalar = bUnit_GetScaler(usys, i); dx_scalar = dx * scalar / unit->scale_length; - if (dx_scalar < (GRID_MIN_PX*2)) + if (dx_scalar < (GRID_MIN_PX * 2)) continue; /* Store the smallest drawn grid size units name so users know how big each grid cell is */ - if (*grid_unit==NULL) { - *grid_unit= bUnit_GetNameDisplay(usys, i); - rv3d->gridview= (scalar * v3d->grid) / unit->scale_length; + if (*grid_unit == NULL) { + *grid_unit = bUnit_GetNameDisplay(usys, i); + rv3d->gridview = (scalar * v3d->grid) / unit->scale_length; } - blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar); + blend_fac = 1 - ((GRID_MIN_PX * 2) / dx_scalar); /* tweak to have the fade a bit nicer */ - blend_fac= (blend_fac * blend_fac) * 2.0f; + blend_fac = (blend_fac * blend_fac) * 2.0f; CLAMP(blend_fac, 0.3f, 1.0f); @@ -337,83 +337,83 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** else { short sublines = v3d->gridsubdiv; - if (dx<GRID_MIN_PX) { - rv3d->gridview*= sublines; - dx*= sublines; - - if (dx<GRID_MIN_PX) { - rv3d->gridview*= sublines; - dx*= sublines; - - if (dx<GRID_MIN_PX) { - rv3d->gridview*= sublines; - dx*=sublines; - if (dx<GRID_MIN_PX); + if (dx < GRID_MIN_PX) { + rv3d->gridview *= sublines; + dx *= sublines; + + if (dx < GRID_MIN_PX) { + rv3d->gridview *= sublines; + dx *= sublines; + + if (dx < GRID_MIN_PX) { + rv3d->gridview *= sublines; + dx *= sublines; + if (dx < GRID_MIN_PX) ; else { UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx); } } - else { // start blending out - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6)); + else { // start blending out + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, sublines*dx); + drawgrid_draw(ar, wx, wy, x, y, sublines * dx); } } - else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6)); + else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, sublines*dx); + drawgrid_draw(ar, wx, wy, x, y, sublines * dx); } } else { - if (dx>(GRID_MIN_PX*10)) { // start blending in - rv3d->gridview/= sublines; - dx/= sublines; - if (dx>(GRID_MIN_PX*10)) { // start blending in - rv3d->gridview/= sublines; - dx/= sublines; - if (dx>(GRID_MIN_PX*10)) { + if (dx > (GRID_MIN_PX * 10)) { // start blending in + rv3d->gridview /= sublines; + dx /= sublines; + if (dx > (GRID_MIN_PX * 10)) { // start blending in + rv3d->gridview /= sublines; + dx /= sublines; + if (dx > (GRID_MIN_PX * 10)) { UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx); } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx*sublines); + drawgrid_draw(ar, wx, wy, x, y, dx * sublines); } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx*sublines); + drawgrid_draw(ar, wx, wy, x, y, dx * sublines); } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx*sublines); + drawgrid_draw(ar, wx, wy, x, y, dx * sublines); } } } - x+= (wx); - y+= (wy); + x += (wx); + y += (wy); UI_GetThemeColor3ubv(TH_GRID, col); setlinestyle(0); /* center cross */ /* horizontal line */ - if ( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) + if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) UI_make_axis_color(col, col2, 'Y'); else UI_make_axis_color(col, col2, 'X'); glColor3ubv(col2); @@ -421,14 +421,14 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** fdrawline(0.0, y, (float)ar->winx, y); /* vertical line */ - if ( ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) + if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) UI_make_axis_color(col, col2, 'Y'); else UI_make_axis_color(col, col2, 'Z'); glColor3ubv(col2); fdrawline(x, 0.0, x, (float)ar->winy); - glDepthMask(1); // enable write in zbuffer + glDepthMask(1); // enable write in zbuffer } #undef GRID_MIN_PX @@ -436,11 +436,11 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) { float grid, grid_scale; unsigned char col_grid[3]; - const int gridlines= v3d->gridlines/2; + const int gridlines = v3d->gridlines / 2; - if (v3d->gridlines<3) return; + if (v3d->gridlines < 3) return; - grid_scale= v3d->grid; + grid_scale = v3d->grid; /* use 'grid_scale' instead of 'v3d->grid' from now on */ /* apply units */ @@ -451,53 +451,53 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) bUnit_GetSystem(&usys, &len, scene->unit.system, B_UNIT_LENGTH); if (usys) { - int i= bUnit_GetBaseUnit(usys); - *grid_unit= bUnit_GetNameDisplay(usys, i); + int i = bUnit_GetBaseUnit(usys); + *grid_unit = bUnit_GetNameDisplay(usys, i); grid_scale = (grid_scale * (float)bUnit_GetScaler(usys, i)) / scene->unit.scale_length; } } - grid= gridlines * grid_scale; + grid = gridlines * grid_scale; - if (v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select + if (v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select UI_GetThemeColor3ubv(TH_GRID, col_grid); /* draw the Y axis and/or grid lines */ if (v3d->gridflag & V3D_SHOW_FLOOR) { - float vert[4][3]= {{0.0f}}; + float vert[4][3] = {{0.0f}}; unsigned char col_bg[3]; unsigned char col_grid_emphasise[3], col_grid_light[3]; int a; - int prev_emphasise= -1; + int prev_emphasise = -1; UI_GetThemeColor3ubv(TH_BACK, col_bg); /* emphasise division lines lighter instead of darker, if background is darker than grid */ UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10); UI_GetColorPtrShade3ubv(col_grid, col_grid_emphasise, - (((col_grid[0]+col_grid[1]+col_grid[2])+30) > - (col_bg[0]+col_bg[1]+col_bg[2])) ? 20 : -10); + (((col_grid[0] + col_grid[1] + col_grid[2]) + 30) > + (col_bg[0] + col_bg[1] + col_bg[2])) ? 20 : -10); /* set fixed axis */ - vert[0][0]= vert[2][1]= grid; - vert[1][0]= vert[3][1]= -grid; + vert[0][0] = vert[2][1] = grid; + vert[1][0] = vert[3][1] = -grid; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vert); - for (a= -gridlines;a<=gridlines;a++) { - const float line= a * grid_scale; - const int is_emphasise= (a % 10) == 0; + for (a = -gridlines; a <= gridlines; a++) { + const float line = a * grid_scale; + const int is_emphasise = (a % 10) == 0; if (is_emphasise != prev_emphasise) { glColor3ubv(is_emphasise ? col_grid_emphasise : col_grid_light); - prev_emphasise= is_emphasise; + prev_emphasise = is_emphasise; } /* set variable axis */ - vert[0][1]= vert[1][1]= - vert[2][0]= vert[3][0]= line; + vert[0][1] = vert[1][1] = + vert[2][0] = vert[3][0] = line; glDrawArrays(GL_LINES, 0, 4); } @@ -511,21 +511,22 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) /* check for the 'show Z axis' preference */ if (v3d->gridflag & (V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) { int axis; - for (axis= 0; axis < 3; axis++) - if (v3d->gridflag & (V3D_SHOW_X << axis)) { - float vert[3]; - unsigned char tcol[3]; - - UI_make_axis_color(col_grid, tcol, 'X' + axis); - glColor3ubv(tcol); - - glBegin(GL_LINE_STRIP); - zero_v3(vert); - vert[axis]= grid; - glVertex3fv(vert ); - vert[axis]= -grid; - glVertex3fv(vert); - glEnd(); + for (axis = 0; axis < 3; axis++) { + if (v3d->gridflag & (V3D_SHOW_X << axis)) { + float vert[3]; + unsigned char tcol[3]; + + UI_make_axis_color(col_grid, tcol, 'X' + axis); + glColor3ubv(tcol); + + glBegin(GL_LINE_STRIP); + zero_v3(vert); + vert[axis] = grid; + glVertex3fv(vert); + vert[axis] = -grid; + glVertex3fv(vert); + glEnd(); + } } } @@ -542,15 +543,15 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) int flag; /* we don't want the clipping for cursor */ - flag= v3d->flag; - v3d->flag= 0; + flag = v3d->flag; + v3d->flag = 0; project_int(ar, give_cursor(scene, v3d), co); - v3d->flag= flag; + v3d->flag = flag; mx = co[0]; my = co[1]; - if (mx!=IS_CLIPPED) { + if (mx != IS_CLIPPED) { setlinestyle(0); cpack(0xFF); circ((float)mx, (float)my, 10.0); @@ -560,10 +561,10 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) setlinestyle(0); cpack(0x0); - sdrawline(mx-20, my, mx-5, my); - sdrawline(mx+5, my, mx+20, my); - sdrawline(mx, my-20, mx, my-5); - sdrawline(mx, my+5, mx, my+20); + sdrawline(mx - 20, my, mx - 5, my); + sdrawline(mx + 5, my, mx + 20, my); + sdrawline(mx, my - 20, mx, my - 5); + sdrawline(mx, my + 5, mx, my + 20); } } @@ -573,9 +574,9 @@ static void draw_view_axis(RegionView3D *rv3d) { const float k = U.rvisize; /* axis size */ const float toll = 0.5; /* used to see when view is quasi-orthogonal */ - const float start = k + 1.0f;/* axis center in screen coordinates, x=y */ + const float start = k + 1.0f; /* axis center in screen coordinates, x=y */ float ydisp = 0.0; /* vertical displacement to allow obj info text */ - int bright = 25*(float)U.rvibright + 5; /* axis alpha (rvibright has range 0-10) */ + int bright = 25 * (float)U.rvibright + 5; /* axis alpha (rvibright has range 0-10) */ float vec[3]; float dx, dy; @@ -654,7 +655,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) float o[3]; // center of rotation float end[3]; // endpoints for drawing - float color[4] = {0.f ,0.4235f, 1.f, 1.f}; // bright blue so it matches device LEDs + float color[4] = {0.0f, 0.4235f, 1.0f, 1.0f}; // bright blue so it matches device LEDs negate_v3_v3(o, rv3d->ofs); @@ -693,7 +694,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) // -- draw ring around rotation center -- { -#define ROT_AXIS_DETAIL 13 +#define ROT_AXIS_DETAIL 13 const float s = 0.05f * scale; const float step = 2.f * (float)(M_PI / ROT_AXIS_DETAIL); @@ -726,18 +727,18 @@ static void draw_rotation_guide(RegionView3D *rv3d) } glEnd(); -#undef ROT_AXIS_DETAIL +#undef ROT_AXIS_DETAIL } color[3] = 1.f; // solid dot } else - color[3] = 0.5f; // see-through dot + color[3] = 0.5f; // see-through dot // -- draw rotation center -- glColor4fv(color); glBegin(GL_POINTS); - glVertex3fv(o); + glVertex3fv(o); glEnd(); // find screen coordinates for rotation center, then draw pretty icon @@ -754,12 +755,12 @@ static void draw_view_icon(RegionView3D *rv3d) { BIFIconID icon; - if ( ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) - icon= ICON_AXIS_TOP; - else if ( ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) - icon= ICON_AXIS_FRONT; - else if ( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) - icon= ICON_AXIS_SIDE; + if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) + icon = ICON_AXIS_TOP; + else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) + icon = ICON_AXIS_FRONT; + else if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) + icon = ICON_AXIS_SIDE; else return; glEnable(GL_BLEND); @@ -801,7 +802,7 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) break; default: - if (rv3d->persp==RV3D_CAMOB) { + if (rv3d->persp == RV3D_CAMOB) { if ((v3d->camera) && (v3d->camera->type == OB_CAMERA)) { Camera *cam; cam = v3d->camera->data; @@ -822,18 +823,18 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) static void draw_viewport_name(ARegion *ar, View3D *v3d) { - RegionView3D *rv3d= ar->regiondata; - const char *name= view3d_get_name(v3d, rv3d); + RegionView3D *rv3d = ar->regiondata; + const char *name = view3d_get_name(v3d, rv3d); char tmpstr[24]; if (v3d->localvd) { BLI_snprintf(tmpstr, sizeof(tmpstr), "%s (Local)", name); - name= tmpstr; + name = tmpstr; } if (name) { UI_ThemeColor(TH_TEXT_HI); - BLF_draw_default_ascii(22, ar->winy-17, 0.0f, name, sizeof(tmpstr)); + BLF_draw_default_ascii(22, ar->winy - 17, 0.0f, name, sizeof(tmpstr)); } } @@ -843,42 +844,42 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d) static void draw_selected_name(Scene *scene, Object *ob) { char info[256], *markern; - short offset=30; + short offset = 30; /* get name of marker on current frame (if available) */ - markern= scene_find_marker_name(scene, CFRA); + markern = scene_find_marker_name(scene, CFRA); /* check if there is an object */ if (ob) { /* name(s) to display depends on type of object */ - if (ob->type==OB_ARMATURE) { - bArmature *arm= ob->data; - char *name= NULL; + if (ob->type == OB_ARMATURE) { + bArmature *arm = ob->data; + char *name = NULL; /* show name of active bone too (if possible) */ if (arm->edbo) { if (arm->act_edbone) - name= ((EditBone *)arm->act_edbone)->name; + name = ((EditBone *)arm->act_edbone)->name; } else if (ob->mode & OB_MODE_POSE) { if (arm->act_bone) { if (arm->act_bone->layer & arm->layer) - name= arm->act_bone->name; + name = arm->act_bone->name; } } if (name && markern) - BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern); + BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name + 2, name, markern); else if (name) - BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, name); + BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name + 2, name); else - BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2); + BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name + 2); } else if (ELEM3(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) { - Key *key= NULL; + Key *key = NULL; KeyBlock *kb = NULL; char shapes[MAX_NAME + 10]; @@ -886,7 +887,7 @@ static void draw_selected_name(Scene *scene, Object *ob) shapes[0] = '\0'; key = ob_get_key(ob); if (key) { - kb = BLI_findlink(&key->block, ob->shapenr-1); + kb = BLI_findlink(&key->block, ob->shapenr - 1); if (kb) { BLI_snprintf(shapes, sizeof(shapes), ": %s ", kb->name); if (ob->shapeflag == OB_SHAPE_LOCK) { @@ -896,20 +897,20 @@ static void draw_selected_name(Scene *scene, Object *ob) } if (markern) - BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern); + BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name + 2, shapes, markern); else - BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, shapes); + BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name + 2, shapes); } else { /* standard object */ if (markern) - BLI_snprintf(info, sizeof(info), "(%d) %s <%s>", CFRA, ob->id.name+2, markern); + BLI_snprintf(info, sizeof(info), "(%d) %s <%s>", CFRA, ob->id.name + 2, markern); else - BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2); + BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name + 2); } /* color depends on whether there is a keyframe */ - if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/(float)(CFRA), ANIMFILTER_KEYS_LOCAL)) + if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_TEXT_HI); @@ -941,25 +942,25 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV camera_params_init(¶ms); camera_params_from_view3d(¶ms, v3d, rv3d); if (no_zoom) - params.zoom= 1.0f; + params.zoom = 1.0f; camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f); - rect_view= params.viewplane; + rect_view = params.viewplane; /* get camera viewplane */ camera_params_init(¶ms); camera_params_from_object(¶ms, v3d->camera); if (no_shift) { - params.shiftx= 0.0f; - params.shifty= 0.0f; + params.shiftx = 0.0f; + params.shifty = 0.0f; } camera_params_compute_viewplane(¶ms, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp); - rect_camera= params.viewplane; + rect_camera = params.viewplane; /* get camera border within viewport */ - viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin)/(rect_view.xmax - rect_view.xmin))*ar->winx; - viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin)/(rect_view.xmax - rect_view.xmin))*ar->winx; - viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin)/(rect_view.ymax - rect_view.ymin))*ar->winy; - viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin)/(rect_view.ymax - rect_view.ymin))*ar->winy; + viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx; + viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx; + viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy; + viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy; } void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2]) @@ -967,8 +968,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R rctf viewborder; view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE); - size_r[0]= viewborder.xmax - viewborder.xmin; - size_r[1]= viewborder.ymax - viewborder.ymin; + size_r[0] = viewborder.xmax - viewborder.xmin; + size_r[1] = viewborder.ymax - viewborder.ymin; } void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, @@ -981,10 +982,10 @@ static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float f { float x3, y3, x4, y4; - x3= x1 + fac * (x2-x1); - y3= y1 + fac * (y2-y1); - x4= x1 + (1.0f - fac) * (x2-x1); - y4= y1 + (1.0f - fac) * (y2-y1); + x3 = x1 + fac * (x2 - x1); + y3 = y1 + fac * (y2 - y1); + x4 = x1 + (1.0f - fac) * (x2 - x1); + y4 = y1 + (1.0f - fac) * (y2 - y1); glBegin(GL_LINES); glVertex2f(x1, y3); @@ -1005,13 +1006,13 @@ static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float f static void drawviewborder_triangle(float x1, float x2, float y1, float y2, const char golden, const char dir) { float ofs; - float w= x2 - x1; - float h= y2 - y1; + float w = x2 - x1; + float h = y2 - y1; glBegin(GL_LINES); if (w > h) { if (golden) { - ofs = w * (1.0f-(1.0f/1.61803399f)); + ofs = w * (1.0f - (1.0f / 1.61803399f)); } else { ofs = h * (h / w); @@ -1029,7 +1030,7 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons } else { if (golden) { - ofs = h * (1.0f-(1.0f/1.61803399f)); + ofs = h * (1.0f - (1.0f / 1.61803399f)); } else { ofs = w * (w / h); @@ -1055,20 +1056,20 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) float x1i, x2i, y1i, y2i; float x3, y3, x4, y4; rctf viewborder; - Camera *ca= NULL; - RegionView3D *rv3d= (RegionView3D *)ar->regiondata; + Camera *ca = NULL; + RegionView3D *rv3d = (RegionView3D *)ar->regiondata; - if (v3d->camera==NULL) + if (v3d->camera == NULL) return; - if (v3d->camera->type==OB_CAMERA) + if (v3d->camera->type == OB_CAMERA) ca = v3d->camera->data; ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE); /* the offsets */ - x1= viewborder.xmin; - y1= viewborder.ymin; - x2= viewborder.xmax; - y2= viewborder.ymax; + x1 = viewborder.xmin; + y1 = viewborder.ymin; + x2 = viewborder.xmax; + y2 = viewborder.ymax; /* apply offsets so the real 3D camera shows through */ @@ -1077,10 +1078,10 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) * obscures the 3D camera border */ /* note: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticeable * but keep it here in case we need to remove the workaround */ - x1i= (int)(x1 - 1.0001f); - y1i= (int)(y1 - 1.0001f); - x2i= (int)(x2 + (1.0f-0.0001f)); - y2i= (int)(y2 + (1.0f-0.0001f)); + x1i = (int)(x1 - 1.0001f); + y1i = (int)(y1 - 1.0001f); + x2i = (int)(x2 + (1.0f - 0.0001f)); + y2i = (int)(y2 + (1.0f - 0.0001f)); /* passepartout, specified in camera edit buttons */ if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) { @@ -1088,7 +1089,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) glColor3f(0, 0, 0); } else { - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0, 0, 0, ca->passepartalpha); } @@ -1116,8 +1117,8 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) #ifdef VIEW3D_CAMERA_BORDER_HACK if (view3d_camera_border_hack_test == TRUE) { glColor4fv(view3d_camera_border_hack_col); - glRectf(x1i+1, y1i+1, x2i-1, y2i-1); - view3d_camera_border_hack_test= FALSE; + glRectf(x1i + 1, y1i + 1, x2i - 1, y2i - 1); + view3d_camera_border_hack_test = FALSE; } #endif @@ -1136,10 +1137,10 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (scene->r.mode & R_BORDER) { cpack(0); - x3= x1+ scene->r.border.xmin*(x2-x1); - y3= y1+ scene->r.border.ymin*(y2-y1); - x4= x1+ scene->r.border.xmax*(x2-x1); - y4= y1+ scene->r.border.ymax*(y2-y1); + x3 = x1 + scene->r.border.xmin * (x2 - x1); + y3 = y1 + scene->r.border.ymin * (y2 - y1); + x4 = x1 + scene->r.border.xmax * (x2 - x1); + y4 = y1 + scene->r.border.ymax * (y2 - y1); cpack(0x4040FF); glRectf(x3, y3, x4, y4); @@ -1150,8 +1151,8 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (ca->dtx & CAM_DTX_CENTER) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - x3= x1+ 0.5f*(x2-x1); - y3= y1+ 0.5f*(y2-y1); + x3 = x1 + 0.5f * (x2 - x1); + y3 = y1 + 0.5f * (y2 - y1); glBegin(GL_LINES); glVertex2f(x1, y3); @@ -1176,12 +1177,12 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (ca->dtx & CAM_DTX_THIRDS) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - drawviewborder_grid3(x1, x2, y1, y2, 1.0f/3.0f); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f / 3.0f); } if (ca->dtx & CAM_DTX_GOLDEN) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399f)); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f - (1.0f / 1.61803399f)); } if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) { @@ -1205,15 +1206,15 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) } if (ca->flag & CAM_SHOWTITLESAFE) { - fac= 0.1; + fac = 0.1; - a= fac*(x2-x1); - x1+= a; - x2-= a; + a = fac * (x2 - x1); + x1 += a; + x2 -= a; - a= fac*(y2-y1); - y1+= a; - y2-= a; + a = fac * (y2 - y1); + y1 += a; + y2 -= a; UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); @@ -1223,29 +1224,29 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (ca && (ca->flag & CAM_SHOWSENSOR)) { /* determine sensor fit, and get sensor x/y, for auto fit we * assume and square sensor and only use sensor_x */ - float sizex= scene->r.xsch*scene->r.xasp; - float sizey= scene->r.ysch*scene->r.yasp; + float sizex = scene->r.xsch * scene->r.xasp; + float sizey = scene->r.ysch * scene->r.yasp; int sensor_fit = camera_sensor_fit(ca->sensor_fit, sizex, sizey); - float sensor_x= ca->sensor_x; - float sensor_y= (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO)? ca->sensor_x: ca->sensor_y; + float sensor_x = ca->sensor_x; + float sensor_y = (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO) ? ca->sensor_x : ca->sensor_y; /* determine sensor plane */ rctf rect; if (sensor_fit == CAMERA_SENSOR_FIT_HOR) { - float sensor_scale = (x2i-x1i) / sensor_x; + float sensor_scale = (x2i - x1i) / sensor_x; float sensor_height = sensor_scale * sensor_y; rect.xmin = x1i; rect.xmax = x2i; - rect.ymin = (y1i + y2i)*0.5f - sensor_height*0.5f; + rect.ymin = (y1i + y2i) * 0.5f - sensor_height * 0.5f; rect.ymax = rect.ymin + sensor_height; } else { - float sensor_scale = (y2i-y1i) / sensor_y; + float sensor_scale = (y2i - y1i) / sensor_y; float sensor_width = sensor_scale * sensor_x; - rect.xmin = (x1i + x2i)*0.5f - sensor_width*0.5f; + rect.xmin = (x1i + x2i) * 0.5f - sensor_width * 0.5f; rect.xmax = rect.xmin + sensor_width; rect.ymin = y1i; rect.ymax = y2i; @@ -1263,7 +1264,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) /* camera name - draw in highlighted text color */ if (ca && (ca->flag & CAM_SHOWNAME)) { UI_ThemeColor(TH_TEXT_HI); - BLF_draw_default(x1i, y1i-15, 0.0f, v3d->camera->id.name+2, sizeof(v3d->camera->id.name)-2); + BLF_draw_default(x1i, y1i - 15, 0.0f, v3d->camera->id.name + 2, sizeof(v3d->camera->id.name) - 2); UI_ThemeColor(TH_WIRE); } } @@ -1272,30 +1273,30 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; struct Base *base = scene->basact; int multisample_enabled; rcti winrct; BLI_assert(ar->regiontype == RGN_TYPE_WINDOW); - if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT) || - paint_facesel_test(base->object))) + if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || + paint_facesel_test(base->object))) { /* do nothing */ } else if ((base && (base->object->mode & OB_MODE_TEXTURE_PAINT)) && - scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)) + scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)) { /* do nothing */ } else if ((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) && - v3d->drawtype > OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) + v3d->drawtype > OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) { /* do nothing */ } - else if (scene->obedit && v3d->drawtype>OB_WIRE && - (v3d->flag & V3D_ZBUF_SELECT)) { + else if (scene->obedit && v3d->drawtype > OB_WIRE && + (v3d->flag & V3D_ZBUF_SELECT)) { /* do nothing */ } else { @@ -1303,7 +1304,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) return; } - if ( !(v3d->flag & V3D_INVALID_BACKBUF) ) return; + if (!(v3d->flag & V3D_INVALID_BACKBUF) ) return; // if (test) { // if (qtest()) { @@ -1312,12 +1313,12 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) // } // } - if (v3d->drawtype > OB_WIRE) v3d->zbuf= TRUE; + if (v3d->drawtype > OB_WIRE) v3d->zbuf = TRUE; /* dithering and AA break color coding, so disable */ glDisable(GL_DITHER); - multisample_enabled= glIsEnabled(GL_MULTISAMPLE_ARB); + multisample_enabled = glIsEnabled(GL_MULTISAMPLE_ARB); if (multisample_enabled) glDisable(GL_MULTISAMPLE_ARB); @@ -1343,10 +1344,10 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) draw_object_backbufsel(scene, v3d, rv3d, base->object); v3d->flag &= ~V3D_INVALID_BACKBUF; - ar->swap= 0; /* mark invalid backbuf for wm draw */ + ar->swap = 0; /* mark invalid backbuf for wm draw */ G.f &= ~G_BACKBUFSEL; - v3d->zbuf= FALSE; + v3d->zbuf = FALSE; glDisable(GL_DEPTH_TEST); glEnable(GL_DITHER); if (multisample_enabled) @@ -1372,15 +1373,15 @@ unsigned int view3d_sample_backbuf(ViewContext *vc, int x, int y) unsigned int col; if (x >= vc->ar->winx || y >= vc->ar->winy) return 0; - x+= vc->ar->winrct.xmin; - y+= vc->ar->winrct.ymin; + x += vc->ar->winrct.xmin; + y += vc->ar->winrct.ymin; view3d_validate_backbuf(vc); glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col); glReadBuffer(GL_BACK); - if (ENDIAN_ORDER==B_ENDIAN) SWITCH_INT(col); + if (ENDIAN_ORDER == B_ENDIAN) SWITCH_INT(col); return WM_framebuffer_to_index(col); } @@ -1394,47 +1395,47 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, short xminc, yminc, xmaxc, ymaxc, xs, ys; /* clip */ - if (xmin<0) xminc= 0; else xminc= xmin; - if (xmax >= vc->ar->winx) xmaxc= vc->ar->winx-1; else xmaxc= xmax; + if (xmin < 0) xminc = 0; else xminc = xmin; + if (xmax >= vc->ar->winx) xmaxc = vc->ar->winx - 1; else xmaxc = xmax; if (xminc > xmaxc) return NULL; - if (ymin<0) yminc= 0; else yminc= ymin; - if (ymax >= vc->ar->winy) ymaxc= vc->ar->winy-1; else ymaxc= ymax; + if (ymin < 0) yminc = 0; else yminc = ymin; + if (ymax >= vc->ar->winy) ymaxc = vc->ar->winy - 1; else ymaxc = ymax; if (yminc > ymaxc) return NULL; - ibuf= IMB_allocImBuf((xmaxc-xminc+1), (ymaxc-yminc+1), 32, IB_rect); + ibuf = IMB_allocImBuf((xmaxc - xminc + 1), (ymaxc - yminc + 1), 32, IB_rect); view3d_validate_backbuf(vc); glReadPixels(vc->ar->winrct.xmin + xminc, vc->ar->winrct.ymin + yminc, - (xmaxc-xminc + 1), - (ymaxc-yminc + 1), + (xmaxc - xminc + 1), + (ymaxc - yminc + 1), GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); glReadBuffer(GL_BACK); - if (ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); + if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); - a= (xmaxc-xminc+1)*(ymaxc-yminc+1); - dr= ibuf->rect; + a = (xmaxc - xminc + 1) * (ymaxc - yminc + 1); + dr = ibuf->rect; while (a--) { - if (*dr) *dr= WM_framebuffer_to_index(*dr); + if (*dr) *dr = WM_framebuffer_to_index(*dr); dr++; } /* put clipped result back, if needed */ - if (xminc==xmin && xmaxc==xmax && yminc==ymin && ymaxc==ymax) + if (xminc == xmin && xmaxc == xmax && yminc == ymin && ymaxc == ymax) return ibuf; - ibuf1= IMB_allocImBuf( (xmax-xmin+1),(ymax-ymin+1),32,IB_rect); - rd= ibuf->rect; - dr= ibuf1->rect; - - for (ys= ymin; ys<=ymax; ys++) { - for (xs= xmin; xs<=xmax; xs++, dr++) { - if ( xs>=xminc && xs<=xmaxc && ys>=yminc && ys<=ymaxc) { - *dr= *rd; + ibuf1 = IMB_allocImBuf( (xmax - xmin + 1), (ymax - ymin + 1), 32, IB_rect); + rd = ibuf->rect; + dr = ibuf1->rect; + + for (ys = ymin; ys <= ymax; ys++) { + for (xs = xmin; xs <= xmax; xs++, dr++) { + if (xs >= xminc && xs <= xmaxc && ys >= yminc && ys <= ymaxc) { + *dr = *rd; rd++; } } @@ -1445,59 +1446,59 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, /* smart function to sample a rect spiralling outside, nice for backbuf selection */ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int size, - unsigned int min, unsigned int max, int *dist, short strict, - void *handle, unsigned int (*indextest)(void *handle, unsigned int index)) + unsigned int min, unsigned int max, int *dist, short strict, + void *handle, unsigned int (*indextest)(void *handle, unsigned int index)) { struct ImBuf *buf; unsigned int *bufmin, *bufmax, *tbuf; int minx, miny; int a, b, rc, nr, amount, dirvec[4][2]; - int distance=0; + int distance = 0; unsigned int index = 0; short indexok = 0; - amount= (size-1)/2; + amount = (size - 1) / 2; - minx = mval[0]-(amount+1); - miny = mval[1]-(amount+1); - buf = view3d_read_backbuf(vc, minx, miny, minx+size-1, miny+size-1); + minx = mval[0] - (amount + 1); + miny = mval[1] - (amount + 1); + buf = view3d_read_backbuf(vc, minx, miny, minx + size - 1, miny + size - 1); if (!buf) return 0; - rc= 0; + rc = 0; - dirvec[0][0]= 1; dirvec[0][1]= 0; - dirvec[1][0]= 0; dirvec[1][1]= -size; - dirvec[2][0]= -1; dirvec[2][1]= 0; - dirvec[3][0]= 0; dirvec[3][1]= size; + dirvec[0][0] = 1; dirvec[0][1] = 0; + dirvec[1][0] = 0; dirvec[1][1] = -size; + dirvec[2][0] = -1; dirvec[2][1] = 0; + dirvec[3][0] = 0; dirvec[3][1] = size; bufmin = buf->rect; tbuf = buf->rect; - bufmax = buf->rect + size*size; - tbuf+= amount*size+ amount; + bufmax = buf->rect + size * size; + tbuf += amount * size + amount; - for (nr=1; nr<=size; nr++) { + for (nr = 1; nr <= size; nr++) { - for (a=0; a<2; a++) { - for (b=0; b<nr; b++, distance++) { - if (*tbuf && *tbuf>=min && *tbuf<max) { //we got a hit + for (a = 0; a < 2; a++) { + for (b = 0; b < nr; b++, distance++) { + if (*tbuf && *tbuf >= min && *tbuf < max) { //we got a hit if (strict) { - indexok = indextest(handle, *tbuf - min+1); + indexok = indextest(handle, *tbuf - min + 1); if (indexok) { - *dist= (short) sqrt( (float)distance ); - index = *tbuf - min+1; + *dist = (short) sqrt( (float)distance); + index = *tbuf - min + 1; goto exit; } } else { - *dist= (short) sqrt( (float)distance ); // XXX, this distance is wrong - - index = *tbuf - min+1; // messy yah, but indices start at 1 + *dist = (short) sqrt( (float)distance); // XXX, this distance is wrong - + index = *tbuf - min + 1; // messy yah, but indices start at 1 goto exit; } } - tbuf+= (dirvec[rc][0]+dirvec[rc][1]); + tbuf += (dirvec[rc][0] + dirvec[rc][1]); - if (tbuf<bufmin || tbuf>=bufmax) { + if (tbuf < bufmin || tbuf >= bufmax) { goto exit; } } @@ -1516,98 +1517,98 @@ exit: static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; BGpic *bgpic; Image *ima; MovieClip *clip; - ImBuf *ibuf= NULL, *freeibuf; + ImBuf *ibuf = NULL, *freeibuf; float vec[4], fac, asp, zoomx, zoomy; float x1, y1, x2, y2, cx, cy; - for ( bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next ) { + for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) { - if ( (bgpic->view == 0) || /* zero for any */ - (bgpic->view & (1<<rv3d->view)) || /* check agaist flags */ - (rv3d->persp==RV3D_CAMOB && bgpic->view == (1<<RV3D_VIEW_CAMERA)) - ) { + if ((bgpic->view == 0) || /* zero for any */ + (bgpic->view & (1 << rv3d->view)) || /* check agaist flags */ + (rv3d->persp == RV3D_CAMOB && bgpic->view == (1 << RV3D_VIEW_CAMERA))) + { /* disable individual images */ - if ((bgpic->flag&V3D_BGPIC_DISABLED)) + if ((bgpic->flag & V3D_BGPIC_DISABLED)) continue; - freeibuf= NULL; - if (bgpic->source==V3D_BGPIC_IMAGE) { - ima= bgpic->ima; - if (ima==NULL) + freeibuf = NULL; + if (bgpic->source == V3D_BGPIC_IMAGE) { + ima = bgpic->ima; + if (ima == NULL) continue; BKE_image_user_calc_frame(&bgpic->iuser, CFRA, 0); - ibuf= BKE_image_get_ibuf(ima, &bgpic->iuser); + ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); } else { - clip= NULL; + clip = NULL; - if (bgpic->flag&V3D_BGPIC_CAMERACLIP) { + if (bgpic->flag & V3D_BGPIC_CAMERACLIP) { if (scene->camera) - clip= object_get_movieclip(scene, scene->camera, 1); + clip = object_get_movieclip(scene, scene->camera, 1); } - else clip= bgpic->clip; + else clip = bgpic->clip; - if (clip==NULL) + if (clip == NULL) continue; BKE_movieclip_user_set_frame(&bgpic->cuser, CFRA); - ibuf= BKE_movieclip_get_ibuf(clip, &bgpic->cuser); + ibuf = BKE_movieclip_get_ibuf(clip, &bgpic->cuser); /* working with ibuf from image and clip has got different workflow now. * ibuf acquired from clip is referenced by cache system and should * be dereferenced after usage. */ - freeibuf= ibuf; + freeibuf = ibuf; } - if (ibuf==NULL) + if (ibuf == NULL) continue; - if ((ibuf->rect==NULL && ibuf->rect_float==NULL) || ibuf->channels!=4) { /* invalid image format */ + if ((ibuf->rect == NULL && ibuf->rect_float == NULL) || ibuf->channels != 4) { /* invalid image format */ if (freeibuf) IMB_freeImBuf(freeibuf); continue; } - if (ibuf->rect==NULL) + if (ibuf->rect == NULL) IMB_rect_from_float(ibuf); - if (rv3d->persp==RV3D_CAMOB) { + if (rv3d->persp == RV3D_CAMOB) { rctf vb; ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE); - x1= vb.xmin; - y1= vb.ymin; - x2= vb.xmax; - y2= vb.ymax; + x1 = vb.xmin; + y1 = vb.ymin; + x2 = vb.xmax; + y2 = vb.ymax; } else { float sco[2]; - const float mval_f[2]= {1.0f, 0.0f}; + const float mval_f[2] = {1.0f, 0.0f}; /* calc window coord */ initgrabz(rv3d, 0.0, 0.0, 0.0); ED_view3d_win_to_delta(ar, mval_f, vec); - fac= maxf(fabsf(vec[0]), maxf(fabsf(vec[1]), fabsf(vec[2]))); /* largest abs axis */ - fac= 1.0f/fac; + fac = maxf(fabsf(vec[0]), maxf(fabsf(vec[1]), fabsf(vec[2]))); /* largest abs axis */ + fac = 1.0f / fac; - asp= ( (float)ibuf->y)/(float)ibuf->x; + asp = ( (float)ibuf->y) / (float)ibuf->x; zero_v3(vec); ED_view3d_project_float_v2(ar, vec, sco, rv3d->persmat); cx = sco[0]; cy = sco[1]; - x1= cx+ fac*(bgpic->xof-bgpic->size); - y1= cy+ asp*fac*(bgpic->yof-bgpic->size); - x2= cx+ fac*(bgpic->xof+bgpic->size); - y2= cy+ asp*fac*(bgpic->yof+bgpic->size); + x1 = cx + fac * (bgpic->xof - bgpic->size); + y1 = cy + asp * fac * (bgpic->yof - bgpic->size); + x2 = cx + fac * (bgpic->xof + bgpic->size); + y2 = cy + asp * fac * (bgpic->yof + bgpic->size); } /* complete clip? */ @@ -1619,29 +1620,29 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) continue; } - zoomx= (x2-x1)/ibuf->x; - zoomy= (y2-y1)/ibuf->y; + zoomx = (x2 - x1) / ibuf->x; + zoomy = (y2 - y1) / ibuf->y; /* for some reason; zoomlevels down refuses to use GL_ALPHA_SCALE */ if (zoomx < 1.0f || zoomy < 1.0f) { - float tzoom= MIN2(zoomx, zoomy); - int mip= 0; + float tzoom = MIN2(zoomx, zoomy); + int mip = 0; - if ((ibuf->userflags&IB_MIPMAP_INVALID) != 0) { + if ((ibuf->userflags & IB_MIPMAP_INVALID) != 0) { IMB_remakemipmap(ibuf, 0); - ibuf->userflags&= ~IB_MIPMAP_INVALID; + ibuf->userflags &= ~IB_MIPMAP_INVALID; } - else if (ibuf->mipmap[0]==NULL) + else if (ibuf->mipmap[0] == NULL) IMB_makemipmap(ibuf, 0); - while (tzoom < 1.0f && mip<8 && ibuf->mipmap[mip]) { - tzoom*= 2.0f; - zoomx*= 2.0f; - zoomy*= 2.0f; + while (tzoom < 1.0f && mip < 8 && ibuf->mipmap[mip]) { + tzoom *= 2.0f; + zoomx *= 2.0f; + zoomy *= 2.0f; mip++; } - if (mip>0) - ibuf= ibuf->mipmap[mip-1]; + if (mip > 0) + ibuf = ibuf->mipmap[mip - 1]; } if (v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -1657,7 +1658,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) ED_region_pixelspace(ar); glPixelZoom(zoomx, zoomy); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f-bgpic->blend); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f - bgpic->blend); glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); glPixelZoom(1.0, 1.0); @@ -1690,10 +1691,10 @@ typedef struct View3DAfter { /* temp storage of Objects that need to be drawn as last */ void add_view3d_after(ListBase *lb, Base *base, int flag) { - View3DAfter *v3da= MEM_callocN(sizeof(View3DAfter), "View 3d after"); + View3DAfter *v3da = MEM_callocN(sizeof(View3DAfter), "View 3d after"); BLI_addtail(lb, v3da); - v3da->base= base; - v3da->flag= flag; + v3da->base = base; + v3da->flag = flag; } /* disables write in zbuffer and draws it over */ @@ -1702,15 +1703,15 @@ static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d) View3DAfter *v3da, *next; glDepthMask(0); - v3d->transp= TRUE; + v3d->transp = TRUE; - for (v3da= v3d->afterdraw_transp.first; v3da; v3da= next) { - next= v3da->next; + for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { + next = v3da->next; draw_object(scene, ar, v3d, v3da->base, v3da->flag); BLI_remlink(&v3d->afterdraw_transp, v3da); MEM_freeN(v3da); } - v3d->transp= FALSE; + v3d->transp = FALSE; glDepthMask(1); @@ -1724,14 +1725,14 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear) if (clear && v3d->zbuf) glClear(GL_DEPTH_BUFFER_BIT); - v3d->xray= TRUE; - for (v3da= v3d->afterdraw_xray.first; v3da; v3da= next) { - next= v3da->next; + v3d->xray = TRUE; + for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { + next = v3da->next; draw_object(scene, ar, v3d, v3da->base, v3da->flag); BLI_remlink(&v3d->afterdraw_xray, v3da); MEM_freeN(v3da); } - v3d->xray= FALSE; + v3d->xray = FALSE; } @@ -1743,18 +1744,18 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int c if (clear && v3d->zbuf) glClear(GL_DEPTH_BUFFER_BIT); - v3d->xray= TRUE; - v3d->transp= TRUE; + v3d->xray = TRUE; + v3d->transp = TRUE; - for (v3da= v3d->afterdraw_xraytransp.first; v3da; v3da= next) { - next= v3da->next; + for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { + next = v3da->next; draw_object(scene, ar, v3d, v3da->base, v3da->flag); BLI_remlink(&v3d->afterdraw_xraytransp, v3da); MEM_freeN(v3da); } - v3d->transp= FALSE; - v3d->xray= FALSE; + v3d->transp = FALSE; + v3d->xray = FALSE; } @@ -1769,11 +1770,11 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int c #if 0 int dupli_ob_sort(void *arg1, void *arg2) { - void *p1= ((DupliObject *)arg1)->ob; - void *p2= ((DupliObject *)arg2)->ob; + void *p1 = ((DupliObject *)arg1)->ob; + void *p2 = ((DupliObject *)arg2)->ob; int val = 0; - if (p1 < p2) val = -1; - else if (p1 > p2) val = 1; + if (p1 < p2) val = -1; + else if (p1 > p2) val = 1; return val; } #endif @@ -1782,40 +1783,40 @@ int dupli_ob_sort(void *arg1, void *arg2) static DupliObject *dupli_step(DupliObject *dob) { while (dob && dob->no_draw) - dob= dob->next; + dob = dob->next; return dob; } static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int color) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; ListBase *lb; - DupliObject *dob_prev= NULL, *dob, *dob_next= NULL; + DupliObject *dob_prev = NULL, *dob, *dob_next = NULL; Base tbase; BoundBox bb, *bb_tmp; /* use a copy because draw_object, calls clear_mesh_caches */ - GLuint displist=0; - short transflag, use_displist= -1; /* -1 is initialize */ + GLuint displist = 0; + short transflag, use_displist = -1; /* -1 is initialize */ char dt, dtx; if (base->object->restrictflag & OB_RESTRICT_VIEW) return; - tbase.flag= OB_FROMDUPLI|base->flag; - lb= object_duplilist(scene, base->object); + tbase.flag = OB_FROMDUPLI | base->flag; + lb = object_duplilist(scene, base->object); // BLI_sortlist(lb, dupli_ob_sort); // might be nice to have if we have a dupli list with mixed objects. - dob=dupli_step(lb->first); - if (dob) dob_next= dupli_step(dob->next); + dob = dupli_step(lb->first); + if (dob) dob_next = dupli_step(dob->next); - for ( ; dob ; dob_prev= dob, dob= dob_next, dob_next= dob_next ? dupli_step(dob_next->next) : NULL) { - tbase.object= dob->ob; + for (; dob; dob_prev = dob, dob = dob_next, dob_next = dob_next ? dupli_step(dob_next->next) : NULL) { + tbase.object = dob->ob; /* extra service: draw the duplicator in drawtype of parent */ /* MIN2 for the drawtype to allow bounding box objects in groups for lods */ - dt= tbase.object->dt; tbase.object->dt= MIN2(tbase.object->dt, base->object->dt); - dtx= tbase.object->dtx; tbase.object->dtx= base->object->dtx; + dt = tbase.object->dt; tbase.object->dt = MIN2(tbase.object->dt, base->object->dt); + dtx = tbase.object->dtx; tbase.object->dtx = base->object->dtx; /* negative scale flag has to propagate */ - transflag= tbase.object->transflag; + transflag = tbase.object->transflag; if (base->object->transflag & OB_NEG_SCALE) tbase.object->transflag ^= OB_NEG_SCALE; @@ -1823,10 +1824,10 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas /* generate displist, test for new object */ if (dob_prev && dob_prev->ob != dob->ob) { - if (use_displist==1) + if (use_displist == 1) glDeleteLists(displist, 1); - use_displist= -1; + use_displist = -1; } /* generate displist */ @@ -1837,31 +1838,31 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas * offset feature (used in group-duplicate.blend but no longer works in 2.5) * so for now it should be ok to - campbell */ - if ( /* if this is the last no need to make a displist */ - (dob_next==NULL || dob_next->ob != dob->ob) || - /* lamp drawing messes with matrices, could be handled smarter... but this works */ - (dob->ob->type == OB_LAMP) || - (dob->type == OB_DUPLIGROUP && dob->animated) || - !(bb_tmp= object_get_boundbox(dob->ob))) + if (/* if this is the last no need to make a displist */ + (dob_next == NULL || dob_next->ob != dob->ob) || + /* lamp drawing messes with matrices, could be handled smarter... but this works */ + (dob->ob->type == OB_LAMP) || + (dob->type == OB_DUPLIGROUP && dob->animated) || + !(bb_tmp = object_get_boundbox(dob->ob))) { // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name+2); - use_displist= 0; + use_displist = 0; } else { // printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name+2); - bb= *bb_tmp; /* must make a copy */ + bb = *bb_tmp; /* must make a copy */ /* disable boundbox check for list creation */ object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); /* need this for next part of code */ - unit_m4(dob->ob->obmat); /* obmat gets restored */ + unit_m4(dob->ob->obmat); /* obmat gets restored */ - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR); glEndList(); - use_displist= 1; + use_displist = 1; object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); } } @@ -1876,14 +1877,14 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR); } - tbase.object->dt= dt; - tbase.object->dtx= dtx; - tbase.object->transflag= transflag; + tbase.object->dt = dt; + tbase.object->dtx = dtx; + tbase.object->transflag = transflag; } /* Transp afterdraw disabled, afterdraw only stores base pointers, and duplis can be same obj */ - free_object_duplilist(lb); /* does restore */ + free_object_duplilist(lb); /* does restore */ if (use_displist) glDeleteLists(displist, 1); @@ -1894,10 +1895,10 @@ static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *bas /* define the color here so draw_dupli_objects_color can be called * from the set loop */ - int color= (base->flag & SELECT)?TH_SELECT:TH_WIRE; + int color = (base->flag & SELECT) ? TH_SELECT : TH_WIRE; /* debug */ - if (base->object->dup_group && base->object->dup_group->id.us<1) - color= TH_REDALERT; + if (base->object->dup_group && base->object->dup_group->id.us < 1) + color = TH_REDALERT; draw_dupli_objects_color(scene, ar, v3d, base, color); } @@ -1909,80 +1910,82 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) /* clamp rect by area */ r.xmin = 0; - r.xmax = ar->winx-1; + r.xmax = ar->winx - 1; r.ymin = 0; - r.ymax = ar->winy-1; + r.ymax = ar->winy - 1; /* Constrain rect to depth bounds */ BLI_isect_rcti(&r, rect, rect); /* assign values to compare with the ViewDepths */ - x= rect->xmin; - y= rect->ymin; + x = rect->xmin; + y = rect->ymin; - w= rect->xmax - rect->xmin; - h= rect->ymax - rect->ymin; + w = rect->xmax - rect->xmin; + h = rect->ymax - rect->ymin; if (w <= 0 || h <= 0) { if (d->depths) MEM_freeN(d->depths); - d->depths= NULL; + d->depths = NULL; - d->damaged= FALSE; + d->damaged = FALSE; } - else if ( d->w != w || - d->h != h || - d->x != x || - d->y != y || - d->depths==NULL - ) { - d->x= x; - d->y= y; - d->w= w; - d->h= h; + else if (d->w != w || + d->h != h || + d->x != x || + d->y != y || + d->depths == NULL + ) + { + d->x = x; + d->y = y; + d->w = w; + d->h = h; if (d->depths) MEM_freeN(d->depths); - d->depths= MEM_mallocN(sizeof(float)*d->w*d->h,"View depths Subset"); + d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths Subset"); - d->damaged= TRUE; + d->damaged = TRUE; } if (d->damaged) { - glReadPixels(ar->winrct.xmin+d->x,ar->winrct.ymin+d->y, d->w,d->h, GL_DEPTH_COMPONENT,GL_FLOAT, d->depths); - glGetDoublev(GL_DEPTH_RANGE,d->depth_range); - d->damaged= FALSE; + glReadPixels(ar->winrct.xmin + d->x, ar->winrct.ymin + d->y, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths); + glGetDoublev(GL_DEPTH_RANGE, d->depth_range); + d->damaged = FALSE; } } /* note, with nouveau drivers the glReadPixels() is very slow. [#24339] */ void ED_view3d_depth_update(ARegion *ar) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; /* Create storage for, and, if necessary, copy depth buffer */ - if (!rv3d->depths) rv3d->depths= MEM_callocN(sizeof(ViewDepths),"ViewDepths"); + if (!rv3d->depths) rv3d->depths = MEM_callocN(sizeof(ViewDepths), "ViewDepths"); if (rv3d->depths) { - ViewDepths *d= rv3d->depths; + ViewDepths *d = rv3d->depths; if (d->w != ar->winx || - d->h != ar->winy || - !d->depths) { - d->w= ar->winx; - d->h= ar->winy; + d->h != ar->winy || + !d->depths) + { + d->w = ar->winx; + d->h = ar->winy; if (d->depths) MEM_freeN(d->depths); - d->depths= MEM_mallocN(sizeof(float)*d->w*d->h,"View depths"); - d->damaged= 1; + d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths"); + d->damaged = 1; } if (d->damaged) { - glReadPixels(ar->winrct.xmin,ar->winrct.ymin,d->w,d->h, - GL_DEPTH_COMPONENT,GL_FLOAT, d->depths); + glReadPixels(ar->winrct.xmin, ar->winrct.ymin, d->w, d->h, + GL_DEPTH_COMPONENT, GL_FLOAT, d->depths); - glGetDoublev(GL_DEPTH_RANGE,d->depth_range); + glGetDoublev(GL_DEPTH_RANGE, d->depth_range); - d->damaged= 0; + d->damaged = 0; } } } @@ -1991,20 +1994,20 @@ void ED_view3d_depth_update(ARegion *ar) float view3d_depth_near(ViewDepths *d) { /* convert to float for comparisons */ - const float near= (float)d->depth_range[0]; - const float far_real= (float)d->depth_range[1]; - float far= far_real; + const float near = (float)d->depth_range[0]; + const float far_real = (float)d->depth_range[1]; + float far = far_real; - const float *depths= d->depths; - float depth= FLT_MAX; - int i= (int)d->w * (int)d->h; /* cast to avoid short overflow */ + const float *depths = d->depths; + float depth = FLT_MAX; + int i = (int)d->w * (int)d->h; /* cast to avoid short overflow */ /* far is both the starting 'far' value * and the closest value found. */ while (i--) { - depth= *depths++; + depth = *depths++; if ((depth < far) && (depth > near)) { - far= depth; + far = depth; } } @@ -2013,11 +2016,11 @@ float view3d_depth_near(ViewDepths *d) void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) { - short zbuf= v3d->zbuf; - RegionView3D *rv3d= ar->regiondata; + short zbuf = v3d->zbuf; + RegionView3D *rv3d = ar->regiondata; - setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2027,32 +2030,32 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) glLoadMatrixf(rv3d->viewmat); - v3d->zbuf= TRUE; + v3d->zbuf = TRUE; glEnable(GL_DEPTH_TEST); draw_gpencil_view3d(scene, v3d, ar, 1); - v3d->zbuf= zbuf; + v3d->zbuf = zbuf; } -void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) +void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *)) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; Base *base; - short zbuf= v3d->zbuf; - short flag= v3d->flag; - float glalphaclip= U.glalphaclip; - int obcenter_dia= U.obcenter_dia; + short zbuf = v3d->zbuf; + short flag = v3d->flag; + float glalphaclip = U.glalphaclip; + int obcenter_dia = U.obcenter_dia; /* temp set drawtype to solid */ /* Setting these temporarily is not nice */ v3d->flag &= ~V3D_SELECT_OUTLINE; U.glalphaclip = 0.5; /* not that nice but means we wont zoom into billboards */ - U.obcenter_dia= 0; + U.obcenter_dia = 0; - setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2067,7 +2070,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) ED_view3d_clipping_set(rv3d); } - v3d->zbuf= TRUE; + v3d->zbuf = TRUE; glEnable(GL_DEPTH_TEST); /* draw set first */ @@ -2085,7 +2088,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) } } - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (v3d->lay & base->lay) { if (func == NULL || func(base)) { /* dupli drawing */ @@ -2098,14 +2101,14 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) } /* this isn't that nice, draw xray objects as if they are normal */ - if ( v3d->afterdraw_transp.first || - v3d->afterdraw_xray.first || - v3d->afterdraw_xraytransp.first - ) { + if (v3d->afterdraw_transp.first || + v3d->afterdraw_xray.first || + v3d->afterdraw_xraytransp.first) + { View3DAfter *v3da, *next; int mask_orig; - v3d->xray= TRUE; + v3d->xray = TRUE; /* transp materials can change the depth mask, see #21388 */ glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); @@ -2113,44 +2116,44 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) if (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) { glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */ - for (v3da= v3d->afterdraw_xray.first; v3da; v3da= next) { - next= v3da->next; + for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { + next = v3da->next; draw_object(scene, ar, v3d, v3da->base, 0); } glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */ } /* draw 3 passes, transp/xray/xraytransp */ - v3d->xray= FALSE; - v3d->transp= TRUE; - for (v3da= v3d->afterdraw_transp.first; v3da; v3da= next) { - next= v3da->next; + v3d->xray = FALSE; + v3d->transp = TRUE; + for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { + next = v3da->next; draw_object(scene, ar, v3d, v3da->base, 0); BLI_remlink(&v3d->afterdraw_transp, v3da); MEM_freeN(v3da); } - v3d->xray= TRUE; - v3d->transp= FALSE; - for (v3da= v3d->afterdraw_xray.first; v3da; v3da= next) { - next= v3da->next; + v3d->xray = TRUE; + v3d->transp = FALSE; + for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { + next = v3da->next; draw_object(scene, ar, v3d, v3da->base, 0); BLI_remlink(&v3d->afterdraw_xray, v3da); MEM_freeN(v3da); } - v3d->xray= TRUE; - v3d->transp= TRUE; - for (v3da= v3d->afterdraw_xraytransp.first; v3da; v3da= next) { - next= v3da->next; + v3d->xray = TRUE; + v3d->transp = TRUE; + for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { + next = v3da->next; draw_object(scene, ar, v3d, v3da->base, 0); BLI_remlink(&v3d->afterdraw_xraytransp, v3da); MEM_freeN(v3da); } - v3d->xray= FALSE; - v3d->transp= FALSE; + v3d->xray = FALSE; + v3d->transp = FALSE; glDepthMask(mask_orig); } @@ -2163,7 +2166,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) U.glalphaclip = glalphaclip; v3d->flag = flag; - U.obcenter_dia= obcenter_dia; + U.obcenter_dia = obcenter_dia; } typedef struct View3DShadow { @@ -2175,7 +2178,7 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object float obmat[][4], ListBase *shadows) { GPULamp *lamp; - Lamp *la = (Lamp*)ob->data; + Lamp *la = (Lamp *)ob->data; View3DShadow *shadow; lamp = GPU_lamp_from_blender(scene, ob, par); @@ -2185,7 +2188,7 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy); if ((ob->lay & v3d->lay) && GPU_lamp_has_shadow_buffer(lamp)) { - shadow= MEM_callocN(sizeof(View3DShadow), "View3DShadow"); + shadow = MEM_callocN(sizeof(View3DShadow), "View3DShadow"); shadow->lamp = lamp; BLI_addtail(shadows, shadow); } @@ -2200,11 +2203,11 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) Base *base; Object *ob; - shadows.first= shadows.last= NULL; + shadows.first = shadows.last = NULL; /* update lamp transform and gather shadow lamps */ for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; + ob = base->object; if (ob->type == OB_LAMP) gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, &shadows); @@ -2213,8 +2216,8 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) DupliObject *dob; ListBase *lb = object_duplilist(scene, ob); - for (dob=lb->first; dob; dob=dob->next) - if (dob->ob->type==OB_LAMP) + for (dob = lb->first; dob; dob = dob->next) + if (dob->ob->type == OB_LAMP) gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, &shadows); free_object_duplilist(lb); @@ -2223,15 +2226,15 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) /* render shadows after updating all lamps, nested object_duplilist * don't work correct since it's replacing object matrices */ - for (shadow=shadows.first; shadow; shadow=shadow->next) { + for (shadow = shadows.first; shadow; shadow = shadow->next) { /* this needs to be done better .. */ float viewmat[4][4], winmat[4][4]; - int drawtype, lay, winsize, flag2=v3d->flag2; - ARegion ar= {NULL}; - RegionView3D rv3d= {{{0}}}; + int drawtype, lay, winsize, flag2 = v3d->flag2; + ARegion ar = {NULL}; + RegionView3D rv3d = {{{0}}}; - drawtype= v3d->drawtype; - lay= v3d->lay; + drawtype = v3d->drawtype; + lay = v3d->lay; v3d->drawtype = OB_SOLID; v3d->lay &= GPU_lamp_shadow_layer(shadow->lamp); @@ -2240,9 +2243,9 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) GPU_lamp_shadow_buffer_bind(shadow->lamp, viewmat, &winsize, winmat); - ar.regiondata= &rv3d; - ar.regiontype= RGN_TYPE_WINDOW; - rv3d.persp= RV3D_CAMOB; + ar.regiondata = &rv3d; + ar.regiontype = RGN_TYPE_WINDOW; + rv3d.persp = RV3D_CAMOB; copy_m4_m4(rv3d.winmat, winmat); copy_m4_m4(rv3d.viewmat, viewmat); invert_m4_m4(rv3d.viewinv, rv3d.viewmat); @@ -2252,8 +2255,8 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE); GPU_lamp_shadow_buffer_unbind(shadow->lamp); - v3d->drawtype= drawtype; - v3d->lay= lay; + v3d->drawtype = drawtype; + v3d->lay = lay; v3d->flag2 = flag2; } @@ -2264,10 +2267,10 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d) { - CustomDataMask mask= 0; + CustomDataMask mask = 0; - if ( ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) || - ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) + if (ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) || + ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; @@ -2286,8 +2289,8 @@ CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d) CustomDataMask ED_view3d_object_datamask(Scene *scene) { - Object *ob= scene->basact ? scene->basact->object : NULL; - CustomDataMask mask= 0; + Object *ob = scene->basact ? scene->basact->object : NULL; + CustomDataMask mask = 0; if (ob) { /* check if we need tfaces & mcols due to face select or texture paint */ @@ -2311,7 +2314,7 @@ CustomDataMask ED_view3d_object_datamask(Scene *scene) /* goes over all modes and view3d settings */ CustomDataMask ED_view3d_screen_datamask(bScreen *screen) { - Scene *scene= screen->scene; + Scene *scene = screen->scene; CustomDataMask mask = CD_MASK_BAREMESH; ScrArea *sa; @@ -2335,13 +2338,13 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view if (winmat) copy_m4_m4(rv3d->winmat, winmat); else - setwinmatrixview3d(ar, v3d, NULL); /* NULL= no pickrect */ + setwinmatrixview3d(ar, v3d, NULL); /* NULL= no pickrect */ /* setup view matrix */ if (viewmat) copy_m4_m4(rv3d->viewmat, viewmat); else - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ /* update utilitity matrices */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); @@ -2355,16 +2358,16 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view float v1[3], v2[3]; float len1, len2; - v1[0]= rv3d->persmat[0][0]; - v1[1]= rv3d->persmat[1][0]; - v1[2]= rv3d->persmat[2][0]; + v1[0] = rv3d->persmat[0][0]; + v1[1] = rv3d->persmat[1][0]; + v1[2] = rv3d->persmat[2][0]; - v2[0]= rv3d->persmat[0][1]; - v2[1]= rv3d->persmat[1][1]; - v2[2]= rv3d->persmat[2][1]; + v2[0] = rv3d->persmat[0][1]; + v2[1] = rv3d->persmat[1][1]; + v2[2] = rv3d->persmat[2][1]; - len1= 1.0f / len_v3(v1); - len2= 1.0f / len_v3(v2); + len1 = 1.0f / len_v3(v1); + len2 = 1.0f / len_v3(v2); rv3d->pixsize = (2.0f * MAX2(len1, len2)) / (float)MAX2(ar->winx, ar->winy); } @@ -2387,7 +2390,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[][4], float winmat[][4], int draw_background) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; Base *base; float backcol[3]; int bwinx, bwiny; @@ -2397,12 +2400,12 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, glPushMatrix(); /* set temporary new size */ - bwinx= ar->winx; - bwiny= ar->winy; - brect= ar->winrct; + bwinx = ar->winx; + bwiny = ar->winy; + brect = ar->winrct; - ar->winx= winx; - ar->winy= winy; + ar->winx = winx; + ar->winy = winy; ar->winrct.xmin = 0; ar->winrct.ymin = 0; ar->winrct.xmax = winx; @@ -2421,7 +2424,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, gpu_update_lamps_shadows(scene, v3d); /* if scene has got active clip, use it for render backdrop */ - if (draw_background && scene->clip && rv3d->persp==RV3D_CAMOB && v3d->camera) { + if (draw_background && scene->clip && rv3d->persp == RV3D_CAMOB && v3d->camera) { MovieClipUser user = {0}; BKE_movieclip_user_set_frame(&user, CFRA); @@ -2443,7 +2446,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, } } - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (bg_ibuf) { unsigned char *pixels, *cp, *dst_cp; @@ -2452,9 +2455,9 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, if (bg_ibuf->rect_float && !bg_ibuf->rect) IMB_rect_from_float(bg_ibuf); - dst_cp = pixels = MEM_callocN(4*sizeof(unsigned char)*bg_ibuf->x*bg_ibuf->y, "draw offscreen clip pixels"); + dst_cp = pixels = MEM_callocN(4 * sizeof(unsigned char) * bg_ibuf->x * bg_ibuf->y, "draw offscreen clip pixels"); cp = (unsigned char *)bg_ibuf->rect; - for (i = 0; i < bg_ibuf->x*bg_ibuf->y; i++, cp += 4, dst_cp += 4) { + for (i = 0; i < bg_ibuf->x * bg_ibuf->y; i++, cp += 4, dst_cp += 4) { dst_cp[0] = cp[0]; dst_cp[1] = cp[1]; dst_cp[2] = cp[2]; @@ -2489,11 +2492,11 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, /* set zbuffer */ if (v3d->drawtype > OB_WIRE) { - v3d->zbuf= TRUE; + v3d->zbuf = TRUE; glEnable(GL_DEPTH_TEST); } else - v3d->zbuf= FALSE; + v3d->zbuf = FALSE; if (rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_set(rv3d); @@ -2504,7 +2507,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, for (SETLOOPER(scene->set, sce_iter, base)) { if (v3d->lay & base->lay) { UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f); - draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR|DRAW_SCENESET); + draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET); if (base->object->transflag & OB_DUPLI) draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE); @@ -2513,7 +2516,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, } /* then draw not selected and the duplis, but skip editmode object */ - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (v3d->lay & base->lay) { /* dupli drawing */ if (base->object->transflag & OB_DUPLI) @@ -2529,16 +2532,16 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, if (v3d->zbuf) glEnable(GL_DEPTH_TEST); /* transp and X-ray afterdraw stuff */ - if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); - if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! - if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); + if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); + if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! + if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); if (rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_disable(); /* cleanup */ if (v3d->zbuf) { - v3d->zbuf= FALSE; + v3d->zbuf = FALSE; glDisable(GL_DEPTH_TEST); } @@ -2552,8 +2555,8 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, GPU_free_images_anim(); /* restore size */ - ar->winx= bwinx; - ar->winy= bwiny; + ar->winx = bwinx; + ar->winy = bwiny; ar->winrct = brect; glPopMatrix(); @@ -2568,7 +2571,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag, int draw_background, char err_out[256]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; ImBuf *ibuf; GPUOffScreen *ofs; @@ -2576,14 +2579,14 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, glPushAttrib(GL_LIGHTING_BIT); /* bind */ - ofs= GPU_offscreen_create(sizex, sizey, err_out); + ofs = GPU_offscreen_create(sizex, sizey, err_out); if (ofs == NULL) return NULL; GPU_offscreen_bind(ofs); /* render 3d view */ - if (rv3d->persp==RV3D_CAMOB && v3d->camera) { + if (rv3d->persp == RV3D_CAMOB && v3d->camera) { CameraParams params; camera_params_init(¶ms); @@ -2598,7 +2601,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, } /* read in pixels & stamp */ - ibuf= IMB_allocImBuf(sizex, sizey, 32, flag); + ibuf = IMB_allocImBuf(sizex, sizey, 32, flag); if (ibuf->rect_float) GPU_offscreen_read_pixels(ofs, GL_FLOAT, ibuf->rect_float); @@ -2624,21 +2627,21 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height, unsigned int flag, int drawtype, int draw_background, char err_out[256]) { - View3D v3d= {NULL}; - ARegion ar= {NULL}; - RegionView3D rv3d= {{{0}}}; + View3D v3d = {NULL}; + ARegion ar = {NULL}; + RegionView3D rv3d = {{{0}}}; /* connect data */ - v3d.regionbase.first= v3d.regionbase.last= &ar; - ar.regiondata= &rv3d; - ar.regiontype= RGN_TYPE_WINDOW; + v3d.regionbase.first = v3d.regionbase.last = &ar; + ar.regiondata = &rv3d; + ar.regiontype = RGN_TYPE_WINDOW; - v3d.camera= camera; - v3d.lay= scene->lay; + v3d.camera = camera; + v3d.lay = scene->lay; v3d.drawtype = drawtype; v3d.flag2 = V3D_RENDER_OVERRIDE; - rv3d.persp= RV3D_CAMOB; + rv3d.persp = RV3D_CAMOB; copy_m4_m4(rv3d.viewinv, v3d.camera->obmat); normalize_m4(rv3d.viewinv); @@ -2653,9 +2656,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w camera_params_compute_matrix(¶ms); copy_m4_m4(rv3d.winmat, params.winmat); - v3d.near= params.clipsta; - v3d.far= params.clipend; - v3d.lens= params.lens; + v3d.near = params.clipsta; + v3d.far = params.clipend; + v3d.lens = params.lens; } mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat); @@ -2672,7 +2675,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w */ static void draw_viewport_fps(Scene *scene, ARegion *ar) { - ScreenFrameRateInfo *fpsi= scene->fps_info; + ScreenFrameRateInfo *fpsi = scene->fps_info; float fps; char printable[16]; int i, tot; @@ -2684,11 +2687,11 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) #if 0 /* this is too simple, better do an average */ - fps = (float)(1.0/(fpsi->lredrawtime-fpsi->redrawtime)) + fps = (float)(1.0 / (fpsi->lredrawtime - fpsi->redrawtime)) #else - fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0/(fpsi->lredrawtime-fpsi->redrawtime)); + fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0 / (fpsi->lredrawtime - fpsi->redrawtime)); - for (i=0, tot=0, fps=0.0f ; i < REDRAW_FRAME_AVERAGE ; i++) { + for (i = 0, tot = 0, fps = 0.0f; i < REDRAW_FRAME_AVERAGE; i++) { if (fpsi->redrawtimes_fps[i]) { fps += fpsi->redrawtimes_fps[i]; tot++; @@ -2705,44 +2708,44 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) } #endif - /* is this more then half a frame behind? */ - if (fps+0.5f < (float)(FPS)) { + /* is this more then half a frame behind? */ + if (fps + 0.5f < (float)(FPS)) { UI_ThemeColor(TH_REDALERT); BLI_snprintf(printable, sizeof(printable), "fps: %.2f", fps); } else { UI_ThemeColor(TH_TEXT_HI); - BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5f)); + BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps + 0.5f)); } - BLF_draw_default_ascii(22, ar->winy-17, 0.0f, printable, sizeof(printable)); + BLF_draw_default_ascii(22, ar->winy - 17, 0.0f, printable, sizeof(printable)); } static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); RenderEngineType *type; if (!rv3d->render_engine) { - type= RE_engines_find(scene->r.engine); + type = RE_engines_find(scene->r.engine); if (!(type->view_update && type->view_draw)) return 0; - rv3d->render_engine= RE_engine_create(type); + rv3d->render_engine = RE_engine_create(type); type->view_update(rv3d->render_engine, C); } view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ED_region_pixelspace(ar); - type= rv3d->render_engine->type; + type = rv3d->render_engine->type; type->view_draw(rv3d->render_engine, C); return 1; @@ -2759,9 +2762,9 @@ static void view3d_main_area_draw_engine_info(RegionView3D *rv3d, ARegion *ar) /* warning: this function has duplicate drawing in ED_view3d_draw_offscreen() */ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); Base *base; float backcol[3]; unsigned int lay_used; @@ -2787,7 +2790,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const else UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* setup view matrices */ view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL); @@ -2799,11 +2802,11 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const /* set zbuffer after we draw clipping region */ if (v3d->drawtype > OB_WIRE) { - v3d->zbuf= TRUE; + v3d->zbuf = TRUE; glEnable(GL_DEPTH_TEST); } else - v3d->zbuf= FALSE; + v3d->zbuf = FALSE; /* enables anti-aliasing for 3D view drawing */ #if 0 @@ -2812,26 +2815,26 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const #endif // needs to be done always, gridview is adjusted in drawgrid() now - rv3d->gridview= v3d->grid; + rv3d->gridview = v3d->grid; if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { drawfloor(scene, v3d, grid_unit); } - if (rv3d->persp==RV3D_CAMOB) { + if (rv3d->persp == RV3D_CAMOB) { if (scene->world) { if (scene->world->mode & WO_STARS) { RE_make_stars(NULL, scene, star_stuff_init_func, star_stuff_vertex_func, - star_stuff_term_func); + star_stuff_term_func); } } - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { if (v3d->flag & V3D_DISPBGPICS) draw_bgpic(scene, ar, v3d); } } } else { - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { ED_region_pixelspace(ar); drawgrid(&scene->unit, ar, v3d, grid_unit); /* XXX make function? replaces persp(1) */ @@ -2857,7 +2860,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const if (v3d->lay & base->lay) { UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f); - draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR|DRAW_SCENESET); + draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET); if (base->object->transflag & OB_DUPLI) { draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE); @@ -2868,11 +2871,11 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const /* Transp and X-ray afterdraw stuff for sets is done later */ } - lay_used= 0; + lay_used = 0; /* then draw not selected and the duplis, but skip editmode object */ - for (base= scene->base.first; base; base= base->next) { - lay_used |= base->lay & ((1<<20)-1); + for (base = scene->base.first; base; base = base->next) { + lay_used |= base->lay & ((1 << 20) - 1); if (v3d->lay & base->lay) { @@ -2880,8 +2883,8 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const if (base->object->transflag & OB_DUPLI) { draw_dupli_objects(scene, ar, v3d, base); } - if ((base->flag & SELECT)==0) { - if (base->object!=scene->obedit) + if ((base->flag & SELECT) == 0) { + if (base->object != scene->obedit) draw_object(scene, ar, v3d, base, 0); } } @@ -2889,23 +2892,23 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const if (v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */ /* find header and force tag redraw */ - ScrArea *sa= CTX_wm_area(C); - ARegion *ar_header= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); ED_region_tag_redraw(ar_header); /* can be NULL */ - v3d->lay_used= lay_used; + v3d->lay_used = lay_used; } /* draw selected and editmode */ - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (v3d->lay & base->lay) { - if (base->object==scene->obedit || ( base->flag & SELECT) ) + if (base->object == scene->obedit || (base->flag & SELECT) ) draw_object(scene, ar, v3d, base, 0); } } // REEB_draw(); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { /* must be before xray draw which clears the depth buffer */ if (v3d->zbuf) glDisable(GL_DEPTH_TEST); draw_gpencil_view3d(scene, v3d, ar, 1); @@ -2913,9 +2916,9 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const } /* Transp and X-ray afterdraw stuff */ - if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); - if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! - if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); + if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); + if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! + if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); @@ -2931,11 +2934,11 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const #endif if (v3d->zbuf) { - v3d->zbuf= FALSE; + v3d->zbuf = FALSE; glDisable(GL_DEPTH_TEST); } - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { BDR_drawSketch(C); } @@ -2947,20 +2950,20 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const char *grid_unit) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); - bScreen *screen= CTX_wm_screen(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + bScreen *screen = CTX_wm_screen(C); Object *ob; - if (rv3d->persp==RV3D_CAMOB) + if (rv3d->persp == RV3D_CAMOB) drawviewborder(scene, ar, v3d); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ - // if (v3d->flag2 & V3D_DISPGP) - draw_gpencil_view3d(scene, v3d, ar, 0); + // if (v3d->flag2 & V3D_DISPGP) + draw_gpencil_view3d(scene, v3d, ar, 0); drawcursor(scene, ar, v3d); } @@ -2970,7 +2973,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha else draw_view_icon(rv3d); - ob= OBACT; + ob = OBACT; if (U.uiflag & USER_DRAWVIEWINFO) draw_selected_name(scene, ob); @@ -2987,14 +2990,14 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha } if (grid_unit) { /* draw below the viewport name */ - char numstr[32]= ""; + char numstr[32] = ""; UI_ThemeColor(TH_TEXT_HI); if (v3d->grid != 1.0f) { BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid); } - BLF_draw_default_ascii(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, + BLF_draw_default_ascii(22, ar->winy - (USER_SHOW_VIEWPORTNAME ? 40 : 20), 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr)); } } @@ -3002,7 +3005,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha void view3d_main_area_draw(const bContext *C, ARegion *ar) { View3D *v3d = CTX_wm_view3d(C); - const char *grid_unit= NULL; + const char *grid_unit = NULL; /* draw viewport using external renderer? */ if (!(v3d->drawtype == OB_RENDER && view3d_main_area_draw_engine(C, ar))) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index f8404937f7e..94853927d4e 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -77,7 +77,7 @@ #include "PIL_time.h" /* smoothview */ -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include /* ********************** view3d_edit: view manipulations ********************* */ @@ -86,7 +86,7 @@ int ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d) return ((v3d->camera) && (v3d->camera->id.lib == NULL) && (v3d->flag2 & V3D_LOCK_CAMERA) && - (rv3d->persp==RV3D_CAMOB)); + (rv3d->persp == RV3D_CAMOB)); } void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) @@ -103,14 +103,14 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) ObjectTfmProtectedChannels obtfm; Object *root_parent; - if ((U.uiflag & USER_CAM_LOCK_NO_PARENT)==0 && (root_parent= v3d->camera->parent)) { + if ((U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0 && (root_parent = v3d->camera->parent)) { Object *ob_update; float view_mat[4][4]; float diff_mat[4][4]; float parent_mat[4][4]; while (root_parent->parent) { - root_parent= root_parent->parent; + root_parent = root_parent->parent; } ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); @@ -124,11 +124,11 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); - ob_update= v3d->camera; + ob_update = v3d->camera; while (ob_update) { DAG_id_tag_update(&ob_update->id, OB_RECALC_OB); - WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, ob_update); - ob_update= ob_update->parent; + WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, ob_update); + ob_update = ob_update->parent; } } else { @@ -137,7 +137,7 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); - WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera); + WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera); } return TRUE; @@ -155,73 +155,73 @@ static void view3d_boxview_clip(ScrArea *sa) ARegion *ar; BoundBox *bb = MEM_callocN(sizeof(BoundBox), "clipbb"); float clip[6][4]; - float x1= 0.0f, y1= 0.0f, z1= 0.0f, ofs[3] = {0.0f, 0.0f, 0.0f}; + float x1 = 0.0f, y1 = 0.0f, z1 = 0.0f, ofs[3] = {0.0f, 0.0f, 0.0f}; int val; /* create bounding box */ - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - RegionView3D *rv3d= ar->regiondata; + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = ar->regiondata; if (rv3d->viewlock & RV3D_BOXCLIP) { if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) { - if (ar->winx>ar->winy) x1= rv3d->dist; - else x1= ar->winx*rv3d->dist/ar->winy; + if (ar->winx > ar->winy) x1 = rv3d->dist; + else x1 = ar->winx * rv3d->dist / ar->winy; - if (ar->winx>ar->winy) y1= ar->winy*rv3d->dist/ar->winx; - else y1= rv3d->dist; + if (ar->winx > ar->winy) y1 = ar->winy * rv3d->dist / ar->winx; + else y1 = rv3d->dist; copy_v2_v2(ofs, rv3d->ofs); } else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) { - ofs[2]= rv3d->ofs[2]; + ofs[2] = rv3d->ofs[2]; - if (ar->winx>ar->winy) z1= ar->winy*rv3d->dist/ar->winx; - else z1= rv3d->dist; + if (ar->winx > ar->winy) z1 = ar->winy * rv3d->dist / ar->winx; + else z1 = rv3d->dist; } } } } - for (val=0; val<8; val++) { + for (val = 0; val < 8; val++) { if (ELEM4(val, 0, 3, 4, 7)) - bb->vec[val][0]= -x1 - ofs[0]; + bb->vec[val][0] = -x1 - ofs[0]; else - bb->vec[val][0]= x1 - ofs[0]; + bb->vec[val][0] = x1 - ofs[0]; if (ELEM4(val, 0, 1, 4, 5)) - bb->vec[val][1]= -y1 - ofs[1]; + bb->vec[val][1] = -y1 - ofs[1]; else - bb->vec[val][1]= y1 - ofs[1]; + bb->vec[val][1] = y1 - ofs[1]; if (val > 3) - bb->vec[val][2]= -z1 - ofs[2]; + bb->vec[val][2] = -z1 - ofs[2]; else - bb->vec[val][2]= z1 - ofs[2]; + bb->vec[val][2] = z1 - ofs[2]; } /* normals for plane equations */ - normal_tri_v3( clip[0],bb->vec[0], bb->vec[1], bb->vec[4]); - normal_tri_v3( clip[1],bb->vec[1], bb->vec[2], bb->vec[5]); - normal_tri_v3( clip[2],bb->vec[2], bb->vec[3], bb->vec[6]); - normal_tri_v3( clip[3],bb->vec[3], bb->vec[0], bb->vec[7]); - normal_tri_v3( clip[4],bb->vec[4], bb->vec[5], bb->vec[6]); - normal_tri_v3( clip[5],bb->vec[0], bb->vec[2], bb->vec[1]); + normal_tri_v3(clip[0], bb->vec[0], bb->vec[1], bb->vec[4]); + normal_tri_v3(clip[1], bb->vec[1], bb->vec[2], bb->vec[5]); + normal_tri_v3(clip[2], bb->vec[2], bb->vec[3], bb->vec[6]); + normal_tri_v3(clip[3], bb->vec[3], bb->vec[0], bb->vec[7]); + normal_tri_v3(clip[4], bb->vec[4], bb->vec[5], bb->vec[6]); + normal_tri_v3(clip[5], bb->vec[0], bb->vec[2], bb->vec[1]); /* then plane equations */ - for (val=0; val<6; val++) { + for (val = 0; val < 6; val++) { clip[val][3] = -dot_v3v3(clip[val], bb->vec[val % 5]); } /* create bounding box */ - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - RegionView3D *rv3d= ar->regiondata; + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = ar->regiondata; if (rv3d->viewlock & RV3D_BOXCLIP) { rv3d->rflag |= RV3D_CLIPPING; memcpy(rv3d->clip, clip, sizeof(clip)); if (rv3d->clipbb) MEM_freeN(rv3d->clipbb); - rv3d->clipbb= MEM_dupallocN(bb); + rv3d->clipbb = MEM_dupallocN(bb); } } } @@ -232,33 +232,33 @@ static void view3d_boxview_clip(ScrArea *sa) static void view3d_boxview_sync(ScrArea *sa, ARegion *ar) { ARegion *artest; - RegionView3D *rv3d= ar->regiondata; - short clip= 0; + RegionView3D *rv3d = ar->regiondata; + short clip = 0; - for (artest= sa->regionbase.first; artest; artest= artest->next) { - if (artest!=ar && artest->regiontype==RGN_TYPE_WINDOW) { - RegionView3D *rv3dtest= artest->regiondata; + for (artest = sa->regionbase.first; artest; artest = artest->next) { + if (artest != ar && artest->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3dtest = artest->regiondata; if (rv3dtest->viewlock) { - rv3dtest->dist= rv3d->dist; + rv3dtest->dist = rv3d->dist; - if ( ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM) ) { - if ( ELEM(rv3dtest->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) - rv3dtest->ofs[0]= rv3d->ofs[0]; - else if ( ELEM(rv3dtest->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) - rv3dtest->ofs[1]= rv3d->ofs[1]; + if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM) ) { + if (ELEM(rv3dtest->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) + rv3dtest->ofs[0] = rv3d->ofs[0]; + else if (ELEM(rv3dtest->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) + rv3dtest->ofs[1] = rv3d->ofs[1]; } - else if ( ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK) ) { - if ( ELEM(rv3dtest->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) - rv3dtest->ofs[0]= rv3d->ofs[0]; - else if ( ELEM(rv3dtest->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) - rv3dtest->ofs[2]= rv3d->ofs[2]; + else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK) ) { + if (ELEM(rv3dtest->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) + rv3dtest->ofs[0] = rv3d->ofs[0]; + else if (ELEM(rv3dtest->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) + rv3dtest->ofs[2] = rv3d->ofs[2]; } - else if ( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT) ) { - if ( ELEM(rv3dtest->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) - rv3dtest->ofs[1]= rv3d->ofs[1]; - if ( ELEM(rv3dtest->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) - rv3dtest->ofs[2]= rv3d->ofs[2]; + else if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT) ) { + if (ELEM(rv3dtest->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) + rv3dtest->ofs[1] = rv3d->ofs[1]; + if (ELEM(rv3dtest->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) + rv3dtest->ofs[2] = rv3d->ofs[2]; } clip |= rv3dtest->viewlock & RV3D_BOXCLIP; @@ -277,15 +277,15 @@ static void view3d_boxview_sync(ScrArea *sa, ARegion *ar) void view3d_boxview_copy(ScrArea *sa, ARegion *ar) { ARegion *artest; - RegionView3D *rv3d= ar->regiondata; - short clip= 0; + RegionView3D *rv3d = ar->regiondata; + short clip = 0; - for (artest= sa->regionbase.first; artest; artest= artest->next) { - if (artest!=ar && artest->regiontype==RGN_TYPE_WINDOW) { - RegionView3D *rv3dtest= artest->regiondata; + for (artest = sa->regionbase.first; artest; artest = artest->next) { + if (artest != ar && artest->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3dtest = artest->regiondata; if (rv3dtest->viewlock) { - rv3dtest->dist= rv3d->dist; + rv3dtest->dist = rv3d->dist; copy_v3_v3(rv3dtest->ofs, rv3d->ofs); ED_region_tag_redraw(artest); @@ -302,34 +302,34 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar) /* 'clip' is used to know if our clip setting has changed */ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, short do_clip) { - ARegion *ar_sync= NULL; - RegionView3D *rv3d= ar->regiondata; + ARegion *ar_sync = NULL; + RegionView3D *rv3d = ar->regiondata; short viewlock; /* this function copies flags from the first of the 3 other quadview * regions to the 2 other, so it assumes this is the region whose * properties are always being edited, weak */ - viewlock= rv3d->viewlock; + viewlock = rv3d->viewlock; - if ((viewlock & RV3D_LOCKED)==0) - viewlock= 0; - else if ((viewlock & RV3D_BOXVIEW)==0) { + if ((viewlock & RV3D_LOCKED) == 0) + viewlock = 0; + else if ((viewlock & RV3D_BOXVIEW) == 0) { viewlock &= ~RV3D_BOXCLIP; - do_clip= TRUE; + do_clip = TRUE; } - for (; ar; ar= ar->prev) { - if (ar->alignment==RGN_ALIGN_QSPLIT) { - rv3d= ar->regiondata; - rv3d->viewlock= viewlock; + for (; ar; ar = ar->prev) { + if (ar->alignment == RGN_ALIGN_QSPLIT) { + rv3d = ar->regiondata; + rv3d->viewlock = viewlock; - if (do_clip && (viewlock & RV3D_BOXCLIP)==0) { + if (do_clip && (viewlock & RV3D_BOXCLIP) == 0) { rv3d->rflag &= ~RV3D_BOXCLIP; } /* use ar_sync so we sync with one of the aligned views below * else the view jumps on changing view settings like 'clip' * since it copies from the perspective view */ - ar_sync= ar; + ar_sync = ar; } } @@ -375,54 +375,54 @@ static void calctrackballvec(rcti *rect, int mx, int my, float vec[3]) { float x, y, radius, d, z, t; - radius= TRACKBALLSIZE; + radius = TRACKBALLSIZE; /* normalize x and y */ - x= (rect->xmax + rect->xmin)/2 - mx; - x/= (float)((rect->xmax - rect->xmin)/4); - y= (rect->ymax + rect->ymin)/2 - my; - y/= (float)((rect->ymax - rect->ymin)/2); + x = (rect->xmax + rect->xmin) / 2 - mx; + x /= (float)((rect->xmax - rect->xmin) / 4); + y = (rect->ymax + rect->ymin) / 2 - my; + y /= (float)((rect->ymax - rect->ymin) / 2); - d = sqrt(x*x + y*y); + d = sqrt(x * x + y * y); if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */ - z= sqrt(radius*radius - d*d); + z = sqrt(radius * radius - d * d); } else { /* On hyperbola */ - t= radius / (float)M_SQRT2; - z= t*t / d; + t = radius / (float)M_SQRT2; + z = t * t / d; } - vec[0]= x; - vec[1]= y; - vec[2]= -z; /* yah yah! */ + vec[0] = x; + vec[1] = y; + vec[2] = -z; /* yah yah! */ } static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) { - static float lastofs[3] = {0,0,0}; + static float lastofs[3] = {0, 0, 0}; RegionView3D *rv3d; - ViewOpsData *vod= MEM_callocN(sizeof(ViewOpsData), "viewops data"); + ViewOpsData *vod = MEM_callocN(sizeof(ViewOpsData), "viewops data"); /* store data */ - op->customdata= vod; - vod->sa= CTX_wm_area(C); - vod->ar= CTX_wm_region(C); - vod->v3d= vod->sa->spacedata.first; - vod->rv3d= rv3d= vod->ar->regiondata; + op->customdata = vod; + vod->sa = CTX_wm_area(C); + vod->ar = CTX_wm_region(C); + vod->v3d = vod->sa->spacedata.first; + vod->rv3d = rv3d = vod->ar->regiondata; /* set the view from the camera, if view locking is enabled. * we may want to make this optional but for now its needed always */ ED_view3d_camera_lock_init(vod->v3d, vod->rv3d); - vod->dist0= rv3d->dist; - vod->camzoom0= rv3d->camzoom; + vod->dist0 = rv3d->dist; + vod->camzoom0 = rv3d->camzoom; copy_qt_qt(vod->viewquat, rv3d->viewquat); copy_qt_qt(vod->oldquat, rv3d->viewquat); - vod->origx= vod->oldx= event->x; - vod->origy= vod->oldy= event->y; - vod->origkey= event->type; /* the key that triggered the operator. */ - vod->use_dyn_ofs= (U.uiflag & USER_ORBIT_SELECTION) ? 1:0; + vod->origx = vod->oldx = event->x; + vod->origy = vod->oldy = event->y; + vod->origkey = event->type; /* the key that triggered the operator. */ + vod->use_dyn_ofs = (U.uiflag & USER_ORBIT_SELECTION) ? 1 : 0; copy_v3_v3(vod->ofs, rv3d->ofs); if (vod->use_dyn_ofs) { @@ -434,7 +434,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) view3d_operator_needs_opengl(C); /* needed for zbuf drawing */ - if ((vod->use_dyn_ofs=ED_view3d_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs))) { + if ((vod->use_dyn_ofs = ED_view3d_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs))) { if (rv3d->is_persp) { float my_origin[3]; /* original G.vd->ofs */ float my_pivot[3]; /* view */ @@ -444,7 +444,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) float mat[3][3]; float upvec[3]; - negate_v3_v3(my_origin, rv3d->ofs); /* ofs is flipped */ + negate_v3_v3(my_origin, rv3d->ofs); /* ofs is flipped */ /* Set the dist value to be the distance from this 3d point * this means youll always be able to zoom into it and panning wont go bad when dist was zero */ @@ -456,7 +456,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) mul_m3_v3(mat, upvec); sub_v3_v3v3(my_pivot, rv3d->ofs, upvec); - negate_v3(my_pivot); /* ofs is flipped */ + negate_v3(my_pivot); /* ofs is flipped */ /* find a new ofs value that is along the view axis (rather than the mouse location) */ closest_to_line_v3(dvec, vod->dyn_ofs, my_pivot, my_origin); @@ -477,16 +477,16 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) } /* lookup, we don't pass on v3d to prevent confusement */ - vod->grid= vod->v3d->grid; - vod->far= vod->v3d->far; + vod->grid = vod->v3d->grid; + vod->far = vod->v3d->far; calctrackballvec(&vod->ar->winrct, event->x, event->y, vod->trackvec); initgrabz(rv3d, -rv3d->ofs[0], -rv3d->ofs[1], -rv3d->ofs[2]); - vod->reverse= 1.0f; + vod->reverse = 1.0f; if (rv3d->persmat[2][1] < 0.0f) - vod->reverse= -1.0f; + vod->reverse = -1.0f; rv3d->rflag |= RV3D_NAVIGATING; } @@ -497,18 +497,18 @@ static void viewops_data_free(bContext *C, wmOperator *op) Paint *p = paint_get_active(CTX_data_scene(C)); if (op->customdata) { - ViewOpsData *vod= op->customdata; - ar= vod->ar; + ViewOpsData *vod = op->customdata; + ar = vod->ar; vod->rv3d->rflag &= ~RV3D_NAVIGATING; if (vod->timer) WM_event_remove_timer(CTX_wm_manager(C), vod->timer->win, vod->timer); MEM_freeN(vod); - op->customdata= NULL; + op->customdata = NULL; } else { - ar= CTX_wm_region(C); + ar = CTX_wm_region(C); } if (p && (p->flags & PAINT_FAST_NAVIGATE)) @@ -568,39 +568,40 @@ static const float snapquats[NUM_SNAP_QUATS][5] = { }; enum { - VIEW_PASS= 0, + VIEW_PASS = 0, VIEW_APPLY, VIEW_CONFIRM }; /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */ -#define VIEW_MODAL_CONFIRM 1 /* used for all view operations */ -#define VIEWROT_MODAL_AXIS_SNAP_ENABLE 2 -#define VIEWROT_MODAL_AXIS_SNAP_DISABLE 3 -#define VIEWROT_MODAL_SWITCH_ZOOM 4 -#define VIEWROT_MODAL_SWITCH_MOVE 5 -#define VIEWROT_MODAL_SWITCH_ROTATE 6 +#define VIEW_MODAL_CONFIRM 1 /* used for all view operations */ +#define VIEWROT_MODAL_AXIS_SNAP_ENABLE 2 +#define VIEWROT_MODAL_AXIS_SNAP_DISABLE 3 +#define VIEWROT_MODAL_SWITCH_ZOOM 4 +#define VIEWROT_MODAL_SWITCH_MOVE 5 +#define VIEWROT_MODAL_SWITCH_ROTATE 6 /* called in transform_ops.c, on each regeneration of keymaps */ void viewrotate_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { - {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {VIEWROT_MODAL_AXIS_SNAP_ENABLE, "AXIS_SNAP_ENABLE", 0, "Enable Axis Snap", ""}, - {VIEWROT_MODAL_AXIS_SNAP_DISABLE, "AXIS_SNAP_DISABLE", 0, "Disable Axis Snap", ""}, + {VIEWROT_MODAL_AXIS_SNAP_ENABLE, "AXIS_SNAP_ENABLE", 0, "Enable Axis Snap", ""}, + {VIEWROT_MODAL_AXIS_SNAP_DISABLE, "AXIS_SNAP_DISABLE", 0, "Disable Axis Snap", ""}, - {VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"}, - {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"}, + {VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"}, + {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; - wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Rotate Modal"); + wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Rotate Modal"); /* this function is called for each spacetype, only needs to add map once */ if (keymap) return; - keymap= WM_modalkeymap_add(keyconf, "View3D Rotate Modal", modal_items); + keymap = WM_modalkeymap_add(keyconf, "View3D Rotate Modal", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); @@ -623,9 +624,9 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf) static void viewrotate_apply(ViewOpsData *vod, int x, int y) { - RegionView3D *rv3d= vod->rv3d; + RegionView3D *rv3d = vod->rv3d; - rv3d->view= RV3D_VIEW_USER; /* need to reset everytime because of view snapping */ + rv3d->view = RV3D_VIEW_USER; /* need to reset everytime because of view snapping */ if (U.flag & USER_TRACKBALL) { float phi, si, q1[4], dvec[3], newvec[3]; @@ -637,8 +638,8 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) si = len_v3(dvec); si /= (float)(2.0 * TRACKBALLSIZE); - cross_v3_v3v3(q1+1, vod->trackvec, newvec); - normalize_v3(q1+1); + cross_v3_v3v3(q1 + 1, vod->trackvec, newvec); + normalize_v3(q1 + 1); /* Allow for rotation beyond the interval [-pi, pi] */ while (si > 1.0f) @@ -651,8 +652,8 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) * - dragged. */ phi = si * (float)(M_PI / 2.0); - q1[0]= cos(phi); - mul_v3_fl(q1+1, sin(phi)); + q1[0] = cos(phi); + mul_v3_fl(q1 + 1, sin(phi)); mul_qt_qtqt(vod->viewquat, q1, vod->oldquat); if (vod->use_dyn_ofs) { @@ -681,17 +682,17 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) const float sensitivity = 0.0035f; /* Get the 3x3 matrix and its inverse from the quaternion */ - quat_to_mat3( m,vod->viewquat); - invert_m3_m3(m_inv,m); + quat_to_mat3(m, vod->viewquat); + invert_m3_m3(m_inv, m); /* Determine the direction of the x vector (for rotating up and down) */ /* This can likely be computed directly from the quaternion. */ - mul_m3_v3(m_inv,xvec); + mul_m3_v3(m_inv, xvec); /* Perform the up/down rotation */ phi = sensitivity * -(y - vod->oldy); q1[0] = cos(phi); - mul_v3_v3fl(q1+1, xvec, sin(phi)); + mul_v3_v3fl(q1 + 1, xvec, sin(phi)); mul_qt_qtqt(vod->viewquat, vod->viewquat, q1); if (vod->use_dyn_ofs) { @@ -720,21 +721,21 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) if (vod->axis_snap) { int i; float viewquat_inv[4]; - float zaxis[3]={0,0,1}; + float zaxis[3] = {0, 0, 1}; invert_qt_qt(viewquat_inv, vod->viewquat); mul_qt_v3(viewquat_inv, zaxis); - for (i = 0 ; i < NUM_SNAP_QUATS; i++) { + for (i = 0; i < NUM_SNAP_QUATS; i++) { float view = (int)snapquats[i][4]; float viewquat_inv_test[4]; - float zaxis_test[3]={0,0,1}; + float zaxis_test[3] = {0, 0, 1}; invert_qt_qt(viewquat_inv_test, snapquats[i]); mul_qt_v3(viewquat_inv_test, zaxis_test); - if (angle_v3v3(zaxis_test, zaxis) < DEG2RADF(45/3)) { + if (angle_v3v3(zaxis_test, zaxis) < DEG2RADF(45 / 3)) { /* find the best roll */ float quat_roll[4], quat_final[4], quat_best[4]; float viewquat_align[4]; /* viewquat aligned to zaxis_test */ @@ -751,10 +752,10 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) invert_qt_qt(viewquat_align_inv, viewquat_align); /* find best roll */ - for (j= 0; j<8; j++) { + for (j = 0; j < 8; j++) { float angle; - float xaxis1[3]={1,0,0}; - float xaxis2[3]={1,0,0}; + float xaxis1[3] = {1, 0, 0}; + float xaxis2[3] = {1, 0, 0}; float quat_final_inv[4]; axis_angle_to_quat(quat_roll, zaxis_test, (float)j * DEG2RADF(45.0f)); @@ -767,24 +768,24 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) invert_qt_qt(quat_final_inv, quat_final); mul_qt_v3(viewquat_align_inv, xaxis1); mul_qt_v3(quat_final_inv, xaxis2); - angle= angle_v3v3(xaxis1, xaxis2); + angle = angle_v3v3(xaxis1, xaxis2); if (angle <= best_angle) { - best_angle= angle; + best_angle = angle; copy_qt_qt(quat_best, quat_final); - if (j) view= 0; /* view grid assumes certain up axis */ + if (j) view = 0; /* view grid assumes certain up axis */ } } copy_qt_qt(vod->viewquat, quat_best); - rv3d->view= view; /* if we snap to a rolled camera the grid is invalid */ + rv3d->view = view; /* if we snap to a rolled camera the grid is invalid */ break; } } } - vod->oldx= x; - vod->oldy= y; + vod->oldx = x; + vod->oldy = y; /* avoid precision loss over time */ normalize_qt(vod->viewquat); @@ -800,44 +801,44 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) static int viewrotate_modal(bContext *C, wmOperator *op, wmEvent *event) { - ViewOpsData *vod= op->customdata; - short event_code= VIEW_PASS; + ViewOpsData *vod = op->customdata; + short event_code = VIEW_PASS; /* execute the events */ - if (event->type==MOUSEMOVE) { - event_code= VIEW_APPLY; + if (event->type == MOUSEMOVE) { + event_code = VIEW_APPLY; } - else if (event->type==EVT_MODAL_MAP) { + else if (event->type == EVT_MODAL_MAP) { switch (event->val) { case VIEW_MODAL_CONFIRM: - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_AXIS_SNAP_ENABLE: - vod->axis_snap= TRUE; - event_code= VIEW_APPLY; + vod->axis_snap = TRUE; + event_code = VIEW_APPLY; break; case VIEWROT_MODAL_AXIS_SNAP_DISABLE: - vod->axis_snap= FALSE; - event_code= VIEW_APPLY; + vod->axis_snap = FALSE; + event_code = VIEW_APPLY; break; case VIEWROT_MODAL_SWITCH_ZOOM: WM_operator_name_call(C, "VIEW3D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL); - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_SWITCH_MOVE: WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, NULL); - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; } } - else if (event->type==vod->origkey && event->val==KM_RELEASE) { - event_code= VIEW_CONFIRM; + else if (event->type == vod->origkey && event->val == KM_RELEASE) { + event_code = VIEW_CONFIRM; } - if (event_code==VIEW_APPLY) { + if (event_code == VIEW_APPLY) { viewrotate_apply(vod, event->x, event->y); } - else if (event_code==VIEW_CONFIRM) { + else if (event_code == VIEW_CONFIRM) { ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); @@ -854,8 +855,8 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) /* makes op->customdata */ viewops_data_create(C, op, event); - vod= op->customdata; - rv3d= vod->rv3d; + vod = op->customdata; + rv3d = vod->rv3d; if (rv3d->viewlock) { /* poll should check but in some cases fails, see poll func for details */ viewops_data_free(C, op); @@ -867,10 +868,10 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) if (U.uiflag & USER_AUTOPERSP) { if (!ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) { - rv3d->persp= RV3D_PERSP; + rv3d->persp = RV3D_PERSP; } } - else if (rv3d->persp==RV3D_CAMOB) { + else if (rv3d->persp == RV3D_CAMOB) { /* changed since 2.4x, use the camera view */ if (vod->v3d->camera) { @@ -878,7 +879,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) } if (!ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) { - rv3d->persp= rv3d->lpersp; + rv3d->persp = rv3d->lpersp; } } ED_region_tag_redraw(vod->ar); @@ -912,8 +913,8 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) static int view3d_camera_active_poll(bContext *C) { if (ED_operator_view3d_active(C)) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); - if (rv3d && rv3d->persp==RV3D_CAMOB) { + RegionView3D *rv3d = CTX_wm_region_view3d(C); + if (rv3d && rv3d->persp == RV3D_CAMOB) { return 1; } } @@ -929,7 +930,7 @@ static int view3d_camera_user_poll(bContext *C) if (ED_view3d_context_user_region(C, &v3d, &ar)) { RegionView3D *rv3d = ar->regiondata; - if (rv3d->persp==RV3D_CAMOB) { + if (rv3d->persp == RV3D_CAMOB) { return 1; } } @@ -959,18 +960,18 @@ void VIEW3D_OT_rotate(wmOperatorType *ot) ot->cancel = viewrotate_cancel; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; } /* NDOF utility functions * (should these functions live in this file?) */ -float ndof_to_axis_angle(struct wmNDOFMotionData* ndof, float axis[3]) +float ndof_to_axis_angle(struct wmNDOFMotionData*ndof, float axis[3]) { return ndof->dt * normalize_v3_v3(axis, ndof->rvec); } -void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4]) +void ndof_to_quat(struct wmNDOFMotionData*ndof, float q[4]) { float axis[3]; float angle; @@ -989,8 +990,8 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event return OPERATOR_CANCELLED; else { View3D *v3d = CTX_wm_view3d(C); - RegionView3D* rv3d = CTX_wm_region_view3d(C); - wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata; + RegionView3D*rv3d = CTX_wm_region_view3d(C); + wmNDOFMotionData*ndof = (wmNDOFMotionData *) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); @@ -1012,7 +1013,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event /* #define DEBUG_NDOF_MOTION */ #ifdef DEBUG_NDOF_MOTION printf("ndof: T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f) dt=%.3f delivered to 3D view\n", - ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt); + ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt); #endif if (ndof->tz) { @@ -1077,7 +1078,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ float angle, rot[4]; - float xvec[3] = {1,0,0}; + float xvec[3] = {1, 0, 0}; /* Determine the direction of the x vector (for rotating up and down) */ mul_qt_v3(view_inv, xvec); @@ -1087,7 +1088,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) angle = -angle; rot[0] = cos(angle); - mul_v3_v3fl(rot+1, xvec, sin(angle)); + mul_v3_v3fl(rot + 1, xvec, sin(angle)); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); /* Perform the orbital rotation */ @@ -1140,9 +1141,9 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) if (event->type != NDOF_MOTION) return OPERATOR_CANCELLED; else { - View3D *v3d= CTX_wm_view3d(C); - RegionView3D* rv3d = CTX_wm_region_view3d(C); - wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata; + View3D *v3d = CTX_wm_view3d(C); + RegionView3D*rv3d = CTX_wm_region_view3d(C); + wmNDOFMotionData*ndof = (wmNDOFMotionData *) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); @@ -1158,7 +1159,7 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) float pan_vec[3] = { ndof->tx, ndof->ty, 0 - }; + }; /* "zoom in" or "translate"? depends on zoom mode in user settings? */ if (ndof->tz) { @@ -1235,19 +1236,20 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot) void viewmove_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { - {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"}, - {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, + {VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"}, + {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; - wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Move Modal"); + wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Move Modal"); /* this function is called for each spacetype, only needs to add map once */ if (keymap) return; - keymap= WM_modalkeymap_add(keyconf, "View3D Move Modal", modal_items); + keymap = WM_modalkeymap_add(keyconf, "View3D Move Modal", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); @@ -1267,10 +1269,10 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf) static void viewmove_apply(ViewOpsData *vod, int x, int y) { - if ((vod->rv3d->persp==RV3D_CAMOB) && !ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) { - const float zoomfac= BKE_screen_view3d_zoom_to_fac((float)vod->rv3d->camzoom) * 2.0f; - vod->rv3d->camdx += (vod->oldx - x)/(vod->ar->winx * zoomfac); - vod->rv3d->camdy += (vod->oldy - y)/(vod->ar->winy * zoomfac); + if ((vod->rv3d->persp == RV3D_CAMOB) && !ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) { + const float zoomfac = BKE_screen_view3d_zoom_to_fac((float)vod->rv3d->camzoom) * 2.0f; + vod->rv3d->camdx += (vod->oldx - x) / (vod->ar->winx * zoomfac); + vod->rv3d->camdy += (vod->oldy - y) / (vod->ar->winy * zoomfac); CLAMP(vod->rv3d->camdx, -1.0f, 1.0f); CLAMP(vod->rv3d->camdy, -1.0f, 1.0f); } @@ -1278,8 +1280,8 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) float dvec[3]; float mval_f[2]; - mval_f[0]= x - vod->oldx; - mval_f[1]= y - vod->oldy; + mval_f[0] = x - vod->oldx; + mval_f[1] = y - vod->oldy; ED_view3d_win_to_delta(vod->ar, mval_f, dvec); add_v3_v3(vod->rv3d->ofs, dvec); @@ -1288,8 +1290,8 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) view3d_boxview_sync(vod->sa, vod->ar); } - vod->oldx= x; - vod->oldy= y; + vod->oldx = x; + vod->oldy = y; ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d); @@ -1300,36 +1302,36 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) { - ViewOpsData *vod= op->customdata; - short event_code= VIEW_PASS; + ViewOpsData *vod = op->customdata; + short event_code = VIEW_PASS; /* execute the events */ - if (event->type==MOUSEMOVE) { - event_code= VIEW_APPLY; + if (event->type == MOUSEMOVE) { + event_code = VIEW_APPLY; } - else if (event->type==EVT_MODAL_MAP) { + else if (event->type == EVT_MODAL_MAP) { switch (event->val) { case VIEW_MODAL_CONFIRM: - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_SWITCH_ZOOM: WM_operator_name_call(C, "VIEW3D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL); - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_SWITCH_ROTATE: WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL); - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; } } - else if (event->type==vod->origkey && event->val==KM_RELEASE) { - event_code= VIEW_CONFIRM; + else if (event->type == vod->origkey && event->val == KM_RELEASE) { + event_code = VIEW_CONFIRM; } - if (event_code==VIEW_APPLY) { + if (event_code == VIEW_APPLY) { viewmove_apply(vod, event->x, event->y); } - else if (event_code==VIEW_CONFIRM) { + else if (event_code == VIEW_CONFIRM) { ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); @@ -1346,7 +1348,7 @@ static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) /* makes op->customdata */ viewops_data_create(C, op, event); - vod= op->customdata; + vod = op->customdata; if (event->type == MOUSEPAN) { viewmove_apply(vod, event->prevx, event->prevy); @@ -1386,7 +1388,7 @@ void VIEW3D_OT_move(wmOperatorType *ot) ot->cancel = viewmove_cancel; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; } /* ************************ viewzoom ******************************** */ @@ -1396,19 +1398,19 @@ void VIEW3D_OT_move(wmOperatorType *ot) void viewzoom_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { - {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, - {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"}, + {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, + {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Zoom Modal"); + wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Zoom Modal"); /* this function is called for each spacetype, only needs to add map once */ if (keymap) return; - keymap= WM_modalkeymap_add(keyconf, "View3D Zoom Modal", modal_items); + keymap = WM_modalkeymap_add(keyconf, "View3D Zoom Modal", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); @@ -1427,7 +1429,7 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf) static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float dvec[3]; @@ -1441,8 +1443,8 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) /* Project cursor position into 3D space */ initgrabz(rv3d, tpos[0], tpos[1], tpos[2]); - mval_f[0]= (float)(((mx - ar->winrct.xmin) * 2) - ar->winx) / 2.0f; - mval_f[1]= (float)(((my - ar->winrct.ymin) * 2) - ar->winy) / 2.0f; + mval_f[0] = (float)(((mx - ar->winrct.xmin) * 2) - ar->winx) / 2.0f; + mval_f[1] = (float)(((my - ar->winrct.ymin) * 2) - ar->winy) / 2.0f; ED_view3d_win_to_delta(ar, mval_f, dvec); /* Calculate view target position for dolly */ @@ -1466,10 +1468,10 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, const short zoom_invert) { - float zfac=1.0; + float zfac = 1.0; short use_cam_zoom; - use_cam_zoom = (vod->rv3d->persp==RV3D_CAMOB) && !(vod->rv3d->is_persp && ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)); + use_cam_zoom = (vod->rv3d->persp == RV3D_CAMOB) && !(vod->rv3d->is_persp && ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)); if (use_cam_zoom) { float delta; @@ -1478,39 +1480,39 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, CLAMP(vod->rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); } - if (viewzoom==USER_ZOOM_CONT) { - double time= PIL_check_seconds_timer(); - float time_step= (float)(time - vod->timer_lastdraw); + if (viewzoom == USER_ZOOM_CONT) { + double time = PIL_check_seconds_timer(); + float time_step = (float)(time - vod->timer_lastdraw); float fac; if (U.uiflag & USER_ZOOM_HORIZ) { - fac= (float)(x - vod->origx); + fac = (float)(x - vod->origx); } else { - fac= (float)(y - vod->origy); + fac = (float)(y - vod->origy); } if (zoom_invert) { - fac= -fac; + fac = -fac; } // oldstyle zoom zfac = 1.0f + ((fac / 20.0f) * time_step); - vod->timer_lastdraw= time; + vod->timer_lastdraw = time; } - else if (viewzoom==USER_ZOOM_SCALE) { + else if (viewzoom == USER_ZOOM_SCALE) { int ctr[2], len1, len2; // method which zooms based on how far you move the mouse - ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin)/2; - ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin)/2; + ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin) / 2; + ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin) / 2; - len1 = (int)sqrt((ctr[0] - x)*(ctr[0] - x) + (ctr[1] - y)*(ctr[1] - y)) + 5; - len2 = (int)sqrt((ctr[0] - vod->origx)*(ctr[0] - vod->origx) + (ctr[1] - vod->origy)*(ctr[1] - vod->origy)) + 5; + len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5; + len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5; - zfac = vod->dist0 * ((float)len2/len1) / vod->rv3d->dist; + zfac = vod->dist0 * ((float)len2 / len1) / vod->rv3d->dist; } - else { /* USER_ZOOM_DOLLY */ + else { /* USER_ZOOM_DOLLY */ float len1, len2; if (U.uiflag & USER_ZOOM_HORIZ) { @@ -1526,23 +1528,23 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, } if (use_cam_zoom) { - zfac = vod->camzoom0 * (2.0f * ((len2/len1)-1.0f) + 1.0f) / vod->rv3d->camzoom; + zfac = vod->camzoom0 * (2.0f * ((len2 / len1) - 1.0f) + 1.0f) / vod->rv3d->camzoom; zfac = 0; } else { - zfac = vod->dist0 * (2.0f * ((len2/len1)-1.0f) + 1.0f) / vod->rv3d->dist; + zfac = vod->dist0 * (2.0f * ((len2 / len1) - 1.0f) + 1.0f) / vod->rv3d->dist; } } if (!use_cam_zoom) { - if (zfac != 1.0f && zfac*vod->rv3d->dist > 0.001f * vod->grid && - zfac * vod->rv3d->dist < 10.0f * vod->far) + if (zfac != 1.0f && zfac * vod->rv3d->dist > 0.001f * vod->grid && + zfac * vod->rv3d->dist < 10.0f * vod->far) view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy); } /* these limits were in old code too */ - if (vod->rv3d->dist<0.001f * vod->grid) vod->rv3d->dist= 0.001f * vod->grid; - if (vod->rv3d->dist>10.0f * vod->far) vod->rv3d->dist=10.0f * vod->far; + if (vod->rv3d->dist < 0.001f * vod->grid) vod->rv3d->dist = 0.001f * vod->grid; + if (vod->rv3d->dist > 10.0f * vod->far) vod->rv3d->dist = 10.0f * vod->far; if (vod->rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(vod->sa, vod->ar); @@ -1555,40 +1557,40 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event) { - ViewOpsData *vod= op->customdata; - short event_code= VIEW_PASS; + ViewOpsData *vod = op->customdata; + short event_code = VIEW_PASS; /* execute the events */ if (event->type == TIMER && event->customdata == vod->timer) { /* continuous zoom */ - event_code= VIEW_APPLY; + event_code = VIEW_APPLY; } - else if (event->type==MOUSEMOVE) { - event_code= VIEW_APPLY; + else if (event->type == MOUSEMOVE) { + event_code = VIEW_APPLY; } - else if (event->type==EVT_MODAL_MAP) { + else if (event->type == EVT_MODAL_MAP) { switch (event->val) { case VIEW_MODAL_CONFIRM: - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_SWITCH_MOVE: WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, NULL); - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_SWITCH_ROTATE: WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL); - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; } } - else if (event->type==vod->origkey && event->val==KM_RELEASE) { - event_code= VIEW_CONFIRM; + else if (event->type == vod->origkey && event->val == KM_RELEASE) { + event_code = VIEW_CONFIRM; } - if (event_code==VIEW_APPLY) { + if (event_code == VIEW_APPLY) { viewzoom_apply(vod, event->x, event->y, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0); } - else if (event_code==VIEW_CONFIRM) { + else if (event_code == VIEW_CONFIRM) { ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); @@ -1606,33 +1608,33 @@ static int viewzoom_exec(bContext *C, wmOperator *op) ARegion *ar; short use_cam_zoom; - int delta= RNA_int_get(op->ptr, "delta"); + int delta = RNA_int_get(op->ptr, "delta"); int mx, my; if (op->customdata) { - ViewOpsData *vod= op->customdata; + ViewOpsData *vod = op->customdata; - sa= vod->sa; - ar= vod->ar; + sa = vod->sa; + ar = vod->ar; } else { - sa= CTX_wm_area(C); - ar= CTX_wm_region(C); + sa = CTX_wm_area(C); + ar = CTX_wm_region(C); } - v3d= sa->spacedata.first; - rv3d= ar->regiondata; + v3d = sa->spacedata.first; + rv3d = ar->regiondata; - mx= RNA_struct_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") : ar->winx / 2; - my= RNA_struct_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") : ar->winy / 2; + mx = RNA_struct_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") : ar->winx / 2; + my = RNA_struct_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") : ar->winy / 2; - use_cam_zoom= (rv3d->persp==RV3D_CAMOB) && !(rv3d->is_persp && ED_view3d_camera_lock_check(v3d, rv3d)); + use_cam_zoom = (rv3d->persp == RV3D_CAMOB) && !(rv3d->is_persp && ED_view3d_camera_lock_check(v3d, rv3d)); if (delta < 0) { /* this min and max is also in viewmove() */ if (use_cam_zoom) { rv3d->camzoom -= 10.0f; - if (rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom= RV3D_CAMZOOM_MIN; + if (rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom = RV3D_CAMZOOM_MIN; } else if (rv3d->dist < 10.0f * v3d->far) { view_zoom_mouseloc(ar, 1.2f, mx, my); @@ -1641,9 +1643,9 @@ static int viewzoom_exec(bContext *C, wmOperator *op) else { if (use_cam_zoom) { rv3d->camzoom += 10.0f; - if (rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom= RV3D_CAMZOOM_MAX; + if (rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom = RV3D_CAMZOOM_MAX; } - else if (rv3d->dist> 0.001f * v3d->grid) { + else if (rv3d->dist > 0.001f * v3d->grid) { view_zoom_mouseloc(ar, .83333f, mx, my); } } @@ -1667,19 +1669,20 @@ static int viewzoom_exec(bContext *C, wmOperator *op) void viewdolly_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { - {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, - {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"}, + {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, + {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; - wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Dolly Modal"); + wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Dolly Modal"); /* this function is called for each spacetype, only needs to add map once */ if (keymap) return; - keymap= WM_modalkeymap_add(keyconf, "View3D Dolly Modal", modal_items); + keymap = WM_modalkeymap_add(keyconf, "View3D Dolly Modal", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); @@ -1703,7 +1706,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) /* makes op->customdata */ viewops_data_create(C, op, event); - vod= op->customdata; + vod = op->customdata; /* if one or the other zoom position aren't set, set from event */ if (!RNA_struct_property_is_set(op->ptr, "mx") || !RNA_struct_property_is_set(op->ptr, "my")) { @@ -1735,8 +1738,8 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) else { if (U.viewzoom == USER_ZOOM_CONT) { /* needs a timer to continue redrawing */ - vod->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); - vod->timer_lastdraw= PIL_check_seconds_timer(); + vod->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); + vod->timer_lastdraw = PIL_check_seconds_timer(); } /* add temp handler */ @@ -1770,7 +1773,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot) ot->cancel = viewzoom_cancel; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "mx", 0, 0, INT_MAX, "Zoom Position X", "", 0, INT_MAX); @@ -1781,13 +1784,13 @@ void VIEW3D_OT_zoom(wmOperatorType *ot) /* ************************ viewdolly ******************************** */ static void view_dolly_mouseloc(ARegion *ar, float orig_ofs[3], float dvec[3], float dfac) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0f - dfac)); } static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_invert) { - float zfac=1.0; + float zfac = 1.0; { float len1, len2; @@ -1820,36 +1823,36 @@ static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_inv static int viewdolly_modal(bContext *C, wmOperator *op, wmEvent *event) { - ViewOpsData *vod= op->customdata; - short event_code= VIEW_PASS; + ViewOpsData *vod = op->customdata; + short event_code = VIEW_PASS; /* execute the events */ - if (event->type==MOUSEMOVE) { - event_code= VIEW_APPLY; + if (event->type == MOUSEMOVE) { + event_code = VIEW_APPLY; } - else if (event->type==EVT_MODAL_MAP) { + else if (event->type == EVT_MODAL_MAP) { switch (event->val) { case VIEW_MODAL_CONFIRM: - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_SWITCH_MOVE: WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, NULL); - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_SWITCH_ROTATE: WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL); - event_code= VIEW_CONFIRM; + event_code = VIEW_CONFIRM; break; } } - else if (event->type==vod->origkey && event->val==KM_RELEASE) { - event_code= VIEW_CONFIRM; + else if (event->type == vod->origkey && event->val == KM_RELEASE) { + event_code = VIEW_CONFIRM; } - if (event_code==VIEW_APPLY) { + if (event_code == VIEW_APPLY) { viewdolly_apply(vod, event->x, event->y, (U.uiflag & USER_ZOOM_INVERT) != 0); } - else if (event_code==VIEW_CONFIRM) { + else if (event_code == VIEW_CONFIRM) { ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); @@ -1867,24 +1870,24 @@ static int viewdolly_exec(bContext *C, wmOperator *op) ARegion *ar; float mousevec[3]; - int delta= RNA_int_get(op->ptr, "delta"); + int delta = RNA_int_get(op->ptr, "delta"); if (op->customdata) { - ViewOpsData *vod= op->customdata; + ViewOpsData *vod = op->customdata; - sa= vod->sa; - ar= vod->ar; + sa = vod->sa; + ar = vod->ar; copy_v3_v3(mousevec, vod->mousevec); } else { - sa= CTX_wm_area(C); - ar= CTX_wm_region(C); + sa = CTX_wm_area(C); + ar = CTX_wm_region(C); negate_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]); normalize_v3(mousevec); } /* v3d= sa->spacedata.first; */ /* UNUSED */ - rv3d= ar->regiondata; + rv3d = ar->regiondata; /* overwrite the mouse vector with the view direction (zoom into the center) */ if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) == 0) { @@ -1916,7 +1919,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event) /* makes op->customdata */ viewops_data_create(C, op, event); - vod= op->customdata; + vod = op->customdata; /* if one or the other zoom position aren't set, set from event */ if (!RNA_struct_property_is_set(op->ptr, "mx") || !RNA_struct_property_is_set(op->ptr, "my")) { @@ -1965,14 +1968,14 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event) /* like ED_operator_region_view3d_active but check its not in ortho view */ static int viewdolly_poll(bContext *C) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d) { if (rv3d->persp == RV3D_PERSP) { return 1; } else { - View3D *v3d= CTX_wm_view3d(C); + View3D *v3d = CTX_wm_view3d(C); if (ED_view3d_camera_lock_check(v3d, rv3d)) { return 1; } @@ -2003,7 +2006,7 @@ void VIEW3D_OT_dolly(wmOperatorType *ot) ot->cancel = viewdolly_cancel; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "mx", 0, 0, INT_MAX, "Zoom Position X", "", 0, INT_MAX); @@ -2014,22 +2017,22 @@ void VIEW3D_OT_dolly(wmOperatorType *ot) static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */ { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); - Scene *scene= CTX_data_scene(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + Scene *scene = CTX_data_scene(C); Base *base; float *curs; - const short skip_camera= ED_view3d_camera_lock_check(v3d, rv3d); + const short skip_camera = ED_view3d_camera_lock_check(v3d, rv3d); - int center= RNA_boolean_get(op->ptr, "center"); + int center = RNA_boolean_get(op->ptr, "center"); float size, min[3], max[3], afm[3]; - int ok= 1, onedone=0; + int ok = 1, onedone = 0; if (center) { /* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */ - curs= give_cursor(scene, v3d); + curs = give_cursor(scene, v3d); zero_v3(min); zero_v3(max); zero_v3(curs); @@ -2038,9 +2041,9 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in INIT_MINMAX(min, max); } - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (BASE_VISIBLE(v3d, base)) { - onedone= 1; + onedone = 1; if (skip_camera && base->object == v3d->camera) { continue; @@ -2062,27 +2065,27 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in } sub_v3_v3v3(afm, max, min); - size= 0.7f*MAX3(afm[0], afm[1], afm[2]); - if (size == 0.0f) ok= 0; + size = 0.7f * MAX3(afm[0], afm[1], afm[2]); + if (size == 0.0f) ok = 0; if (ok) { float new_dist; float new_ofs[3]; new_dist = size; - new_ofs[0]= -(min[0]+max[0])/2.0f; - new_ofs[1]= -(min[1]+max[1])/2.0f; - new_ofs[2]= -(min[2]+max[2])/2.0f; + new_ofs[0] = -(min[0] + max[0]) / 2.0f; + new_ofs[1] = -(min[1] + max[1]) / 2.0f; + new_ofs[2] = -(min[2] + max[2]) / 2.0f; // correction for window aspect ratio - if (ar->winy>2 && ar->winx>2) { - size= (float)ar->winx/(float)ar->winy; - if (size < 1.0f) size= 1.0f/size; - new_dist*= size; + if (ar->winy > 2 && ar->winx > 2) { + size = (float)ar->winx / (float)ar->winy; + if (size < 1.0f) size = 1.0f / size; + new_dist *= size; } - if ((rv3d->persp==RV3D_CAMOB) && !ED_view3d_camera_lock_check(v3d, rv3d)) { - rv3d->persp= RV3D_PERSP; + if ((rv3d->persp == RV3D_CAMOB) && !ED_view3d_camera_lock_check(v3d, rv3d)) { + rv3d->persp = RV3D_PERSP; smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } else { @@ -2091,7 +2094,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in } // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -2117,15 +2120,15 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) /* like a localview without local!, was centerview() in 2.4x */ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); - Scene *scene= CTX_data_scene(C); - Object *ob= OBACT; - Object *obedit= CTX_data_edit_object(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + Scene *scene = CTX_data_scene(C); + Object *ob = OBACT; + Object *obedit = CTX_data_edit_object(C); float size, min[3], max[3], afm[3]; - int ok=0, ok_dist=1; - const short skip_camera= ED_view3d_camera_lock_check(v3d, rv3d); + int ok = 0, ok_dist = 1; + const short skip_camera = ED_view3d_camera_lock_check(v3d, rv3d); /* SMOOTHVIEW */ float new_ofs[3]; @@ -2137,32 +2140,32 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* hard-coded exception, we look for the one selected armature */ /* this is weak code this way, we should make a generic active/selection callback interface once... */ Base *base; - for (base=scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (TESTBASELIB(v3d, base)) { - if (base->object->type==OB_ARMATURE) + if (base->object->type == OB_ARMATURE) if (base->object->mode & OB_MODE_POSE) break; } } if (base) - ob= base->object; + ob = base->object; } if (obedit) { - ok = minmax_verts(obedit, min, max); /* only selected */ + ok = minmax_verts(obedit, min, max); /* only selected */ } else if (ob && (ob->mode & OB_MODE_POSE)) { if (ob->pose) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; float vec[3]; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->flag & BONE_SELECTED) { if (pchan->bone->layer & arm->layer) { - bPoseChannel *pchan_tx= pchan->custom_tx ? pchan->custom_tx : pchan; - ok= 1; + bPoseChannel *pchan_tx = pchan->custom_tx ? pchan->custom_tx : pchan; + ok = 1; mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head); DO_MINMAX(vec, min, max); mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail); @@ -2173,14 +2176,14 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) } } else if (paint_facesel_test(ob)) { - ok= paintface_minmax(ob, min, max); + ok = paintface_minmax(ob, min, max); } else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { - ok= PE_minmax(scene, min, max); + ok = PE_minmax(scene, min, max); } else { Base *base; - for (base= FIRSTBASE; base; base = base->next) { + for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { if (skip_camera && base->object == v3d->camera) { @@ -2188,31 +2191,31 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) } /* account for duplis */ - if (minmax_object_duplis(scene, base->object, min, max)==0) - minmax_object(base->object, min, max); /* use if duplis not found */ + if (minmax_object_duplis(scene, base->object, min, max) == 0) + minmax_object(base->object, min, max); /* use if duplis not found */ - ok= 1; + ok = 1; } } } - if (ok==0) return OPERATOR_FINISHED; + if (ok == 0) return OPERATOR_FINISHED; sub_v3_v3v3(afm, max, min); - size= MAX3(afm[0], afm[1], afm[2]); + size = MAX3(afm[0], afm[1], afm[2]); if (!rv3d->is_persp) { if (size < 0.0001f) { /* if its a sinble point. don't even re-scale */ - ok_dist= 0; + ok_dist = 0; } else { /* perspective should be a bit farther away to look nice */ - size*= 0.7f; + size *= 0.7f; } } else { - if (size <= v3d->near*1.5f) { - size= v3d->near*1.5f; + if (size <= v3d->near * 1.5f) { + size = v3d->near * 1.5f; } } @@ -2222,14 +2225,14 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) new_dist = size; /* correction for window aspect ratio */ - if (ar->winy>2 && ar->winx>2) { - size= (float)ar->winx/(float)ar->winy; - if (size<1.0f) size= 1.0f/size; - new_dist*= size; + if (ar->winy > 2 && ar->winx > 2) { + size = (float)ar->winx / (float)ar->winy; + if (size < 1.0f) size = 1.0f / size; + new_dist *= size; } - if (rv3d->persp==RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) { - rv3d->persp= RV3D_PERSP; + if (rv3d->persp == RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) { + rv3d->persp = RV3D_PERSP; smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } else { @@ -2262,11 +2265,11 @@ void VIEW3D_OT_view_selected(wmOperatorType *ot) static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); - Scene *scene= CTX_data_scene(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + Scene *scene = CTX_data_scene(C); if (rv3d) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); /* non camera center */ float new_ofs[3]; @@ -2296,7 +2299,7 @@ void VIEW3D_OT_view_center_cursor(wmOperatorType *ot) static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was view3d_home() in 2.4x */ { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); float xfac, yfac; float size[2]; @@ -2308,18 +2311,18 @@ static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was ED_view3d_context_user_region(C, &v3d, &ar); rv3d = ar->regiondata; - rv3d->camdx= rv3d->camdy= 0.0f; + rv3d->camdx = rv3d->camdy = 0.0f; ED_view3d_calc_camera_border_size(scene, ar, v3d, rv3d, size); /* 4px is just a little room from the edge of the area */ - xfac= (float)ar->winx / (float)(size[0] + 4); - yfac= (float)ar->winy / (float)(size[1] + 4); + xfac = (float)ar->winx / (float)(size[0] + 4); + yfac = (float)ar->winy / (float)(size[1] + 4); - rv3d->camzoom= BKE_screen_view3d_zoom_from_fac(MIN2(xfac, yfac)); + rv3d->camzoom = BKE_screen_view3d_zoom_from_fac(MIN2(xfac, yfac)); CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; } @@ -2344,9 +2347,9 @@ void VIEW3D_OT_view_center_camera(wmOperatorType *ot) static int render_border_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); - ARegion *ar= CTX_wm_region(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); - Scene *scene= CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ED_view3d_context_rv3d(C); + Scene *scene = CTX_data_scene(C); rcti rect; rctf vb; @@ -2360,10 +2363,10 @@ static int render_border_exec(bContext *C, wmOperator *op) /* calculate range */ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE); - scene->r.border.xmin = ((float)rect.xmin-vb.xmin)/(vb.xmax-vb.xmin); - scene->r.border.ymin = ((float)rect.ymin-vb.ymin)/(vb.ymax-vb.ymin); - scene->r.border.xmax = ((float)rect.xmax-vb.xmin)/(vb.xmax-vb.xmin); - scene->r.border.ymax = ((float)rect.ymax-vb.ymin)/(vb.ymax-vb.ymin); + scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / (vb.xmax - vb.xmin); + scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / (vb.ymax - vb.ymin); + scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / (vb.xmax - vb.xmin); + scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / (vb.ymax - vb.ymin); /* actually set border */ CLAMP(scene->r.border.xmin, 0.0f, 1.0f); @@ -2374,9 +2377,9 @@ static int render_border_exec(bContext *C, wmOperator *op) /* drawing a border surrounding the entire camera view switches off border rendering * or the border covers no pixels */ if ((scene->r.border.xmin <= 0.0f && scene->r.border.xmax >= 1.0f && - scene->r.border.ymin <= 0.0f && scene->r.border.ymax >= 1.0f) || - (scene->r.border.xmin == scene->r.border.xmax || - scene->r.border.ymin == scene->r.border.ymax )) + scene->r.border.ymin <= 0.0f && scene->r.border.ymax >= 1.0f) || + (scene->r.border.xmin == scene->r.border.xmax || + scene->r.border.ymin == scene->r.border.ymax)) { scene->r.mode &= ~R_BORDER; } @@ -2384,7 +2387,7 @@ static int render_border_exec(bContext *C, wmOperator *op) scene->r.mode |= R_BORDER; } - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL); return OPERATOR_FINISHED; @@ -2406,7 +2409,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot) ot->poll = view3d_camera_active_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); @@ -2419,10 +2422,10 @@ void VIEW3D_OT_render_border(wmOperatorType *ot) static int view3d_zoom_border_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); - Scene *scene= CTX_data_scene(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + Scene *scene = CTX_data_scene(C); /* Zooms in on a border drawn by the user */ rcti rect; @@ -2434,7 +2437,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) /* ZBuffer depth vars */ bglMats mats; - float depth_close= FLT_MAX; + float depth_close = FLT_MAX; double cent[2], p[3]; /* note; otherwise opengl won't work */ @@ -2452,25 +2455,25 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) { /* avoid allocating the whole depth buffer */ - ViewDepths depth_temp= {0}; + ViewDepths depth_temp = {0}; /* avoid view3d_update_depths() for speed. */ view3d_update_depths_rect(ar, &depth_temp, &rect); /* find the closest Z pixel */ - depth_close= view3d_depth_near(&depth_temp); + depth_close = view3d_depth_near(&depth_temp); MEM_freeN(depth_temp.depths); } - cent[0] = (((double)rect.xmin)+((double)rect.xmax)) / 2; - cent[1] = (((double)rect.ymin)+((double)rect.ymax)) / 2; + cent[0] = (((double)rect.xmin) + ((double)rect.xmax)) / 2; + cent[1] = (((double)rect.ymin) + ((double)rect.ymax)) / 2; if (rv3d->is_persp) { double p_corner[3]; /* no depths to use, we cant do anything! */ - if (depth_close==FLT_MAX) { + if (depth_close == FLT_MAX) { BKE_report(op->reports, RPT_ERROR, "Depth Too Large"); return OPERATOR_CANCELLED; } @@ -2479,18 +2482,18 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) || (!gluUnProject((double)rect.xmin, (double)rect.ymin, depth_close, - mats.modelview, mats.projection, (GLint *)mats.viewport, - &p_corner[0], &p_corner[1], &p_corner[2]))) + mats.modelview, mats.projection, (GLint *)mats.viewport, + &p_corner[0], &p_corner[1], &p_corner[2]))) { return OPERATOR_CANCELLED; } - dvec[0] = p[0]-p_corner[0]; - dvec[1] = p[1]-p_corner[1]; - dvec[2] = p[2]-p_corner[2]; + dvec[0] = p[0] - p_corner[0]; + dvec[1] = p[1] - p_corner[1]; + dvec[2] = p[2] - p_corner[2]; new_dist = len_v3(dvec); - if (new_dist <= v3d->near * 1.5f) new_dist= v3d->near * 1.5f; + if (new_dist <= v3d->near * 1.5f) new_dist = v3d->near * 1.5f; new_ofs[0] = -p[0]; new_ofs[1] = -p[1]; @@ -2498,7 +2501,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) } else { /* othographic */ - /* find the current window width and height */ + /* find the current window width and height */ vb[0] = ar->winx; vb[1] = ar->winy; @@ -2520,20 +2523,20 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) initgrabz(rv3d, -new_ofs[0], -new_ofs[1], -new_ofs[2]); - mval_f[0]= (rect.xmin + rect.xmax - vb[0]) / 2.0f; - mval_f[1]= (rect.ymin + rect.ymax - vb[1]) / 2.0f; + mval_f[0] = (rect.xmin + rect.xmax - vb[0]) / 2.0f; + mval_f[1] = (rect.ymin + rect.ymax - vb[1]) / 2.0f; ED_view3d_win_to_delta(ar, mval_f, dvec); /* center the view to the center of the rectangle */ sub_v3_v3(new_ofs, dvec); } /* work out the ratios, so that everything selected fits when we zoom */ - xscale = ((rect.xmax-rect.xmin)/vb[0]); - yscale = ((rect.ymax-rect.ymin)/vb[1]); - scale = (xscale >= yscale)?xscale:yscale; + xscale = ((rect.xmax - rect.xmin) / vb[0]); + yscale = ((rect.ymax - rect.ymin) / vb[1]); + scale = (xscale >= yscale) ? xscale : yscale; /* zoom in as required, or as far as we can go */ - new_dist = ((new_dist*scale) >= 0.001f * v3d->grid)? new_dist*scale:0.001f * v3d->grid; + new_dist = ((new_dist * scale) >= 0.001f * v3d->grid) ? new_dist * scale : 0.001f * v3d->grid; } smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); @@ -2546,8 +2549,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) static int view3d_zoom_border_invoke(bContext *C, wmOperator *op, wmEvent *event) { - View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); /* if in camera view do not exec the operator so we do not conflict with set render border*/ if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) @@ -2585,19 +2588,19 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) /* sets the view to 1:1 camera/render-pixel */ static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar, View3D *v3d) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float size[2]; - int im_width= (scene->r.size*scene->r.xsch)/100; + int im_width = (scene->r.size * scene->r.xsch) / 100; ED_view3d_calc_camera_border_size(scene, ar, v3d, rv3d, size); - rv3d->camzoom= BKE_screen_view3d_zoom_from_fac((float)im_width/size[0]); + rv3d->camzoom = BKE_screen_view3d_zoom_from_fac((float)im_width / size[0]); CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); } static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); View3D *v3d; ARegion *ar; @@ -2607,7 +2610,7 @@ static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) view3d_set_1_to_1_viewborder(scene, ar, v3d); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -2637,7 +2640,8 @@ static EnumPropertyItem prop_view_items[] = { {RV3D_VIEW_TOP, "TOP", 0, "Top", "View From the Top"}, {RV3D_VIEW_BOTTOM, "BOTTOM", 0, "Bottom", "View From the Bottom"}, {RV3D_VIEW_CAMERA, "CAMERA", 0, "Camera", "View From the active camera"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; /* would like to make this a generic function - outside of transform */ @@ -2646,19 +2650,19 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, float q1, float q2, float q3, float q4, short view, int perspo, int align_active) { - RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */ + RegionView3D *rv3d = ar->regiondata; /* no NULL check is needed, poll checks */ float new_quat[4]; - new_quat[0]= q1; new_quat[1]= q2; - new_quat[2]= q3; new_quat[3]= q4; + new_quat[0] = q1; new_quat[1] = q2; + new_quat[2] = q3; new_quat[3] = q4; normalize_qt(new_quat); if (align_active) { /* align to active object */ - Object *obact= CTX_data_active_object(C); - if (obact==NULL) { + Object *obact = CTX_data_active_object(C); + if (obact == NULL) { /* no active object, ignore this option */ - align_active= FALSE; + align_active = FALSE; } else { float obact_quat[4]; @@ -2667,15 +2671,15 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, /* same as transform manipulator when normal is set */ ED_getTransformOrientationMatrix(C, twmat, FALSE); - mat3_to_quat( obact_quat,twmat); + mat3_to_quat(obact_quat, twmat); invert_qt(obact_quat); mul_qt_qtqt(new_quat, new_quat, obact_quat); - rv3d->view= view= RV3D_VIEW_USER; + rv3d->view = view = RV3D_VIEW_USER; } } - if (align_active==FALSE) { + if (align_active == FALSE) { /* normal operation */ if (rv3d->viewlock) { /* only pass on if */ @@ -2700,17 +2704,17 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, return; } - if (rv3d->persp==RV3D_CAMOB && v3d->camera) { + if (rv3d->persp == RV3D_CAMOB && v3d->camera) { - if (U.uiflag & USER_AUTOPERSP) rv3d->persp= view ? RV3D_ORTHO : RV3D_PERSP; - else if (rv3d->persp==RV3D_CAMOB) rv3d->persp= perspo; + if (U.uiflag & USER_AUTOPERSP) rv3d->persp = view ? RV3D_ORTHO : RV3D_PERSP; + else if (rv3d->persp == RV3D_CAMOB) rv3d->persp = perspo; smooth_view(C, v3d, ar, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL); } else { - if (U.uiflag & USER_AUTOPERSP) rv3d->persp= view ? RV3D_ORTHO : RV3D_PERSP; - else if (rv3d->persp==RV3D_CAMOB) rv3d->persp= perspo; + if (U.uiflag & USER_AUTOPERSP) rv3d->persp = view ? RV3D_ORTHO : RV3D_PERSP; + else if (rv3d->persp == RV3D_CAMOB) rv3d->persp = perspo; smooth_view(C, v3d, ar, NULL, NULL, NULL, new_quat, NULL, NULL); } @@ -2722,7 +2726,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) View3D *v3d; ARegion *ar; RegionView3D *rv3d; - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); static int perspo = RV3D_PERSP; int viewnum, align_active, nextperspo; @@ -2735,25 +2739,25 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) /* set this to zero, gets handled in axis_set_view */ if (rv3d->viewlock) - align_active= 0; + align_active = 0; /* Use this to test if we started out with a camera */ if (rv3d->persp == RV3D_CAMOB) { - nextperspo= rv3d->lpersp; + nextperspo = rv3d->lpersp; } else { - nextperspo= perspo; + nextperspo = perspo; } switch (viewnum) { - case RV3D_VIEW_BOTTOM : + case RV3D_VIEW_BOTTOM: axis_set_view(C, v3d, ar, 0.0, -1.0, 0.0, 0.0, viewnum, nextperspo, align_active); break; case RV3D_VIEW_BACK: - axis_set_view(C, v3d, ar, 0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0), + axis_set_view(C, v3d, ar, 0.0, 0.0, (float)-cos(M_PI / 4.0), (float)-cos(M_PI / 4.0), viewnum, nextperspo, align_active); break; @@ -2768,7 +2772,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) break; case RV3D_VIEW_FRONT: - axis_set_view(C, v3d, ar, (float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0, + axis_set_view(C, v3d, ar, (float)cos(M_PI / 4.0), (float)-sin(M_PI / 4.0), 0.0, 0.0, viewnum, nextperspo, align_active); break; @@ -2778,24 +2782,24 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) break; case RV3D_VIEW_CAMERA: - if (rv3d->viewlock==0) { + if (rv3d->viewlock == 0) { /* lastview - */ if (rv3d->persp != RV3D_CAMOB) { - Object *ob= OBACT; + Object *ob = OBACT; if (!rv3d->smooth_timer) { /* store settings of current view before allowing overwriting with camera view * only if we're not currently in a view transition */ copy_qt_qt(rv3d->lviewquat, rv3d->viewquat); - rv3d->lview= rv3d->view; - rv3d->lpersp= rv3d->persp; + rv3d->lview = rv3d->view; + rv3d->lpersp = rv3d->persp; } #if 0 - if (G.qual==LR_ALTKEY) { + if (G.qual == LR_ALTKEY) { if (oldcamera && is_an_active_object(oldcamera)) { - v3d->camera= oldcamera; + v3d->camera = oldcamera; } handle_view3d_lock(); } @@ -2804,32 +2808,32 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) /* first get the default camera for the view lock type */ if (v3d->scenelock) { /* sets the camera view if available */ - v3d->camera= scene->camera; + v3d->camera = scene->camera; } else { /* use scene camera if one is not set (even though we're unlocked) */ - if (v3d->camera==NULL) { - v3d->camera= scene->camera; + if (v3d->camera == NULL) { + v3d->camera = scene->camera; } } /* if the camera isn't found, check a number of options */ - if (v3d->camera==NULL && ob && ob->type==OB_CAMERA) - v3d->camera= ob; + if (v3d->camera == NULL && ob && ob->type == OB_CAMERA) + v3d->camera = ob; - if (v3d->camera==NULL) - v3d->camera= scene_find_camera(scene); + if (v3d->camera == NULL) + v3d->camera = scene_find_camera(scene); /* couldnt find any useful camera, bail out */ - if (v3d->camera==NULL) + if (v3d->camera == NULL) return OPERATOR_CANCELLED; /* important these don't get out of sync for locked scenes */ if (v3d->scenelock) - scene->camera= v3d->camera; + scene->camera = v3d->camera; /* finally do snazzy view zooming */ - rv3d->persp= RV3D_CAMOB; + rv3d->persp = RV3D_CAMOB; smooth_view(C, v3d, ar, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); } @@ -2843,11 +2847,11 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) } break; - default : + default: break; } - if (rv3d->persp != RV3D_CAMOB) perspo= rv3d->persp; + if (rv3d->persp != RV3D_CAMOB) perspo = rv3d->persp; return OPERATOR_FINISHED; } @@ -2876,7 +2880,8 @@ static EnumPropertyItem prop_view_orbit_items[] = { {V3D_VIEW_STEPRIGHT, "ORBITRIGHT", 0, "Orbit Right", "Orbit the view around to the Right"}, {V3D_VIEW_STEPUP, "ORBITUP", 0, "Orbit Up", "Orbit the view Up"}, {V3D_VIEW_STEPDOWN, "ORBITDOWN", 0, "Orbit Down", "Orbit the view Down"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; static int vieworbit_exec(bContext *C, wmOperator *op) { @@ -2892,31 +2897,31 @@ static int vieworbit_exec(bContext *C, wmOperator *op) orbitdir = RNA_enum_get(op->ptr, "type"); - if (rv3d->viewlock==0) { + if (rv3d->viewlock == 0) { if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { if (orbitdir == V3D_VIEW_STEPLEFT || orbitdir == V3D_VIEW_STEPRIGHT) { float si; /* z-axis */ - phi= (float)(M_PI/360.0)*U.pad_rot_angle; - if (orbitdir == V3D_VIEW_STEPRIGHT) phi= -phi; - si= (float)sin(phi); - q1[0]= (float)cos(phi); - q1[1]= q1[2]= 0.0; - q1[3]= si; + phi = (float)(M_PI / 360.0) * U.pad_rot_angle; + if (orbitdir == V3D_VIEW_STEPRIGHT) phi = -phi; + si = (float)sin(phi); + q1[0] = (float)cos(phi); + q1[1] = q1[2] = 0.0; + q1[3] = si; mul_qt_qtqt(new_quat, rv3d->viewquat, q1); - rv3d->view= RV3D_VIEW_USER; + rv3d->view = RV3D_VIEW_USER; } else if (orbitdir == V3D_VIEW_STEPDOWN || orbitdir == V3D_VIEW_STEPUP) { /* horizontal axis */ - copy_v3_v3(q1+1, rv3d->viewinv[0]); + copy_v3_v3(q1 + 1, rv3d->viewinv[0]); - normalize_v3(q1+1); - phi= (float)(M_PI/360.0)*U.pad_rot_angle; - if (orbitdir == V3D_VIEW_STEPDOWN) phi= -phi; - q1[0]= (float)cos(phi); - mul_v3_fl(q1+1, sin(phi)); + normalize_v3(q1 + 1); + phi = (float)(M_PI / 360.0) * U.pad_rot_angle; + if (orbitdir == V3D_VIEW_STEPDOWN) phi = -phi; + q1[0] = (float)cos(phi); + mul_v3_fl(q1 + 1, sin(phi)); mul_qt_qtqt(new_quat, rv3d->viewquat, q1); - rv3d->view= RV3D_VIEW_USER; + rv3d->view = RV3D_VIEW_USER; } smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, new_quat, NULL, NULL); @@ -2947,23 +2952,24 @@ static EnumPropertyItem prop_view_pan_items[] = { {V3D_VIEW_PANRIGHT, "PANRIGHT", 0, "Pan Right", "Pan the view to the Right"}, {V3D_VIEW_PANUP, "PANUP", 0, "Pan Up", "Pan the view Up"}, {V3D_VIEW_PANDOWN, "PANDOWN", 0, "Pan Down", "Pan the view Down"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; static int viewpan_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); float vec[3]; - float mval_f[2]= {0.0f, 0.0f}; + float mval_f[2] = {0.0f, 0.0f}; int pandir; pandir = RNA_enum_get(op->ptr, "type"); initgrabz(rv3d, 0.0, 0.0, 0.0); - if (pandir == V3D_VIEW_PANRIGHT) { mval_f[0]= -32.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } - else if (pandir == V3D_VIEW_PANLEFT) { mval_f[0]= 32.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } - else if (pandir == V3D_VIEW_PANUP) { mval_f[1]= -25.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } - else if (pandir == V3D_VIEW_PANDOWN) { mval_f[1]= 25.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } + if (pandir == V3D_VIEW_PANRIGHT) { mval_f[0] = -32.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } + else if (pandir == V3D_VIEW_PANLEFT) { mval_f[0] = 32.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } + else if (pandir == V3D_VIEW_PANUP) { mval_f[1] = -25.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } + else if (pandir == V3D_VIEW_PANDOWN) { mval_f[1] = 25.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } add_v3_v3(rv3d->ofs, vec); if (rv3d->viewlock & RV3D_BOXVIEW) @@ -3000,10 +3006,10 @@ static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op)) ED_view3d_context_user_region(C, &v3d_dummy, &ar); rv3d = ar->regiondata; - if (rv3d->viewlock==0) { - if (rv3d->persp!=RV3D_ORTHO) - rv3d->persp=RV3D_ORTHO; - else rv3d->persp=RV3D_PERSP; + if (rv3d->viewlock == 0) { + if (rv3d->persp != RV3D_ORTHO) + rv3d->persp = RV3D_ORTHO; + else rv3d->persp = RV3D_PERSP; ED_region_tag_redraw(ar); } @@ -3031,7 +3037,7 @@ void VIEW3D_OT_view_persportho(wmOperatorType *ot) static BGpic *background_image_add(bContext *C) { - View3D *v3d= CTX_wm_view3d(C); + View3D *v3d = CTX_wm_view3d(C); return ED_view3D_background_image_new(v3d); } @@ -3045,21 +3051,21 @@ static int background_image_add_exec(bContext *C, wmOperator *UNUSED(op)) static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - View3D *v3d= CTX_wm_view3d(C); - Image *ima= NULL; + View3D *v3d = CTX_wm_view3d(C); + Image *ima = NULL; BGpic *bgpic; - char name[MAX_ID_NAME-2]; + char name[MAX_ID_NAME - 2]; /* check input variables */ if (RNA_struct_property_is_set(op->ptr, "filepath")) { char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima= BKE_add_image_file(path); + ima = BKE_add_image_file(path); } else if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", name); - ima= (Image *)find_id("IM", name); + ima = (Image *)find_id("IM", name); } bgpic = background_image_add(C); @@ -3067,14 +3073,14 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU if (ima) { bgpic->ima = ima; - if (ima->id.us==0) id_us_plus(&ima->id); + if (ima->id.us == 0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); if (!(v3d->flag & V3D_DISPBGPICS)) v3d->flag |= V3D_DISPBGPICS; } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -3095,7 +3101,7 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot) ot->flag = 0; /* properties */ - RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Image name to assign"); + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign"); RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); } @@ -3105,11 +3111,11 @@ static int background_image_remove_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); int index = RNA_int_get(op->ptr, "index"); - BGpic *bgpic_rem= BLI_findlink(&v3d->bgpicbase, index); + BGpic *bgpic_rem = BLI_findlink(&v3d->bgpicbase, index); if (bgpic_rem) { ED_view3D_background_image_remove(v3d, bgpic_rem); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } else { @@ -3141,14 +3147,14 @@ static void calc_clipping_plane(float clip[6][4], BoundBox *clipbb) { int val; - for (val=0; val<4; val++) { + for (val = 0; val < 4; val++) { - normal_tri_v3( clip[val],clipbb->vec[val], clipbb->vec[val==3?0:val+1], clipbb->vec[val+4]); + normal_tri_v3(clip[val], clipbb->vec[val], clipbb->vec[val == 3 ? 0 : val + 1], clipbb->vec[val + 4]); - clip[val][3]= - - clip[val][0]*clipbb->vec[val][0] - - clip[val][1]*clipbb->vec[val][1] - - clip[val][2]*clipbb->vec[val][2]; + /* TODO - this is just '-dot_v3v3(clip[val], clipbb->vec[val])' isnt it? - sould replace */ + clip[val][3] = -clip[val][0] * clipbb->vec[val][0] - + clip[val][1] * clipbb->vec[val][1] - + clip[val][2] * clipbb->vec[val][2]; } } @@ -3160,7 +3166,7 @@ static void calc_local_clipping(float clip_local[][4], BoundBox *clipbb, float m invert_m4_m4(imat, mat); - for (i=0; i<8; i++) { + for (i = 0; i < 8; i++) { mul_v3_m4v3(clipbb_local.vec[i], imat, clipbb->vec[i]); } @@ -3175,7 +3181,7 @@ void ED_view3d_clipping_local(RegionView3D *rv3d, float mat[][4]) static int view3d_clipping_exec(bContext *C, wmOperator *op) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); ViewContext vc; bglMats mats; rcti rect; @@ -3186,7 +3192,7 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); rv3d->rflag |= RV3D_CLIPPING; - rv3d->clipbb= MEM_callocN(sizeof(BoundBox), "clipbb"); + rv3d->clipbb = MEM_callocN(sizeof(BoundBox), "clipbb"); /* note; otherwise opengl won't work */ view3d_operator_needs_opengl(C); @@ -3200,14 +3206,14 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op) static int view3d_clipping_invoke(bContext *C, wmOperator *op, wmEvent *event) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); - ARegion *ar= CTX_wm_region(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + ARegion *ar = CTX_wm_region(C); if (rv3d->rflag & RV3D_CLIPPING) { rv3d->rflag &= ~RV3D_CLIPPING; ED_region_tag_redraw(ar); if (rv3d->clipbb) MEM_freeN(rv3d->clipbb); - rv3d->clipbb= NULL; + rv3d->clipbb = NULL; return OPERATOR_FINISHED; } else { @@ -3247,21 +3253,21 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot) /* mx my in region coords */ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3]; int mval[2]; // short ctrl= 0; // XXX int flip; - fp= give_cursor(scene, v3d); + fp = give_cursor(scene, v3d); // if (obedit && ctrl) lr_click= 1; copy_v3_v3(oldcurs, fp); project_int_noclip(ar, fp, mval); - flip= initgrabz(rv3d, fp[0], fp[1], fp[2]); + flip = initgrabz(rv3d, fp[0], fp[1], fp[2]); /* reset the depth based on the view offset */ if (flip) { @@ -3269,20 +3275,20 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve /* re initialize */ project_int_noclip(ar, fp, mval); - flip= initgrabz(rv3d, fp[0], fp[1], fp[2]); + flip = initgrabz(rv3d, fp[0], fp[1], fp[2]); (void)flip; } - if (mval[0]!=IS_CLIPPED) { + if (mval[0] != IS_CLIPPED) { short depth_used = 0; if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */ view3d_operator_needs_opengl(C); if (ED_view3d_autodist(scene, ar, v3d, event->mval, fp)) - depth_used= 1; + depth_used = 1; } - if (depth_used==0) { + if (depth_used == 0) { float mval_f[2]; VECSUB2D(mval_f, mval, event->mval); ED_view3d_win_to_delta(ar, mval_f, dvec); @@ -3291,21 +3297,21 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve } else { - dx= ((float)(event->mval[0]-(ar->winx/2)))*rv3d->zfac/(ar->winx/2); - dy= ((float)(event->mval[1]-(ar->winy/2)))*rv3d->zfac/(ar->winy/2); + dx = ((float)(event->mval[0] - (ar->winx / 2))) * rv3d->zfac / (ar->winx / 2); + dy = ((float)(event->mval[1] - (ar->winy / 2))) * rv3d->zfac / (ar->winy / 2); - fz= rv3d->persmat[0][3]*fp[0]+ rv3d->persmat[1][3]*fp[1]+ rv3d->persmat[2][3]*fp[2]+ rv3d->persmat[3][3]; - fz= fz/rv3d->zfac; + fz = rv3d->persmat[0][3] * fp[0] + rv3d->persmat[1][3] * fp[1] + rv3d->persmat[2][3] * fp[2] + rv3d->persmat[3][3]; + fz = fz / rv3d->zfac; - fp[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0]; - fp[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1]; - fp[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2]; + fp[0] = (rv3d->persinv[0][0] * dx + rv3d->persinv[1][0] * dy + rv3d->persinv[2][0] * fz) - rv3d->ofs[0]; + fp[1] = (rv3d->persinv[0][1] * dx + rv3d->persinv[1][1] * dy + rv3d->persinv[2][1] * fz) - rv3d->ofs[1]; + fp[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy + rv3d->persinv[2][2] * fz) - rv3d->ofs[2]; } if (v3d && v3d->localvd) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); else - WM_event_add_notifier(C, NC_SCENE|NA_EDITED, scene); + WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); return OPERATOR_FINISHED; } @@ -3346,7 +3352,7 @@ static int manipulator_invoke(bContext *C, wmOperator *op, wmEvent *event) /* note; otherwise opengl won't work */ view3d_operator_needs_opengl(C); - if (0==BIF_do_manipulator(C, event, op)) + if (0 == BIF_do_manipulator(C, event, op)) return OPERATOR_PASS_THROUGH; return OPERATOR_FINISHED; @@ -3373,7 +3379,7 @@ static int enable_manipulator_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE { View3D *v3d = CTX_wm_view3d(C); - v3d->twtype=0; + v3d->twtype = 0; if (RNA_boolean_get(op->ptr, "translate")) v3d->twtype |= V3D_MANIP_TRANSLATE; @@ -3382,7 +3388,7 @@ static int enable_manipulator_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE if (RNA_boolean_get(op->ptr, "scale")) v3d->twtype |= V3D_MANIP_SCALE; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -3409,11 +3415,11 @@ void VIEW3D_OT_enable_manipulator(wmOperatorType *ot) static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int margin) { - ViewDepths depth_temp= {0}; + ViewDepths depth_temp = {0}; rcti rect; float depth_close; - if (margin==0) { + if (margin == 0) { /* Get Z Depths, needed for perspective, nice for ortho */ rect.xmin = mval[0]; rect.ymin = mval[1]; @@ -3429,7 +3435,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg } view3d_update_depths_rect(ar, &depth_temp, &rect); - depth_close= view3d_depth_near(&depth_temp); + depth_close = view3d_depth_near(&depth_temp); if (depth_temp.depths) MEM_freeN(depth_temp.depths); return depth_close; } @@ -3438,16 +3444,16 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3]) { bglMats mats; /* ZBuffer depth vars */ - float depth_close= FLT_MAX; + float depth_close = FLT_MAX; double cent[2], p[3]; /* Get Z Depths, needed for perspective, nice for ortho */ bgl_get_mats(&mats); draw_depth(scene, ar, v3d, NULL); - depth_close= view_autodist_depth_margin(ar, mval, 4); + depth_close = view_autodist_depth_margin(ar, mval, 4); - if (depth_close==FLT_MAX) + if (depth_close == FLT_MAX) return 0; cent[0] = (double)mval[0]; @@ -3468,13 +3474,13 @@ int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2] int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, float *autodist ) { /* Get Z Depths, needed for perspective, nice for ortho */ - switch(mode) { - case 0: - draw_depth(scene, ar, v3d, NULL); - break; - case 1: - draw_depth_gpencil(scene, ar, v3d); - break; + switch (mode) { + case 0: + draw_depth(scene, ar, v3d, NULL); + break; + case 1: + draw_depth_gpencil(scene, ar, v3d); + break; } return 1; @@ -3490,11 +3496,11 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl /* Get Z Depths, needed for perspective, nice for ortho */ if (force_depth) - depth= *force_depth; + depth = *force_depth; else - depth= view_autodist_depth_margin(ar, mval, margin); + depth = view_autodist_depth_margin(ar, mval, margin); - if (depth==FLT_MAX) + if (depth == FLT_MAX) return 0; cent[0] = (double)mval[0]; @@ -3503,7 +3509,7 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl bgl_get_mats(&mats); if (!gluUnProject(cent[0], cent[1], depth, - mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) + mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) { return 0; } @@ -3516,9 +3522,9 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth) { - *depth= view_autodist_depth_margin(ar, mval, margin); + *depth = view_autodist_depth_margin(ar, mval, margin); - return (*depth==FLT_MAX) ? 0:1; + return (*depth == FLT_MAX) ? 0 : 1; } static int depth_segment_cb(int x, int y, void *userData) @@ -3527,13 +3533,13 @@ static int depth_segment_cb(int x, int y, void *userData) int mval[2]; float depth; - mval[0]= x; - mval[1]= y; + mval[0] = x; + mval[1] = y; - depth= view_autodist_depth_margin(data->ar, mval, data->margin); + depth = view_autodist_depth_margin(data->ar, mval, data->margin); if (depth != FLT_MAX) { - data->depth= depth; + data->depth = depth; return 0; } else { @@ -3548,18 +3554,18 @@ int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], cons int p1[2]; int p2[2]; - data.ar= ar; - data.margin= margin; - data.depth= FLT_MAX; + data.ar = ar; + data.margin = margin; + data.depth = FLT_MAX; copy_v2_v2_int(p1, mval_sta); copy_v2_v2_int(p2, mval_end); plot_line_v2v2i(p1, p2, depth_segment_cb, &data); - *depth= data.depth; + *depth = data.depth; - return (*depth==FLT_MAX) ? 0:1; + return (*depth == FLT_MAX) ? 0 : 1; } /** @@ -3585,9 +3591,9 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) float nmat[3][3]; float vec[3]; - vec[0]= 0.0f; - vec[1]= 0.0f; - vec[2]= -(*dist); + vec[0] = 0.0f; + vec[1] = 0.0f; + vec[2] = -(*dist); copy_m3_m4(nmat, mat); normalize_m3(nmat); @@ -3599,8 +3605,8 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist) { - float iviewquat[4]= {-quat[0], quat[1], quat[2], quat[3]}; - float dvec[3]= {0.0f, 0.0f, dist}; + float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]}; + float dvec[3] = {0.0f, 0.0f, dist}; quat_to_mat4(mat, iviewquat); mul_mat3_m4_v3(mat, dvec); @@ -3618,7 +3624,7 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, camera_params_init(¶ms); camera_params_from_object(¶ms, ob); - *lens= params.lens; + *lens = params.lens; } } @@ -3632,13 +3638,13 @@ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], co BGpic *ED_view3D_background_image_new(View3D *v3d) { - BGpic *bgpic= MEM_callocN(sizeof(BGpic), "Background Image"); + BGpic *bgpic = MEM_callocN(sizeof(BGpic), "Background Image"); - bgpic->size= 5.0; - bgpic->blend= 0.5; - bgpic->iuser.fie_ima= 2; - bgpic->iuser.ok= 1; - bgpic->view= 0; /* 0 for all */ + bgpic->size = 5.0; + bgpic->blend = 0.5; + bgpic->iuser.fie_ima = 2; + bgpic->iuser.ok = 1; + bgpic->view = 0; /* 0 for all */ bgpic->flag |= V3D_BGPIC_EXPANDED; BLI_addtail(&v3d->bgpicbase, bgpic); @@ -3655,13 +3661,13 @@ void ED_view3D_background_image_remove(View3D *v3d, BGpic *bgpic) void ED_view3D_background_image_clear(View3D *v3d) { - BGpic *bgpic= v3d->bgpicbase.first; + BGpic *bgpic = v3d->bgpicbase.first; while (bgpic) { - BGpic *next_bgpic= bgpic->next; + BGpic *next_bgpic = bgpic->next; ED_view3D_background_image_remove(v3d, bgpic); - bgpic= next_bgpic; + bgpic = next_bgpic; } } diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 819d3e0ca4a..0e7c71f0c0a 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -56,7 +56,7 @@ #include "PIL_time.h" /* smoothview */ -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */ enum { FLY_MODAL_CANCEL = 1, @@ -174,7 +174,7 @@ typedef struct FlyInfo { unsigned char use_freelook; int mval[2]; /* latest 2D mouse values */ - wmNDOFMotionData* ndof; /* latest 3D mouse values */ + wmNDOFMotionData*ndof; /* latest 3D mouse values */ /* fly state state */ float speed; /* the speed the view is moving per redraw */ @@ -265,9 +265,9 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), struct ARegion *UNUSE } /* FlyInfo->state */ -#define FLY_RUNNING 0 -#define FLY_CANCEL 1 -#define FLY_CONFIRM 2 +#define FLY_RUNNING 0 +#define FLY_CANCEL 1 +#define FLY_CONFIRM 2 static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event) { @@ -312,7 +312,7 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event fly->use_freelook = FALSE; #ifdef NDOF_FLY_DRAW_TOOMUCH - fly->redraw= 1; + fly->redraw = 1; #endif zero_v3(fly->dvec_prev); @@ -348,8 +348,8 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event (fly->v3d->camera != NULL) && (fly->rv3d->is_persp == FALSE)) { - ((Camera *)fly->v3d->camera->data)->type= CAM_PERSP; - fly->is_ortho_cam= TRUE; + ((Camera *)fly->v3d->camera->data)->type = CAM_PERSP; + fly->is_ortho_cam = TRUE; } if (fly->rv3d->persp == RV3D_CAMOB) { @@ -376,7 +376,7 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event else { /* perspective or ortho */ if (fly->rv3d->persp == RV3D_ORTHO) - fly->rv3d->persp = RV3D_PERSP; /*if ortho projection, make perspective */ + fly->rv3d->persp = RV3D_PERSP; /*if ortho projection, make perspective */ copy_qt_qt(fly->rot_backup, fly->rv3d->viewquat); copy_v3_v3(fly->ofs_backup, fly->rv3d->ofs); @@ -444,8 +444,9 @@ static int flyEnd(bContext *C, FlyInfo *fly) DAG_id_tag_update(fly->root_parent ? &fly->root_parent->id : &v3d->camera->id, OB_RECALC_OB); } else { /* not camera */ + /* Apply the fly mode view */ - /*restore the dist*/ + /* restore the dist */ float mat[3][3]; upvec[0] = upvec[1] = 0; upvec[2] = fly->dist_backup; /*x and y are 0*/ @@ -489,14 +490,14 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) // puts("ndof motion detected in fly mode!"); // static const char* tag_name = "3D mouse position"; - wmNDOFMotionData* incoming_ndof = (wmNDOFMotionData*)event->customdata; + wmNDOFMotionData *incoming_ndof = (wmNDOFMotionData *)event->customdata; switch (incoming_ndof->progress) { case P_STARTING: // start keeping track of 3D mouse position #ifdef NDOF_FLY_DEBUG puts("start keeping track of 3D mouse position"); #endif - // fall through... + // fall through... case P_IN_PROGRESS: // update 3D mouse position #ifdef NDOF_FLY_DEBUG @@ -584,8 +585,8 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) fly->pan_view = FALSE; break; - /* implement WASD keys, - * comments only for 'forward '*/ + /* implement WASD keys, + * comments only for 'forward '*/ case FLY_MODAL_DIR_FORWARD: if (fly->axis == 2 && fly->speed < 0.0f) { /* reverse direction stops, tap again to continue */ fly->axis = -1; @@ -686,11 +687,11 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) } } -static void move_camera(bContext* C, RegionView3D* rv3d, FlyInfo* fly, int orientationChanged, int positionChanged) +static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orientationChanged, int positionChanged) { /* we are in camera view so apply the view ofs and quat to the view matrix and set the camera to the view */ - View3D* v3d = fly->v3d; + View3D*v3d = fly->v3d; Scene *scene = fly->scene; ID *id_key; @@ -766,19 +767,18 @@ static int flyApply(bContext *C, FlyInfo *fly) RegionView3D *rv3d = fly->rv3d; ARegion *ar = fly->ar; - float mat[3][3], /* 3x3 copy of the view matrix so we can move along the view axis */ - dvec[3] = {0, 0, 0}, /* this is the direction thast added to the view offset per redraw */ + float mat[3][3]; /* 3x3 copy of the view matrix so we can move along the view axis */ + float dvec[3] = {0, 0, 0}; /* this is the direction thast added to the view offset per redraw */ /* Camera Uprighting variables */ - upvec[3] = {0, 0, 0}, /* stores the view's up vector */ + float upvec[3] = {0, 0, 0}; /* stores the view's up vector */ - moffset[2], /* mouse offset from the views center */ - tmp_quat[4]; /* used for rotating the view */ + float moffset[2]; /* mouse offset from the views center */ + float tmp_quat[4]; /* used for rotating the view */ - int -// cent_orig[2], /* view center */ -//XXX- can avoid using // cent[2], /* view center modified */ - xmargin, ymargin; /* x and y margin are define the safe area where the mouses movement wont rotate the view */ +// int cent_orig[2], /* view center */ +//XXX- can avoid using // cent[2], /* view center modified */ + int xmargin, ymargin; /* x and y margin are define the safe area where the mouses movement wont rotate the view */ #ifdef NDOF_FLY_DEBUG { @@ -839,7 +839,7 @@ static int flyApply(bContext *C, FlyInfo *fly) float time_redraw; float time_redraw_clamped; #ifdef NDOF_FLY_DRAW_TOOMUCH - fly->redraw= 1; + fly->redraw = 1; #endif time_current = PIL_check_seconds_timer(); time_redraw = (float)(time_current - fly->time_lastdraw); @@ -870,7 +870,7 @@ static int flyApply(bContext *C, FlyInfo *fly) } else { float roll; /* similar to the angle between the camera's up and the Z-up, - * but its very rough so just roll */ + * but its very rough so just roll */ /* rotate about the X axis- look up/down */ if (moffset[1]) { @@ -883,7 +883,7 @@ static int flyApply(bContext *C, FlyInfo *fly) mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); if (fly->xlock) - fly->xlock = 2; /*check for rotation*/ + fly->xlock = 2; /*check for rotation*/ if (fly->zlock) fly->zlock = 2; fly->xlock_momentum = 0.0f; @@ -919,7 +919,7 @@ static int flyApply(bContext *C, FlyInfo *fly) mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); if (fly->xlock) - fly->xlock = 2;/*check for rotation*/ + fly->xlock = 2; /*check for rotation*/ if (fly->zlock) fly->zlock = 2; } @@ -940,7 +940,7 @@ static int flyApply(bContext *C, FlyInfo *fly) mul_m3_v3(mat, upvec); /* Rotate about the relative up vec */ axis_angle_to_quat(tmp_quat, upvec, - roll * time_redraw_clamped * fly->zlock_momentum * FLY_ZUP_CORRECT_FAC); + roll * time_redraw_clamped * fly->zlock_momentum * FLY_ZUP_CORRECT_FAC); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); fly->zlock_momentum += FLY_ZUP_CORRECT_ACCEL; @@ -1031,9 +1031,9 @@ static int flyApply(bContext *C, FlyInfo *fly) static int flyApply_ndof(bContext *C, FlyInfo *fly) { /* shorthand for oft-used variables */ - wmNDOFMotionData* ndof = fly->ndof; + wmNDOFMotionData *ndof = fly->ndof; const float dt = ndof->dt; - RegionView3D* rv3d = fly->rv3d; + RegionView3D*rv3d = fly->rv3d; const int flag = U.ndof_flag; #if 0 @@ -1056,7 +1056,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) float speed = 10.f; /* blender units per second */ /* ^^ this is ok for default cube scene, but should scale with.. something */ - float trans[3] = {lateral_sensitivity * ndof->tvec[0], + float trans[3] = {lateral_sensitivity *ndof->tvec[0], vertical_sensitivity * ndof->tvec[1], forward_sensitivity * ndof->tvec[2]}; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index c20ea004e9d..aa76d9a94c1 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -85,57 +85,57 @@ */ /* view3d handler codes */ -#define VIEW3D_HANDLER_BACKGROUND 1 -#define VIEW3D_HANDLER_PROPERTIES 2 -#define VIEW3D_HANDLER_OBJECT 3 -#define VIEW3D_HANDLER_PREVIEW 4 -#define VIEW3D_HANDLER_MULTIRES 5 -#define VIEW3D_HANDLER_TRANSFORM 6 +#define VIEW3D_HANDLER_BACKGROUND 1 +#define VIEW3D_HANDLER_PROPERTIES 2 +#define VIEW3D_HANDLER_OBJECT 3 +#define VIEW3D_HANDLER_PREVIEW 4 +#define VIEW3D_HANDLER_MULTIRES 5 +#define VIEW3D_HANDLER_TRANSFORM 6 #define VIEW3D_HANDLER_GREASEPENCIL 7 -#define VIEW3D_HANDLER_BONESKETCH 8 +#define VIEW3D_HANDLER_BONESKETCH 8 /* end XXX ************* */ static void do_view3d_header_buttons(bContext *C, void *arg, int event); #define B_SCENELOCK 101 -#define B_FULL 102 -#define B_HOME 103 -#define B_VIEWBUT 104 -#define B_PERSP 105 +#define B_FULL 102 +#define B_HOME 103 +#define B_VIEWBUT 104 +#define B_PERSP 105 #define B_MODESELECT 108 -#define B_SEL_VERT 110 -#define B_SEL_EDGE 111 -#define B_SEL_FACE 112 -#define B_MAN_TRANS 116 -#define B_MAN_ROT 117 -#define B_MAN_SCALE 118 -#define B_NDOF 119 -#define B_MAN_MODE 120 -#define B_REDR 122 -#define B_NOP 123 +#define B_SEL_VERT 110 +#define B_SEL_EDGE 111 +#define B_SEL_FACE 112 +#define B_MAN_TRANS 116 +#define B_MAN_ROT 117 +#define B_MAN_SCALE 118 +#define B_NDOF 119 +#define B_MAN_MODE 120 +#define B_REDR 122 +#define B_NOP 123 // XXX quickly ported across static void handle_view3d_lock(bContext *C) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= CTX_wm_view3d(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = CTX_wm_view3d(C); if (v3d != NULL && sa != NULL) { - if (v3d->localvd==NULL && v3d->scenelock && sa->spacetype==SPACE_VIEW3D) { + if (v3d->localvd == NULL && v3d->scenelock && sa->spacetype == SPACE_VIEW3D) { /* copy to scene */ - scene->lay= v3d->lay; - scene->layact= v3d->layact; - scene->camera= v3d->camera; + scene->lay = v3d->lay; + scene->layact = v3d->layact; + scene->camera = v3d->camera; /* not through notifier, listener don't have context * and non-open screens or spaces need to be updated too */ BKE_screen_view3d_main_sync(&bmain->screen, scene); /* notifiers for scene update */ - WM_event_add_notifier(C, NC_SCENE|ND_LAYER, scene); + WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); } } } @@ -150,11 +150,11 @@ static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d) { /* sanity check - when in editmode disallow switching the editmode layer off since its confusing * an alternative would be to always draw the editmode object. */ - if (scene->obedit && (scene->obedit->lay & v3d->lay)==0) { + if (scene->obedit && (scene->obedit->lay & v3d->lay) == 0) { int bit; - for (bit=0; bit<32; bit++) { - if (scene->obedit->lay & (1<<bit)) { - v3d->lay |= 1<<bit; + for (bit = 0; bit < 32; bit++) { + if (scene->obedit->lay & (1 << bit)) { + v3d->lay |= 1 << bit; break; } } @@ -163,11 +163,11 @@ static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d) static int view3d_layers_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - int nr= RNA_int_get(op->ptr, "nr"); - int toggle= RNA_boolean_get(op->ptr, "toggle"); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = sa->spacedata.first; + int nr = RNA_int_get(op->ptr, "nr"); + int toggle = RNA_boolean_get(op->ptr, "toggle"); if (nr < 0) return OPERATOR_CANCELLED; @@ -175,16 +175,16 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) if (nr == 0) { /* all layers */ if (!v3d->layact) - v3d->layact= 1; + v3d->layact = 1; - if (toggle && v3d->lay == ((1<<20)-1)) { + if (toggle && v3d->lay == ((1 << 20) - 1)) { /* return to active layer only */ v3d->lay = v3d->layact; view3d_layers_editmode_ensure(scene, v3d); } else { - v3d->lay |= (1<<20)-1; + v3d->lay |= (1 << 20) - 1; } } else { @@ -192,24 +192,24 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) nr--; if (RNA_boolean_get(op->ptr, "extend")) { - if (toggle && v3d->lay & (1<<nr) && (v3d->lay & ~(1<<nr))) - v3d->lay &= ~(1<<nr); + if (toggle && v3d->lay & (1 << nr) && (v3d->lay & ~(1 << nr))) + v3d->lay &= ~(1 << nr); else - v3d->lay |= (1<<nr); + v3d->lay |= (1 << nr); } else { - v3d->lay = (1<<nr); + v3d->lay = (1 << nr); } view3d_layers_editmode_ensure(scene, v3d); /* set active layer, ensure to always have one */ - if (v3d->lay & (1<<nr)) - v3d->layact= 1<<nr; - else if ((v3d->lay & v3d->layact)==0) { - for (bit=0; bit<32; bit++) { - if (v3d->lay & (1<<bit)) { - v3d->layact= 1<<bit; + if (v3d->lay & (1 << nr)) + v3d->layact = 1 << nr; + else if ((v3d->lay & v3d->layact) == 0) { + for (bit = 0; bit < 32; bit++) { + if (v3d->lay & (1 << bit)) { + v3d->layact = 1 << bit; break; } } @@ -238,7 +238,7 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_boolean_set(op->ptr, "extend", FALSE); if (event->alt) { - int nr= RNA_int_get(op->ptr, "nr") + 10; + int nr = RNA_int_get(op->ptr, "nr") + 10; RNA_int_set(op->ptr, "nr", nr); } view3d_layers_exec(C, op); @@ -248,7 +248,7 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, wmEvent *event) static int view3d_layers_poll(bContext *C) { - return (ED_operator_view3d_active(C) && CTX_wm_view3d(C)->localvd==NULL); + return (ED_operator_view3d_active(C) && CTX_wm_view3d(C)->localvd == NULL); } void VIEW3D_OT_layers(wmOperatorType *ot) @@ -264,7 +264,7 @@ void VIEW3D_OT_layers(wmOperatorType *ot) ot->poll = view3d_layers_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "nr", 1, 0, 20, "Number", "The layer number to set, zero for all layers", 0, 20); RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Add this layer to the current view layers"); @@ -280,29 +280,29 @@ static int modeselect_addmode(char *str, const char *title, int id, int icon) static char *view3d_modeselect_pup(Scene *scene) { - Object *ob= OBACT; + Object *ob = OBACT; static char string[512]; - const char *title= IFACE_("Mode: %t"); + const char *title = IFACE_("Mode: %t"); char *str = string; BLI_strncpy(str, title, sizeof(string)); str += modeselect_addmode(str, N_("Object Mode"), OB_MODE_OBJECT, ICON_OBJECT_DATA); - if (ob==NULL || ob->data==NULL) return string; + if (ob == NULL || ob->data == NULL) return string; if (ob->id.lib) return string; if (!((ID *)ob->data)->lib) { /* if active object is editable */ if ( ((ob->type == OB_MESH) - || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT) - || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) { + || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT) + || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) { str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT); } else if (ob->type == OB_ARMATURE) { if (ob->mode & OB_MODE_POSE) - str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT); + str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT | OB_MODE_POSE, ICON_EDITMODE_HLT); else str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT); } @@ -317,13 +317,13 @@ static char *view3d_modeselect_pup(Scene *scene) } /* if active object is an armature */ - if (ob->type==OB_ARMATURE) { + if (ob->type == OB_ARMATURE) { str += modeselect_addmode(str, N_("Pose Mode"), OB_MODE_POSE, ICON_POSE_HLT); } - if ( ob->particlesystem.first || - modifiers_findByType(ob, eModifierType_Cloth) || - modifiers_findByType(ob, eModifierType_Softbody)) + if (ob->particlesystem.first || + modifiers_findByType(ob, eModifierType_Cloth) || + modifiers_findByType(ob, eModifierType_Softbody)) { str += modeselect_addmode(str, N_("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE); } @@ -340,7 +340,7 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event) View3D *v3d = sa->spacedata.first; Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = NULL; - int ctrl = win->eventstate->ctrl, shift= win->eventstate->shift; + int ctrl = win->eventstate->ctrl, shift = win->eventstate->shift; PointerRNA props_ptr; if (obedit && obedit->type == OB_MESH) { @@ -348,83 +348,83 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event) } /* watch it: if sa->win does not exist, check that when calling direct drawing routines */ - switch(event) { - case B_REDR: - ED_area_tag_redraw(sa); - break; - - case B_MODESELECT: - WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set"); - RNA_enum_set(&props_ptr, "mode", v3d->modeselect); - WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr); - WM_operator_properties_free(&props_ptr); - break; - - case B_SEL_VERT: - if (em) { - if (shift==0 || em->selectmode==0) - em->selectmode= SCE_SELECT_VERTEX; - ts->selectmode= em->selectmode; - EDBM_selectmode_set(em); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); - ED_undo_push(C, "Selectmode Set: Vertex"); - } - break; - case B_SEL_EDGE: - if (em) { - if (shift==0 || em->selectmode==0) { - if ( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX) { - if (ctrl) EDBM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE); + switch (event) { + case B_REDR: + ED_area_tag_redraw(sa); + break; + + case B_MODESELECT: + WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set"); + RNA_enum_set(&props_ptr, "mode", v3d->modeselect); + WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr); + WM_operator_properties_free(&props_ptr); + break; + + case B_SEL_VERT: + if (em) { + if (shift == 0 || em->selectmode == 0) + em->selectmode = SCE_SELECT_VERTEX; + ts->selectmode = em->selectmode; + EDBM_selectmode_set(em); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + ED_undo_push(C, "Selectmode Set: Vertex"); + } + break; + case B_SEL_EDGE: + if (em) { + if (shift == 0 || em->selectmode == 0) { + if ( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX) { + if (ctrl) EDBM_convertsel(em, SCE_SELECT_VERTEX, SCE_SELECT_EDGE); + } + em->selectmode = SCE_SELECT_EDGE; } - em->selectmode = SCE_SELECT_EDGE; + ts->selectmode = em->selectmode; + EDBM_selectmode_set(em); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + ED_undo_push(C, "Selectmode Set: Edge"); } - ts->selectmode= em->selectmode; - EDBM_selectmode_set(em); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); - ED_undo_push(C, "Selectmode Set: Edge"); - } - break; - case B_SEL_FACE: - if (em) { - if ( shift==0 || em->selectmode==0) { - if ( ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)) { - if (ctrl) EDBM_convertsel(em, (ts->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE); + break; + case B_SEL_FACE: + if (em) { + if (shift == 0 || em->selectmode == 0) { + if ( ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)) { + if (ctrl) EDBM_convertsel(em, (ts->selectmode ^ SCE_SELECT_FACE), SCE_SELECT_FACE); + } + em->selectmode = SCE_SELECT_FACE; } - em->selectmode = SCE_SELECT_FACE; + ts->selectmode = em->selectmode; + EDBM_selectmode_set(em); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + ED_undo_push(C, "Selectmode Set: Face"); } - ts->selectmode= em->selectmode; - EDBM_selectmode_set(em); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); - ED_undo_push(C, "Selectmode Set: Face"); - } - break; + break; - case B_MAN_TRANS: - if ( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_TRANSLATE; - } - ED_area_tag_redraw(sa); - break; - case B_MAN_ROT: - if ( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_ROTATE; - } - ED_area_tag_redraw(sa); - break; - case B_MAN_SCALE: - if ( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_SCALE; - } - ED_area_tag_redraw(sa); - break; - case B_NDOF: - ED_area_tag_redraw(sa); - break; - case B_MAN_MODE: - ED_area_tag_redraw(sa); - break; - default: - break; + case B_MAN_TRANS: + if (shift == 0 || v3d->twtype == 0) { + v3d->twtype = V3D_MANIP_TRANSLATE; + } + ED_area_tag_redraw(sa); + break; + case B_MAN_ROT: + if (shift == 0 || v3d->twtype == 0) { + v3d->twtype = V3D_MANIP_ROTATE; + } + ED_area_tag_redraw(sa); + break; + case B_MAN_SCALE: + if (shift == 0 || v3d->twtype == 0) { + v3d->twtype = V3D_MANIP_SCALE; + } + ED_area_tag_redraw(sa); + break; + case B_NDOF: + ED_area_tag_redraw(sa); + break; + case B_MAN_MODE: + ED_area_tag_redraw(sa); + break; + default: + break; } } @@ -445,7 +445,7 @@ static int object_mode_icon(int mode) void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C) { Object *obedit = CTX_data_edit_object(C); - uiBlock *block= uiLayoutGetBlock(layout); + uiBlock *block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL); @@ -453,35 +453,35 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C) BMEditMesh *em = BMEdit_FromObject(obedit); uiLayout *row; - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); - uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select - Shift-Click for multiple modes"); - uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select - Shift-Click for multiple modes"); - uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Face select - Shift-Click for multiple modes"); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); + uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select - Shift-Click for multiple modes"); + uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select - Shift-Click for multiple modes"); + uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Face select - Shift-Click for multiple modes"); } } void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) { - bScreen *screen= CTX_wm_screen(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); + bScreen *screen = CTX_wm_screen(C); + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = sa->spacedata.first; + Scene *scene = CTX_data_scene(C); + ToolSettings *ts = CTX_data_tool_settings(C); PointerRNA v3dptr, toolsptr, sceneptr; - Object *ob= OBACT; + Object *ob = OBACT; Object *obedit = CTX_data_edit_object(C); uiBlock *block; uiBut *but; uiLayout *row; - const float dpi_fac= UI_DPI_FAC; + const float dpi_fac = UI_DPI_FAC; int is_paint = 0; RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr); RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr); RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr); - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL); /* other buttons: */ @@ -490,31 +490,31 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) /* mode */ if (ob) { v3d->modeselect = ob->mode; - is_paint = ELEM4(ob->mode, OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT,OB_MODE_TEXTURE_PAINT); + is_paint = ELEM4(ob->mode, OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT); } else { v3d->modeselect = OB_MODE_OBJECT; } - row= uiLayoutRow(layout, 1); - uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , - 0,0,126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_("Mode")); + row = uiLayoutRow(layout, 1); + uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene), + 0, 0, 126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_("Mode")); /* Draw type */ uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - if (obedit==NULL && is_paint) { + if (obedit == NULL && is_paint) { /* Manipulators aren't used in paint modes */ if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) { /* masks aren't used for sculpt and particle painting */ PointerRNA meshptr; RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr); - if (ob->mode & (OB_MODE_TEXTURE_PAINT|OB_MODE_VERTEX_PAINT)) { + if (ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT)) { uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } else { - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, 1); uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } @@ -523,7 +523,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) else { const char *str_menu; - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, 1); uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* pose/object only however we want to allow in weight paint mode too @@ -533,16 +533,16 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } /* Transform widget / manipulators */ - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, 1); uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - block= uiLayoutGetBlock(row); + block = uiLayoutGetBlock(row); if (v3d->twflag & V3D_USE_MANIPULATOR) { - but = uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Translate manipulator - Shift-Click for multiple modes")); + but = uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0, 0, UI_UNIT_X, UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Translate manipulator - Shift-Click for multiple modes")); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ - but = uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Rotate manipulator - Shift-Click for multiple modes")); + but = uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0, 0, UI_UNIT_X, UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Rotate manipulator - Shift-Click for multiple modes")); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ - but = uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Scale manipulator - Shift-Click for multiple modes")); + but = uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0, 0, UI_UNIT_X, UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Scale manipulator - Shift-Click for multiple modes")); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ } @@ -551,12 +551,12 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } str_menu = BIF_menustringTransformOrientation(C, "Orientation"); - but = uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, TIP_("Transform Orientation")); + but = uiDefButC(block, MENU, B_MAN_MODE, str_menu, 0, 0, 70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, TIP_("Transform Orientation")); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ MEM_freeN((void *)str_menu); } - if (obedit==NULL && v3d->localvd==NULL) { + if (obedit == NULL && v3d->localvd == NULL) { unsigned int ob_lay = ob ? ob->lay : 0; /* Layers */ diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index e4133723089..99da487f923 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -132,7 +132,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0); @@ -190,10 +190,10 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANUP); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANDOWN); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPLEFT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPUP); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPDOWN); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPLEFT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPUP); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPDOWN); /* active aligned, replaces '*' key in 2.4x */ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0); @@ -205,13 +205,13 @@ void view3d_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP); RNA_boolean_set(kmi->ptr, "align_active", TRUE); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BACK); RNA_boolean_set(kmi->ptr, "align_active", TRUE); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT); RNA_boolean_set(kmi->ptr, "align_active", TRUE); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM); RNA_boolean_set(kmi->ptr, "align_active", TRUE); @@ -287,22 +287,22 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "enumerate", TRUE); /* selection key-combinations */ - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "center", TRUE); RNA_boolean_set(kmi->ptr, "object", FALSE); RNA_boolean_set(kmi->ptr, "enumerate", FALSE); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "center", TRUE); RNA_boolean_set(kmi->ptr, "object", FALSE); RNA_boolean_set(kmi->ptr, "enumerate", TRUE); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "center", FALSE); RNA_boolean_set(kmi->ptr, "object", FALSE); RNA_boolean_set(kmi->ptr, "enumerate", TRUE); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "center", TRUE); RNA_boolean_set(kmi->ptr, "object", FALSE); @@ -311,7 +311,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", FALSE); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", TRUE); WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0); @@ -319,7 +319,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT | KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b15dc6ab3c7..4251592e986 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -88,18 +88,18 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include // TODO: should return whether there is valid context to continue void view3d_set_viewcontext(bContext *C, ViewContext *vc) { memset(vc, 0, sizeof(ViewContext)); - vc->ar= CTX_wm_region(C); - vc->scene= CTX_data_scene(C); - vc->v3d= CTX_wm_view3d(C); - vc->rv3d= CTX_wm_region_view3d(C); - vc->obact= CTX_data_active_object(C); - vc->obedit= CTX_data_edit_object(C); + vc->ar = CTX_wm_region(C); + vc->scene = CTX_data_scene(C); + vc->v3d = CTX_wm_view3d(C); + vc->rv3d = CTX_wm_region_view3d(C); + vc->obact = CTX_data_active_object(C); + vc->obedit = CTX_data_edit_object(C); } int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int mval[2], const short do_fallback) @@ -107,14 +107,14 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m float dvec[3]; int mval_cpy[2]; - mval_cpy[0]= mval[0]; - mval_cpy[1]= mval[1]; + mval_cpy[0] = mval[0]; + mval_cpy[1] = mval[1]; project_int_noclip(vc->ar, fp, mval_cpy); initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); - if (mval_cpy[0]!=IS_CLIPPED) { + if (mval_cpy[0] != IS_CLIPPED) { float mval_f[2]; VECSUB2D(mval_f, mval_cpy, mval); ED_view3d_win_to_delta(vc->ar, mval_f, dvec); @@ -151,8 +151,8 @@ void view3d_get_transformation(const ARegion *ar, RegionView3D *rv3d, Object *ob for (i = 0; i < 4; ++i) { for (j = 0; j < 4; ++j) { - mats->projection[i*4+j] = rv3d->winmat[i][j]; - mats->modelview[i*4+j] = cpy[i][j]; + mats->projection[i * 4 + j] = rv3d->winmat[i][j]; + mats->modelview[i * 4 + j] = cpy[i][j]; } } @@ -170,10 +170,10 @@ static void EDBM_backbuf_checkAndSelectVerts(BMEditMesh *em, int select) { BMVert *eve; BMIter iter; - int index= bm_wireoffs; + int index = bm_wireoffs; eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL); - for ( ; eve; eve=BM_iter_step(&iter), index++) { + for (; eve; eve = BM_iter_step(&iter), index++) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { if (EDBM_check_backbuf(index)) { BM_vert_select_set(em->bm, eve, select); @@ -186,10 +186,10 @@ static void EDBM_backbuf_checkAndSelectEdges(BMEditMesh *em, int select) { BMEdge *eed; BMIter iter; - int index= bm_solidoffs; + int index = bm_solidoffs; eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL); - for ( ; eed; eed=BM_iter_step(&iter), index++) { + for (; eed; eed = BM_iter_step(&iter), index++) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { if (EDBM_check_backbuf(index)) { BM_edge_select_set(em->bm, eed, select); @@ -202,10 +202,10 @@ static void EDBM_backbuf_checkAndSelectFaces(BMEditMesh *em, int select) { BMFace *efa; BMIter iter; - int index= 1; + int index = 1; efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL); - for ( ; efa; efa=BM_iter_step(&iter), index++) { + for (; efa; efa = BM_iter_step(&iter), index++) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (EDBM_check_backbuf(index)) { BM_face_select_set(em->bm, efa, select); @@ -222,10 +222,10 @@ static void EDBM_backbuf_checkAndSelectVerts_obmode(Mesh *me, int select) int a; if (mv) { - for (a=1; a<=me->totvert; a++, mv++) { + for (a = 1; a <= me->totvert; a++, mv++) { if (EDBM_check_backbuf(a)) { if (!(mv->flag & ME_HIDE)) { - mv->flag = select?(mv->flag|SELECT):(mv->flag&~SELECT); + mv->flag = select ? (mv->flag | SELECT) : (mv->flag & ~SELECT); } } } @@ -239,9 +239,9 @@ static void EDBM_backbuf_checkAndSelectTFaces(Mesh *me, int select) int a; if (mpoly) { - for (a=1; a<=me->totpoly; a++, mpoly++) { + for (a = 1; a <= me->totpoly; a++, mpoly++) { if (EDBM_check_backbuf(a)) { - mpoly->flag = select?(mpoly->flag|ME_FACE_SEL):(mpoly->flag&~ME_FACE_SEL); + mpoly->flag = select ? (mpoly->flag | ME_FACE_SEL) : (mpoly->flag & ~ME_FACE_SEL); } } } @@ -272,7 +272,7 @@ static int view3d_selectable_data(bContext *C) if (ob->mode & OB_MODE_SCULPT) { return 0; } - if ((ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) && + if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) && !paint_facesel_test(ob) && !paint_vertsel_test(ob)) { return 0; @@ -298,19 +298,19 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) if (edge_fully_inside_rect(rect, x1, y1, x2, y2)) return 1; /* check points completely out rect */ - if (x1<rect->xmin && x2<rect->xmin) return 0; - if (x1>rect->xmax && x2>rect->xmax) return 0; - if (y1<rect->ymin && y2<rect->ymin) return 0; - if (y1>rect->ymax && y2>rect->ymax) return 0; + if (x1 < rect->xmin && x2 < rect->xmin) return 0; + if (x1 > rect->xmax && x2 > rect->xmax) return 0; + if (y1 < rect->ymin && y2 < rect->ymin) return 0; + if (y1 > rect->ymax && y2 > rect->ymax) return 0; /* simple check lines intersecting. */ - d1= (y1-y2)*(x1- rect->xmin ) + (x2-x1)*(y1- rect->ymin ); - d2= (y1-y2)*(x1- rect->xmin ) + (x2-x1)*(y1- rect->ymax ); - d3= (y1-y2)*(x1- rect->xmax ) + (x2-x1)*(y1- rect->ymax ); - d4= (y1-y2)*(x1- rect->xmax ) + (x2-x1)*(y1- rect->ymin ); + d1 = (y1 - y2) * (x1 - rect->xmin) + (x2 - x1) * (y1 - rect->ymin); + d2 = (y1 - y2) * (x1 - rect->xmin) + (x2 - x1) * (y1 - rect->ymax); + d3 = (y1 - y2) * (x1 - rect->xmax) + (x2 - x1) * (y1 - rect->ymax); + d4 = (y1 - y2) * (x1 - rect->xmax) + (x2 - x1) * (y1 - rect->ymin); - if (d1<0 && d2<0 && d3<0 && d4<0) return 0; - if (d1>0 && d2>0 && d3>0 && d4>0) return 0; + if (d1 < 0 && d2 < 0 && d3 < 0 && d4 < 0) return 0; + if (d1 > 0 && d2 > 0 && d3 > 0 && d4 > 0) return 0; return 1; } @@ -322,47 +322,47 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) int lasso_inside(int mcords[][2], short moves, int sx, int sy) { /* we do the angle rule, define that all added angles should be about zero or 2*PI */ - float angletot=0.0, len, dot, ang, cross, fp1[2], fp2[2]; + float angletot = 0.0, len, dot, ang, cross, fp1[2], fp2[2]; int a; int *p1, *p2; - if (sx==IS_CLIPPED) + if (sx == IS_CLIPPED) return 0; - p1= mcords[moves-1]; - p2= mcords[0]; + p1 = mcords[moves - 1]; + p2 = mcords[0]; /* first vector */ - fp1[0]= (float)(p1[0]-sx); - fp1[1]= (float)(p1[1]-sy); - len= sqrt(fp1[0]*fp1[0] + fp1[1]*fp1[1]); - fp1[0]/= len; - fp1[1]/= len; + fp1[0] = (float)(p1[0] - sx); + fp1[1] = (float)(p1[1] - sy); + len = sqrt(fp1[0] * fp1[0] + fp1[1] * fp1[1]); + fp1[0] /= len; + fp1[1] /= len; - for (a=0; a<moves; a++) { + for (a = 0; a < moves; a++) { /* second vector */ - fp2[0]= (float)(p2[0]-sx); - fp2[1]= (float)(p2[1]-sy); - len= sqrt(fp2[0]*fp2[0] + fp2[1]*fp2[1]); - fp2[0]/= len; - fp2[1]/= len; + fp2[0] = (float)(p2[0] - sx); + fp2[1] = (float)(p2[1] - sy); + len = sqrt(fp2[0] * fp2[0] + fp2[1] * fp2[1]); + fp2[0] /= len; + fp2[1] /= len; /* dot and angle and cross */ - dot= fp1[0]*fp2[0] + fp1[1]*fp2[1]; - ang= fabs(saacos(dot)); + dot = fp1[0] * fp2[0] + fp1[1] * fp2[1]; + ang = fabs(saacos(dot)); - cross= (float)((p1[1]-p2[1])*(p1[0]-sx) + (p2[0]-p1[0])*(p1[1]-sy)); + cross = (float)((p1[1] - p2[1]) * (p1[0] - sx) + (p2[0] - p1[0]) * (p1[1] - sy)); - if (cross<0.0f) angletot-= ang; - else angletot+= ang; + if (cross < 0.0f) angletot -= ang; + else angletot += ang; /* circulate */ - fp1[0]= fp2[0]; fp1[1]= fp2[1]; - p1= p2; - p2= mcords[a+1]; + fp1[0] = fp2[0]; fp1[1] = fp2[1]; + p1 = p2; + p2 = mcords[a + 1]; } - if ( fabs(angletot) > 4.0 ) return 1; + if (fabs(angletot) > 4.0) return 1; return 0; } @@ -372,7 +372,7 @@ int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int int v1[2], v2[2]; int a; - if (x0==IS_CLIPPED || x1==IS_CLIPPED) + if (x0 == IS_CLIPPED || x1 == IS_CLIPPED) return 0; v1[0] = x0, v1[1] = y0; @@ -384,9 +384,9 @@ int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int /* no points in lasso, so we have to intersect with lasso edge */ - if ( isect_line_line_v2_int(mcords[0], mcords[moves-1], v1, v2) > 0) return 1; - for (a=0; a<moves-1; a++) { - if ( isect_line_line_v2_int(mcords[a], mcords[a+1], v1, v2) > 0) return 1; + if (isect_line_line_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return 1; + for (a = 0; a < moves - 1; a++) { + if (isect_line_line_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return 1; } return 0; @@ -401,12 +401,12 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], s bPoseChannel *pchan; float vec[3]; int sco1[2], sco2[2]; - bArmature *arm= ob->data; + bArmature *arm = ob->data; - if (ob->type!=OB_ARMATURE || ob->pose==NULL) return; + if (ob->type != OB_ARMATURE || ob->pose == NULL) return; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) { mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); project_int(vc->ar, vec, sco1); mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); @@ -424,7 +424,7 @@ static void object_deselect_all_visible(Scene *scene, View3D *v3d) { Base *base; - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (BASE_SELECTABLE(v3d, base)) { ED_base_object_select(base, BA_DESELECT); } @@ -438,14 +438,14 @@ static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short move if (extend == 0 && select) object_deselect_all_visible(vc->scene, vc->v3d); - for (base= vc->scene->base.first; base; base= base->next) { + for (base = vc->scene->base.first; base; base = base->next) { if (BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */ project_short(vc->ar, base->object->obmat[3], &base->sx); if (lasso_inside(mcords, moves, base->sx, base->sy)) { if (select) ED_base_object_select(base, BA_SELECT); else ED_base_object_select(base, BA_DESELECT); - base->object->flag= base->flag; + base->object->flag = base->flag; } if (base->object->mode & OB_MODE_POSE) { do_lasso_select_pose(vc, base->object, mcords, moves, select); @@ -461,11 +461,11 @@ static void lasso_select_boundbox(rcti *rect, int mcords[][2], short moves) rect->xmin = rect->xmax = mcords[0][0]; rect->ymin = rect->ymax = mcords[0][1]; - for (a=1; a<moves; a++) { - if (mcords[a][0]<rect->xmin) rect->xmin = mcords[a][0]; - else if (mcords[a][0]>rect->xmax) rect->xmax = mcords[a][0]; - if (mcords[a][1]<rect->ymin) rect->ymin = mcords[a][1]; - else if (mcords[a][1]>rect->ymax) rect->ymax = mcords[a][1]; + for (a = 1; a < moves; a++) { + if (mcords[a][0] < rect->xmin) rect->xmin = mcords[a][0]; + else if (mcords[a][0] > rect->xmax) rect->xmax = mcords[a][0]; + if (mcords[a][1] < rect->ymin) rect->ymin = mcords[a][1]; + else if (mcords[a][1] > rect->ymax) rect->ymax = mcords[a][1]; } } @@ -481,11 +481,11 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int { LassoSelectUserData *data = userData; - if (EDBM_check_backbuf(bm_solidoffs+index)) { - if (data->pass==0) { - if ( edge_fully_inside_rect(data->rect, x0, y0, x1, y1) && - lasso_inside(data->mcords, data->moves, x0, y0) && - lasso_inside(data->mcords, data->moves, x1, y1)) { + if (EDBM_check_backbuf(bm_solidoffs + index)) { + if (data->pass == 0) { + if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1) && + lasso_inside(data->mcords, data->moves, x0, y0) && + lasso_inside(data->mcords, data->moves, x1, y1)) { BM_elem_select_set(data->vc->em->bm, eed, data->select); data->done = 1; } @@ -509,7 +509,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { LassoSelectUserData data; - ToolSettings *ts= vc->scene->toolsettings; + ToolSettings *ts = vc->scene->toolsettings; rcti rect; int bbsel; @@ -518,7 +518,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, /* set editmesh */ vc->em = BMEdit_FromObject(vc->obedit); - data.vc= vc; + data.vc = vc; data.rect = ▭ data.mcords = mcords; data.moves = moves; @@ -529,11 +529,11 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, if (extend == 0 && select) EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT); - /* for non zbuf projections, don't change the GL state */ + /* for non zbuf projections, don't change the GL state */ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); glLoadMatrixf(vc->rv3d->viewmat); - bbsel= EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); + bbsel = EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); if (ts->selectmode & SCE_SELECT_VERTEX) { if (bbsel) { @@ -548,7 +548,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, data.pass = 0; mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_CLIP_TEST_OFF); - if (data.done==0) { + if (data.done == 0) { data.pass = 1; mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_CLIP_TEST_OFF); } @@ -582,7 +582,7 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) if (draw_uvs_face_check()) { /* Face Center Sel */ float cent[2]; ok = 0; - for (efa= em->faces.first; efa; efa= efa->next) { + for (efa = em->faces.first; efa; efa = efa->next) { /* assume not touched */ efa->tmp.l = 0; tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); @@ -600,11 +600,11 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) } else { /* Vert Sel*/ - for (efa= em->faces.first; efa; efa= efa->next) { + for (efa = em->faces.first; efa; efa = efa->next) { tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); if (uvedit_face_visible(scene, ima, efa, tf)) { - nverts= efa->v4? 4: 3; - for (i=0; i<nverts; i++) { + nverts = efa->v4 ? 4 : 3; + for (i = 0; i < nverts; i++) { if ((select) != (simaUVSel_Check(efa, tf, i))) { uvco_to_areaco_noclip(tf->uv[i], screenUV); if (BLI_in_rcti(&rect, screenUV[0], screenUV[1]) && lasso_inside(mcords, moves, screenUV[0], screenUV[1])) { @@ -622,7 +622,7 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) } if (ok && G.sima->flag & SI_SYNC_UVSEL) { if (select) EM_select_flush(vc->em); - else EM_deselect_flush(vc->em); + else EM_deselect_flush(vc->em); } } #endif @@ -630,28 +630,28 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { LassoSelectUserData *data = userData; - Object *obedit= data->vc->obedit; - Curve *cu= (Curve*)obedit->data; + Object *obedit = data->vc->obedit; + Curve *cu = (Curve *)obedit->data; if (lasso_inside(data->mcords, data->moves, x, y)) { if (bp) { - bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; } else { if (cu->drawflag & CU_HIDE_HANDLES) { /* can only be beztindex==0 here since handles are hidden */ - bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); + bezt->f1 = bezt->f2 = bezt->f3 = data->select ? (bezt->f2 | SELECT) : (bezt->f2 & ~SELECT); } else { - if (beztindex==0) { - bezt->f1 = data->select?(bezt->f1|SELECT):(bezt->f1&~SELECT); + if (beztindex == 0) { + bezt->f1 = data->select ? (bezt->f1 | SELECT) : (bezt->f1 & ~SELECT); } - else if (beztindex==1) { - bezt->f2 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); + else if (beztindex == 1) { + bezt->f2 = data->select ? (bezt->f2 | SELECT) : (bezt->f2 & ~SELECT); } else { - bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT); + bezt->f3 = data->select ? (bezt->f3 | SELECT) : (bezt->f3 & ~SELECT); } } @@ -682,7 +682,7 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, LassoSelectUserData *data = userData; if (lasso_inside(data->mcords, data->moves, x, y)) { - bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short moves, short extend, short select) @@ -703,42 +703,42 @@ static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short move static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - bArmature *arm= vc->obedit->data; + bArmature *arm = vc->obedit->data; EditBone *ebone; float vec[3]; short sco1[2], sco2[2], didpoint; - int change= FALSE; + int change = FALSE; - if (extend==0 && select) + if (extend == 0 && select) ED_armature_deselect_all_visible(vc->obedit); /* set editdata in vc */ - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { - if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE)==0) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) { mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head); project_short(vc->ar, vec, sco1); mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail); project_short(vc->ar, vec, sco2); - didpoint= 0; + didpoint = 0; if (lasso_inside(mcords, moves, sco1[0], sco1[1])) { if (select) ebone->flag |= BONE_ROOTSEL; else ebone->flag &= ~BONE_ROOTSEL; - didpoint= 1; - change= TRUE; + didpoint = 1; + change = TRUE; } if (lasso_inside(mcords, moves, sco2[0], sco2[1])) { if (select) ebone->flag |= BONE_TIPSEL; else ebone->flag &= ~BONE_TIPSEL; - didpoint= 1; - change= TRUE; + didpoint = 1; + change = TRUE; } /* if one of points selected, we skip the bone itself */ - if (didpoint==0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { - if (select) ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED; - else ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - change= TRUE; + if (didpoint == 0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { + if (select) ebone->flag |= BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED; + else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + change = TRUE; } } } @@ -746,7 +746,7 @@ static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short mov if (change) { ED_armature_sync_selection(arm->edbo); ED_armature_validate_active(arm); - WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obedit); + WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit); } } @@ -755,25 +755,25 @@ static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short mov static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - MetaBall *mb = (MetaBall*)vc->obedit->data; + MetaBall *mb = (MetaBall *)vc->obedit->data; MetaElem *ml; float vec[3]; short sco[2]; if (extend == 0 && select) { - for (ml= mb->editelems->first; ml; ml= ml->next) { + for (ml = mb->editelems->first; ml; ml = ml->next) { ml->flag &= ~SELECT; } } - for (ml= mb->editelems->first; ml; ml= ml->next) { + for (ml = mb->editelems->first; ml; ml = ml->next) { mul_v3_m4v3(vec, vc->obedit->obmat, &ml->x); project_short(vc->ar, vec, sco); if (lasso_inside(mcords, moves, sco[0], sco[1])) { - if (select) ml->flag |= SELECT; - else ml->flag &= ~SELECT; + if (select) ml->flag |= SELECT; + else ml->flag &= ~SELECT; } } } @@ -786,36 +786,36 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) unsigned int *rt; int a, index; char *selar; - int sx= rect->xmax-rect->xmin+1; - int sy= rect->ymax-rect->ymin+1; + int sx = rect->xmax - rect->xmin + 1; + int sy = rect->ymax - rect->ymin + 1; - me= vc->obact->data; + me = vc->obact->data; - if (me==NULL || me->totvert==0 || sx*sy <= 0) + if (me == NULL || me->totvert == 0 || sx * sy <= 0) return OPERATOR_CANCELLED; - selar= MEM_callocN(me->totvert+1, "selar"); + selar = MEM_callocN(me->totvert + 1, "selar"); if (extend == 0 && select) paintvert_deselect_all_visible(vc->obact, SEL_DESELECT, FALSE); view3d_validate_backbuf(vc); - ibuf = IMB_allocImBuf(sx,sy,32,IB_rect); + ibuf = IMB_allocImBuf(sx, sy, 32, IB_rect); rt = ibuf->rect; - glReadPixels(rect->xmin+vc->ar->winrct.xmin, rect->ymin+vc->ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - if (ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); + glReadPixels(rect->xmin + vc->ar->winrct.xmin, rect->ymin + vc->ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); - a= sx*sy; + a = sx * sy; while (a--) { if (*rt) { - index= WM_framebuffer_to_index(*rt); - if (index<=me->totvert) selar[index]= 1; + index = WM_framebuffer_to_index(*rt); + if (index <= me->totvert) selar[index] = 1; } rt++; } - mvert= me->mvert; + mvert = me->mvert; for (a = 1; a <= me->totvert; a++, mvert++) { if (selar[a]) { if ((mvert->flag & ME_HIDE) == 0) { @@ -839,16 +839,16 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) static void do_lasso_select_paintvert(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - Object *ob= vc->obact; - Mesh *me= ob?ob->data:NULL; + Object *ob = vc->obact; + Mesh *me = ob ? ob->data : NULL; rcti rect; - if (me==NULL || me->totvert==0) + if (me == NULL || me->totvert == 0) return; - if (extend==0 && select) - paintvert_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */ - bm_vertoffs= me->totvert+1; /* max index array */ + if (extend == 0 && select) + paintvert_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */ + bm_vertoffs = me->totvert + 1; /* max index array */ lasso_select_boundbox(&rect, mcords, moves); EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -861,17 +861,17 @@ static void do_lasso_select_paintvert(ViewContext *vc, int mcords[][2], short mo } static void do_lasso_select_paintface(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - Object *ob= vc->obact; - Mesh *me= ob?ob->data:NULL; + Object *ob = vc->obact; + Mesh *me = ob ? ob->data : NULL; rcti rect; - if (me==NULL || me->totpoly==0) + if (me == NULL || me->totpoly == 0) return; - if (extend==0 && select) - paintface_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */ + if (extend == 0 && select) + paintface_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */ - bm_vertoffs= me->totpoly+1; /* max index array */ + bm_vertoffs = me->totpoly + 1; /* max index array */ lasso_select_boundbox(&rect, mcords, moves); EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -896,10 +896,10 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) lasso_select_boundbox(&rect, mcords, moves); /* store selection in temp test flag */ - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { - node_centf[0] = (node->totr.xmin+node->totr.xmax)/2; - node_centf[1] = (node->totr.ymin+node->totr.ymax)/2; + node_centf[0] = (node->totr.xmin + node->totr.xmax) / 2; + node_centf[1] = (node->totr.ymin + node->totr.ymax) / 2; ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); if (BLI_in_rcti(&rect, node_cent[0], node_cent[1]) && lasso_inside(mcords, moves, node_cent[0], node_cent[1])) { @@ -919,43 +919,43 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc, int mcords[][2], s { Object *ob = CTX_data_active_object(C); - if (vc->obedit==NULL) { /* Object Mode */ + if (vc->obedit == NULL) { /* Object Mode */ if (paint_facesel_test(ob)) do_lasso_select_paintface(vc, mcords, moves, extend, select); else if (paint_vertsel_test(ob)) do_lasso_select_paintvert(vc, mcords, moves, extend, select); - else if (ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) + else if (ob && ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) ; else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) PE_lasso_select(C, mcords, moves, extend, select); else { do_lasso_select_objects(vc, mcords, moves, extend, select); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, vc->scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene); } } else { /* Edit Mode */ - switch(vc->obedit->type) { - case OB_MESH: - do_lasso_select_mesh(vc, mcords, moves, extend, select); - break; - case OB_CURVE: - case OB_SURF: - do_lasso_select_curve(vc, mcords, moves, extend, select); - break; - case OB_LATTICE: - do_lasso_select_lattice(vc, mcords, moves, extend, select); - break; - case OB_ARMATURE: - do_lasso_select_armature(vc, mcords, moves, extend, select); - break; - case OB_MBALL: - do_lasso_select_meta(vc, mcords, moves, extend, select); - break; - default: - assert(!"lasso select on incorrect object type"); + switch (vc->obedit->type) { + case OB_MESH: + do_lasso_select_mesh(vc, mcords, moves, extend, select); + break; + case OB_CURVE: + case OB_SURF: + do_lasso_select_curve(vc, mcords, moves, extend, select); + break; + case OB_LATTICE: + do_lasso_select_lattice(vc, mcords, moves, extend, select); + break; + case OB_ARMATURE: + do_lasso_select_armature(vc, mcords, moves, extend, select); + break; + case OB_MBALL: + do_lasso_select_meta(vc, mcords, moves, extend, select); + break; + default: + assert(!"lasso select on incorrect object type"); } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc->obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc->obedit->data); } } @@ -965,29 +965,29 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc, int mcords[][2], s static int view3d_lasso_select_exec(bContext *C, wmOperator *op) { ViewContext vc; - int i= 0; + int i = 0; int mcords[1024][2]; RNA_BEGIN(op->ptr, itemptr, "path") { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); - mcords[i][0]= (int)loc[0]; - mcords[i][1]= (int)loc[1]; + mcords[i][0] = (int)loc[0]; + mcords[i][1] = (int)loc[1]; i++; - if (i>=1024) break; + if (i >= 1024) break; } RNA_END; - if (i>1) { + if (i > 1) { short extend, select; view3d_operator_needs_opengl(C); /* setup view context for argument to callbacks */ view3d_set_viewcontext(C, &vc); - extend= RNA_boolean_get(op->ptr, "extend"); - select= !RNA_boolean_get(op->ptr, "deselect"); + extend = RNA_boolean_get(op->ptr, "extend"); + select = !RNA_boolean_get(op->ptr, "deselect"); view3d_lasso_select(C, &vc, mcords, i, extend, select); return OPERATOR_FINISHED; @@ -1023,41 +1023,41 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot) static unsigned int samplerect(unsigned int *buf, int size, unsigned int dontdo) { Base *base; - unsigned int *bufmin,*bufmax; - int a,b,rc,tel,len,dirvec[4][2],maxob; - unsigned int retval=0; + unsigned int *bufmin, *bufmax; + int a, b, rc, tel, len, dirvec[4][2], maxob; + unsigned int retval = 0; - base= LASTBASE; - if (base==0) return 0; - maxob= base->selcol; + base = LASTBASE; + if (base == 0) return 0; + maxob = base->selcol; - len= (size-1)/2; - rc= 0; + len = (size - 1) / 2; + rc = 0; - dirvec[0][0]= 1; - dirvec[0][1]= 0; - dirvec[1][0]= 0; - dirvec[1][1]= -size; - dirvec[2][0]= -1; - dirvec[2][1]= 0; - dirvec[3][0]= 0; - dirvec[3][1]= size; + dirvec[0][0] = 1; + dirvec[0][1] = 0; + dirvec[1][0] = 0; + dirvec[1][1] = -size; + dirvec[2][0] = -1; + dirvec[2][1] = 0; + dirvec[3][0] = 0; + dirvec[3][1] = size; - bufmin= buf; - bufmax= buf+ size*size; - buf+= len*size+ len; + bufmin = buf; + bufmax = buf + size * size; + buf += len * size + len; - for (tel=1;tel<=size;tel++) { + for (tel = 1; tel <= size; tel++) { - for (a=0;a<2;a++) { - for (b=0;b<tel;b++) { + for (a = 0; a < 2; a++) { + for (b = 0; b < tel; b++) { - if (*buf && *buf<=maxob && *buf!=dontdo) return *buf; - if ( *buf==dontdo ) retval= dontdo; /* if only color dontdo is available, still return dontdo */ + if (*buf && *buf <= maxob && *buf != dontdo) return *buf; + if (*buf == dontdo) retval = dontdo; /* if only color dontdo is available, still return dontdo */ - buf+= (dirvec[rc][0]+dirvec[rc][1]); + buf += (dirvec[rc][0] + dirvec[rc][1]); - if (buf<bufmin || buf>=bufmax) return retval; + if (buf < bufmin || buf >= bufmax) return retval; } rc++; rc &= 3; @@ -1072,19 +1072,19 @@ static unsigned int samplerect(unsigned int *buf, int size, unsigned int dontdo) /* The max number of menu items in an object select menu */ typedef struct SelMenuItemF { - char idname[MAX_ID_NAME-2]; + char idname[MAX_ID_NAME - 2]; int icon; } SelMenuItemF; -#define SEL_MENU_SIZE 22 +#define SEL_MENU_SIZE 22 static SelMenuItemF object_mouse_select_menu_data[SEL_MENU_SIZE]; /* special (crappy) operator only for menu select */ static EnumPropertyItem *object_select_menu_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { - EnumPropertyItem *item= NULL, item_tmp= {0}; - int totitem= 0; - int i= 0; + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + int i = 0; /* don't need context but avoid docgen using this */ if (C == NULL || object_mouse_select_menu_data[i].idname[0] == '\0') { @@ -1092,42 +1092,42 @@ static EnumPropertyItem *object_select_menu_enum_itemf(bContext *C, PointerRNA * } for (; i < SEL_MENU_SIZE && object_mouse_select_menu_data[i].idname[0] != '\0'; i++) { - item_tmp.name= object_mouse_select_menu_data[i].idname; - item_tmp.identifier= object_mouse_select_menu_data[i].idname; - item_tmp.value= i; - item_tmp.icon= object_mouse_select_menu_data[i].icon; + item_tmp.name = object_mouse_select_menu_data[i].idname; + item_tmp.identifier = object_mouse_select_menu_data[i].idname; + item_tmp.value = i; + item_tmp.icon = object_mouse_select_menu_data[i].icon; RNA_enum_item_add(&item, &totitem, &item_tmp); } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } static int object_select_menu_exec(bContext *C, wmOperator *op) { - int name_index= RNA_enum_get(op->ptr, "name"); - short extend= RNA_boolean_get(op->ptr, "extend"); + int name_index = RNA_enum_get(op->ptr, "name"); + short extend = RNA_boolean_get(op->ptr, "extend"); short changed = 0; - const char *name= object_mouse_select_menu_data[name_index].idname; + const char *name = object_mouse_select_menu_data[name_index].idname; if (!extend) { - CTX_DATA_BEGIN(C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN(C, Base *, base, selectable_bases) { if (base->flag & SELECT) { ED_base_object_select(base, BA_DESELECT); - changed= 1; + changed = 1; } } CTX_DATA_END; } - CTX_DATA_BEGIN(C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN(C, Base *, base, selectable_bases) { /* this is a bit dodjy, there should only be ONE object with this name, but library objects can mess this up */ - if (strcmp(name, base->object->id.name+2)==0) { + if (strcmp(name, base->object->id.name + 2) == 0) { ED_base_object_activate(C, base); ED_base_object_select(base, BA_SELECT); - changed= 1; + changed = 1; } } CTX_DATA_END; @@ -1137,7 +1137,7 @@ static int object_select_menu_exec(bContext *C, wmOperator *op) /* undo? */ if (changed) { - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } else { @@ -1159,10 +1159,10 @@ void VIEW3D_OT_select_menu(wmOperatorType *ot) ot->exec = object_select_menu_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "name", DummyRNA_NULL_items, 0, "Object Name", ""); + prop = RNA_def_enum(ot->srna, "name", DummyRNA_NULL_items, 0, "Object Name", ""); RNA_def_enum_funcs(prop, object_select_menu_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; @@ -1174,9 +1174,9 @@ static void deselectall_except(Scene *scene, Base *b) /* deselect all except b { Base *base; - for (base= FIRSTBASE; base; base= base->next) { + for (base = FIRSTBASE; base; base = base->next) { if (base->flag & SELECT) { - if (b!=base) { + if (b != base) { ED_base_object_select(base, BA_DESELECT); } } @@ -1187,45 +1187,45 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int { short baseCount = 0; short ok; - LinkNode *linklist= NULL; + LinkNode *linklist = NULL; - CTX_DATA_BEGIN(C, Base*, base, selectable_bases) { - ok= FALSE; + CTX_DATA_BEGIN(C, Base *, base, selectable_bases) { + ok = FALSE; /* two selection methods, the CTRL select uses max dist of 15 */ if (buffer) { int a; - for (a=0; a<hits; a++) { + for (a = 0; a < hits; a++) { /* index was converted */ - if (base->selcol==buffer[ (4 * a) + 3 ]) - ok= TRUE; + if (base->selcol == buffer[(4 * a) + 3]) + ok = TRUE; } } else { - int temp, dist=15; + int temp, dist = 15; project_short(vc->ar, base->object->obmat[3], &base->sx); - temp= abs(base->sx -mval[0]) + abs(base->sy -mval[1]); + temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]); if (temp < dist) - ok= TRUE; + ok = TRUE; } if (ok) { baseCount++; BLI_linklist_prepend(&linklist, base); - if (baseCount==SEL_MENU_SIZE) + if (baseCount == SEL_MENU_SIZE) break; } } CTX_DATA_END; - if (baseCount==0) { + if (baseCount == 0) { return NULL; } if (baseCount == 1) { - Base *base= (Base *)linklist->link; + Base *base = (Base *)linklist->link; BLI_linklist_free(linklist, NULL); return base; } @@ -1236,12 +1236,12 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int memset(object_mouse_select_menu_data, 0, sizeof(object_mouse_select_menu_data)); - for (node = linklist, i = 0; node; node= node->next, i++) { - Base *base=node->link; - Object *ob= base->object; - char *name= ob->id.name+2; + for (node = linklist, i = 0; node; node = node->next, i++) { + Base *base = node->link; + Object *ob = base->object; + char *name = ob->id.name + 2; - BLI_strncpy(object_mouse_select_menu_data[i].idname, name, MAX_ID_NAME-2); + BLI_strncpy(object_mouse_select_menu_data[i].idname, name, MAX_ID_NAME - 2); object_mouse_select_menu_data[i].icon = uiIconFromID(&ob->id); } @@ -1265,50 +1265,50 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff { rcti rect; int offs; - short a, hits15, hits9=0, hits5=0; - short has_bones15=0, has_bones9=0, has_bones5=0; - - BLI_init_rcti(&rect, mval[0]-14, mval[0]+14, mval[1]-14, mval[1]+14); - hits15= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); - if (hits15>0) { - for (a=0; a<hits15; a++) if (buffer[4*a+3] & 0xFFFF0000) has_bones15= 1; - - offs= 4*hits15; - BLI_init_rcti(&rect, mval[0]-9, mval[0]+9, mval[1]-9, mval[1]+9); - hits9= view3d_opengl_select(vc, buffer+offs, MAXPICKBUF-offs, &rect); - if (hits9>0) { - for (a=0; a<hits9; a++) if (buffer[offs+4*a+3] & 0xFFFF0000) has_bones9= 1; - - offs+= 4*hits9; - BLI_init_rcti(&rect, mval[0]-5, mval[0]+5, mval[1]-5, mval[1]+5); - hits5= view3d_opengl_select(vc, buffer+offs, MAXPICKBUF-offs, &rect); - if (hits5>0) { - for (a=0; a<hits5; a++) if (buffer[offs+4*a+3] & 0xFFFF0000) has_bones5= 1; + short a, hits15, hits9 = 0, hits5 = 0; + short has_bones15 = 0, has_bones9 = 0, has_bones5 = 0; + + BLI_init_rcti(&rect, mval[0] - 14, mval[0] + 14, mval[1] - 14, mval[1] + 14); + hits15 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); + if (hits15 > 0) { + for (a = 0; a < hits15; a++) if (buffer[4 * a + 3] & 0xFFFF0000) has_bones15 = 1; + + offs = 4 * hits15; + BLI_init_rcti(&rect, mval[0] - 9, mval[0] + 9, mval[1] - 9, mval[1] + 9); + hits9 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect); + if (hits9 > 0) { + for (a = 0; a < hits9; a++) if (buffer[offs + 4 * a + 3] & 0xFFFF0000) has_bones9 = 1; + + offs += 4 * hits9; + BLI_init_rcti(&rect, mval[0] - 5, mval[0] + 5, mval[1] - 5, mval[1] + 5); + hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect); + if (hits5 > 0) { + for (a = 0; a < hits5; a++) if (buffer[offs + 4 * a + 3] & 0xFFFF0000) has_bones5 = 1; } } if (has_bones5) { - offs= 4*hits15 + 4*hits9; - memcpy(buffer, buffer+offs, 4*offs); + offs = 4 * hits15 + 4 * hits9; + memcpy(buffer, buffer + offs, 4 * offs); return hits5; } if (has_bones9) { - offs= 4*hits15; - memcpy(buffer, buffer+offs, 4*offs); + offs = 4 * hits15; + memcpy(buffer, buffer + offs, 4 * offs); return hits9; } if (has_bones15) { return hits15; } - if (hits5>0) { - offs= 4*hits15 + 4*hits9; - memcpy(buffer, buffer+offs, 4*offs); + if (hits5 > 0) { + offs = 4 * hits15 + 4 * hits9; + memcpy(buffer, buffer + offs, 4 * offs); return hits5; } - if (hits9>0) { - offs= 4*hits15; - memcpy(buffer, buffer+offs, 4*offs); + if (hits9 > 0) { + offs = 4 * hits15; + memcpy(buffer, buffer + offs, 4 * offs); return hits9; } return hits15; @@ -1320,90 +1320,90 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff /* returns basact */ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, const int mval[2], Base *startbase, int has_bones) { - Scene *scene= vc->scene; - View3D *v3d= vc->v3d; - Base *base, *basact= NULL; - static int lastmval[2]={-100, -100}; - int a, donearest= 0; + Scene *scene = vc->scene; + View3D *v3d = vc->v3d; + Base *base, *basact = NULL; + static int lastmval[2] = {-100, -100}; + int a, donearest = 0; /* define if we use solid nearest select or not */ - if (v3d->drawtype>OB_WIRE) { - donearest= 1; - if ( ABS(mval[0]-lastmval[0])<3 && ABS(mval[1]-lastmval[1])<3) { - if (!has_bones) /* hrms, if theres bones we always do nearest */ - donearest= 0; + if (v3d->drawtype > OB_WIRE) { + donearest = 1; + if (ABS(mval[0] - lastmval[0]) < 3 && ABS(mval[1] - lastmval[1]) < 3) { + if (!has_bones) /* hrms, if theres bones we always do nearest */ + donearest = 0; } } - lastmval[0]= mval[0]; lastmval[1]= mval[1]; + lastmval[0] = mval[0]; lastmval[1] = mval[1]; if (donearest) { - unsigned int min= 0xFFFFFFFF; - int selcol= 0, notcol=0; + unsigned int min = 0xFFFFFFFF; + int selcol = 0, notcol = 0; if (has_bones) { /* we skip non-bone hits */ - for (a=0; a<hits; a++) { - if ( min > buffer[4*a+1] && (buffer[4*a+3] & 0xFFFF0000) ) { - min= buffer[4*a+1]; - selcol= buffer[4*a+3] & 0xFFFF; + for (a = 0; a < hits; a++) { + if (min > buffer[4 * a + 1] && (buffer[4 * a + 3] & 0xFFFF0000) ) { + min = buffer[4 * a + 1]; + selcol = buffer[4 * a + 3] & 0xFFFF; } } } else { /* only exclude active object when it is selected... */ - if (BASACT && (BASACT->flag & SELECT) && hits>1) notcol= BASACT->selcol; + if (BASACT && (BASACT->flag & SELECT) && hits > 1) notcol = BASACT->selcol; - for (a=0; a<hits; a++) { - if ( min > buffer[4*a+1] && notcol!=(buffer[4*a+3] & 0xFFFF)) { - min= buffer[4*a+1]; - selcol= buffer[4*a+3] & 0xFFFF; + for (a = 0; a < hits; a++) { + if (min > buffer[4 * a + 1] && notcol != (buffer[4 * a + 3] & 0xFFFF)) { + min = buffer[4 * a + 1]; + selcol = buffer[4 * a + 3] & 0xFFFF; } } } - base= FIRSTBASE; + base = FIRSTBASE; while (base) { if (BASE_SELECTABLE(v3d, base)) { - if (base->selcol==selcol) break; + if (base->selcol == selcol) break; } - base= base->next; + base = base->next; } - if (base) basact= base; + if (base) basact = base; } else { - base= startbase; + base = startbase; while (base) { /* skip objects with select restriction, to prevent prematurely ending this loop * with an un-selectable choice */ if (base->object->restrictflag & OB_RESTRICT_SELECT) { - base=base->next; - if (base==NULL) base= FIRSTBASE; - if (base==startbase) break; + base = base->next; + if (base == NULL) base = FIRSTBASE; + if (base == startbase) break; } if (BASE_SELECTABLE(v3d, base)) { - for (a=0; a<hits; a++) { + for (a = 0; a < hits; a++) { if (has_bones) { /* skip non-bone objects */ - if ((buffer[4*a+3] & 0xFFFF0000)) { - if (base->selcol== (buffer[(4*a)+3] & 0xFFFF)) - basact= base; + if ((buffer[4 * a + 3] & 0xFFFF0000)) { + if (base->selcol == (buffer[(4 * a) + 3] & 0xFFFF)) + basact = base; } } else { - if (base->selcol== (buffer[(4*a)+3] & 0xFFFF)) - basact= base; + if (base->selcol == (buffer[(4 * a) + 3] & 0xFFFF)) + basact = base; } } } if (basact) break; - base= base->next; - if (base==NULL) base= FIRSTBASE; - if (base==startbase) break; + base = base->next; + if (base == NULL) base = FIRSTBASE; + if (base == startbase) break; } } @@ -1414,22 +1414,22 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) { ViewContext vc; - Base *basact= NULL; - unsigned int buffer[4*MAXPICKBUF]; + Base *basact = NULL; + unsigned int buffer[4 * MAXPICKBUF]; int hits; /* setup view context for argument to callbacks */ view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); - hits= mixed_bones_object_selectbuffer(&vc, buffer, mval); + hits = mixed_bones_object_selectbuffer(&vc, buffer, mval); - if (hits>0) { - int a, has_bones= 0; + if (hits > 0) { + int a, has_bones = 0; - for (a=0; a<hits; a++) if (buffer[4*a+3] & 0xFFFF0000) has_bones= 1; + for (a = 0; a < hits; a++) if (buffer[4 * a + 3] & 0xFFFF0000) has_bones = 1; - basact= mouse_select_eval_buffer(&vc, buffer, hits, mval, vc.scene->base.first, has_bones); + basact = mouse_select_eval_buffer(&vc, buffer, hits, mval, vc.scene->base.first, has_bones); } return basact; @@ -1439,18 +1439,18 @@ static void deselect_all_tracks(MovieTracking *tracking) { MovieTrackingObject *object; - object= tracking->objects.first; + object = tracking->objects.first; while (object) { - ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object); - MovieTrackingTrack *track= tracksbase->first; + ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object); + MovieTrackingTrack *track = tracksbase->first; while (track) { BKE_tracking_deselect_track(track, TRACK_AREA_ALL); - track= track->next; + track = track->next; } - object= object->next; + object = object->next; } } @@ -1458,11 +1458,11 @@ static void deselect_all_tracks(MovieTracking *tracking) static int mouse_select(bContext *C, const int mval[2], short extend, short obcenter, short enumerate) { ViewContext vc; - ARegion *ar= CTX_wm_region(C); - View3D *v3d= CTX_wm_view3d(C); - Scene *scene= CTX_data_scene(C); - Base *base, *startbase=NULL, *basact=NULL, *oldbasact=NULL; - int temp, a, dist=100; + ARegion *ar = CTX_wm_region(C); + View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + Base *base, *startbase = NULL, *basact = NULL, *oldbasact = NULL; + int temp, a, dist = 100; int retval = 0; short hits; @@ -1470,8 +1470,8 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce view3d_set_viewcontext(C, &vc); /* always start list from basact in wire mode */ - startbase= FIRSTBASE; - if (BASACT && BASACT->next) startbase= BASACT->next; + startbase = FIRSTBASE; + if (BASACT && BASACT->next) startbase = BASACT->next; /* This block uses the control key to make the object selected by its center point rather than its contents */ /* in editmode do not activate */ @@ -1479,58 +1479,58 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* note; shift+alt goes to group-flush-selecting */ if (enumerate) { - basact= object_mouse_select_menu(C, &vc, NULL, 0, mval, extend); + basact = object_mouse_select_menu(C, &vc, NULL, 0, mval, extend); } else { - base= startbase; + base = startbase; while (base) { if (BASE_SELECTABLE(v3d, base)) { project_short(ar, base->object->obmat[3], &base->sx); - temp= abs(base->sx -mval[0]) + abs(base->sy -mval[1]); - if (base==BASACT) temp+=10; - if (temp<dist ) { + temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]); + if (base == BASACT) temp += 10; + if (temp < dist) { - dist= temp; - basact= base; + dist = temp; + basact = base; } } - base= base->next; + base = base->next; - if (base==NULL) base= FIRSTBASE; - if (base==startbase) break; + if (base == NULL) base = FIRSTBASE; + if (base == startbase) break; } } } else { - unsigned int buffer[4*MAXPICKBUF]; + unsigned int buffer[4 * MAXPICKBUF]; /* if objects have posemode set, the bones are in the same selection buffer */ - hits= mixed_bones_object_selectbuffer(&vc, buffer, mval); + hits = mixed_bones_object_selectbuffer(&vc, buffer, mval); - if (hits>0) { - int has_bones= 0; + if (hits > 0) { + int has_bones = 0; /* note: bundles are handling in the same way as bones */ - for (a=0; a<hits; a++) if (buffer[4*a+3] & 0xFFFF0000) has_bones= 1; + for (a = 0; a < hits; a++) if (buffer[4 * a + 3] & 0xFFFF0000) has_bones = 1; /* note; shift+alt goes to group-flush-selecting */ - if (has_bones==0 && enumerate) { - basact= object_mouse_select_menu(C, &vc, buffer, hits, mval, extend); + if (has_bones == 0 && enumerate) { + basact = object_mouse_select_menu(C, &vc, buffer, hits, mval, extend); } else { - basact= mouse_select_eval_buffer(&vc, buffer, hits, mval, startbase, has_bones); + basact = mouse_select_eval_buffer(&vc, buffer, hits, mval, startbase, has_bones); } if (has_bones && basact) { - if (basact->object->type==OB_CAMERA) { - if (BASACT==basact) { + if (basact->object->type == OB_CAMERA) { + if (BASACT == basact) { int i, hitresult; - int changed= 0; + int changed = 0; - for (i=0; i< hits; i++) { - hitresult= buffer[3+(i*4)]; + for (i = 0; i < hits; i++) { + hitresult = buffer[3 + (i * 4)]; /* if there's bundles in buffer select bundles first, * so non-camera elements should be ignored in buffer */ @@ -1540,36 +1540,36 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* index of bundle is 1<<16-based. if there's no "bone" index * in hight word, this buffer value belongs to camera,. not to bundle */ - if (buffer[4*i+3] & 0xFFFF0000) { - MovieClip *clip= object_get_movieclip(scene, basact->object, 0); - MovieTracking *tracking= &clip->tracking; + if (buffer[4 * i + 3] & 0xFFFF0000) { + MovieClip *clip = object_get_movieclip(scene, basact->object, 0); + MovieTracking *tracking = &clip->tracking; ListBase *tracksbase; MovieTrackingTrack *track; - track= BKE_tracking_indexed_track(&clip->tracking, hitresult >> 16, &tracksbase); + track = BKE_tracking_indexed_track(&clip->tracking, hitresult >> 16, &tracksbase); if (TRACK_SELECTED(track) && extend) { - changed= 0; + changed = 0; BKE_tracking_deselect_track(track, TRACK_AREA_ALL); } else { - int oldsel= TRACK_SELECTED(track) ? 1 : 0; + int oldsel = TRACK_SELECTED(track) ? 1 : 0; if (!extend) deselect_all_tracks(tracking); BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, extend); - if (oldsel!=(TRACK_SELECTED(track) ? 1 : 0)) - changed= 1; + if (oldsel != (TRACK_SELECTED(track) ? 1 : 0)) + changed = 1; } - basact->flag|= SELECT; - basact->object->flag= basact->flag; + basact->flag |= SELECT; + basact->object->flag = basact->flag; - retval= 1; + retval = 1; - WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, track); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, track); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); break; } @@ -1578,31 +1578,31 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce if (!changed) { /* fallback to regular object selection if no new bundles were selected, * allows to select object parented to reconstruction object */ - basact= mouse_select_eval_buffer(&vc, buffer, hits, mval, startbase, 0); + basact = mouse_select_eval_buffer(&vc, buffer, hits, mval, startbase, 0); } } } - else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend) ) { /* then bone is found */ + else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend) ) { /* then bone is found */ /* we make the armature selected: * not-selected active object in posemode won't work well for tools */ - basact->flag|= SELECT; - basact->object->flag= basact->flag; + basact->flag |= SELECT; + basact->object->flag = basact->flag; retval = 1; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, basact->object); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object); /* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */ if (BASACT && (BASACT->object->mode & OB_MODE_WEIGHT_PAINT)) { /* prevent activating */ - basact= NULL; + basact = NULL; } } /* prevent bone selecting to pass on to object selecting */ - if (basact==BASACT) - basact= NULL; + if (basact == BASACT) + basact = NULL; } } } @@ -1619,7 +1619,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* also prevent making it active on mouse selection */ else if (BASE_SELECTABLE(v3d, basact)) { - oldbasact= BASACT; + oldbasact = BASACT; if (!extend) { deselectall_except(scene, basact); @@ -1630,7 +1630,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce } else { if (basact->flag & SELECT) { - if (basact==oldbasact) + if (basact == oldbasact) ED_base_object_select(basact, BA_DESELECT); } else ED_base_object_select(basact, BA_SELECT); @@ -1641,7 +1641,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce } } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } return retval; @@ -1657,22 +1657,22 @@ typedef struct BoxSelectUserData { int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2) { - int radsq= rad*rad; + int radsq = rad * rad; float v1[2], v2[2], v3[2]; /* check points in circle itself */ - if ( (x1-centx)*(x1-centx) + (y1-centy)*(y1-centy) <= radsq ) return 1; - if ( (x2-centx)*(x2-centx) + (y2-centy)*(y2-centy) <= radsq ) return 1; + if ( (x1 - centx) * (x1 - centx) + (y1 - centy) * (y1 - centy) <= radsq) return 1; + if ( (x2 - centx) * (x2 - centx) + (y2 - centy) * (y2 - centy) <= radsq) return 1; /* pointdistline */ - v3[0]= centx; - v3[1]= centy; - v1[0]= x1; - v1[1]= y1; - v2[0]= x2; - v2[1]= y2; + v3[0] = centx; + v3[1] = centy; + v1[0] = x1; + v1[1] = y1; + v2[0] = x2; + v2[1] = y2; - if ( dist_to_line_segment_v2(v3, v1, v2) < (float)rad ) return 1; + if (dist_to_line_segment_v2(v3, v1, v2) < (float)rad) return 1; return 0; } @@ -1680,28 +1680,28 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { BoxSelectUserData *data = userData; - Object *obedit= data->vc->obedit; - Curve *cu= (Curve*)obedit->data; + Object *obedit = data->vc->obedit; + Curve *cu = (Curve *)obedit->data; if (BLI_in_rcti(data->rect, x, y)) { if (bp) { - bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; } else { if (cu->drawflag & CU_HIDE_HANDLES) { /* can only be beztindex==0 here since handles are hidden */ - bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); + bezt->f1 = bezt->f2 = bezt->f3 = data->select ? (bezt->f2 | SELECT) : (bezt->f2 & ~SELECT); } else { - if (beztindex==0) { - bezt->f1 = data->select?(bezt->f1|SELECT):(bezt->f1&~SELECT); + if (beztindex == 0) { + bezt->f1 = data->select ? (bezt->f1 | SELECT) : (bezt->f1 & ~SELECT); } - else if (beztindex==1) { - bezt->f2 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); + else if (beztindex == 1) { + bezt->f2 = data->select ? (bezt->f2 | SELECT) : (bezt->f2 & ~SELECT); } else { - bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT); + bezt->f3 = data->select ? (bezt->f3 | SELECT) : (bezt->f3 & ~SELECT); } } @@ -1731,14 +1731,14 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i BoxSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y)) { - bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int extend) { BoxSelectUserData data; - data.vc= vc; + data.vc = vc; data.rect = rect; data.select = select; @@ -1763,8 +1763,8 @@ static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, int x0 { BoxSelectUserData *data = userData; - if (EDBM_check_backbuf(bm_solidoffs+index)) { - if (data->pass==0) { + if (EDBM_check_backbuf(bm_solidoffs + index)) { + if (data->pass == 0) { if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1)) { BM_elem_select_set(data->vc->em->bm, eed, data->select); data->done = 1; @@ -1788,10 +1788,10 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, int x, static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int extend) { BoxSelectUserData data; - ToolSettings *ts= vc->scene->toolsettings; + ToolSettings *ts = vc->scene->toolsettings; int bbsel; - data.vc= vc; + data.vc = vc; data.rect = rect; data.select = select; data.pass = 0; @@ -1804,7 +1804,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); glLoadMatrixf(vc->rv3d->viewmat); - bbsel= EDBM_init_backbuf_border(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax); + bbsel = EDBM_init_backbuf_border(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax); if (ts->selectmode & SCE_SELECT_VERTEX) { if (bbsel) { @@ -1815,12 +1815,12 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten } } if (ts->selectmode & SCE_SELECT_EDGE) { - /* Does both bbsel and non-bbsel versions (need screen cos for both) */ + /* Does both bbsel and non-bbsel versions (need screen cos for both) */ data.pass = 0; mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_CLIP_TEST_OFF); - if (data.done==0) { + if (data.done == 0) { data.pass = 1; mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_CLIP_TEST_OFF); } @@ -1844,33 +1844,33 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten static int do_meta_box_select(ViewContext *vc, rcti *rect, int select, int extend) { - MetaBall *mb = (MetaBall*)vc->obedit->data; + MetaBall *mb = (MetaBall *)vc->obedit->data; MetaElem *ml; int a; - unsigned int buffer[4*MAXPICKBUF]; + unsigned int buffer[4 * MAXPICKBUF]; short hits; - hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, rect); + hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect); if (extend == 0 && select) { - for (ml= mb->editelems->first; ml; ml= ml->next) { + for (ml = mb->editelems->first; ml; ml = ml->next) { ml->flag &= ~SELECT; } } - for (ml= mb->editelems->first; ml; ml= ml->next) { - for (a=0; a<hits; a++) { - if (ml->selcol1==buffer[ (4 * a) + 3 ]) { + for (ml = mb->editelems->first; ml; ml = ml->next) { + for (a = 0; a < hits; a++) { + if (ml->selcol1 == buffer[(4 * a) + 3]) { ml->flag |= MB_SCALE_RAD; - if (select) ml->flag |= SELECT; - else ml->flag &= ~SELECT; + if (select) ml->flag |= SELECT; + else ml->flag &= ~SELECT; break; } - if (ml->selcol2==buffer[ (4 * a) + 3 ]) { + if (ml->selcol2 == buffer[(4 * a) + 3]) { ml->flag &= ~MB_SCALE_RAD; - if (select) ml->flag |= SELECT; - else ml->flag &= ~SELECT; + if (select) ml->flag |= SELECT; + else ml->flag &= ~SELECT; break; } } @@ -1881,45 +1881,45 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, int select, int exten static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, short extend) { - bArmature *arm= vc->obedit->data; + bArmature *arm = vc->obedit->data; EditBone *ebone; int a; - unsigned int buffer[4*MAXPICKBUF]; + unsigned int buffer[4 * MAXPICKBUF]; short hits; - hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, rect); + hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect); /* clear flag we use to detect point was affected */ - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) ebone->flag &= ~BONE_DONE; - if (extend==0 && select) + if (extend == 0 && select) ED_armature_deselect_all_visible(vc->obedit); /* first we only check points inside the border */ - for (a=0; a<hits; a++) { - int index = buffer[(4*a)+3]; - if (index!=-1) { + for (a = 0; a < hits; a++) { + int index = buffer[(4 * a) + 3]; + if (index != -1) { ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY)); - if ((ebone->flag & BONE_UNSELECTABLE)==0) { + if ((ebone->flag & BONE_UNSELECTABLE) == 0) { if (index & BONESEL_TIP) { ebone->flag |= BONE_DONE; - if (select) ebone->flag |= BONE_TIPSEL; - else ebone->flag &= ~BONE_TIPSEL; + if (select) ebone->flag |= BONE_TIPSEL; + else ebone->flag &= ~BONE_TIPSEL; } if (index & BONESEL_ROOT) { ebone->flag |= BONE_DONE; - if (select) ebone->flag |= BONE_ROOTSEL; - else ebone->flag &= ~BONE_ROOTSEL; + if (select) ebone->flag |= BONE_ROOTSEL; + else ebone->flag &= ~BONE_ROOTSEL; } } } } /* now we have to flush tag from parents... */ - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { if (ebone->parent->flag & BONE_DONE) ebone->flag |= BONE_DONE; @@ -1927,17 +1927,17 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, sho } /* only select/deselect entire bones when no points where in the rect */ - for (a=0; a<hits; a++) { - int index = buffer[(4*a)+3]; - if (index!=-1) { + for (a = 0; a < hits; a++) { + int index = buffer[(4 * a) + 3]; + if (index != -1) { ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY)); if (index & BONESEL_BONE) { - if ((ebone->flag & BONE_UNSELECTABLE)==0) { + if ((ebone->flag & BONE_UNSELECTABLE) == 0) { if (!(ebone->flag & BONE_DONE)) { if (select) - ebone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED); + ebone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); else - ebone->flag &= ~(BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED); + ebone->flag &= ~(BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); } } } @@ -1952,24 +1952,24 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, sho static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, int select, int extend) { Bone *bone; - Object *ob= vc->obact; - unsigned int *vbuffer=NULL; /* selection buffer */ - unsigned int *col; /* color in buffer */ + Object *ob = vc->obact; + unsigned int *vbuffer = NULL; /* selection buffer */ + unsigned int *col; /* color in buffer */ int bone_only; - int bone_selected=0; - int totobj= MAXPICKBUF; // XXX solve later + int bone_selected = 0; + int totobj = MAXPICKBUF; // XXX solve later short hits; if ((ob) && (ob->mode & OB_MODE_POSE)) - bone_only= 1; + bone_only = 1; else - bone_only= 0; + bone_only = 0; if (extend == 0 && select) { if (bone_only) { CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) { - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) { - pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { + pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } } CTX_DATA_END; @@ -1980,8 +1980,8 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i } /* selection buffer now has bones potentially too, so we add MAXPICKBUF */ - vbuffer = MEM_mallocN(4 * (totobj+MAXPICKBUF) * sizeof(unsigned int), "selection buffer"); - hits= view3d_opengl_select(vc, vbuffer, 4*(totobj+MAXPICKBUF), rect); + vbuffer = MEM_mallocN(4 * (totobj + MAXPICKBUF) * sizeof(unsigned int), "selection buffer"); + hits = view3d_opengl_select(vc, vbuffer, 4 * (totobj + MAXPICKBUF), rect); /* * LOGIC NOTES (theeth): * The buffer and ListBase have the same relative order, which makes the selection @@ -1994,30 +1994,30 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i * does it incorrectly. */ - if (hits>0) { /* no need to loop if there's no hit */ + if (hits > 0) { /* no need to loop if there's no hit */ Base *base; col = vbuffer + 3; - for (base= vc->scene->base.first; base && hits; base= base->next) { + for (base = vc->scene->base.first; base && hits; base = base->next) { if (BASE_SELECTABLE(vc->v3d, base)) { - while (base->selcol == (*col & 0xFFFF)) { /* we got an object */ + while (base->selcol == (*col & 0xFFFF)) { /* we got an object */ - if (*col & 0xFFFF0000) { /* we got a bone */ + if (*col & 0xFFFF0000) { /* we got a bone */ bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY)); if (bone) { if (select) { - if ((bone->flag & BONE_UNSELECTABLE)==0) { + if ((bone->flag & BONE_UNSELECTABLE) == 0) { bone->flag |= BONE_SELECTED; - bone_selected=1; + bone_selected = 1; // XXX select_actionchannel_by_name(base->object->action, bone->name, 1); } } else { - bArmature *arm= base->object->data; + bArmature *arm = base->object->data; bone->flag &= ~BONE_SELECTED; // XXX select_actionchannel_by_name(base->object->action, bone->name, 0); - if (arm->act_bone==bone) - arm->act_bone= NULL; + if (arm->act_bone == bone) + arm->act_bone = NULL; } } @@ -2029,18 +2029,18 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i ED_base_object_select(base, BA_DESELECT); } - col+=4; /* next color */ + col += 4; /* next color */ hits--; - if (hits==0) break; + if (hits == 0) break; } } if (bone_selected) { - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, base->object); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object); } } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, vc->scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene); } MEM_freeN(vbuffer); @@ -2055,14 +2055,14 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) short extend; short select; - int ret= OPERATOR_CANCELLED; + int ret = OPERATOR_CANCELLED; view3d_operator_needs_opengl(C); /* setup view context for argument to callbacks */ view3d_set_viewcontext(C, &vc); - select= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); + select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); rect.xmax = RNA_int_get(op->ptr, "xmax"); @@ -2070,59 +2070,59 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) extend = RNA_boolean_get(op->ptr, "extend"); if (vc.obedit) { - switch(vc.obedit->type) { - case OB_MESH: - vc.em = BMEdit_FromObject(vc.obedit); - ret= do_mesh_box_select(&vc, &rect, select, extend); + switch (vc.obedit->type) { + case OB_MESH: + vc.em = BMEdit_FromObject(vc.obedit); + ret = do_mesh_box_select(&vc, &rect, select, extend); // if (EM_texFaceCheck()) - if (ret & OPERATOR_FINISHED) { - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); - } - break; - case OB_CURVE: - case OB_SURF: - ret= do_nurbs_box_select(&vc, &rect, select, extend); - if (ret & OPERATOR_FINISHED) { - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); - } - break; - case OB_MBALL: - ret= do_meta_box_select(&vc, &rect, select, extend); - if (ret & OPERATOR_FINISHED) { - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); - } - break; - case OB_ARMATURE: - ret= do_armature_box_select(&vc, &rect, select, extend); - if (ret & OPERATOR_FINISHED) { - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit); - } - break; - case OB_LATTICE: - ret= do_lattice_box_select(&vc, &rect, select, extend); - if (ret & OPERATOR_FINISHED) { - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); - } - break; - default: - assert(!"border select on incorrect object type"); + if (ret & OPERATOR_FINISHED) { + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); + } + break; + case OB_CURVE: + case OB_SURF: + ret = do_nurbs_box_select(&vc, &rect, select, extend); + if (ret & OPERATOR_FINISHED) { + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); + } + break; + case OB_MBALL: + ret = do_meta_box_select(&vc, &rect, select, extend); + if (ret & OPERATOR_FINISHED) { + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); + } + break; + case OB_ARMATURE: + ret = do_armature_box_select(&vc, &rect, select, extend); + if (ret & OPERATOR_FINISHED) { + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit); + } + break; + case OB_LATTICE: + ret = do_lattice_box_select(&vc, &rect, select, extend); + if (ret & OPERATOR_FINISHED) { + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); + } + break; + default: + assert(!"border select on incorrect object type"); } } - else { /* no editmode, unified for bones and objects */ + else { /* no editmode, unified for bones and objects */ if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) { /* pass */ } else if (vc.obact && paint_facesel_test(vc.obact)) { - ret= do_paintface_box_select(&vc, &rect, select, extend); + ret = do_paintface_box_select(&vc, &rect, select, extend); } else if (vc.obact && paint_vertsel_test(vc.obact)) { - ret= do_paintvert_box_select(&vc, &rect, select, extend); + ret = do_paintvert_box_select(&vc, &rect, select, extend); } else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) { - ret= PE_border_select(C, &rect, select, extend); + ret = PE_border_select(C, &rect, select, extend); } else { /* object mode with none active */ - ret= do_object_pose_box_select(C, &vc, &rect, select, extend); + ret = do_object_pose_box_select(C, &vc, &rect, select, extend); } } @@ -2161,7 +2161,7 @@ static int vertsel_vert_pick(struct bContext *C, Mesh *me, const int mval[2], un ViewContext vc; view3d_set_viewcontext(C, &vc); - if (!me || me->totvert==0) + if (!me || me->totvert == 0) return 0; if (size > 0) { @@ -2169,14 +2169,14 @@ static int vertsel_vert_pick(struct bContext *C, Mesh *me, const int mval[2], un * on an face in the backbuf, we can still select a vert */ int dist; - *index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totvert+1, &dist,0,NULL, NULL); + *index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totvert + 1, &dist, 0, NULL, NULL); } else { /* sample only on the exact position */ *index = view3d_sample_backbuf(&vc, mval[0], mval[1]); } - if ((*index)<=0 || (*index)>(unsigned int)me->totvert) + if ((*index) <= 0 || (*index) > (unsigned int)me->totvert) return 0; (*index)--; @@ -2188,12 +2188,12 @@ static int vertsel_vert_pick(struct bContext *C, Mesh *me, const int mval[2], un /* gets called via generic mouse select operator */ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], short extend, Object *obact) { - Mesh* me= obact->data; /* already checked for NULL */ + Mesh*me = obact->data; /* already checked for NULL */ unsigned int index = 0; MVert *mv; if (vertsel_vert_pick(C, me, mval, &index, 50)) { - mv = me->mvert+index; + mv = me->mvert + index; if (extend) { mv->flag ^= SELECT; } @@ -2202,7 +2202,7 @@ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], shor mv->flag |= SELECT; } paintvert_flush_flags(obact); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); return 1; } return 0; @@ -2213,36 +2213,36 @@ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], shor static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Object *obedit= CTX_data_edit_object(C); - Object *obact= CTX_data_active_object(C); - short extend= RNA_boolean_get(op->ptr, "extend"); - short center= RNA_boolean_get(op->ptr, "center"); - short enumerate= RNA_boolean_get(op->ptr, "enumerate"); - short object= RNA_boolean_get(op->ptr, "object"); - int retval = 0; + Object *obedit = CTX_data_edit_object(C); + Object *obact = CTX_data_active_object(C); + short extend = RNA_boolean_get(op->ptr, "extend"); + short center = RNA_boolean_get(op->ptr, "center"); + short enumerate = RNA_boolean_get(op->ptr, "enumerate"); + short object = RNA_boolean_get(op->ptr, "object"); + int retval = 0; view3d_operator_needs_opengl(C); if (object) { - obedit= NULL; - obact= NULL; + obedit = NULL; + obact = NULL; /* ack, this is incorrect but to do this correctly we would need an * alternative editmode/objectmode keymap, this copies the functionality * from 2.4x where Ctrl+Select in editmode does object select only */ - center= FALSE; + center = FALSE; } - if (obedit && object==FALSE) { - if (obedit->type==OB_MESH) + if (obedit && object == FALSE) { + if (obedit->type == OB_MESH) retval = mouse_mesh(C, event->mval, extend); - else if (obedit->type==OB_ARMATURE) + else if (obedit->type == OB_ARMATURE) retval = mouse_armature(C, event->mval, extend); - else if (obedit->type==OB_LATTICE) + else if (obedit->type == OB_LATTICE) retval = mouse_lattice(C, event->mval, extend); else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) retval = mouse_nurb(C, event->mval, extend); - else if (obedit->type==OB_MBALL) + else if (obedit->type == OB_MBALL) retval = mouse_mball(C, event->mval, extend); } @@ -2261,9 +2261,9 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) * FINISHED to signal one operator worked * */ if (retval) - return OPERATOR_PASS_THROUGH|OPERATOR_FINISHED; + return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED; else - return OPERATOR_PASS_THROUGH; /* nothing selected, just passthrough */ + return OPERATOR_PASS_THROUGH; /* nothing selected, just passthrough */ } void VIEW3D_OT_select(wmOperatorType *ot) @@ -2301,9 +2301,9 @@ static void mesh_circle_doSelectVert(void *userData, BMVert *eve, int x, int y, { CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx*mx + my*my); + float r = sqrt(mx * mx + my * my); - if (r<=data->radius) { + if (r <= data->radius) { BM_elem_select_set(data->vc->em->bm, eve, data->select); } } @@ -2319,20 +2319,20 @@ static void mesh_circle_doSelectFace(void *userData, BMFace *efa, int x, int y, { CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx*mx + my*my); + float r = sqrt(mx * mx + my * my); - if (r<=data->radius) { + if (r <= data->radius) { BM_elem_select_set(data->vc->em->bm, efa, data->select); } } static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - ToolSettings *ts= vc->scene->toolsettings; + ToolSettings *ts = vc->scene->toolsettings; int bbsel; CircleSelectUserData data; - bbsel= EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0)); + bbsel = EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad + 1.0)); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ vc->em = BMEdit_FromObject(vc->obedit); @@ -2345,7 +2345,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f if (ts->selectmode & SCE_SELECT_VERTEX) { if (bbsel) { - EDBM_backbuf_checkAndSelectVerts(vc->em, select==LEFTMOUSE); + EDBM_backbuf_checkAndSelectVerts(vc->em, select == LEFTMOUSE); } else { mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, V3D_CLIP_TEST_RV3D_CLIPPING); @@ -2354,7 +2354,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f if (ts->selectmode & SCE_SELECT_EDGE) { if (bbsel) { - EDBM_backbuf_checkAndSelectEdges(vc->em, select==LEFTMOUSE); + EDBM_backbuf_checkAndSelectEdges(vc->em, select == LEFTMOUSE); } else { mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_CLIP_TEST_OFF); @@ -2363,7 +2363,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f if (ts->selectmode & SCE_SELECT_FACE) { if (bbsel) { - EDBM_backbuf_checkAndSelectFaces(vc->em, select==LEFTMOUSE); + EDBM_backbuf_checkAndSelectFaces(vc->em, select == LEFTMOUSE); } else { mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data); @@ -2376,15 +2376,15 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f static void paint_facesel_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - Object *ob= vc->obact; - Mesh *me = ob?ob->data:NULL; + Object *ob = vc->obact; + Mesh *me = ob ? ob->data : NULL; /* int bbsel; */ /* UNUSED */ if (me) { - bm_vertoffs= me->totpoly+1; /* max index array */ + bm_vertoffs = me->totpoly + 1; /* max index array */ - /* bbsel= */ /* UNUSED */ EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0)); - EDBM_backbuf_checkAndSelectTFaces(me, select==LEFTMOUSE); + /* bbsel= */ /* UNUSED */ EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad + 1.0)); + EDBM_backbuf_checkAndSelectTFaces(me, select == LEFTMOUSE); EDBM_free_backbuf(); } } @@ -2392,15 +2392,15 @@ static void paint_facesel_circle_select(ViewContext *vc, int select, const int m static void paint_vertsel_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - Object *ob= vc->obact; - Mesh *me = ob?ob->data:NULL; + Object *ob = vc->obact; + Mesh *me = ob ? ob->data : NULL; /* int bbsel; */ /* UNUSED */ /* CircleSelectUserData data = {NULL}; */ /* UNUSED */ if (me) { - bm_vertoffs= me->totvert+1; /* max index array */ + bm_vertoffs = me->totvert + 1; /* max index array */ - /* bbsel= */ /* UNUSED */ EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0f)); - EDBM_backbuf_checkAndSelectVerts_obmode(me, select==LEFTMOUSE); + /* bbsel= */ /* UNUSED */ EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad + 1.0f)); + EDBM_backbuf_checkAndSelectVerts_obmode(me, select == LEFTMOUSE); EDBM_free_backbuf(); paintvert_flush_flags(ob); @@ -2412,30 +2412,30 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint { CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx*mx + my*my); - Object *obedit= data->vc->obedit; - Curve *cu= (Curve*)obedit->data; + float r = sqrt(mx * mx + my * my); + Object *obedit = data->vc->obedit; + Curve *cu = (Curve *)obedit->data; - if (r<=data->radius) { + if (r <= data->radius) { if (bp) { - bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; } else { if (cu->drawflag & CU_HIDE_HANDLES) { /* can only be beztindex==0 here since handles are hidden */ - bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); + bezt->f1 = bezt->f2 = bezt->f3 = data->select ? (bezt->f2 | SELECT) : (bezt->f2 & ~SELECT); } else { - if (beztindex==0) { - bezt->f1 = data->select?(bezt->f1|SELECT):(bezt->f1&~SELECT); + if (beztindex == 0) { + bezt->f1 = data->select ? (bezt->f1 | SELECT) : (bezt->f1 & ~SELECT); } - else if (beztindex==1) { - bezt->f2 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); + else if (beztindex == 1) { + bezt->f2 = data->select ? (bezt->f2 | SELECT) : (bezt->f2 & ~SELECT); } else { - bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT); + bezt->f3 = data->select ? (bezt->f3 | SELECT) : (bezt->f3 & ~SELECT); } } @@ -2464,10 +2464,10 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int { CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx*mx + my*my); + float r = sqrt(mx * mx + my * my); - if (r<=data->radius) { - bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + if (r <= data->radius) { + bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } static void lattice_circle_select(ViewContext *vc, int select, const int mval[2], float rad) @@ -2491,7 +2491,7 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int { CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx*mx + my*my); + float r = sqrt(mx * mx + my * my); if (r <= data->radius) { if (data->select) @@ -2508,7 +2508,7 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f bArmature *arm = vc->obact->data; bPose *pose = vc->obact->pose; bPoseChannel *pchan; - int change= FALSE; + int change = FALSE; /* set vc->edit data */ data.select = select; @@ -2521,7 +2521,7 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f /* check each PoseChannel... */ // TODO: could be optimized at some point for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - short sco1[2], sco2[2], didpoint=0; + short sco1[2], sco2[2], didpoint = 0; float vec[3]; /* skip invisible bones */ @@ -2540,15 +2540,15 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f * - the call to check also does the selection already */ if (pchan_circle_doSelectJoint(&data, pchan, sco1[0], sco1[1])) - didpoint= 1; + didpoint = 1; if (pchan_circle_doSelectJoint(&data, pchan, sco2[0], sco2[1])) - didpoint= 1; + didpoint = 1; change |= didpoint; } if (change) { - WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obact); + WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obact); } } @@ -2556,7 +2556,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int { CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx*mx + my*my); + float r = sqrt(mx * mx + my * my); if (r <= data->radius) { if (head) { @@ -2578,9 +2578,9 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int static void armature_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { CircleSelectUserData data; - bArmature *arm= vc->obedit->data; + bArmature *arm = vc->obedit->data; EditBone *ebone; - int change= FALSE; + int change = FALSE; /* set vc->edit data */ data.select = select; @@ -2592,8 +2592,8 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 /* check each EditBone... */ // TODO: could be optimized at some point - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { - short sco1[2], sco2[2], didpoint=0; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + short sco1[2], sco2[2], didpoint = 0; float vec[3]; /* project head location to screenspace */ @@ -2608,18 +2608,18 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 * - the call to check also does the selection already */ if (armature_circle_doSelectJoint(&data, ebone, sco1[0], sco1[1], 1)) - didpoint= 1; + didpoint = 1; if (armature_circle_doSelectJoint(&data, ebone, sco2[0], sco2[1], 0)) - didpoint= 1; + didpoint = 1; /* only if the endpoints didn't get selected, deal with the middle of the bone too */ // XXX should we just do this always? - if ( (didpoint==0) && edge_inside_circle(mval[0], mval[1], rad, sco1[0], sco1[1], sco2[0], sco2[1]) ) { + if ( (didpoint == 0) && edge_inside_circle(mval[0], mval[1], rad, sco1[0], sco1[1], sco2[0], sco2[1]) ) { if (select) - ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED; + ebone->flag |= BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED; else - ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - change= TRUE; + ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + change = TRUE; } change |= didpoint; @@ -2628,7 +2628,7 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 if (change) { ED_armature_sync_selection(arm->edbo); ED_armature_validate_active(arm); - WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obedit); + WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit); } } @@ -2636,43 +2636,43 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 static void obedit_circle_select(ViewContext *vc, short select, const int mval[2], float rad) { - switch(vc->obedit->type) { - case OB_MESH: - mesh_circle_select(vc, select, mval, rad); - break; - case OB_CURVE: - case OB_SURF: - nurbscurve_circle_select(vc, select, mval, rad); - break; - case OB_LATTICE: - lattice_circle_select(vc, select, mval, rad); - break; - case OB_ARMATURE: - armature_circle_select(vc, select, mval, rad); - break; - default: - return; + switch (vc->obedit->type) { + case OB_MESH: + mesh_circle_select(vc, select, mval, rad); + break; + case OB_CURVE: + case OB_SURF: + nurbscurve_circle_select(vc, select, mval, rad); + break; + case OB_LATTICE: + lattice_circle_select(vc, select, mval, rad); + break; + case OB_ARMATURE: + armature_circle_select(vc, select, mval, rad); + break; + default: + return; } } /* not a real operator, only for circle test */ static int view3d_circle_select_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); - Object *obact= CTX_data_active_object(C); - View3D *v3d= sa->spacedata.first; - int x= RNA_int_get(op->ptr, "x"); - int y= RNA_int_get(op->ptr, "y"); - int radius= RNA_int_get(op->ptr, "radius"); - int gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + Object *obact = CTX_data_active_object(C); + View3D *v3d = sa->spacedata.first; + int x = RNA_int_get(op->ptr, "x"); + int y = RNA_int_get(op->ptr, "y"); + int radius = RNA_int_get(op->ptr, "radius"); + int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); int select; - select= (gesture_mode==GESTURE_MODAL_SELECT); + select = (gesture_mode == GESTURE_MODAL_SELECT); - if ( CTX_data_edit_object(C) || paint_facesel_test(obact) || paint_vertsel_test(obact) || - (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT|OB_MODE_POSE))) ) + if (CTX_data_edit_object(C) || paint_facesel_test(obact) || paint_vertsel_test(obact) || + (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) ) { ViewContext vc; int mval[2]; @@ -2680,20 +2680,20 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); - mval[0]= x; - mval[1]= y; + mval[0] = x; + mval[1] = y; if (CTX_data_edit_object(C)) { obedit_circle_select(&vc, select, mval, (float)radius); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } else if (paint_facesel_test(obact)) { paint_facesel_circle_select(&vc, select, mval, (float)radius); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } else if (paint_vertsel_test(obact)) { paint_vertsel_circle_select(&vc, select, mval, (float)radius); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } else if (obact->mode & OB_MODE_POSE) pose_circle_select(&vc, select, mval, (float)radius); @@ -2705,20 +2705,20 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) } else { Base *base; - select= select?BA_SELECT:BA_DESELECT; - for (base= FIRSTBASE; base; base= base->next) { + select = select ? BA_SELECT : BA_DESELECT; + for (base = FIRSTBASE; base; base = base->next) { if (BASE_SELECTABLE(v3d, base)) { project_short(ar, base->object->obmat[3], &base->sx); - if (base->sx!=IS_CLIPPED) { - int dx= base->sx-x; - int dy= base->sy-y; - if ( dx*dx + dy*dy < radius*radius) + if (base->sx != IS_CLIPPED) { + int dx = base->sx - x; + int dy = base->sy - y; + if (dx * dx + dy * dy < radius * radius) ED_base_object_select(base, select); } } } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); } return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 1d8395c0967..9d160fb361a 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -73,7 +73,7 @@ #include "view3d_intern.h" -extern float originmat[3][3]; /* XXX object.c */ +extern float originmat[3][3]; /* XXX object.c */ /* ************************************************** */ /* ********************* old transform stuff ******** */ @@ -91,8 +91,8 @@ typedef struct TransVert { /* SELECT == (1 << 0) */ #define TX_VERT_USE_MAPLOC (1 << 1) -static TransVert *transvmain=NULL; -static int tottrans= 0; +static TransVert *transvmain = NULL; +static int tottrans = 0; /* copied from editobject.c, now uses (almost) proper depgraph */ static void special_transvert_update(Object *obedit) @@ -100,21 +100,21 @@ static void special_transvert_update(Object *obedit) if (obedit) { DAG_id_tag_update(obedit->data, 0); - if (obedit->type==OB_MESH) { - Mesh *me= obedit->data; - BM_mesh_normals_update(me->edit_btmesh->bm, TRUE); // does face centers too + if (obedit->type == OB_MESH) { + Mesh *me = obedit->data; + BM_mesh_normals_update(me->edit_btmesh->bm, TRUE); // does face centers too } else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu= obedit->data; - ListBase *nurbs= curve_editnurbs(cu); - Nurb *nu= nurbs->first; + Curve *cu = obedit->data; + ListBase *nurbs = curve_editnurbs(cu); + Nurb *nu = nurbs->first; while (nu) { /* keep handles' vectors unchanged */ if (nu->bezt) { - int a= nu->pntsu; - TransVert *tv= transvmain; - BezTriple *bezt= nu->bezt; + int a = nu->pntsu; + TransVert *tv = transvmain; + BezTriple *bezt = nu->bezt; while (a--) { if (bezt->f1 & SELECT) tv++; @@ -123,12 +123,12 @@ static void special_transvert_update(Object *obedit) float v[3]; if (bezt->f1 & SELECT) { - sub_v3_v3v3(v, (tv-1)->oldloc, tv->oldloc); + sub_v3_v3v3(v, (tv - 1)->oldloc, tv->oldloc); add_v3_v3v3(bezt->vec[0], bezt->vec[1], v); } if (bezt->f3 & SELECT) { - sub_v3_v3v3(v, (tv+1)->oldloc, tv->oldloc); + sub_v3_v3v3(v, (tv + 1)->oldloc, tv->oldloc); add_v3_v3v3(bezt->vec[2], bezt->vec[1], v); } @@ -143,17 +143,17 @@ static void special_transvert_update(Object *obedit) test2DNurb(nu); testhandlesNurb(nu); /* test for bezier too */ - nu= nu->next; + nu = nu->next; } } - else if (obedit->type==OB_ARMATURE) { - bArmature *arm= obedit->data; + else if (obedit->type == OB_ARMATURE) { + bArmature *arm = obedit->data; EditBone *ebo; - TransVert *tv= transvmain; - int a=0; + TransVert *tv = transvmain; + int a = 0; /* Ensure all bone tails are correctly adjusted */ - for (ebo= arm->edbo->first; ebo; ebo=ebo->next) { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { /* adjust tip if both ends selected */ if ((ebo->flag & BONE_ROOTSEL) && (ebo->flag & BONE_TIPSEL)) { if (tv) { @@ -163,13 +163,13 @@ static void special_transvert_update(Object *obedit) add_v3_v3(ebo->tail, diffvec); a++; - if (a<tottrans) tv++; + if (a < tottrans) tv++; } } } /* Ensure all bones are correctly adjusted */ - for (ebo= arm->edbo->first; ebo; ebo=ebo->next) { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { if ((ebo->flag & BONE_CONNECTED) && ebo->parent) { /* If this bone has a parent tip that has been moved */ if (ebo->parent->flag & BONE_TIPSEL) { @@ -184,8 +184,8 @@ static void special_transvert_update(Object *obedit) if (arm->flag & ARM_MIRROR_EDIT) transform_armature_mirror_update(obedit); } - else if (obedit->type==OB_LATTICE) { - Lattice *lt= obedit->data; + else if (obedit->type == OB_LATTICE) { + Lattice *lt = obedit->data; if (lt->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(lt->editlatt->latt); @@ -195,7 +195,7 @@ static void special_transvert_update(Object *obedit) static void set_mapped_co(void *vuserdata, int index, float *co, float *UNUSED(no), short *UNUSED(no_s)) { - void ** userdata = vuserdata; + void **userdata = vuserdata; BMEditMesh *em = userdata[0]; TransVert *tv = userdata[1]; BMVert *eve = EDBM_get_vert_for_index(em, index); @@ -208,28 +208,28 @@ static void set_mapped_co(void *vuserdata, int index, float *co, float *UNUSED(n /* copied from editobject.c, needs to be replaced with new transform code still */ /* mode flags: */ -#define TM_ALL_JOINTS 1 /* all joints (for bones only) */ -#define TM_SKIP_HANDLES 2 /* skip handles when control point is selected (for curves only) */ +#define TM_ALL_JOINTS 1 /* all joints (for bones only) */ +#define TM_SKIP_HANDLES 2 /* skip handles when control point is selected (for curves only) */ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) { Nurb *nu; BezTriple *bezt; BPoint *bp; - TransVert *tv=NULL; + TransVert *tv = NULL; MetaElem *ml; BMVert *eve; - EditBone *ebo; + EditBone *ebo; float total, center[3], centroid[3]; int a; - tottrans= 0; // global! + tottrans = 0; // global! INIT_MINMAX(min, max); zero_v3(centroid); - if (obedit->type==OB_MESH) { - Mesh *me= obedit->data; - BMEditMesh *em= me->edit_btmesh; + if (obedit->type == OB_MESH) { + Mesh *me = obedit->data; + BMEditMesh *em = me->edit_btmesh; BMesh *bm = em->bm; BMIter iter; void *userdata[2] = {em, NULL}; @@ -239,21 +239,22 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) * perhaps this could use its own array instead? - campbell */ // transform now requires awareness for select mode, so we tag the f1 flags in verts - tottrans= 0; + tottrans = 0; if (em->selectmode & SCE_SELECT_VERTEX) { BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT)) { BM_elem_index_set(eve, 1); /* set_dirty! */ tottrans++; } - else BM_elem_index_set(eve, 0); /* set_dirty! */ + else BM_elem_index_set(eve, 0); /* set_dirty! */ } } else if (em->selectmode & SCE_SELECT_EDGE) { BMEdge *eed; - BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) - BM_elem_index_set(eve, 0); /* set_dirty! */ + BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { + BM_elem_index_set(eve, 0); /* set_dirty! */ + } BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SELECT)) { @@ -262,14 +263,16 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) } } - BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) + BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (BM_elem_index_get(eve)) tottrans++; + } } else { BMFace *efa; - BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) + BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { BM_elem_index_set(eve, 0); /* set_dirty! */ + } BM_ITER(efa, &iter, bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) { @@ -290,17 +293,17 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) /* and now make transverts */ if (tottrans) { - tv=transvmain= MEM_callocN(tottrans*sizeof(TransVert), "maketransverts"); + tv = transvmain = MEM_callocN(tottrans * sizeof(TransVert), "maketransverts"); a = 0; BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (BM_elem_index_get(eve)) { BM_elem_index_set(eve, a); /* set_dirty! */ copy_v3_v3(tv->oldloc, eve->co); - tv->loc= eve->co; - if (eve->no[0] != 0.0f || eve->no[1] != 0.0f ||eve->no[2] != 0.0f) - tv->nor= eve->no; // note this is a hackish signal (ton) - tv->flag= BM_elem_index_get(eve) & SELECT; + tv->loc = eve->co; + if (eve->no[0] != 0.0f || eve->no[1] != 0.0f || eve->no[2] != 0.0f) + tv->nor = eve->no; // note this is a hackish signal (ton) + tv->flag = BM_elem_index_get(eve) & SELECT; tv++; a++; } @@ -319,19 +322,19 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) EDBM_free_index_arrays(em); } } - else if (obedit->type==OB_ARMATURE) { - bArmature *arm= obedit->data; - int totmalloc= BLI_countlist(arm->edbo); + else if (obedit->type == OB_ARMATURE) { + bArmature *arm = obedit->data; + int totmalloc = BLI_countlist(arm->edbo); totmalloc *= 2; /* probably overkill but bones can have 2 trans verts each */ - tv=transvmain= MEM_callocN(totmalloc*sizeof(TransVert), "maketransverts armature"); + tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts armature"); - for (ebo= arm->edbo->first; ebo; ebo=ebo->next) { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { if (ebo->layer & arm->layer) { - short tipsel= (ebo->flag & BONE_TIPSEL); - short rootsel= (ebo->flag & BONE_ROOTSEL); - short rootok= (!(ebo->parent && (ebo->flag & BONE_CONNECTED) && (ebo->parent->flag & BONE_TIPSEL))); + short tipsel = (ebo->flag & BONE_TIPSEL); + short rootsel = (ebo->flag & BONE_ROOTSEL); + short rootok = (!(ebo->parent && (ebo->flag & BONE_CONNECTED) && (ebo->parent->flag & BONE_TIPSEL))); if ((tipsel && rootsel) || (rootsel)) { /* Don't add the tip (unless mode & TM_ALL_JOINTS, for getting all joints), @@ -340,27 +343,27 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) */ if (rootok) { copy_v3_v3(tv->oldloc, ebo->head); - tv->loc= ebo->head; - tv->nor= NULL; - tv->flag= 1; + tv->loc = ebo->head; + tv->nor = NULL; + tv->flag = 1; tv++; tottrans++; } if ((mode & TM_ALL_JOINTS) && (tipsel)) { copy_v3_v3(tv->oldloc, ebo->tail); - tv->loc= ebo->tail; - tv->nor= NULL; - tv->flag= 1; + tv->loc = ebo->tail; + tv->nor = NULL; + tv->flag = 1; tv++; tottrans++; } } else if (tipsel) { copy_v3_v3(tv->oldloc, ebo->tail); - tv->loc= ebo->tail; - tv->nor= NULL; - tv->flag= 1; + tv->loc = ebo->tail; + tv->nor = NULL; + tv->flag = 1; tv++; tottrans++; } @@ -368,49 +371,49 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) } } else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu= obedit->data; - int totmalloc= 0; - ListBase *nurbs= curve_editnurbs(cu); + Curve *cu = obedit->data; + int totmalloc = 0; + ListBase *nurbs = curve_editnurbs(cu); - for (nu= nurbs->first; nu; nu= nu->next) { + for (nu = nurbs->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) - totmalloc += 3*nu->pntsu; + totmalloc += 3 * nu->pntsu; else - totmalloc += nu->pntsu*nu->pntsv; + totmalloc += nu->pntsu * nu->pntsv; } - tv=transvmain= MEM_callocN(totmalloc*sizeof(TransVert), "maketransverts curve"); + tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts curve"); - nu= nurbs->first; + nu = nurbs->first; while (nu) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - if (bezt->hide==0) { - int skip_handle= 0; + if (bezt->hide == 0) { + int skip_handle = 0; if (bezt->f2 & SELECT) - skip_handle= mode & TM_SKIP_HANDLES; + skip_handle = mode & TM_SKIP_HANDLES; if ((bezt->f1 & SELECT) && !skip_handle) { copy_v3_v3(tv->oldloc, bezt->vec[0]); - tv->loc= bezt->vec[0]; - tv->flag= bezt->f1 & SELECT; + tv->loc = bezt->vec[0]; + tv->flag = bezt->f1 & SELECT; tv++; tottrans++; } if (bezt->f2 & SELECT) { copy_v3_v3(tv->oldloc, bezt->vec[1]); - tv->loc= bezt->vec[1]; - tv->val= &(bezt->alfa); - tv->oldval= bezt->alfa; - tv->flag= bezt->f2 & SELECT; + tv->loc = bezt->vec[1]; + tv->val = &(bezt->alfa); + tv->oldval = bezt->alfa; + tv->flag = bezt->f2 & SELECT; tv++; tottrans++; } if ((bezt->f3 & SELECT) && !skip_handle) { copy_v3_v3(tv->oldloc, bezt->vec[2]); - tv->loc= bezt->vec[2]; - tv->flag= bezt->f3 & SELECT; + tv->loc = bezt->vec[2]; + tv->flag = bezt->f3 & SELECT; tv++; tottrans++; } @@ -419,16 +422,16 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - if (bp->hide==0) { + if (bp->hide == 0) { if (bp->f1 & SELECT) { copy_v3_v3(tv->oldloc, bp->vec); - tv->loc= bp->vec; - tv->val= &(bp->alfa); - tv->oldval= bp->alfa; - tv->flag= bp->f1 & SELECT; + tv->loc = bp->vec; + tv->val = &(bp->alfa); + tv->oldval = bp->alfa; + tv->flag = bp->f1 & SELECT; tv++; tottrans++; } @@ -436,44 +439,44 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) bp++; } } - nu= nu->next; + nu = nu->next; } } - else if (obedit->type==OB_MBALL) { - MetaBall *mb= obedit->data; - int totmalloc= BLI_countlist(mb->editelems); + else if (obedit->type == OB_MBALL) { + MetaBall *mb = obedit->data; + int totmalloc = BLI_countlist(mb->editelems); - tv=transvmain= MEM_callocN(totmalloc*sizeof(TransVert), "maketransverts mball"); + tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts mball"); - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { if (ml->flag & SELECT) { - tv->loc= &ml->x; + tv->loc = &ml->x; copy_v3_v3(tv->oldloc, tv->loc); - tv->val= &(ml->rad); - tv->oldval= ml->rad; - tv->flag= 1; + tv->val = &(ml->rad); + tv->oldval = ml->rad; + tv->flag = 1; tv++; tottrans++; } - ml= ml->next; + ml = ml->next; } } - else if (obedit->type==OB_LATTICE) { - Lattice *lt= obedit->data; + else if (obedit->type == OB_LATTICE) { + Lattice *lt = obedit->data; - bp= lt->editlatt->latt->def; + bp = lt->editlatt->latt->def; - a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; - tv=transvmain= MEM_callocN(a*sizeof(TransVert), "maketransverts latt"); + tv = transvmain = MEM_callocN(a * sizeof(TransVert), "maketransverts latt"); while (a--) { if (bp->f1 & SELECT) { - if (bp->hide==0) { + if (bp->hide == 0) { copy_v3_v3(tv->oldloc, bp->vec); - tv->loc= bp->vec; - tv->flag= bp->f1 & SELECT; + tv->loc = bp->vec; + tv->flag = bp->f1 & SELECT; tv++; tottrans++; } @@ -486,13 +489,13 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) /* prevent memory leak. happens for curves/latticies due to */ /* difficult condition of adding points to trans data */ MEM_freeN(transvmain); - transvmain= NULL; + transvmain = NULL; } /* cent etc */ - tv= transvmain; - total= 0.0; - for (a=0; a<tottrans; a++, tv++) { + tv = transvmain; + total = 0.0; + for (a = 0; a < tottrans; a++, tv++) { if (tv->flag & SELECT) { add_v3_v3(centroid, tv->oldloc); total += 1.0f; @@ -500,7 +503,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) } } if (total != 0.0f) { - mul_v3_fl(centroid, 1.0f/total); + mul_v3_fl(centroid, 1.0f / total); } mid_v3_v3v3(center, min, max); @@ -510,34 +513,34 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Object *obedit= CTX_data_edit_object(C); - Scene *scene= CTX_data_scene(C); - RegionView3D *rv3d= CTX_wm_region_data(C); + Main *bmain = CTX_data_main(C); + Object *obedit = CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + RegionView3D *rv3d = CTX_wm_region_data(C); TransVert *tv; float gridf, imat[3][3], bmat[3][3], vec[3]; int a; - gridf= rv3d->gridview; + gridf = rv3d->gridview; if (obedit) { - tottrans= 0; + tottrans = 0; if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)) make_trans_verts(obedit, bmat[0], bmat[1], 0); - if (tottrans==0) return OPERATOR_CANCELLED; + if (tottrans == 0) return OPERATOR_CANCELLED; copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - tv= transvmain; - for (a=0; a<tottrans; a++, tv++) { + tv = transvmain; + for (a = 0; a < tottrans; a++, tv++) { copy_v3_v3(vec, tv->loc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); - vec[0]= gridf*floorf(0.5f+ vec[0]/gridf); - vec[1]= gridf*floorf(0.5f+ vec[1]/gridf); - vec[2]= gridf*floorf(0.5f+ vec[2]/gridf); + vec[0] = gridf * floorf(0.5f + vec[0] / gridf); + vec[1] = gridf * floorf(0.5f + vec[1] / gridf); + vec[2] = gridf * floorf(0.5f + vec[2] / gridf); sub_v3_v3(vec, obedit->obmat[3]); mul_m3_v3(imat, vec); @@ -547,31 +550,31 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) special_transvert_update(obedit); MEM_freeN(transvmain); - transvmain= NULL; + transvmain = NULL; } else { struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID); - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; - bArmature *arm= ob->data; + bArmature *arm = ob->data; invert_m4_m4(ob->imat, ob->obmat); - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->flag & BONE_SELECTED) { if (pchan->bone->layer & arm->layer) { - if ((pchan->bone->flag & BONE_CONNECTED)==0) { + if ((pchan->bone->flag & BONE_CONNECTED) == 0) { float nLoc[3]; /* get nearest grid point to snap to */ copy_v3_v3(nLoc, pchan->pose_mat[3]); /* We must operate in world space! */ mul_m4_v3(ob->obmat, nLoc); - vec[0]= gridf * (float)(floor(0.5f+ nLoc[0]/gridf)); - vec[1]= gridf * (float)(floor(0.5f+ nLoc[1]/gridf)); - vec[2]= gridf * (float)(floor(0.5f+ nLoc[2]/gridf)); + vec[0] = gridf * (float)(floor(0.5f + nLoc[0] / gridf)); + vec[1] = gridf * (float)(floor(0.5f + nLoc[1] / gridf)); + vec[2] = gridf * (float)(floor(0.5f + nLoc[2] / gridf)); /* Back in object space... */ mul_m4_v3(ob->imat, vec); @@ -579,12 +582,12 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) armature_loc_pose_to_bone(pchan, vec, vec); /* adjust location */ - if ((pchan->protectflag & OB_LOCK_LOCX)==0) - pchan->loc[0]= vec[0]; - if ((pchan->protectflag & OB_LOCK_LOCY)==0) - pchan->loc[1]= vec[1]; - if ((pchan->protectflag & OB_LOCK_LOCZ)==0) - pchan->loc[2]= vec[2]; + if ((pchan->protectflag & OB_LOCK_LOCX) == 0) + pchan->loc[0] = vec[0]; + if ((pchan->protectflag & OB_LOCK_LOCY) == 0) + pchan->loc[1] = vec[1]; + if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) + pchan->loc[2] = vec[2]; /* auto-keyframing */ ED_autokeyframe_pchan(C, scene, ob, pchan, ks); @@ -595,16 +598,16 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) } } } - ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); + ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { ob->recalc |= OB_RECALC_OB; - vec[0]= -ob->obmat[3][0]+gridf*floorf(0.5f+ ob->obmat[3][0]/gridf); - vec[1]= -ob->obmat[3][1]+gridf*floorf(0.5f+ ob->obmat[3][1]/gridf); - vec[2]= -ob->obmat[3][2]+gridf*floorf(0.5f+ ob->obmat[3][2]/gridf); + vec[0] = -ob->obmat[3][0] + gridf *floorf(0.5f + ob->obmat[3][0] / gridf); + vec[1] = -ob->obmat[3][1] + gridf *floorf(0.5f + ob->obmat[3][1] / gridf); + vec[2] = -ob->obmat[3][2] + gridf *floorf(0.5f + ob->obmat[3][2] / gridf); if (ob->parent) { where_is_object(scene, ob); @@ -612,12 +615,12 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); } - if ((ob->protectflag & OB_LOCK_LOCX)==0) - ob->loc[0]+= vec[0]; - if ((ob->protectflag & OB_LOCK_LOCY)==0) - ob->loc[1]+= vec[1]; - if ((ob->protectflag & OB_LOCK_LOCZ)==0) - ob->loc[2]+= vec[2]; + if ((ob->protectflag & OB_LOCK_LOCX) == 0) + ob->loc[0] += vec[0]; + if ((ob->protectflag & OB_LOCK_LOCY) == 0) + ob->loc[1] += vec[1]; + if ((ob->protectflag & OB_LOCK_LOCZ) == 0) + ob->loc[2] += vec[2]; /* auto-keyframing */ ED_autokeyframe_object(C, scene, ob, ks); @@ -627,7 +630,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) } DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -644,35 +647,35 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) ot->poll = ED_operator_region_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *************************************************** */ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Object *obedit= CTX_data_edit_object(C); - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Main *bmain = CTX_data_main(C); + Object *obedit = CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); TransVert *tv; float *curs, imat[3][3], bmat[3][3], vec[3]; int a; - curs= give_cursor(scene, v3d); + curs = give_cursor(scene, v3d); if (obedit) { - tottrans= 0; + tottrans = 0; if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)) make_trans_verts(obedit, bmat[0], bmat[1], 0); - if (tottrans==0) return OPERATOR_CANCELLED; + if (tottrans == 0) return OPERATOR_CANCELLED; copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - tv= transvmain; - for (a=0; a<tottrans; a++, tv++) { + tv = transvmain; + for (a = 0; a < tottrans; a++, tv++) { sub_v3_v3v3(vec, curs, obedit->obmat[3]); mul_m3_v3(imat, vec); copy_v3_v3(tv->loc, vec); @@ -681,34 +684,34 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) special_transvert_update(obedit); MEM_freeN(transvmain); - transvmain= NULL; + transvmain = NULL; } else { struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID); - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; - bArmature *arm= ob->data; + bArmature *arm = ob->data; invert_m4_m4(ob->imat, ob->obmat); copy_v3_v3(vec, curs); mul_m4_v3(ob->imat, vec); - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->flag & BONE_SELECTED) { if (pchan->bone->layer & arm->layer) { - if ((pchan->bone->flag & BONE_CONNECTED)==0) { + if ((pchan->bone->flag & BONE_CONNECTED) == 0) { /* Get position in pchan (pose) space. */ armature_loc_pose_to_bone(pchan, vec, vec); /* copy new position */ - if ((pchan->protectflag & OB_LOCK_LOCX)==0) - pchan->loc[0]= vec[0]; - if ((pchan->protectflag & OB_LOCK_LOCY)==0) - pchan->loc[1]= vec[1]; - if ((pchan->protectflag & OB_LOCK_LOCZ)==0) - pchan->loc[2]= vec[2]; + if ((pchan->protectflag & OB_LOCK_LOCX) == 0) + pchan->loc[0] = vec[0]; + if ((pchan->protectflag & OB_LOCK_LOCY) == 0) + pchan->loc[1] = vec[1]; + if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) + pchan->loc[2] = vec[2]; /* auto-keyframing */ ED_autokeyframe_pchan(C, scene, ob, pchan, ks); @@ -719,16 +722,16 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) } } } - ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); + ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { ob->recalc |= OB_RECALC_OB; - vec[0]= -ob->obmat[3][0] + curs[0]; - vec[1]= -ob->obmat[3][1] + curs[1]; - vec[2]= -ob->obmat[3][2] + curs[2]; + vec[0] = -ob->obmat[3][0] + curs[0]; + vec[1] = -ob->obmat[3][1] + curs[1]; + vec[2] = -ob->obmat[3][2] + curs[2]; if (ob->parent) { where_is_object(scene, ob); @@ -736,12 +739,12 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); } - if ((ob->protectflag & OB_LOCK_LOCX)==0) - ob->loc[0]+= vec[0]; - if ((ob->protectflag & OB_LOCK_LOCY)==0) - ob->loc[1]+= vec[1]; - if ((ob->protectflag & OB_LOCK_LOCZ)==0) - ob->loc[2]+= vec[2]; + if ((ob->protectflag & OB_LOCK_LOCX) == 0) + ob->loc[0] += vec[0]; + if ((ob->protectflag & OB_LOCK_LOCY) == 0) + ob->loc[1] += vec[1]; + if ((ob->protectflag & OB_LOCK_LOCZ) == 0) + ob->loc[2] += vec[2]; /* auto-keyframing */ ED_autokeyframe_object(C, scene, ob, ks); @@ -751,7 +754,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) } DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -768,26 +771,26 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *************************************************** */ static int snap_curs_to_grid(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - RegionView3D *rv3d= CTX_wm_region_data(C); - View3D *v3d= CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + RegionView3D *rv3d = CTX_wm_region_data(C); + View3D *v3d = CTX_wm_view3d(C); float gridf, *curs; - gridf= rv3d->gridview; - curs= give_cursor(scene, v3d); + gridf = rv3d->gridview; + curs = give_cursor(scene, v3d); - curs[0]= gridf*floorf(0.5f+curs[0]/gridf); - curs[1]= gridf*floorf(0.5f+curs[1]/gridf); - curs[2]= gridf*floorf(0.5f+curs[2]/gridf); + curs[0] = gridf * floorf(0.5f + curs[0] / gridf); + curs[1] = gridf * floorf(0.5f + curs[1] / gridf); + curs[2] = gridf * floorf(0.5f + curs[2] / gridf); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); // hrm + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); // hrm return OPERATOR_FINISHED; } @@ -804,23 +807,23 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot) ot->poll = ED_operator_region_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************************************************** */ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) { - MovieClip *clip= object_get_movieclip(scene, ob, 0); + MovieClip *clip = object_get_movieclip(scene, ob, 0); MovieTracking *tracking; MovieTrackingObject *object; - int ok= 0; + int ok = 0; float min[3], max[3], mat[4][4], pos[3], cammat[4][4] = MAT4_UNITY; if (!clip) return; - tracking= &clip->tracking; + tracking = &clip->tracking; copy_m4_m4(cammat, ob->obmat); @@ -828,9 +831,9 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) INIT_MINMAX(min, max); - for (object= tracking->objects.first; object; object= object->next) { - ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object); - MovieTrackingTrack *track= tracksbase->first; + for (object = tracking->objects.first; object; object = object->next) { + ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object); + MovieTrackingTrack *track = tracksbase->first; float obmat[4][4]; if (object->flag & TRACKING_OBJECT_CAMERA) { @@ -846,13 +849,13 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) } while (track) { - if ((track->flag&TRACK_HAS_BUNDLE) && TRACK_SELECTED(track)) { - ok= 1; + if ((track->flag & TRACK_HAS_BUNDLE) && TRACK_SELECTED(track)) { + ok = 1; mul_v3_m4v3(pos, obmat, track->bundle_pos); DO_MINMAX(pos, min, max); } - track= track->next; + track = track->next; } } @@ -863,30 +866,30 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Object *obedit = CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); TransVert *tv; float *curs, bmat[3][3], vec[3], min[3], max[3], centroid[3]; int count, a; - curs= give_cursor(scene, v3d); + curs = give_cursor(scene, v3d); - count= 0; + count = 0; INIT_MINMAX(min, max); zero_v3(centroid); if (obedit) { - tottrans=0; + tottrans = 0; if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)) - make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS|TM_SKIP_HANDLES); - if (tottrans==0) return OPERATOR_CANCELLED; + make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS | TM_SKIP_HANDLES); + if (tottrans == 0) return OPERATOR_CANCELLED; copy_m3_m4(bmat, obedit->obmat); - tv= transvmain; - for (a=0; a<tottrans; a++, tv++) { + tv = transvmain; + for (a = 0; a < tottrans; a++, tv++) { copy_v3_v3(vec, tv->loc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); @@ -894,23 +897,23 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) DO_MINMAX(vec, min, max); } - if (v3d->around==V3D_CENTROID) { - mul_v3_fl(centroid, 1.0f/(float)tottrans); + if (v3d->around == V3D_CENTROID) { + mul_v3_fl(centroid, 1.0f / (float)tottrans); copy_v3_v3(curs, centroid); } else { mid_v3_v3v3(curs, min, max); } MEM_freeN(transvmain); - transvmain= NULL; + transvmain = NULL; } else { - Object *obact= CTX_data_active_object(C); + Object *obact = CTX_data_active_object(C); if (obact && (obact->mode & OB_MODE_POSE)) { - bArmature *arm= obact->data; + bArmature *arm = obact->data; bPoseChannel *pchan; - for (pchan = obact->pose->chanbase.first; pchan; pchan=pchan->next) { + for (pchan = obact->pose->chanbase.first; pchan; pchan = pchan->next) { if (arm->layer & pchan->bone->layer) { if (pchan->bone->flag & BONE_SELECTED) { copy_v3_v3(vec, pchan->pose_head); @@ -923,13 +926,13 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) } } else { - CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { + CTX_DATA_BEGIN(C, Object *, ob, selected_objects) { copy_v3_v3(vec, ob->obmat[3]); /* special case for camera -- snap to bundles */ - if (ob->type==OB_CAMERA) { + if (ob->type == OB_CAMERA) { /* snap to bundles should happen only when bundles are visible */ - if (v3d->flag2&V3D_SHOW_RECONSTRUCTION) { + if (v3d->flag2 & V3D_SHOW_RECONSTRUCTION) { bundle_midpoint(scene, ob, vec); } } @@ -941,8 +944,8 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; } if (count) { - if (v3d->around==V3D_CENTROID) { - mul_v3_fl(centroid, 1.0f/(float)count); + if (v3d->around == V3D_CENTROID) { + mul_v3_fl(centroid, 1.0f / (float)count); copy_v3_v3(curs, centroid); } else { @@ -950,7 +953,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) } } } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -967,17 +970,17 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************************** */ static int snap_curs_to_active(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Object *obact= CTX_data_active_object(C); - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Object *obedit = CTX_data_edit_object(C); + Object *obact = CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); float *curs; curs = give_cursor(scene, v3d); @@ -985,7 +988,7 @@ static int snap_curs_to_active(bContext *C, wmOperator *UNUSED(op)) if (obedit) { if (obedit->type == OB_MESH) { /* check active */ - Mesh *me= obedit->data; + Mesh *me = obedit->data; BMEditSelection ese; if (EDBM_get_actSelection(me->edit_btmesh, &ese)) { @@ -1001,7 +1004,7 @@ static int snap_curs_to_active(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -1017,23 +1020,21 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************************************************** */ /*New Code - Snap Cursor to Center -*/ static int snap_curs_to_center(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); float *curs; - curs= give_cursor(scene, v3d); + curs = give_cursor(scene, v3d); - curs[0]= 0.0; - curs[1]= 0.0; - curs[2]= 0.0; + zero_v3(curs); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -1050,7 +1051,7 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************************************************** */ @@ -1062,16 +1063,16 @@ int minmax_verts(Object *obedit, float *min, float *max) float centroid[3], vec[3], bmat[3][3]; int a; - tottrans=0; + tottrans = 0; if (ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE)) make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS); - if (tottrans==0) return 0; + if (tottrans == 0) return 0; copy_m3_m4(bmat, obedit->obmat); - tv= transvmain; - for (a=0; a<tottrans; a++, tv++) { + tv = transvmain; + for (a = 0; a < tottrans; a++, tv++) { copy_v3_v3(vec, (tv->flag & TX_VERT_USE_MAPLOC) ? tv->maploc : tv->loc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); @@ -1080,7 +1081,7 @@ int minmax_verts(Object *obedit, float *min, float *max) } MEM_freeN(transvmain); - transvmain= NULL; + transvmain = NULL; return 1; } diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 88a490e23b8..82ab6cd7193 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -64,7 +64,7 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include /* ******************* view3d space & buttons ************** */ @@ -76,7 +76,7 @@ static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOper static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa) { - wmOperator *op= WM_operator_last_redo(C); + wmOperator *op = WM_operator_last_redo(C); if (op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); else BLI_strncpy(pa->drawname, IFACE_("Operator"), sizeof(pa->drawname)); @@ -85,7 +85,7 @@ static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa) static void view3d_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOperator *op) { if (op->type->flag & OPTYPE_MACRO) { - for (op= op->macro.first; op; op= op->next) { + for (op = op->macro.first; op; op = op->next) { uiItemL(pa->layout, op->type->name, ICON_NONE); view3d_panel_operator_redo_operator(C, pa, op); } @@ -98,15 +98,15 @@ static void view3d_panel_operator_redo_operator(const bContext *C, Panel *pa, wm /* TODO de-duplicate redo panel functions - campbell */ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) { - wmOperator *op= WM_operator_last_redo(C); + wmOperator *op = WM_operator_last_redo(C); uiBlock *block; - if (op==NULL) + if (op == NULL) return; - if (WM_operator_poll((bContext*)C, op->type) == 0) + if (WM_operator_poll((bContext *)C, op->type) == 0) return; - block= uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(pa->layout); if (!WM_operator_check_ui_enabled(C, op->type->name)) uiLayoutSetEnabled(pa->layout, 0); @@ -127,10 +127,10 @@ typedef struct CustomTool { static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) { - wmOperatorType *ot= arg2; + wmOperatorType *ot = arg2; if (ot) { - CustomTool *ct= MEM_callocN(sizeof(CustomTool), "CustomTool"); + CustomTool *ct = MEM_callocN(sizeof(CustomTool), "CustomTool"); BLI_addtail(arg_listbase, ct); BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME); @@ -141,15 +141,15 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { - GHashIterator *iter= WM_operatortype_iter(); + GHashIterator *iter = WM_operatortype_iter(); - for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot= BLI_ghashIterator_getValue(iter); + for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot = BLI_ghashIterator_getValue(iter); if (BLI_strcasestr(ot->name, str)) { - if (WM_operator_poll((bContext*)C, ot)) { + if (WM_operator_poll((bContext *)C, ot)) { - if (0==uiSearchItemAdd(items, ot->name, ot, 0)) + if (0 == uiSearchItemAdd(items, ot->name, ot, 0)) break; } } @@ -163,15 +163,15 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) { static char search[OP_MAX_TYPENAME]; wmEvent event; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); uiBlock *block; uiBut *but; /* clear initial search string, then all items show */ - search[0]= 0; + search[0] = 0; - block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1); + block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); @@ -183,11 +183,11 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) uiBlockSetDirection(block, UI_DOWN); uiEndBlock(C, block); - event= *(win->eventstate); /* XXX huh huh? make api call */ - event.type= EVT_BUT_OPEN; - event.val= KM_PRESS; - event.customdata= but; - event.customdatafree= FALSE; + event = *(win->eventstate); /* XXX huh huh? make api call */ + event.type = EVT_BUT_OPEN; + event.val = KM_PRESS; + event.customdata = but; + event.customdatafree = FALSE; wm_event_add(win, &event); return block; @@ -196,25 +196,25 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) { - SpaceLink *sl= CTX_wm_space_data(C); - SpaceType *st= NULL; + SpaceLink *sl = CTX_wm_space_data(C); + SpaceType *st = NULL; uiLayout *col; - const char *context= CTX_data_mode_string(C); + const char *context = CTX_data_mode_string(C); if (sl) - st= BKE_spacetype_from_id(sl->spacetype); + st = BKE_spacetype_from_id(sl->spacetype); if (st && st->toolshelf.first) { CustomTool *ct; - for (ct= st->toolshelf.first; ct; ct= ct->next) { - if (0==strncmp(context, ct->context, OP_MAX_TYPENAME)) { - col= uiLayoutColumn(pa->layout, 1); + for (ct = st->toolshelf.first; ct; ct = ct->next) { + if (0 == strncmp(context, ct->context, OP_MAX_TYPENAME)) { + col = uiLayoutColumn(pa->layout, 1); uiItemFullO(col, ct->opname, NULL, ICON_NONE, NULL, WM_OP_INVOKE_REGION_WIN, 0); } } } - col= uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, 1); uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &st->toolshelf, "Add Tool", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add Tool in shelf, gets saved in files"); } @@ -223,10 +223,10 @@ void view3d_toolshelf_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel tools"); + pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel tools"); strcpy(pt->idname, "VIEW3D_PT_tool_shelf"); strcpy(pt->label, "Tool Shelf"); - pt->draw= view3d_panel_tool_shelf; + pt->draw = view3d_panel_tool_shelf; BLI_addtail(&art->paneltypes, pt); } @@ -234,11 +234,11 @@ void view3d_tool_props_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator"); + pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator"); strcpy(pt->idname, "VIEW3D_PT_last_operator"); strcpy(pt->label, "Operator"); - pt->draw_header= view3d_panel_operator_redo_header; - pt->draw= view3d_panel_operator_redo; + pt->draw_header = view3d_panel_operator_redo_header; + pt->draw = view3d_panel_operator_redo; BLI_addtail(&art->paneltypes, pt); } @@ -246,8 +246,8 @@ void view3d_tool_props_register(ARegionType *art) static int view3d_toolshelf(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= view3d_has_tools_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = view3d_has_tools_region(sa); if (ar) ED_region_toggle_hidden(C, ar); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 19dc48c648c..f6b03a5fac3 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -71,7 +71,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" // own include /* use this call when executing an operator, * event system doesn't set for each event the @@ -79,7 +79,7 @@ void view3d_operator_needs_opengl(const bContext *C) { wmWindow *win = CTX_wm_window(C); - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); view3d_region_operator_needs_opengl(win, ar); } @@ -87,10 +87,10 @@ void view3d_operator_needs_opengl(const bContext *C) void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar) { /* for debugging purpose, context should always be OK */ - if ((ar == NULL) || (ar->regiontype!=RGN_TYPE_WINDOW)) + if ((ar == NULL) || (ar->regiontype != RGN_TYPE_WINDOW)) printf("view3d_region_operator_needs_opengl error, wrong region\n"); else { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; wmSubWindowSet(win, ar->swinid); glMatrixMode(GL_PROJECTION); @@ -126,20 +126,20 @@ struct SmoothViewStore { void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera, float *ofs, float *quat, float *dist, float *lens) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); - RegionView3D *rv3d= ar->regiondata; - struct SmoothViewStore sms= {0}; - short ok= FALSE; + RegionView3D *rv3d = ar->regiondata; + struct SmoothViewStore sms = {0}; + short ok = FALSE; /* initialize sms */ copy_v3_v3(sms.new_ofs, rv3d->ofs); copy_qt_qt(sms.new_quat, rv3d->viewquat); - sms.new_dist= rv3d->dist; - sms.new_lens= v3d->lens; - sms.to_camera= 0; + sms.new_dist = rv3d->dist; + sms.new_lens = v3d->lens; + sms.to_camera = 0; /* note on camera locking, this is a little confusing but works ok. * we may be changing the view 'as if' there is no active camera, but infact @@ -156,12 +156,12 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec /* store the options we want to end with */ if (ofs) copy_v3_v3(sms.new_ofs, ofs); if (quat) copy_qt_qt(sms.new_quat, quat); - if (dist) sms.new_dist= *dist; - if (lens) sms.new_lens= *lens; + if (dist) sms.new_dist = *dist; + if (lens) sms.new_lens = *lens; if (camera) { ED_view3d_from_object(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); - sms.to_camera= 1; /* restore view3d values in end */ + sms.to_camera = 1; /* restore view3d values in end */ } if (C && U.smooth_viewtx) { @@ -184,30 +184,30 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec /* original values */ if (oldcamera) { - sms.orig_dist= rv3d->dist; // below function does weird stuff with it... + sms.orig_dist = rv3d->dist; // below function does weird stuff with it... ED_view3d_from_object(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { copy_v3_v3(sms.orig_ofs, rv3d->ofs); copy_qt_qt(sms.orig_quat, rv3d->viewquat); - sms.orig_dist= rv3d->dist; - sms.orig_lens= v3d->lens; + sms.orig_dist = rv3d->dist; + sms.orig_lens = v3d->lens; } /* grid draw as floor */ - if ((rv3d->viewlock & RV3D_LOCKED)==0) { + if ((rv3d->viewlock & RV3D_LOCKED) == 0) { /* use existing if exists, means multiple calls to smooth view wont loose the original 'view' setting */ - sms.orig_view= rv3d->sms ? rv3d->sms->orig_view : rv3d->view; - rv3d->view= RV3D_VIEW_USER; + sms.orig_view = rv3d->sms ? rv3d->sms->orig_view : rv3d->view; + rv3d->view = RV3D_VIEW_USER; } - sms.time_allowed= (double)U.smooth_viewtx / 1000.0; + sms.time_allowed = (double)U.smooth_viewtx / 1000.0; /* if this is view rotation only * we can decrease the time allowed by * the angle between quats * this means small rotations wont lag */ if (quat && !ofs && !dist) { - float vec1[3]={0,0,1}, vec2[3]= {0,0,1}; + float vec1[3] = {0, 0, 1}, vec2[3] = {0, 0, 1}; float q1[4], q2[4]; invert_qt_qt(q1, sms.new_quat); @@ -221,26 +221,26 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec } /* ensure it shows correct */ - if (sms.to_camera) rv3d->persp= RV3D_PERSP; + if (sms.to_camera) rv3d->persp = RV3D_PERSP; rv3d->rflag |= RV3D_NAVIGATING; /* keep track of running timer! */ - if (rv3d->sms==NULL) - rv3d->sms= MEM_mallocN(sizeof(struct SmoothViewStore), "smoothview v3d"); - *rv3d->sms= sms; + if (rv3d->sms == NULL) + rv3d->sms = MEM_mallocN(sizeof(struct SmoothViewStore), "smoothview v3d"); + *rv3d->sms = sms; if (rv3d->smooth_timer) WM_event_remove_timer(wm, win, rv3d->smooth_timer); /* TIMER1 is hardcoded in keymap */ - rv3d->smooth_timer= WM_event_add_timer(wm, win, TIMER1, 1.0/100.0); /* max 30 frs/sec */ + rv3d->smooth_timer = WM_event_add_timer(wm, win, TIMER1, 1.0 / 100.0); /* max 30 frs/sec */ - ok= TRUE; + ok = TRUE; } } /* if we get here nothing happens */ if (ok == FALSE) { - if (sms.to_camera==0) { + if (sms.to_camera == 0) { copy_v3_v3(rv3d->ofs, sms.new_ofs); copy_qt_qt(rv3d->viewquat, sms.new_quat); rv3d->dist = sms.new_dist; @@ -258,16 +258,16 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); - struct SmoothViewStore *sms= rv3d->sms; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + struct SmoothViewStore *sms = rv3d->sms; float step, step_inv; /* escape if not our timer */ - if (rv3d->smooth_timer==NULL || rv3d->smooth_timer!=event->customdata) + if (rv3d->smooth_timer == NULL || rv3d->smooth_timer != event->customdata) return OPERATOR_PASS_THROUGH; if (sms->time_allowed != 0.0) - step = (float)((rv3d->smooth_timer->duration)/sms->time_allowed); + step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed); else step = 1.0f; @@ -276,7 +276,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent /* if we went to camera, store the original */ if (sms->to_camera) { - rv3d->persp= RV3D_CAMOB; + rv3d->persp = RV3D_CAMOB; copy_v3_v3(rv3d->ofs, sms->orig_ofs); copy_qt_qt(rv3d->viewquat, sms->orig_quat); rv3d->dist = sms->orig_dist; @@ -291,33 +291,33 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent ED_view3d_camera_lock_sync(v3d, rv3d); } - if ((rv3d->viewlock & RV3D_LOCKED)==0) { - rv3d->view= sms->orig_view; + if ((rv3d->viewlock & RV3D_LOCKED) == 0) { + rv3d->view = sms->orig_view; } MEM_freeN(rv3d->sms); - rv3d->sms= NULL; + rv3d->sms = NULL; WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rv3d->smooth_timer); - rv3d->smooth_timer= NULL; + rv3d->smooth_timer = NULL; rv3d->rflag &= ~RV3D_NAVIGATING; } else { int i; /* ease in/out */ - if (step < 0.5f) step = (float)pow(step*2.0f, 2.0)/2.0f; - else step = (float)1.0f-(powf(2.0f*(1.0f-step),2.0f)/2.0f); + if (step < 0.5f) step = (float)pow(step * 2.0f, 2.0) / 2.0f; + else step = (float)1.0f - (powf(2.0f * (1.0f - step), 2.0f) / 2.0f); - step_inv = 1.0f-step; + step_inv = 1.0f - step; - for (i=0; i<3; i++) - rv3d->ofs[i] = sms->new_ofs[i] * step + sms->orig_ofs[i]*step_inv; + for (i = 0; i < 3; i++) + rv3d->ofs[i] = sms->new_ofs[i] * step + sms->orig_ofs[i] * step_inv; interp_qt_qtqt(rv3d->viewquat, sms->orig_quat, sms->new_quat, step); - rv3d->dist = sms->new_dist * step + sms->orig_dist*step_inv; - v3d->lens = sms->new_lens * step + sms->orig_lens*step_inv; + rv3d->dist = sms->new_dist * step + sms->orig_dist * step_inv; + v3d->lens = sms->new_lens * step + sms->orig_lens * step_inv; ED_view3d_camera_lock_sync(v3d, rv3d); } @@ -325,7 +325,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent if (rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_copy(CTX_wm_area(C), CTX_wm_region(C)); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -349,13 +349,13 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot) static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); ObjectTfmProtectedChannels obtfm; copy_qt_qt(rv3d->lviewquat, rv3d->viewquat); - rv3d->lview= rv3d->view; + rv3d->lview = rv3d->view; if (rv3d->persp != RV3D_CAMOB) { - rv3d->lpersp= rv3d->persp; + rv3d->lpersp = rv3d->persp; } object_tfm_protected_backup(v3d->camera, &obtfm); @@ -367,7 +367,7 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); rv3d->persp = RV3D_CAMOB; - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, v3d->camera); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, v3d->camera); return OPERATOR_FINISHED; @@ -375,9 +375,9 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) static int view3d_camera_to_view_poll(bContext *C) { - View3D *v3d= CTX_wm_view3d(C); - if (v3d && v3d->camera && v3d->camera->id.lib==NULL) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + View3D *v3d = CTX_wm_view3d(C); + if (v3d && v3d->camera && v3d->camera->id.lib == NULL) { + RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d && !rv3d->viewlock) { return 1; } @@ -398,16 +398,16 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot) ot->poll = view3d_camera_to_view_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* unlike VIEW3D_OT_view_selected this is for framing a render and not * meant to take into account vertex/bone selection for eg. */ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Object *camera_ob= v3d->camera; + Object *camera_ob = v3d->camera; float r_co[3]; /* the new location to apply */ @@ -427,7 +427,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o /* notifiers */ DAG_id_tag_update(&camera_ob->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, camera_ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, camera_ob); return OPERATOR_FINISHED; } else { @@ -437,9 +437,9 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o static int view3d_camera_to_view_selected_poll(bContext *C) { - View3D *v3d= CTX_wm_view3d(C); - if (v3d && v3d->camera && v3d->camera->id.lib==NULL) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + View3D *v3d = CTX_wm_view3d(C); + if (v3d && v3d->camera && v3d->camera->id.lib == NULL) { + RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d) { if (rv3d->is_persp == FALSE) { CTX_wm_operator_poll_msg_set(C, "Only valid for a perspective camera view"); @@ -465,7 +465,7 @@ void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot) ot->poll = view3d_camera_to_view_selected_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -475,7 +475,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op)) ARegion *ar; RegionView3D *rv3d; - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); /* no NULL check is needed, poll checks */ @@ -483,16 +483,16 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op)) rv3d = ar->regiondata; if (ob) { - Object *camera_old= (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : NULL; - rv3d->persp= RV3D_CAMOB; - v3d->camera= ob; + Object *camera_old = (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : NULL; + rv3d->persp = RV3D_CAMOB; + v3d->camera = ob; if (v3d->scenelock) - scene->camera= ob; + scene->camera = ob; if (camera_old != ob) /* unlikely but looks like a glitch when set to the same */ smooth_view(C, v3d, ar, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS | NC_OBJECT | ND_DRAW, CTX_data_scene(C)); } return OPERATOR_FINISHED; @@ -519,7 +519,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) ot->poll = ED_operator_rv3d_user_region_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************** */ @@ -532,8 +532,8 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co /* near zero floating point values can give issues with gluUnProject * in side view on some implementations */ - if (fabs(mats->modelview[0]) < 1e-6) mats->modelview[0]= 0.0; - if (fabs(mats->modelview[5]) < 1e-6) mats->modelview[5]= 0.0; + if (fabs(mats->modelview[0]) < 1e-6) mats->modelview[0] = 0.0; + if (fabs(mats->modelview[5]) < 1e-6) mats->modelview[5] = 0.0; /* Set up viewport so that gluUnProject will give correct values */ mats->viewport[0] = 0; @@ -541,9 +541,9 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co /* four clipping planes and bounding volume */ /* first do the bounding volume */ - for (val=0; val<4; val++) { - xs= (val==0||val==3)?rect->xmin:rect->xmax; - ys= (val==0||val==1)?rect->ymin:rect->ymax; + for (val = 0; val < 4; val++) { + xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax; + ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax; gluUnProject(xs, ys, 0.0, mats->modelview, mats->projection, mats->viewport, &p[0], &p[1], &p[2]); copy_v3fl_v3db(bb->vec[val], p); @@ -555,28 +555,28 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co /* verify if we have negative scale. doing the transform before cross * product flips the sign of the vector compared to doing cross product * before transform then, so we correct for that. */ - for (a=0; a<16; a++) - ((float*)modelview)[a] = mats->modelview[a]; + for (a = 0; a < 16; a++) + ((float *)modelview)[a] = mats->modelview[a]; flip_sign = is_negative_m4(modelview); /* then plane equations */ - for (val=0; val<4; val++) { + for (val = 0; val < 4; val++) { - normal_tri_v3(planes[val], bb->vec[val], bb->vec[val==3?0:val+1], bb->vec[val+4]); + normal_tri_v3(planes[val], bb->vec[val], bb->vec[val == 3 ? 0 : val + 1], bb->vec[val + 4]); if (flip_sign) negate_v3(planes[val]); - planes[val][3]= - planes[val][0]*bb->vec[val][0] - - planes[val][1]*bb->vec[val][1] - - planes[val][2]*bb->vec[val][2]; + planes[val][3] = -planes[val][0] * bb->vec[val][0] + - planes[val][1] * bb->vec[val][1] + - planes[val][2] * bb->vec[val][2]; } } /* create intersection coordinates in view Z direction at mouse coordinates */ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; if (rv3d->is_persp) { float vec[3]; @@ -602,7 +602,7 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2] /* clipping */ if (rv3d->rflag & RV3D_CLIPPING) { int a; - for (a=0; a<4; a++) { + for (a = 0; a < 4; a++) { clip_line_plane(ray_start, ray_end, rv3d->clip[a]); } } @@ -643,11 +643,11 @@ void ED_view3d_global_to_vector(RegionView3D *rv3d, const float coord[3], float int initgrabz(RegionView3D *rv3d, float x, float y, float z) { - int flip= FALSE; - if (rv3d==NULL) return flip; - rv3d->zfac= rv3d->persmat[0][3]*x+ rv3d->persmat[1][3]*y+ rv3d->persmat[2][3]*z+ rv3d->persmat[3][3]; + int flip = FALSE; + if (rv3d == NULL) return flip; + rv3d->zfac = rv3d->persmat[0][3] * x + rv3d->persmat[1][3] * y + rv3d->persmat[2][3] * z + rv3d->persmat[3][3]; if (rv3d->zfac < 0.0f) - flip= TRUE; + flip = TRUE; /* if x,y,z is exactly the viewport offset, zfac is 0 and we don't want that * (accounting for near zero values) */ @@ -659,14 +659,14 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z) /* NOTE: I've changed this to flip zfac to be positive again for now so that GPencil draws ok * Aligorith, 2009Aug31 */ //if (rv3d->zfac < 0.0f) rv3d->zfac = 1.0f; - if (rv3d->zfac < 0.0f) rv3d->zfac= -rv3d->zfac; + if (rv3d->zfac < 0.0f) rv3d->zfac = -rv3d->zfac; return flip; } void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float line_sta[3]; float line_end[3]; @@ -683,11 +683,11 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[ } } else { - const float dx= (2.0f * mval[0] / (float)ar->winx) - 1.0f; - const float dy= (2.0f * mval[1] / (float)ar->winy) - 1.0f; - line_sta[0]= (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0]; - line_sta[1]= (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1]; - line_sta[2]= (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2]; + const float dx = (2.0f * mval[0] / (float)ar->winx) - 1.0f; + const float dy = (2.0f * mval[1] / (float)ar->winy) - 1.0f; + line_sta[0] = (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0]; + line_sta[1] = (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1]; + line_sta[2] = (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2]; add_v3_v3v3(line_end, line_sta, rv3d->viewinv[2]); closest_to_line_v3(out, depth_pt, line_sta, line_end); @@ -698,15 +698,15 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[ /* only to detect delta motion */ void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float dx, dy; - dx= 2.0f*mval[0]*rv3d->zfac/ar->winx; - dy= 2.0f*mval[1]*rv3d->zfac/ar->winy; + dx = 2.0f * mval[0] * rv3d->zfac / ar->winx; + dy = 2.0f * mval[1] * rv3d->zfac / ar->winy; - out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy); - out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy); - out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy); + out[0] = (rv3d->persinv[0][0] * dx + rv3d->persinv[1][0] * dy); + out[1] = (rv3d->persinv[0][1] * dx + rv3d->persinv[1][1] * dy); + out[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy); } /* doesn't rely on initgrabz */ @@ -714,12 +714,12 @@ void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3]) * the mouse cursor as a normalized vector */ void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; if (rv3d->is_persp) { - out[0]= 2.0f * (mval[0] / ar->winx) - 1.0f; - out[1]= 2.0f * (mval[1] / ar->winy) - 1.0f; - out[2]= -0.5f; + out[0] = 2.0f * (mval[0] / ar->winx) - 1.0f; + out[1] = 2.0f * (mval[1] / ar->winy) - 1.0f; + out[2] = -0.5f; mul_project_m4_v3(rv3d->persinv, out); sub_v3_v3(out, rv3d->viewinv[3]); } @@ -745,7 +745,7 @@ float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y) void ED_view3d_depth_tag_update(RegionView3D *rv3d) { if (rv3d->depths) - rv3d->depths->damaged= 1; + rv3d->depths->damaged = 1; } void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][4]) @@ -762,7 +762,7 @@ void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, { double ux, uy, uz; - gluUnProject(x,y,z, mats->modelview, mats->projection, + gluUnProject(x, y, z, mats->modelview, mats->projection, (GLint *)mats->viewport, &ux, &uy, &uz); out[0] = ux; @@ -776,14 +776,14 @@ void ED_view3d_project_float_v2(const ARegion *ar, const float vec[3], float adr float vec4[4]; copy_v3_v3(vec4, vec); - vec4[3]= 1.0; + vec4[3] = 1.0; /* adr[0]= IS_CLIPPED; */ /* always overwritten */ mul_m4_v4(mat, vec4); if (vec4[3] > FLT_EPSILON) { - adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3]; - adr[1] = (float)(ar->winy/2.0f)+(ar->winy/2.0f)*vec4[1]/vec4[3]; + adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; + adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; } else { adr[0] = adr[1] = 0.0f; @@ -796,15 +796,15 @@ void ED_view3d_project_float_v3(ARegion *ar, const float vec[3], float adr[3], f float vec4[4]; copy_v3_v3(vec4, vec); - vec4[3]= 1.0; + vec4[3] = 1.0; /* adr[0]= IS_CLIPPED; */ /* always overwritten */ mul_m4_v4(mat, vec4); if (vec4[3] > FLT_EPSILON) { - adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3]; - adr[1] = (float)(ar->winy/2.0f)+(ar->winy/2.0f)*vec4[1]/vec4[3]; - adr[2] = vec4[2]/vec4[3]; + adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; + adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; + adr[2] = vec4[2] / vec4[3]; } else { zero_v3(adr); @@ -817,41 +817,41 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb) float mat[4][4]; float vec[4], min, max; - int a, flag= -1, fl; + int a, flag = -1, fl; - if (bb==NULL) return 1; + if (bb == NULL) return 1; if (bb->flag & OB_BB_DISABLED) return 1; mult_m4_m4m4(mat, rv3d->persmat, obmat); - for (a=0; a<8; a++) { + for (a = 0; a < 8; a++) { copy_v3_v3(vec, bb->vec[a]); - vec[3]= 1.0; + vec[3] = 1.0; mul_m4_v4(mat, vec); - max= vec[3]; - min= -vec[3]; + max = vec[3]; + min = -vec[3]; - fl= 0; - if (vec[0] < min) fl+= 1; - if (vec[0] > max) fl+= 2; - if (vec[1] < min) fl+= 4; - if (vec[1] > max) fl+= 8; - if (vec[2] < min) fl+= 16; - if (vec[2] > max) fl+= 32; + fl = 0; + if (vec[0] < min) fl += 1; + if (vec[0] > max) fl += 2; + if (vec[1] < min) fl += 4; + if (vec[1] > max) fl += 8; + if (vec[2] < min) fl += 16; + if (vec[2] > max) fl += 32; flag &= fl; - if (flag==0) return 1; + if (flag == 0) return 1; } return 0; } -void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */ +void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */ { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; - adr[0]= IS_CLIPPED; + adr[0] = IS_CLIPPED; if (rv3d->rflag & RV3D_CLIPPING) { if (ED_view3d_clipping_test(rv3d, vec, FALSE)) { @@ -860,19 +860,19 @@ void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */ } copy_v3_v3(vec4, vec); - vec4[3]= 1.0; + vec4[3] = 1.0; mul_m4_v4(rv3d->persmat, vec4); - if ( vec4[3] > (float)BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ - fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); + if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */ + fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); - if ( fx>0 && fx<ar->winx) { + if (fx > 0 && fx < ar->winx) { - fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); + fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); if (fy > 0.0f && fy < (float)ar->winy) { - adr[0]= (short)floor(fx); - adr[1]= (short)floor(fy); + adr[0] = (short)floor(fx); + adr[1] = (short)floor(fy); } } } @@ -880,24 +880,24 @@ void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */ void project_int(ARegion *ar, const float vec[3], int adr[2]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; copy_v3_v3(vec4, vec); - vec4[3]= 1.0; - adr[0]= (int)2140000000.0f; + vec4[3] = 1.0; + adr[0] = (int)2140000000.0f; mul_m4_v4(rv3d->persmat, vec4); - if ( vec4[3] > (float)BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ - fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); + if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */ + fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); - if ( fx>-2140000000.0f && fx<2140000000.0f) { - fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); + if (fx > -2140000000.0f && fx < 2140000000.0f) { + fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); - if (fy>-2140000000.0f && fy<2140000000.0f) { - adr[0]= (int)floor(fx); - adr[1]= (int)floor(fy); + if (fy > -2140000000.0f && fy < 2140000000.0f) { + adr[0] = (int)floor(fx); + adr[1] = (int)floor(fy); } } } @@ -905,17 +905,17 @@ void project_int(ARegion *ar, const float vec[3], int adr[2]) void project_int_noclip(ARegion *ar, const float vec[3], int adr[2]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; copy_v3_v3(vec4, vec); - vec4[3]= 1.0; + vec4[3] = 1.0; mul_m4_v4(rv3d->persmat, vec4); - if ( fabs(vec4[3]) > BL_NEAR_CLIP ) { - fx = (ar->winx/2)*(1 + vec4[0]/vec4[3]); - fy = (ar->winy/2)*(1 + vec4[1]/vec4[3]); + if (fabs(vec4[3]) > BL_NEAR_CLIP) { + fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); + fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); adr[0] = (int)floor(fx); adr[1] = (int)floor(fy); @@ -928,25 +928,25 @@ void project_int_noclip(ARegion *ar, const float vec[3], int adr[2]) void project_short_noclip(ARegion *ar, const float vec[3], short adr[2]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; copy_v3_v3(vec4, vec); - vec4[3]= 1.0; - adr[0]= IS_CLIPPED; + vec4[3] = 1.0; + adr[0] = IS_CLIPPED; mul_m4_v4(rv3d->persmat, vec4); - if ( vec4[3] > (float)BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ - fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); + if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */ + fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); - if ( fx>-32700 && fx<32700) { + if (fx > -32700 && fx < 32700) { - fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); + fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); if (fy > -32700.0f && fy < 32700.0f) { - adr[0]= (short)floor(fx); - adr[1]= (short)floor(fy); + adr[0] = (short)floor(fx); + adr[1] = (short)floor(fy); } } } @@ -957,37 +957,37 @@ void apply_project_float(float persmat[4][4], int winx, int winy, const float ve float vec4[4]; copy_v3_v3(vec4, vec); - vec4[3]= 1.0; - adr[0]= IS_CLIPPED; + vec4[3] = 1.0; + adr[0] = IS_CLIPPED; mul_m4_v4(persmat, vec4); if (vec4[3] > (float)BL_NEAR_CLIP) { - adr[0] = (float)(winx/2.0f)+(winx/2.0f)*vec4[0]/vec4[3]; - adr[1] = (float)(winy/2.0f)+(winy/2.0f)*vec4[1]/vec4[3]; + adr[0] = (float)(winx / 2.0f) + (winx / 2.0f) * vec4[0] / vec4[3]; + adr[1] = (float)(winy / 2.0f) + (winy / 2.0f) * vec4[1] / vec4[3]; } } void project_float(ARegion *ar, const float vec[3], float adr[2]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; apply_project_float(rv3d->persmat, ar->winx, ar->winy, vec, adr); } void project_float_noclip(ARegion *ar, const float vec[3], float adr[2]) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; float vec4[4]; copy_v3_v3(vec4, vec); - vec4[3]= 1.0; + vec4[3] = 1.0; mul_m4_v4(rv3d->persmat, vec4); - if ( fabs(vec4[3]) > BL_NEAR_CLIP ) { - adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3]; - adr[1] = (float)(ar->winy/2.0f)+(ar->winy/2.0f)*vec4[1]/vec4[3]; + if (fabs(vec4[3]) > BL_NEAR_CLIP) { + adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; + adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; } else { adr[0] = ar->winx / 2.0f; @@ -1003,8 +1003,8 @@ int ED_view3d_clip_range_get(View3D *v3d, RegionView3D *rv3d, float *clipsta, fl camera_params_init(¶ms); camera_params_from_view3d(¶ms, v3d, rv3d); - if (clipsta) *clipsta= params.clipsta; - if (clipend) *clipend= params.clipend; + if (clipsta) *clipsta = params.clipsta; + if (clipend) *clipend = params.clipend; return params.is_ortho; } @@ -1019,22 +1019,22 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winx, int winy, camera_params_from_view3d(¶ms, v3d, rv3d); camera_params_compute_viewplane(¶ms, winx, winy, 1.0f, 1.0f); - if (viewplane) *viewplane= params.viewplane; - if (clipsta) *clipsta= params.clipsta; - if (clipend) *clipend= params.clipend; + if (viewplane) *viewplane = params.viewplane; + if (clipsta) *clipsta = params.clipsta; + if (clipend) *clipend = params.clipend; return params.is_ortho; } -void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for picking */ +void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for picking */ { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; rctf viewplane; float clipsta, clipend, x1, y1, x2, y2; int orth; - orth= ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend); - rv3d->is_persp= !orth; + orth = ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend); + rv3d->is_persp = !orth; #if 0 printf("%s: %d %d %f %f %f %f %f %f\n", __func__, winx, winy, @@ -1042,20 +1042,20 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick clipsta, clipend); #endif - x1= viewplane.xmin; - y1= viewplane.ymin; - x2= viewplane.xmax; - y2= viewplane.ymax; - - if (rect) { /* picking */ - rect->xmin/= (float)ar->winx; - rect->xmin = x1+rect->xmin*(x2-x1); - rect->ymin/= (float)ar->winy; - rect->ymin = y1+rect->ymin*(y2-y1); - rect->xmax/= (float)ar->winx; - rect->xmax = x1+rect->xmax*(x2-x1); - rect->ymax/= (float)ar->winy; - rect->ymax = y1+rect->ymax*(y2-y1); + x1 = viewplane.xmin; + y1 = viewplane.ymin; + x2 = viewplane.xmax; + y2 = viewplane.ymax; + + if (rect) { /* picking */ + rect->xmin /= (float)ar->winx; + rect->xmin = x1 + rect->xmin * (x2 - x1); + rect->ymin /= (float)ar->winy; + rect->ymin = y1 + rect->ymin * (y2 - y1); + rect->xmax /= (float)ar->winx; + rect->xmax = x1 + rect->xmax * (x2 - x1); + rect->ymax /= (float)ar->winy; + rect->ymax = y1 + rect->ymax * (y2 - y1); if (orth) wmOrtho(rect->xmin, rect->xmax, rect->ymin, rect->ymax, -clipend, clipend); else wmFrustum(rect->xmin, rect->xmax, rect->ymin, rect->ymax, clipsta, clipend); @@ -1067,7 +1067,7 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick } /* update matrix in 3d view region */ - glGetFloatv(GL_PROJECTION_MATRIX, (float*)rv3d->winmat); + glGetFloatv(GL_PROJECTION_MATRIX, (float *)rv3d->winmat); } static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short smooth) @@ -1075,7 +1075,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short float bmat[4][4]; float tmat[3][3]; - rv3d->view= RV3D_VIEW_USER; /* don't show the grid */ + rv3d->view = RV3D_VIEW_USER; /* don't show the grid */ copy_m4_m4(bmat, ob->obmat); normalize_m4(bmat); @@ -1085,66 +1085,66 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short copy_m3_m4(tmat, rv3d->viewmat); if (smooth) { float new_quat[4]; - if (rv3d->persp==RV3D_CAMOB && v3d->camera) { + if (rv3d->persp == RV3D_CAMOB && v3d->camera) { /* were from a camera view */ float orig_ofs[3]; - float orig_dist= rv3d->dist; - float orig_lens= v3d->lens; + float orig_dist = rv3d->dist; + float orig_lens = v3d->lens; copy_v3_v3(orig_ofs, rv3d->ofs); /* Switch from camera view */ - mat3_to_quat( new_quat,tmat); + mat3_to_quat(new_quat, tmat); - rv3d->persp=RV3D_PERSP; - rv3d->dist= 0.0; + rv3d->persp = RV3D_PERSP; + rv3d->dist = 0.0; ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX - rv3d->persp=RV3D_CAMOB; /* just to be polite, not needed */ + rv3d->persp = RV3D_CAMOB; /* just to be polite, not needed */ } else { - mat3_to_quat( new_quat,tmat); + mat3_to_quat(new_quat, tmat); smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX } } else { - mat3_to_quat( rv3d->viewquat,tmat); + mat3_to_quat(rv3d->viewquat, tmat); } } -#define QUATSET(a, b, c, d, e) a[0]=b; a[1]=c; a[2]=d; a[3]=e; +#define QUATSET(a, b, c, d, e) { a[0] = b; a[1] = c; a[2] = d; a[3] = e; } (void)0 int ED_view3d_lock(RegionView3D *rv3d) { - switch(rv3d->view) { - case RV3D_VIEW_BOTTOM : - QUATSET(rv3d->viewquat,0.0, -1.0, 0.0, 0.0); - break; + switch (rv3d->view) { + case RV3D_VIEW_BOTTOM: + QUATSET(rv3d->viewquat, 0.0, -1.0, 0.0, 0.0); + break; - case RV3D_VIEW_BACK: - QUATSET(rv3d->viewquat,0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0)); - break; + case RV3D_VIEW_BACK: + QUATSET(rv3d->viewquat, 0.0, 0.0, (float)-cos(M_PI / 4.0), (float)-cos(M_PI / 4.0)); + break; - case RV3D_VIEW_LEFT: - QUATSET(rv3d->viewquat,0.5, -0.5, 0.5, 0.5); - break; + case RV3D_VIEW_LEFT: + QUATSET(rv3d->viewquat, 0.5, -0.5, 0.5, 0.5); + break; - case RV3D_VIEW_TOP: - QUATSET(rv3d->viewquat,1.0, 0.0, 0.0, 0.0); - break; + case RV3D_VIEW_TOP: + QUATSET(rv3d->viewquat, 1.0, 0.0, 0.0, 0.0); + break; - case RV3D_VIEW_FRONT: - QUATSET(rv3d->viewquat,(float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0); - break; + case RV3D_VIEW_FRONT: + QUATSET(rv3d->viewquat, (float)cos(M_PI / 4.0), (float)-sin(M_PI / 4.0), 0.0, 0.0); + break; - case RV3D_VIEW_RIGHT: - QUATSET(rv3d->viewquat, 0.5, -0.5, -0.5, -0.5); - break; - default: - return FALSE; + case RV3D_VIEW_RIGHT: + QUATSET(rv3d->viewquat, 0.5, -0.5, -0.5, -0.5); + break; + default: + return FALSE; } return TRUE; @@ -1153,14 +1153,14 @@ int ED_view3d_lock(RegionView3D *rv3d) /* don't set windows active in here, is used by renderwin too */ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) { - if (rv3d->persp==RV3D_CAMOB) { /* obs/camera */ + if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */ if (v3d->camera) { where_is_object(scene, v3d->camera); obmat_to_viewmat(v3d, rv3d, v3d->camera, 0); } else { - quat_to_mat4( rv3d->viewmat,rv3d->viewquat); - rv3d->viewmat[3][2]-= rv3d->dist; + quat_to_mat4(rv3d->viewmat, rv3d->viewquat); + rv3d->viewmat[3][2] -= rv3d->dist; } } else { @@ -1168,28 +1168,28 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) if (rv3d->viewlock) ED_view3d_lock(rv3d); - quat_to_mat4( rv3d->viewmat,rv3d->viewquat); - if (rv3d->persp==RV3D_PERSP) rv3d->viewmat[3][2]-= rv3d->dist; + quat_to_mat4(rv3d->viewmat, rv3d->viewquat); + if (rv3d->persp == RV3D_PERSP) rv3d->viewmat[3][2] -= rv3d->dist; if (v3d->ob_centre) { - Object *ob= v3d->ob_centre; + Object *ob = v3d->ob_centre; float vec[3]; copy_v3_v3(vec, ob->obmat[3]); - if (ob->type==OB_ARMATURE && v3d->ob_centre_bone[0]) { - bPoseChannel *pchan= get_pose_channel(ob->pose, v3d->ob_centre_bone); + if (ob->type == OB_ARMATURE && v3d->ob_centre_bone[0]) { + bPoseChannel *pchan = get_pose_channel(ob->pose, v3d->ob_centre_bone); if (pchan) { copy_v3_v3(vec, pchan->pose_mat[3]); mul_m4_v3(ob->obmat, vec); } } - translate_m4( rv3d->viewmat,-vec[0], -vec[1], -vec[2]); + translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]); } else if (v3d->ob_centre_cursor) { float vec[3]; copy_v3_v3(vec, give_cursor(scene, v3d)); translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]); } - else translate_m4( rv3d->viewmat,rv3d->ofs[0], rv3d->ofs[1], rv3d->ofs[2]); + else translate_m4(rv3d->viewmat, rv3d->ofs[0], rv3d->ofs[1], rv3d->ofs[2]); } } @@ -1200,9 +1200,9 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) */ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input) { - Scene *scene= vc->scene; - View3D *v3d= vc->v3d; - ARegion *ar= vc->ar; + Scene *scene = vc->scene; + View3D *v3d = vc->v3d; + ARegion *ar = vc->ar; rctf rect; short code, hits; char dt, dtx; @@ -1210,11 +1210,11 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b G.f |= G_PICKSEL; /* case not a border select */ - if (input->xmin ==input->xmax) { - rect.xmin = input->xmin-12; // seems to be default value for bones only now - rect.xmax = input->xmin+12; - rect.ymin = input->ymin-12; - rect.ymax = input->ymin+12; + if (input->xmin == input->xmax) { + rect.xmin = input->xmin - 12; // seems to be default value for bones only now + rect.xmax = input->xmin + 12; + rect.ymin = input->ymin - 12; + rect.ymax = input->ymin + 12; } else { rect.xmin = input->xmin; @@ -1227,41 +1227,41 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b mult_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat); if (v3d->drawtype > OB_WIRE) { - v3d->zbuf= TRUE; + v3d->zbuf = TRUE; glEnable(GL_DEPTH_TEST); } if (vc->rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_set(vc->rv3d); - glSelectBuffer( bufsize, (GLuint *)buffer); + glSelectBuffer(bufsize, (GLuint *)buffer); glRenderMode(GL_SELECT); - glInitNames(); /* these two calls whatfor? It doesnt work otherwise */ + glInitNames(); /* these two calls whatfor? It doesnt work otherwise */ glPushName(-1); - code= 1; + code = 1; - if (vc->obedit && vc->obedit->type==OB_MBALL) { - draw_object(scene, ar, v3d, BASACT, DRAW_PICKING|DRAW_CONSTCOLOR); + if (vc->obedit && vc->obedit->type == OB_MBALL) { + draw_object(scene, ar, v3d, BASACT, DRAW_PICKING | DRAW_CONSTCOLOR); } - else if ((vc->obedit && vc->obedit->type==OB_ARMATURE)) { + else if ((vc->obedit && vc->obedit->type == OB_ARMATURE)) { /* if not drawing sketch, draw bones */ if (!BDR_drawSketchNames(vc)) { - draw_object(scene, ar, v3d, BASACT, DRAW_PICKING|DRAW_CONSTCOLOR); + draw_object(scene, ar, v3d, BASACT, DRAW_PICKING | DRAW_CONSTCOLOR); } } else { Base *base; - v3d->xray= TRUE; // otherwise it postpones drawing - for (base= scene->base.first; base; base= base->next) { + v3d->xray = TRUE; // otherwise it postpones drawing + for (base = scene->base.first; base; base = base->next) { if (base->lay & v3d->lay) { if (base->object->restrictflag & OB_RESTRICT_SELECT) - base->selcol= 0; + base->selcol = 0; else { - base->selcol= code; + base->selcol = code; glLoadName(code); - draw_object(scene, ar, v3d, base, DRAW_PICKING|DRAW_CONSTCOLOR); + draw_object(scene, ar, v3d, base, DRAW_PICKING | DRAW_CONSTCOLOR); /* we draw group-duplicators for selection too */ if ((base->object->transflag & OB_DUPLI) && base->object->dup_group) { @@ -1269,22 +1269,22 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b DupliObject *dob; Base tbase; - tbase.flag= OB_FROMDUPLI; - lb= object_duplilist(scene, base->object); + tbase.flag = OB_FROMDUPLI; + lb = object_duplilist(scene, base->object); - for (dob= lb->first; dob; dob= dob->next) { - tbase.object= dob->ob; + for (dob = lb->first; dob; dob = dob->next) { + tbase.object = dob->ob; copy_m4_m4(dob->ob->obmat, dob->mat); /* extra service: draw the duplicator in drawtype of parent */ /* MIN2 for the drawtype to allow bounding box objects in groups for lods */ - dt= tbase.object->dt; tbase.object->dt= MIN2(tbase.object->dt, base->object->dt); - dtx= tbase.object->dtx; tbase.object->dtx= base->object->dtx; + dt = tbase.object->dt; tbase.object->dt = MIN2(tbase.object->dt, base->object->dt); + dtx = tbase.object->dtx; tbase.object->dtx = base->object->dtx; - draw_object(scene, ar, v3d, &tbase, DRAW_PICKING|DRAW_CONSTCOLOR); + draw_object(scene, ar, v3d, &tbase, DRAW_PICKING | DRAW_CONSTCOLOR); - tbase.object->dt= dt; - tbase.object->dtx= dtx; + tbase.object->dt = dt; + tbase.object->dtx = dtx; copy_m4_m4(dob->ob->obmat, dob->omat); } @@ -1294,18 +1294,18 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b } } } - v3d->xray= FALSE; // restore + v3d->xray = FALSE; // restore } - glPopName(); /* see above (pushname) */ - hits= glRenderMode(GL_RENDER); + glPopName(); /* see above (pushname) */ + hits = glRenderMode(GL_RENDER); G.f &= ~G_PICKSEL; setwinmatrixview3d(ar, v3d, NULL); mult_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat); if (v3d->drawtype > OB_WIRE) { - v3d->zbuf= 0; + v3d->zbuf = 0; glDisable(GL_DEPTH_TEST); } // XXX persp(PERSP_WIN); @@ -1313,7 +1313,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b if (vc->rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_disable(); - if (hits<0) printf("Too many objects in select buffer\n"); // XXX make error message + if (hits < 0) printf("Too many objects in select buffer\n"); // XXX make error message return hits; } @@ -1326,64 +1326,64 @@ static unsigned int free_localbit(Main *bmain) ScrArea *sa; bScreen *sc; - lay= 0; + lay = 0; /* sometimes we loose a localview: when an area is closed */ /* check all areas: which localviews are in use? */ - for (sc= bmain->screen.first; sc; sc= sc->id.next) { - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl= sa->spacedata.first; - for (; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + for (sc = bmain->screen.first; sc; sc = sc->id.next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { + SpaceLink *sl = sa->spacedata.first; + for (; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; lay |= v3d->lay; } } } } - if ( (lay & 0x01000000)==0) return 0x01000000; - if ( (lay & 0x02000000)==0) return 0x02000000; - if ( (lay & 0x04000000)==0) return 0x04000000; - if ( (lay & 0x08000000)==0) return 0x08000000; - if ( (lay & 0x10000000)==0) return 0x10000000; - if ( (lay & 0x20000000)==0) return 0x20000000; - if ( (lay & 0x40000000)==0) return 0x40000000; - if ( (lay & 0x80000000)==0) return 0x80000000; + if ((lay & 0x01000000) == 0) return 0x01000000; + if ((lay & 0x02000000) == 0) return 0x02000000; + if ((lay & 0x04000000) == 0) return 0x04000000; + if ((lay & 0x08000000) == 0) return 0x08000000; + if ((lay & 0x10000000) == 0) return 0x10000000; + if ((lay & 0x20000000) == 0) return 0x20000000; + if ((lay & 0x40000000) == 0) return 0x40000000; + if ((lay & 0x80000000) == 0) return 0x80000000; return 0; } int ED_view3d_scene_layer_set(int lay, const int *values, int *active) { - int i, tot= 0; + int i, tot = 0; /* ensure we always have some layer selected */ - for (i=0; i<20; i++) + for (i = 0; i < 20; i++) if (values[i]) tot++; - if (tot==0) + if (tot == 0) return lay; - for (i=0; i<20; i++) { + for (i = 0; i < 20; i++) { if (active) { /* if this value has just been switched on, make that layer active */ - if (values[i] && (lay & (1<<i))==0) { - *active = (1<<i); + if (values[i] && (lay & (1 << i)) == 0) { + *active = (1 << i); } } - if (values[i]) lay |= (1<<i); - else lay &= ~(1<<i); + if (values[i]) lay |= (1 << i); + else lay &= ~(1 << i); } /* ensure always an active layer */ - if (active && (lay & *active)==0) { - for (i=0; i<20; i++) { - if (lay & (1<<i)) { - *active= 1<<i; + if (active && (lay & *active) == 0) { + for (i = 0; i < 20; i++) { + if (lay & (1 << i)) { + *active = 1 << i; break; } } @@ -1394,97 +1394,97 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active) static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) { - View3D *v3d= sa->spacedata.first; + View3D *v3d = sa->spacedata.first; Base *base; float size = 0.0, min[3], max[3], box[3]; unsigned int locallay; - int ok=0; + int ok = 0; if (v3d->localvd) return; INIT_MINMAX(min, max); - locallay= free_localbit(bmain); + locallay = free_localbit(bmain); - if (locallay==0) { - printf("Sorry, no more than 8 localviews\n"); // XXX error - ok= 0; + if (locallay == 0) { + printf("Sorry, no more than 8 localviews\n"); // XXX error + ok = 0; } else { if (scene->obedit) { minmax_object(scene->obedit, min, max); - ok= 1; + ok = 1; BASACT->lay |= locallay; - scene->obedit->lay= BASACT->lay; + scene->obedit->lay = BASACT->lay; } else { - for (base= FIRSTBASE; base; base= base->next) { + for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { minmax_object(base->object, min, max); base->lay |= locallay; - base->object->lay= base->lay; - ok= 1; + base->object->lay = base->lay; + ok = 1; } } } - box[0]= (max[0]-min[0]); - box[1]= (max[1]-min[1]); - box[2]= (max[2]-min[2]); - size= MAX3(box[0], box[1], box[2]); - if (size <= 0.01f) size= 0.01f; + box[0] = (max[0] - min[0]); + box[1] = (max[1] - min[1]); + box[2] = (max[2] - min[2]); + size = MAX3(box[0], box[1], box[2]); + if (size <= 0.01f) size = 0.01f; } if (ok) { ARegion *ar; - v3d->localvd= MEM_mallocN(sizeof(View3D), "localview"); + v3d->localvd = MEM_mallocN(sizeof(View3D), "localview"); memcpy(v3d->localvd, v3d, sizeof(View3D)); - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; - rv3d->localvd= MEM_mallocN(sizeof(RegionView3D), "localview region"); + rv3d->localvd = MEM_mallocN(sizeof(RegionView3D), "localview region"); memcpy(rv3d->localvd, rv3d, sizeof(RegionView3D)); - rv3d->ofs[0]= -(min[0]+max[0])/2.0f; - rv3d->ofs[1]= -(min[1]+max[1])/2.0f; - rv3d->ofs[2]= -(min[2]+max[2])/2.0f; + rv3d->ofs[0] = -(min[0] + max[0]) / 2.0f; + rv3d->ofs[1] = -(min[1] + max[1]) / 2.0f; + rv3d->ofs[2] = -(min[2] + max[2]) / 2.0f; - rv3d->dist= size; + rv3d->dist = size; /* perspective should be a bit farther away to look nice */ - if (rv3d->persp==RV3D_ORTHO) - rv3d->dist*= 0.7f; + if (rv3d->persp == RV3D_ORTHO) + rv3d->dist *= 0.7f; // correction for window aspect ratio - if (ar->winy>2 && ar->winx>2) { - float asp= (float)ar->winx/(float)ar->winy; - if (asp < 1.0f) asp= 1.0f/asp; - rv3d->dist*= asp; + if (ar->winy > 2 && ar->winx > 2) { + float asp = (float)ar->winx / (float)ar->winy; + if (asp < 1.0f) asp = 1.0f / asp; + rv3d->dist *= asp; } - if (rv3d->persp==RV3D_CAMOB) rv3d->persp= RV3D_PERSP; + if (rv3d->persp == RV3D_CAMOB) rv3d->persp = RV3D_PERSP; - v3d->cursor[0]= -rv3d->ofs[0]; - v3d->cursor[1]= -rv3d->ofs[1]; - v3d->cursor[2]= -rv3d->ofs[2]; + v3d->cursor[0] = -rv3d->ofs[0]; + v3d->cursor[1] = -rv3d->ofs[1]; + v3d->cursor[2] = -rv3d->ofs[2]; } } - v3d->lay= locallay; + v3d->lay = locallay; } else { /* clear flags */ - for (base= FIRSTBASE; base; base= base->next) { - if ( base->lay & locallay ) { - base->lay-= locallay; - if (base->lay==0) base->lay= v3d->layact; + for (base = FIRSTBASE; base; base = base->next) { + if (base->lay & locallay) { + base->lay -= locallay; + if (base->lay == 0) base->lay = v3d->layact; if (base->object != scene->obedit) base->flag |= SELECT; - base->object->lay= base->lay; + base->object->lay = base->lay; } } } @@ -1494,37 +1494,37 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) static void restore_localviewdata(ScrArea *sa, int free) { ARegion *ar; - View3D *v3d= sa->spacedata.first; + View3D *v3d = sa->spacedata.first; - if (v3d->localvd==NULL) return; + if (v3d->localvd == NULL) return; - v3d->near= v3d->localvd->near; - v3d->far= v3d->localvd->far; - v3d->lay= v3d->localvd->lay; - v3d->layact= v3d->localvd->layact; - v3d->drawtype= v3d->localvd->drawtype; - v3d->camera= v3d->localvd->camera; + v3d->near = v3d->localvd->near; + v3d->far = v3d->localvd->far; + v3d->lay = v3d->localvd->lay; + v3d->layact = v3d->localvd->layact; + v3d->drawtype = v3d->localvd->drawtype; + v3d->camera = v3d->localvd->camera; if (free) { MEM_freeN(v3d->localvd); - v3d->localvd= NULL; + v3d->localvd = NULL; } - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; if (rv3d->localvd) { - rv3d->dist= rv3d->localvd->dist; + rv3d->dist = rv3d->localvd->dist; copy_v3_v3(rv3d->ofs, rv3d->localvd->ofs); copy_qt_qt(rv3d->viewquat, rv3d->localvd->viewquat); - rv3d->view= rv3d->localvd->view; - rv3d->persp= rv3d->localvd->persp; - rv3d->camzoom= rv3d->localvd->camzoom; + rv3d->view = rv3d->localvd->view; + rv3d->persp = rv3d->localvd->persp; + rv3d->camzoom = rv3d->localvd->camzoom; if (free) { MEM_freeN(rv3d->localvd); - rv3d->localvd= NULL; + rv3d->localvd = NULL; } } } @@ -1533,28 +1533,28 @@ static void restore_localviewdata(ScrArea *sa, int free) static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) { - View3D *v3d= sa->spacedata.first; + View3D *v3d = sa->spacedata.first; struct Base *base; unsigned int locallay; if (v3d->localvd) { - locallay= v3d->lay & 0xFF000000; + locallay = v3d->lay & 0xFF000000; restore_localviewdata(sa, 1); // 1 = free /* for when in other window the layers have changed */ - if (v3d->scenelock) v3d->lay= scene->lay; + if (v3d->scenelock) v3d->lay = scene->lay; - for (base= FIRSTBASE; base; base= base->next) { - if ( base->lay & locallay ) { - base->lay-= locallay; - if (base->lay==0) base->lay= v3d->layact; + for (base = FIRSTBASE; base; base = base->next) { + if (base->lay & locallay) { + base->lay -= locallay; + if (base->lay == 0) base->lay = v3d->layact; if (base->object != scene->obedit) { base->flag |= SELECT; base->object->flag |= SELECT; } - base->object->lay= base->lay; + base->object->lay = base->lay; } } @@ -1564,7 +1564,7 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) static int localview_exec(bContext *C, wmOperator *UNUSED(unused)) { - View3D *v3d= CTX_wm_view3d(C); + View3D *v3d = CTX_wm_view3d(C); if (v3d->localvd) endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); @@ -1603,9 +1603,9 @@ static void SaveState(bContext *C, wmWindow *win) if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) GPU_paint_set_mipmap(1); - queue_back= win->queue; + queue_back = win->queue; - win->queue.first= win->queue.last= NULL; + win->queue.first = win->queue.last = NULL; //XXX waitcursor(1); } @@ -1626,7 +1626,7 @@ static void RestoreState(bContext *C, wmWindow *win) //XXX G.qual= 0; if (win) /* check because closing win can set to NULL */ - win->queue= queue_back; + win->queue = queue_back; GPU_state_init(); GPU_set_tpage(NULL, 0, 0); @@ -1642,37 +1642,37 @@ static void game_set_commmandline_options(GameData *gm) if ( (syshandle = SYS_GetSystem()) ) { /* User defined settings */ - test= (U.gameflags & USER_DISABLE_MIPMAP); + test = (U.gameflags & USER_DISABLE_MIPMAP); GPU_set_mipmap(!test); SYS_WriteCommandLineInt(syshandle, "nomipmap", test); /* File specific settings: */ /* Only test the first one. These two are switched * simultaneously. */ - test= (gm->flag & GAME_SHOW_FRAMERATE); + test = (gm->flag & GAME_SHOW_FRAMERATE); SYS_WriteCommandLineInt(syshandle, "show_framerate", test); SYS_WriteCommandLineInt(syshandle, "show_profile", test); test = (gm->flag & GAME_SHOW_DEBUG_PROPS); SYS_WriteCommandLineInt(syshandle, "show_properties", test); - test= (gm->flag & GAME_SHOW_PHYSICS); + test = (gm->flag & GAME_SHOW_PHYSICS); SYS_WriteCommandLineInt(syshandle, "show_physics", test); - test= (gm->flag & GAME_ENABLE_ALL_FRAMES); + test = (gm->flag & GAME_ENABLE_ALL_FRAMES); SYS_WriteCommandLineInt(syshandle, "fixedtime", test); - test= (gm->flag & GAME_ENABLE_ANIMATION_RECORD); + test = (gm->flag & GAME_ENABLE_ANIMATION_RECORD); SYS_WriteCommandLineInt(syshandle, "animation_record", test); - test= (gm->flag & GAME_IGNORE_DEPRECATION_WARNINGS); + test = (gm->flag & GAME_IGNORE_DEPRECATION_WARNINGS); SYS_WriteCommandLineInt(syshandle, "ignore_deprecation_warnings", test); - test= (gm->matmode == GAME_MAT_MULTITEX); + test = (gm->matmode == GAME_MAT_MULTITEX); SYS_WriteCommandLineInt(syshandle, "blender_material", test); - test= (gm->matmode == GAME_MAT_GLSL); + test = (gm->matmode == GAME_MAT_GLSL); SYS_WriteCommandLineInt(syshandle, "blender_glsl_material", test); - test= (gm->flag & GAME_DISPLAY_LISTS); + test = (gm->flag & GAME_DISPLAY_LISTS); SYS_WriteCommandLineInt(syshandle, "displaylists", test); @@ -1688,11 +1688,11 @@ static int game_engine_poll(bContext *C) * if we try to auto run the BGE. Ideally we want the * context to be set as soon as we load the file. */ - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; - if (CTX_wm_area(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; + if (CTX_wm_area(C) == NULL) return 0; - if (CTX_data_mode_enum(C)!=CTX_MODE_OBJECT) + if (CTX_data_mode_enum(C) != CTX_MODE_OBJECT) return 0; return 1; @@ -1700,20 +1700,20 @@ static int game_engine_poll(bContext *C) int ED_view3d_context_activate(bContext *C) { - bScreen *sc= CTX_wm_screen(C); - ScrArea *sa= CTX_wm_area(C); + bScreen *sc = CTX_wm_screen(C); + ScrArea *sa = CTX_wm_area(C); ARegion *ar; /* sa can be NULL when called from python */ - if (sa==NULL || sa->spacetype != SPACE_VIEW3D) - for (sa=sc->areabase.first; sa; sa= sa->next) - if (sa->spacetype==SPACE_VIEW3D) + if (sa == NULL || sa->spacetype != SPACE_VIEW3D) + for (sa = sc->areabase.first; sa; sa = sa->next) + if (sa->spacetype == SPACE_VIEW3D) break; if (!sa) return 0; - for (ar=sa->regionbase.first; ar; ar=ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->regiontype == RGN_TYPE_WINDOW) break; @@ -1731,9 +1731,9 @@ static int game_engine_exec(bContext *C, wmOperator *op) { #ifdef WITH_GAMEENGINE Scene *startscene = CTX_data_scene(C); - ScrArea /* *sa, */ /* UNUSED */ *prevsa= CTX_wm_area(C); - ARegion *ar, *prevar= CTX_wm_region(C); - wmWindow *prevwin= CTX_wm_window(C); + ScrArea /* *sa, */ /* UNUSED */ *prevsa = CTX_wm_area(C); + ARegion *ar, *prevar = CTX_wm_region(C); + wmWindow *prevwin = CTX_wm_window(C); RegionView3D *rv3d; rcti cam_frame; @@ -1744,20 +1744,20 @@ static int game_engine_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* redraw to hide any menus/popups, we don't go back to - * the window manager until after this operator exits */ + * the window manager until after this operator exits */ WM_redraw_windows(C); - rv3d= CTX_wm_region_view3d(C); + rv3d = CTX_wm_region_view3d(C); /* sa= CTX_wm_area(C); */ /* UNUSED */ - ar= CTX_wm_region(C); + ar = CTX_wm_region(C); view3d_operator_needs_opengl(C); game_set_commmandline_options(&startscene->gm); if ((rv3d->persp == RV3D_CAMOB) && - (startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) && - (startscene->gm.stereoflag != STEREO_DOME)) + (startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) && + (startscene->gm.stereoflag != STEREO_DOME)) { /* Letterbox */ rctf cam_framef; @@ -1782,7 +1782,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) /* window wasnt closed while the BGE was running */ if (BLI_findindex(&CTX_wm_manager(C)->windows, prevwin) == -1) { - prevwin= NULL; + prevwin = NULL; CTX_wm_window_set(C, NULL); } @@ -1831,42 +1831,42 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f float alignaxis[3] = {0.0, 0.0, 0.0}; float norm[3], axis[3], angle, new_quat[4]; - if (axisidx > 0) alignaxis[axisidx-1]= 1.0; - else alignaxis[-axisidx-1]= -1.0; + if (axisidx > 0) alignaxis[axisidx - 1] = 1.0; + else alignaxis[-axisidx - 1] = -1.0; normalize_v3_v3(norm, vec); - angle= (float)acos(dot_v3v3(alignaxis, norm)); + angle = (float)acos(dot_v3v3(alignaxis, norm)); cross_v3_v3v3(axis, alignaxis, norm); - axis_angle_to_quat( new_quat,axis, -angle); + axis_angle_to_quat(new_quat, axis, -angle); - rv3d->view= RV3D_VIEW_USER; + rv3d->view = RV3D_VIEW_USER; - if (rv3d->persp==RV3D_CAMOB && v3d->camera) { + if (rv3d->persp == RV3D_CAMOB && v3d->camera) { /* switch out of camera view */ float orig_ofs[3]; - float orig_dist= rv3d->dist; - float orig_lens= v3d->lens; + float orig_dist = rv3d->dist; + float orig_lens = v3d->lens; copy_v3_v3(orig_ofs, rv3d->ofs); - rv3d->persp= RV3D_PERSP; - rv3d->dist= 0.0; + rv3d->persp = RV3D_PERSP; + rv3d->dist = 0.0; ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX } else { - if (rv3d->persp==RV3D_CAMOB) rv3d->persp= RV3D_PERSP; /* switch out of camera mode */ + if (rv3d->persp == RV3D_CAMOB) rv3d->persp = RV3D_PERSP; /* switch out of camera mode */ smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX } } float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]) { - return (rv3d->persmat[3][3] + ( - rv3d->persmat[0][3]*co[0] + - rv3d->persmat[1][3]*co[1] + - rv3d->persmat[2][3]*co[2]) - ) * rv3d->pixsize; + return (rv3d->persmat[3][3] + ( + rv3d->persmat[0][3] * co[0] + + rv3d->persmat[1][3] * co[1] + + rv3d->persmat[2][3] * co[2]) + ) * rv3d->pixsize; } /* view matrix properties utilities */ @@ -1887,8 +1887,8 @@ void ED_view3d_operator_properties_viewmat(wmOperatorType *ot) void ED_view3d_operator_properties_viewmat_set(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ED_view3d_context_rv3d(C); if (!RNA_struct_property_is_set(op->ptr, "region_width")) RNA_int_set(op->ptr, "region_width", ar->winx); |