[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38919] trunk/blender/source/blender/ editors/space_view3d: no functional changes.
Campbell Barton
ideasman42 at gmail.com
Tue Aug 2 10:12:50 CEST 2011
Revision: 38919
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38919
Author: campbellbarton
Date: 2011-08-02 08:12:50 +0000 (Tue, 02 Aug 2011)
Log Message:
-----------
no functional changes.
style edits, also renamed ndof_to_angle_axis --> ndof_to_axis_angle
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
trunk/blender/source/blender/editors/space_view3d/view3d_fly.c
trunk/blender/source/blender/editors/space_view3d/view3d_intern.h
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2011-08-02 07:49:34 UTC (rev 38918)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2011-08-02 08:12:50 UTC (rev 38919)
@@ -930,7 +930,7 @@
// NDOF utility functions
// (should these functions live in this file?)
-float ndof_to_angle_axis(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);
}
@@ -940,7 +940,7 @@
float axis[3];
float angle;
- angle= ndof_to_angle_axis(ndof, axis);
+ angle= ndof_to_axis_angle(ndof, axis);
axis_angle_to_quat(q, axis, angle);
}
@@ -1023,7 +1023,7 @@
mul_qt_qtqt(rot, rot, view_inv_conj);
#else // ---------------------------------------- Mike's revised version
float axis[3];
- float angle = rot_sensitivity * ndof_to_angle_axis(ndof, axis);
+ float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis);
if (invert)
angle = -angle;
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_fly.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_fly.c 2011-08-02 07:49:34 UTC (rev 38918)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_fly.c 2011-08-02 08:12:50 UTC (rev 38919)
@@ -109,7 +109,7 @@
wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Fly Modal");
/* this function is called for each spacetype, only needs to add map once */
- if(keymap) return;
+ if (keymap) return;
keymap= WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items);
@@ -261,21 +261,21 @@
fly->ar = CTX_wm_region(C);
fly->scene= CTX_data_scene(C);
- #ifdef NDOF_FLY_DEBUG
+#ifdef NDOF_FLY_DEBUG
puts("\n-- fly begin --");
- #endif
+#endif
- if(fly->rv3d->persp==RV3D_CAMOB && fly->v3d->camera->id.lib) {
+ if (fly->rv3d->persp==RV3D_CAMOB && fly->v3d->camera->id.lib) {
BKE_report(op->reports, RPT_ERROR, "Cannot fly a camera from an external library");
return FALSE;
}
- if(fly->v3d->ob_centre) {
+ if (fly->v3d->ob_centre) {
BKE_report(op->reports, RPT_ERROR, "Cannot fly when the view is locked to an object");
return FALSE;
}
- if(fly->rv3d->persp==RV3D_CAMOB && fly->v3d->camera->constraints.first) {
+ if (fly->rv3d->persp==RV3D_CAMOB && fly->v3d->camera->constraints.first) {
BKE_report(op->reports, RPT_ERROR, "Cannot fly an object with constraints");
return FALSE;
}
@@ -319,7 +319,7 @@
fly->dist_backup= fly->rv3d->dist;
if (fly->rv3d->persp==RV3D_CAMOB) {
Object *ob_back;
- if((U.uiflag & USER_CAM_LOCK_NO_PARENT)==0 && (fly->root_parent=fly->v3d->camera->parent)) {
+ if ((U.uiflag & USER_CAM_LOCK_NO_PARENT)==0 && (fly->root_parent=fly->v3d->camera->parent)) {
while(fly->root_parent->parent)
fly->root_parent= fly->root_parent->parent;
ob_back= fly->root_parent;
@@ -337,7 +337,8 @@
negate_v3_v3(fly->rv3d->ofs, fly->v3d->camera->obmat[3]);
fly->rv3d->dist=0.0;
- } else {
+ }
+ else {
/* perspective or ortho */
if (fly->rv3d->persp==RV3D_ORTHO)
fly->rv3d->persp= RV3D_PERSP; /*if ortho projection, make perspective */
@@ -373,12 +374,12 @@
float upvec[3];
- if(fly->state == FLY_RUNNING)
+ if (fly->state == FLY_RUNNING)
return OPERATOR_RUNNING_MODAL;
- #ifdef NDOF_FLY_DEBUG
+#ifdef NDOF_FLY_DEBUG
puts("\n-- fly end --");
- #endif
+#endif
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), fly->timer);
@@ -390,14 +391,14 @@
/* Revert to original view? */
if (fly->persp_backup==RV3D_CAMOB) { /* a camera view */
Object *ob_back;
- if(fly->root_parent)ob_back= fly->root_parent;
- else ob_back= fly->v3d->camera;
+ ob_back= (fly->root_parent) ? fly->root_parent : fly->v3d->camera;
/* store the original camera loc and rot */
object_tfm_restore(ob_back, fly->obtfm);
DAG_id_tag_update(&ob_back->id, OB_RECALC_OB);
- } else {
+ }
+ else {
/* Non Camera we need to reset the view back to the original location bacause the user canceled*/
copy_qt_qt(rv3d->viewquat, fly->rot_backup);
copy_v3_v3(rv3d->ofs, fly->ofs_backup);
@@ -422,13 +423,13 @@
rv3d->rflag &= ~RV3D_NAVIGATING;
//XXX2.5 BIF_view3d_previewrender_signal(fly->sa, PR_DBASE|PR_DISPRECT); /* not working at the moment not sure why */
- if(fly->obtfm)
+ if (fly->obtfm)
MEM_freeN(fly->obtfm);
- if(fly->ndof)
+ if (fly->ndof)
MEM_freeN(fly->ndof);
- if(fly->state == FLY_CONFIRM) {
+ if (fly->state == FLY_CONFIRM) {
MEM_freeN(fly);
return OPERATOR_FINISHED;
}
@@ -451,37 +452,37 @@
// static const char* tag_name = "3D mouse position";
wmNDOFMotionData* incoming_ndof = (wmNDOFMotionData*) event->customdata;
- switch (incoming_ndof->progress)
- {
+ switch (incoming_ndof->progress) {
case P_STARTING:
// start keeping track of 3D mouse position
- #ifdef NDOF_FLY_DEBUG
+#ifdef NDOF_FLY_DEBUG
puts("start keeping track of 3D mouse position");
- #endif
+#endif
// fall through...
case P_IN_PROGRESS:
// update 3D mouse position
- #ifdef NDOF_FLY_DEBUG
+#ifdef NDOF_FLY_DEBUG
putchar('.'); fflush(stdout);
- #endif
- if (fly->ndof == NULL)
+#endif
+ if (fly->ndof == NULL) {
// fly->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
fly->ndof = MEM_dupallocN(incoming_ndof);
// fly->ndof = malloc(sizeof(wmNDOFMotionData));
- else
+ }
+ else {
memcpy(fly->ndof, incoming_ndof, sizeof(wmNDOFMotionData));
+ }
break;
case P_FINISHING:
// stop keeping track of 3D mouse position
- #ifdef NDOF_FLY_DEBUG
+#ifdef NDOF_FLY_DEBUG
puts("stop keeping track of 3D mouse position");
- #endif
- if (fly->ndof)
- {
+#endif
+ if (fly->ndof) {
MEM_freeN(fly->ndof);
// free(fly->ndof);
fly->ndof = NULL;
- }
+ }
/* update the time else the view will jump when 2D mouse/timer resume */
fly->time_lastdraw= PIL_check_seconds_timer();
break;
@@ -511,7 +512,9 @@
/*Mouse wheel delays range from 0.5==slow to 0.01==fast*/
time_wheel = 1.0f + (10.0f - (20.0f * MIN2(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */
- if (fly->speed<0.0f) fly->speed= 0.0f;
+ if (fly->speed < 0.0f) {
+ fly->speed= 0.0f;
+ }
else {
if (event->shift)
fly->speed += fly->grid*time_wheel * 0.1f;
@@ -530,7 +533,9 @@
fly->time_lastwheel = time_currwheel;
time_wheel = 1.0f + (10.0f - (20.0f * MIN2(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */
- if (fly->speed>0) fly->speed=0;
+ if (fly->speed > 0.0f) {
+ fly->speed=0;
+ }
else {
if (event->shift)
fly->speed-= fly->grid*time_wheel * 0.1f;
@@ -614,7 +619,7 @@
ID *id_key;
/* transform the parent or the camera? */
- if(fly->root_parent) {
+ if (fly->root_parent) {
Object *ob_update;
float view_mat[4][4];
@@ -702,10 +707,10 @@
unsigned char
apply_rotation= 1; /* if the user presses shift they can look about without movinf the direction there looking*/
- #ifdef NDOF_FLY_DEBUG
+#ifdef NDOF_FLY_DEBUG
static unsigned int iteration = 1;
printf("fly timer %d\n", iteration++);
- #endif
+#endif
xmargin= ar->winx/20.0f;
@@ -736,18 +741,18 @@
*
* the mouse moves isnt linear */
- if(moffset[0]) {
+ if (moffset[0]) {
moffset[0] /= ar->winx - (xmargin*2);
moffset[0] *= fabsf(moffset[0]);
}
- if(moffset[1]) {
+ if (moffset[1]) {
moffset[1] /= ar->winy - (ymargin*2);
moffset[1] *= fabsf(moffset[1]);
}
/* Should we redraw? */
- if(fly->speed != 0.0f || moffset[0] || moffset[1] || fly->zlock || fly->xlock || dvec[0] || dvec[1] || dvec[2] ) {
+ if (fly->speed != 0.0f || moffset[0] || moffset[1] || fly->zlock || fly->xlock || dvec[0] || dvec[1] || dvec[2] ) {
float dvec_tmp[3];
double time_current; /*time how fast it takes for us to redraw, this is so simple scenes dont fly too fast */
float time_redraw;
@@ -781,8 +786,8 @@
mul_m3_v3(mat, dvec_tmp);
mul_v3_fl(dvec_tmp, time_redraw * 200.0f * fly->grid);
-
- } else {
+ }
+ else {
float roll; /* similar to the angle between the camera's up and the Z-up, but its very rough so just roll*/
/* rotate about the X axis- look up/down */
@@ -803,23 +808,24 @@
if (moffset[0]) {
/* if we're upside down invert the moffset */
- upvec[0]=0;
- upvec[1]=1;
- upvec[2]=0;
+ upvec[0]= 0.0f;
+ upvec[1]= 1.0f;
+ upvec[2]= 0.0f;
mul_m3_v3(mat, upvec);
- if(upvec[2] < 0.0f)
+ if (upvec[2] < 0.0f)
moffset[0]= -moffset[0];
/* make the lock vectors */
if (fly->zlock) {
- upvec[0]=0;
- upvec[1]=0;
- upvec[2]=1;
- } else {
- upvec[0]=0;
- upvec[1]=1;
- upvec[2]=0;
+ upvec[0]= 0.0f;
+ upvec[1]= 0.0f;
+ upvec[2]= 1.0f;
+ }
+ else {
+ upvec[0]= 0.0f;
+ upvec[1]= 1.0f;
+ upvec[2]= 0.0f;
mul_m3_v3(mat, upvec);
}
@@ -831,25 +837,26 @@
}
if (fly->zlock==2) {
- upvec[0]=1;
- upvec[1]=0;
- upvec[2]=0;
+ upvec[0]= 1.0f;
+ upvec[1]= 0.0f;
+ upvec[2]= 0.0f;
mul_m3_v3(mat, upvec);
/*make sure we have some z rolling*/
if (fabsf(upvec[2]) > 0.00001f) {
- roll= upvec[2]*5;
- upvec[0]=0; /*rotate the view about this axis*/
- upvec[1]=0;
- upvec[2]=1;
+ roll= upvec[2] * 5.0f;
+ upvec[0]= 0.0f; /*rotate the view about this axis*/
+ upvec[1]= 0.0f;
+ upvec[2]= 1.0f;
mul_m3_v3(mat, upvec);
axis_angle_to_quat( tmp_quat, upvec, roll*time_redraw_clamped*fly->zlock_momentum * FLY_ZUP_CORRECT_FAC); /* Rotate about the relative up vec */
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
fly->zlock_momentum += FLY_ZUP_CORRECT_ACCEL;
- } else {
- fly->zlock=1; /* dont check until the view rotates again */
+ }
+ else {
+ fly->zlock= 1; /* dont check until the view rotates again */
fly->zlock_momentum= 0.0f;
}
}
@@ -860,8 +867,8 @@
upvec[2]=1;
mul_m3_v3(mat, upvec);
/*make sure we have some z rolling*/
- if (fabs(upvec[2]) > 0.00001) {
- roll= upvec[2] * -5;
+ if (fabs(upvec[2]) > 0.00001f) {
+ roll= upvec[2] * -5.0f;
upvec[0]= 1.0f; /*rotate the view about this axis*/
upvec[1]= 0.0f;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list