Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-02-22 20:52:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-22 20:52:06 +0400
commit1955407f7e85cc05601bc952f12de8464ee78ffa (patch)
tree86088aea5c02db3349af231b994c5fdc8513ee8a /source/blender/editors/space_view3d/view3d_view.c
parent34e2fb40c75f92532bdb4ceae955b38c998904ae (diff)
code cleanyp - no functional changes.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_view.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c345
1 files changed, 175 insertions, 170 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index c05f9de691b..915a1fae412 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -102,7 +102,7 @@ void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar)
float *give_cursor(Scene *scene, View3D *v3d)
{
- if(v3d && v3d->localvd) return v3d->cursor;
+ if (v3d && v3d->localvd) return v3d->cursor;
else return scene->cursor;
}
@@ -149,15 +149,15 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec
* camera to be moved or changed, so only when the camera is not being set should
* we allow camera option locking to initialize the view settings from the camera.
*/
- if(camera == NULL && oldcamera == NULL) {
+ if (camera == NULL && oldcamera == NULL) {
ED_view3d_camera_lock_init(v3d, rv3d);
}
/* 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 (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 (camera) {
ED_view3d_from_object(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens);
@@ -194,7 +194,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec
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;
@@ -221,15 +221,15 @@ 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)
+ if (rv3d->sms==NULL)
rv3d->sms= MEM_mallocN(sizeof(struct SmoothViewStore), "smoothview v3d");
*rv3d->sms= sms;
- if(rv3d->smooth_timer)
+ 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 */
@@ -239,15 +239,15 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec
}
/* if we get here nothing happens */
- if(ok == FALSE) {
- if(sms.to_camera==0) {
+ if (ok == FALSE) {
+ 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;
v3d->lens = sms.new_lens;
}
- if(rv3d->viewlock & RV3D_BOXVIEW)
+ if (rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_copy(sa, ar);
ED_region_tag_redraw(ar);
@@ -263,19 +263,19 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent
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)
+ if (sms->time_allowed != 0.0)
step = (float)((rv3d->smooth_timer->duration)/sms->time_allowed);
else
step = 1.0f;
/* end timer */
- if(step >= 1.0f) {
+ if (step >= 1.0f) {
/* if we went to camera, store the original */
- if(sms->to_camera) {
+ if (sms->to_camera) {
rv3d->persp= RV3D_CAMOB;
copy_v3_v3(rv3d->ofs, sms->orig_ofs);
copy_qt_qt(rv3d->viewquat, sms->orig_quat);
@@ -291,7 +291,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent
ED_view3d_camera_lock_sync(v3d, rv3d);
}
- if((rv3d->viewlock & RV3D_LOCKED)==0) {
+ if ((rv3d->viewlock & RV3D_LOCKED)==0) {
rv3d->view= sms->orig_view;
}
@@ -322,7 +322,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent
ED_view3d_camera_lock_sync(v3d, rv3d);
}
- if(rv3d->viewlock & RV3D_BOXVIEW)
+ 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);
@@ -354,7 +354,7 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
copy_qt_qt(rv3d->lviewquat, rv3d->viewquat);
rv3d->lview= rv3d->view;
- if(rv3d->persp != RV3D_CAMOB) {
+ if (rv3d->persp != RV3D_CAMOB) {
rv3d->lpersp= rv3d->persp;
}
@@ -376,9 +376,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) {
+ if (v3d && v3d->camera && v3d->camera->id.lib==NULL) {
RegionView3D *rv3d= CTX_wm_region_view3d(C);
- if(rv3d && !rv3d->viewlock) {
+ if (rv3d && !rv3d->viewlock) {
return 1;
}
}
@@ -438,9 +438,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) {
+ if (v3d && v3d->camera && v3d->camera->id.lib==NULL) {
RegionView3D *rv3d= CTX_wm_region_view3d(C);
- if(rv3d) {
+ if (rv3d) {
if (rv3d->is_persp == FALSE) {
CTX_wm_operator_poll_msg_set(C, "Only valid for a perspective camera view");
}
@@ -482,14 +482,14 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op))
ED_view3d_context_user_region(C, &v3d, &ar);
rv3d = ar->regiondata;
- if(ob) {
+ if (ob) {
Object *camera_old= (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : NULL;
rv3d->persp= RV3D_CAMOB;
v3d->camera= ob;
- if(v3d->scenelock)
+ if (v3d->scenelock)
scene->camera= ob;
- if(camera_old != ob) /* unlikely but looks like a glitch when set to the same */
+ 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));
@@ -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,7 +541,7 @@ 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++) {
+ for (val=0; val<4; val++) {
xs= (val==0||val==3)?rect->xmin:rect->xmax;
ys= (val==0||val==1)?rect->ymin:rect->ymax;
@@ -555,16 +555,16 @@ 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++)
+ 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]);
- if(flip_sign)
+ if (flip_sign)
negate_v3(planes[val]);
planes[val][3]= - planes[val][0]*bb->vec[val][0]
@@ -578,7 +578,7 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2]
{
RegionView3D *rv3d= ar->regiondata;
- if(rv3d->is_persp) {
+ if (rv3d->is_persp) {
float vec[3];
ED_view3d_win_to_vector(ar, mval, vec);
@@ -600,9 +600,9 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2]
}
/* clipping */
- if(rv3d->rflag & RV3D_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]);
}
}
@@ -644,7 +644,7 @@ 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;
+ 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;
@@ -671,13 +671,13 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[
float line_sta[3];
float line_end[3];
- if(rv3d->is_persp) {
+ if (rv3d->is_persp) {
float mousevec[3];
copy_v3_v3(line_sta, rv3d->viewinv[3]);
ED_view3d_win_to_vector(ar, mval, mousevec);
add_v3_v3v3(line_end, line_sta, mousevec);
- if(isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], TRUE) == 0) {
+ if (isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], TRUE) == 0) {
/* highly unlikely to ever happen, mouse vec paralelle with view plane */
zero_v3(out);
}
@@ -716,7 +716,7 @@ void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3])
{
RegionView3D *rv3d= ar->regiondata;
- if(rv3d->is_persp) {
+ 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;
@@ -736,7 +736,7 @@ float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y)
x -= vc->ar->winrct.xmin;
y -= vc->ar->winrct.ymin;
- if(vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h)
+ if (vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h)
return vd->depths[y * vd->w + x];
else
return 1;
@@ -744,7 +744,7 @@ float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y)
void ED_view3d_depth_tag_update(RegionView3D *rv3d)
{
- if(rv3d->depths)
+ if (rv3d->depths)
rv3d->depths->damaged= 1;
}
@@ -780,10 +780,11 @@ void ED_view3d_project_float(const ARegion *ar, const float vec[3], float adr[2]
mul_m4_v4(mat, vec4);
- if( vec4[3]>FLT_EPSILON ) {
+ 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];
- } else {
+ }
+ else {
adr[0] = adr[1] = 0.0f;
}
}
@@ -799,11 +800,12 @@ void ED_view3d_project_float_v3(ARegion *ar, float *vec, float *adr, float mat[4
mul_m4_v4(mat, vec4);
- if( vec4[3]>FLT_EPSILON ) {
+ 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];
- } else {
+ }
+ else {
adr[0] = adr[1] = adr[2] = 0.0f;
}
}
@@ -816,12 +818,12 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
float vec[4], min, max;
int a, flag= -1, fl;
- if(bb==NULL) return 1;
- if(bb->flag & OB_BB_DISABLED) 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;
mul_m4_v4(mat, vec);
@@ -829,15 +831,15 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
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;
+ 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;
@@ -850,8 +852,8 @@ void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */
adr[0]= IS_CLIPPED;
- if(rv3d->rflag & RV3D_CLIPPING) {
- if(ED_view3d_test_clipping(rv3d, vec, 0))
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ if (ED_view3d_test_clipping(rv3d, vec, 0))
return;
}
@@ -859,14 +861,14 @@ void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */
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 */
+ 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]);
- if(fy > 0.0f && fy < (float)ar->winy) {
+ if (fy > 0.0f && fy < (float)ar->winy) {
adr[0]= (short)floor(fx);
adr[1]= (short)floor(fy);
}
@@ -885,13 +887,13 @@ void project_int(ARegion *ar, const float vec[3], int adr[2])
mul_m4_v4(rv3d->persmat, vec4);
- if( vec4[3] > (float)BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */
+ 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) {
+ if ( fx>-2140000000.0f && fx<2140000000.0f) {
fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]);
- if(fy>-2140000000.0f && fy<2140000000.0f) {
+ if (fy>-2140000000.0f && fy<2140000000.0f) {
adr[0]= (int)floor(fx);
adr[1]= (int)floor(fy);
}
@@ -909,7 +911,7 @@ void project_int_noclip(ARegion *ar, const float vec[3], int adr[2])
mul_m4_v4(rv3d->persmat, vec4);
- if( fabs(vec4[3]) > BL_NEAR_CLIP ) {
+ 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]);
@@ -933,14 +935,14 @@ void project_short_noclip(ARegion *ar, const float vec[3], short adr[2])
mul_m4_v4(rv3d->persmat, vec4);
- if( vec4[3] > (float)BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */
+ 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]);
- if(fy > -32700.0f && fy < 32700.0f) {
+ if (fy > -32700.0f && fy < 32700.0f) {
adr[0]= (short)floor(fx);
adr[1]= (short)floor(fy);
}
@@ -958,7 +960,7 @@ void apply_project_float(float persmat[4][4], int winx, int winy, const float ve
mul_m4_v4(persmat, vec4);
- if(vec4[3] > (float)BL_NEAR_CLIP) {
+ 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];
}
@@ -981,7 +983,7 @@ void project_float_noclip(ARegion *ar, const float vec[3], float adr[2])
mul_m4_v4(rv3d->persmat, vec4);
- if( fabs(vec4[3]) > BL_NEAR_CLIP ) {
+ 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];
}
@@ -999,8 +1001,8 @@ int ED_view3d_clip_range_get(View3D *v3d, RegionView3D *rv3d, float *clipsta, fl
camera_params_init(&params);
camera_params_from_view3d(&params, 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;
}
@@ -1015,9 +1017,9 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winx, int winy,
camera_params_from_view3d(&params, v3d, rv3d);
camera_params_compute_viewplane(&params, 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;
}
@@ -1043,7 +1045,7 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick
x2= viewplane.xmax;
y2= viewplane.ymax;
- if(rect) { /* picking */
+ if (rect) { /* picking */
rect->xmin/= (float)ar->winx;
rect->xmin= x1+rect->xmin*(x2-x1);
rect->ymin/= (float)ar->winy;
@@ -1053,12 +1055,12 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick
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);
+ 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);
}
else {
- if(orth) wmOrtho(x1, x2, y1, y2, clipsta, clipend);
+ if (orth) wmOrtho(x1, x2, y1, y2, clipsta, clipend);
else wmFrustum(x1, x2, y1, y2, clipsta, clipend);
}
@@ -1100,11 +1102,13 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short
rv3d->persp=RV3D_CAMOB; /* just to be polite, not needed */
- } else {
+ }
+ else {
mat3_to_quat( new_quat,tmat);
smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX
}
- } else {
+ }
+ else {
mat3_to_quat( rv3d->viewquat,tmat);
}
}
@@ -1147,8 +1151,8 @@ int ED_view3d_lock(RegionView3D *rv3d)
/* dont 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(v3d->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);
}
@@ -1159,19 +1163,19 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d)
}
else {
/* should be moved to better initialize later on XXX */
- if(rv3d->viewlock)
+ 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;
- if(v3d->ob_centre) {
+ if (rv3d->persp==RV3D_PERSP) rv3d->viewmat[3][2]-= rv3d->dist;
+ if (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]) {
+ if (ob->type==OB_ARMATURE && v3d->ob_centre_bone[0]) {
bPoseChannel *pchan= get_pose_channel(ob->pose, v3d->ob_centre_bone);
- if(pchan) {
+ if (pchan) {
copy_v3_v3(vec, pchan->pose_mat[3]);
mul_m4_v3(ob->obmat, vec);
}
@@ -1204,7 +1208,7 @@ 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) {
+ 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;
@@ -1220,12 +1224,12 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
setwinmatrixview3d(ar, v3d, &rect);
mult_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
- if(v3d->drawtype > OB_WIRE) {
+ if (v3d->drawtype > OB_WIRE) {
v3d->zbuf= TRUE;
glEnable(GL_DEPTH_TEST);
}
- if(vc->rv3d->rflag & RV3D_CLIPPING)
+ if (vc->rv3d->rflag & RV3D_CLIPPING)
view3d_set_clipping(vc->rv3d);
glSelectBuffer( bufsize, (GLuint *)buffer);
@@ -1234,12 +1238,12 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
glPushName(-1);
code= 1;
- if(vc->obedit && vc->obedit->type==OB_MBALL) {
+ 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)) {
+ if (!BDR_drawSketchNames(vc)) {
draw_object(scene, ar, v3d, BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
}
}
@@ -1247,8 +1251,8 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
Base *base;
v3d->xray= TRUE; // otherwise it postpones drawing
- for(base= scene->base.first; base; base= base->next) {
- if(base->lay & v3d->lay) {
+ for (base= scene->base.first; base; base= base->next) {
+ if (base->lay & v3d->lay) {
if (base->object->restrictflag & OB_RESTRICT_SELECT)
base->selcol= 0;
@@ -1258,7 +1262,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
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) {
+ if ((base->object->transflag & OB_DUPLI) && base->object->dup_group) {
ListBase *lb;
DupliObject *dob;
Base tbase;
@@ -1266,7 +1270,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
tbase.flag= OB_FROMDUPLI;
lb= object_duplilist(scene, base->object);
- for(dob= lb->first; dob; dob= dob->next) {
+ for (dob= lb->first; dob; dob= dob->next) {
tbase.object= dob->ob;
copy_m4_m4(dob->ob->obmat, dob->mat);
@@ -1298,16 +1302,16 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
setwinmatrixview3d(ar, v3d, NULL);
mult_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
- if(v3d->drawtype > OB_WIRE) {
+ if (v3d->drawtype > OB_WIRE) {
v3d->zbuf= 0;
glDisable(GL_DEPTH_TEST);
}
// XXX persp(PERSP_WIN);
- if(vc->rv3d->rflag & RV3D_CLIPPING)
+ if (vc->rv3d->rflag & RV3D_CLIPPING)
view3d_clr_clipping();
- 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;
}
@@ -1324,11 +1328,11 @@ static unsigned int free_localbit(Main *bmain)
/* 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) {
+ 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) {
+ for (; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
View3D *v3d= (View3D*) sl;
lay |= v3d->lay;
}
@@ -1336,14 +1340,14 @@ static unsigned int free_localbit(Main *bmain)
}
}
- 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;
}
@@ -1353,14 +1357,14 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active)
int i, tot= 0;
/* ensure we always have some layer selected */
- for(i=0; i<20; i++)
- if(values[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 */
@@ -1375,8 +1379,8 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active)
/* ensure always an active layer */
if (active && (lay & *active)==0) {
- for(i=0; i<20; i++) {
- if(lay & (1<<i)) {
+ for (i=0; i<20; i++) {
+ if (lay & (1<<i)) {
*active= 1<<i;
break;
}
@@ -1394,18 +1398,18 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa)
unsigned int locallay;
int ok=0;
- if(v3d->localvd) return;
+ if (v3d->localvd) return;
INIT_MINMAX(min, max);
locallay= free_localbit(bmain);
- if(locallay==0) {
+ if (locallay==0) {
printf("Sorry, no more than 8 localviews\n"); // XXX error
ok= 0;
}
else {
- if(scene->obedit) {
+ if (scene->obedit) {
minmax_object(scene->obedit, min, max);
ok= 1;
@@ -1414,8 +1418,8 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa)
scene->obedit->lay= BASACT->lay;
}
else {
- for(base= FIRSTBASE; base; base= base->next) {
- if(TESTBASE(v3d, base)) {
+ 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;
@@ -1428,18 +1432,18 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa)
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 (size <= 0.01f) size= 0.01f;
}
- if(ok) {
+ if (ok) {
ARegion *ar;
v3d->localvd= MEM_mallocN(sizeof(View3D), "localview");
memcpy(v3d->localvd, v3d, sizeof(View3D));
- for(ar= sa->regionbase.first; ar; ar= ar->next) {
- if(ar->regiontype == RGN_TYPE_WINDOW) {
+ for (ar= sa->regionbase.first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d= ar->regiondata;
rv3d->localvd= MEM_mallocN(sizeof(RegionView3D), "localview region");
@@ -1451,13 +1455,13 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa)
rv3d->dist= size;
/* perspective should be a bit farther away to look nice */
- if(rv3d->persp==RV3D_ORTHO)
+ if (rv3d->persp==RV3D_ORTHO)
rv3d->dist*= 0.7f;
// correction for window aspect ratio
- if(ar->winy>2 && ar->winx>2) {
+ if (ar->winy>2 && ar->winx>2) {
float asp= (float)ar->winx/(float)ar->winy;
- if(asp < 1.0f) asp= 1.0f/asp;
+ if (asp < 1.0f) asp= 1.0f/asp;
rv3d->dist*= asp;
}
@@ -1473,11 +1477,11 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa)
}
else {
/* clear flags */
- for(base= FIRSTBASE; base; base= base->next) {
- if( base->lay & locallay ) {
+ 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;
+ if (base->lay==0) base->lay= v3d->layact;
+ if (base->object != scene->obedit) base->flag |= SELECT;
base->object->lay= base->lay;
}
}
@@ -1490,7 +1494,7 @@ static void restore_localviewdata(ScrArea *sa, int free)
ARegion *ar;
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;
@@ -1499,16 +1503,16 @@ static void restore_localviewdata(ScrArea *sa, int free)
v3d->drawtype= v3d->localvd->drawtype;
v3d->camera= v3d->localvd->camera;
- if(free) {
+ if (free) {
MEM_freeN(v3d->localvd);
v3d->localvd= NULL;
}
- for(ar= sa->regionbase.first; ar; ar= ar->next) {
- if(ar->regiontype == RGN_TYPE_WINDOW) {
+ for (ar= sa->regionbase.first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d= ar->regiondata;
- if(rv3d->localvd) {
+ if (rv3d->localvd) {
rv3d->dist= rv3d->localvd->dist;
copy_v3_v3(rv3d->ofs, rv3d->localvd->ofs);
copy_qt_qt(rv3d->viewquat, rv3d->localvd->viewquat);
@@ -1516,7 +1520,7 @@ static void restore_localviewdata(ScrArea *sa, int free)
rv3d->persp= rv3d->localvd->persp;
rv3d->camzoom= rv3d->localvd->camzoom;
- if(free) {
+ if (free) {
MEM_freeN(rv3d->localvd);
rv3d->localvd= NULL;
}
@@ -1531,20 +1535,20 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa)
struct Base *base;
unsigned int locallay;
- if(v3d->localvd) {
+ if (v3d->localvd) {
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 ) {
+ 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) {
+ if (base->lay==0) base->lay= v3d->layact;
+ if (base->object != scene->obedit) {
base->flag |= SELECT;
base->object->flag |= SELECT;
}
@@ -1560,7 +1564,7 @@ static int localview_exec(bContext *C, wmOperator *UNUSED(unused))
{
View3D *v3d= CTX_wm_view3d(C);
- if(v3d->localvd)
+ if (v3d->localvd)
endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C));
else
initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C));
@@ -1594,7 +1598,7 @@ static void SaveState(bContext *C, wmWindow *win)
glPushAttrib(GL_ALL_ATTRIB_BITS);
- if(obact && obact->mode & OB_MODE_TEXTURE_PAINT)
+ if (obact && obact->mode & OB_MODE_TEXTURE_PAINT)
GPU_paint_set_mipmap(1);
queue_back= win->queue;
@@ -1608,7 +1612,7 @@ static void RestoreState(bContext *C, wmWindow *win)
{
Object *obact = CTX_data_active_object(C);
- if(obact && obact->mode & OB_MODE_TEXTURE_PAINT)
+ if (obact && obact->mode & OB_MODE_TEXTURE_PAINT)
GPU_paint_set_mipmap(0);
//XXX curarea->win_swap = 0;
@@ -1619,7 +1623,7 @@ static void RestoreState(bContext *C, wmWindow *win)
//XXX waitcursor(0);
//XXX G.qual= 0;
- if(win) /* check because closing win can set to NULL */
+ if (win) /* check because closing win can set to NULL */
win->queue= queue_back;
GPU_state_init();
@@ -1682,11 +1686,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;
@@ -1699,19 +1703,19 @@ int ED_view3d_context_activate(bContext *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)
+ if (!sa)
return 0;
- for(ar=sa->regionbase.first; ar; ar=ar->next)
- if(ar->regiontype == RGN_TYPE_WINDOW)
+ for (ar=sa->regionbase.first; ar; ar=ar->next)
+ if (ar->regiontype == RGN_TYPE_WINDOW)
break;
- if(!ar)
+ if (!ar)
return 0;
// bad context switch ..
@@ -1734,7 +1738,7 @@ static int game_engine_exec(bContext *C, wmOperator *op)
(void)op; /* unused */
// bad context switch ..
- if(!ED_view3d_context_activate(C))
+ if (!ED_view3d_context_activate(C))
return OPERATOR_CANCELLED;
/* redraw to hide any menus/popups, we don't go back to
@@ -1749,7 +1753,7 @@ static int game_engine_exec(bContext *C, wmOperator *op)
game_set_commmandline_options(&startscene->gm);
- if((rv3d->persp == RV3D_CAMOB) &&
+ if ((rv3d->persp == RV3D_CAMOB) &&
(startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) &&
(startscene->gm.stereoflag != STEREO_DOME))
{
@@ -1775,14 +1779,14 @@ static int game_engine_exec(bContext *C, wmOperator *op)
StartKetsjiShell(C, ar, &cam_frame, 1);
/* window wasnt closed while the BGE was running */
- if(BLI_findindex(&CTX_wm_manager(C)->windows, prevwin) == -1) {
+ if (BLI_findindex(&CTX_wm_manager(C)->windows, prevwin) == -1) {
prevwin= NULL;
CTX_wm_window_set(C, NULL);
}
ED_area_tag_redraw(CTX_wm_area(C));
- if(prevwin) {
+ if (prevwin) {
/* restore context, in case it changed in the meantime, for
example by working in another window or closing it */
CTX_wm_region_set(C, prevar);
@@ -1825,7 +1829,7 @@ 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;
+ if (axisidx > 0) alignaxis[axisidx-1]= 1.0;
else alignaxis[-axisidx-1]= -1.0;
normalize_v3_v3(norm, vec);
@@ -1847,7 +1851,8 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f
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 {
+ }
+ else {
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
}
@@ -1883,13 +1888,13 @@ void ED_view3d_operator_properties_viewmat_set(bContext *C, wmOperator *op)
ARegion *ar= CTX_wm_region(C);
RegionView3D *rv3d= ED_view3d_context_rv3d(C);
- if(!RNA_struct_property_is_set(op->ptr, "region_width"))
+ if (!RNA_struct_property_is_set(op->ptr, "region_width"))
RNA_int_set(op->ptr, "region_width", ar->winx);
- if(!RNA_struct_property_is_set(op->ptr, "region_height"))
+ if (!RNA_struct_property_is_set(op->ptr, "region_height"))
RNA_int_set(op->ptr, "region_height", ar->winy);
- if(!RNA_struct_property_is_set(op->ptr, "perspective_matrix"))
+ if (!RNA_struct_property_is_set(op->ptr, "perspective_matrix"))
RNA_float_set_array(op->ptr, "perspective_matrix", (float *)rv3d->persmat);
}