[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34498] trunk/blender/source/blender/ editors: - Clear rotation for objects now works on delta transforms too.
Joshua Leung
aligorith at gmail.com
Wed Jan 26 11:25:16 CET 2011
Revision: 34498
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34498
Author: aligorith
Date: 2011-01-26 10:25:15 +0000 (Wed, 26 Jan 2011)
Log Message:
-----------
- Clear rotation for objects now works on delta transforms too. The
only case that doesn't fully work yet is the one where quats/axis-
angle are converted to eulers first.
- Fixed incorrect comment
- Removed obsolete "armature_clear" var from clear origin operator.
This was some ancient stuff from 2.4x code that ended up getting
ported across...
Modified Paths:
--------------
trunk/blender/source/blender/editors/armature/editarmature.c
trunk/blender/source/blender/editors/object/object_transform.c
Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c 2011-01-26 09:35:35 UTC (rev 34497)
+++ trunk/blender/source/blender/editors/armature/editarmature.c 2011-01-26 10:25:15 UTC (rev 34498)
@@ -5082,7 +5082,7 @@
return OPERATOR_CANCELLED;
}
- /* only clear those channels that are not locked */
+ /* only clear relevant transforms for selected bones */
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
{
/* run provided clearing function */
Modified: trunk/blender/source/blender/editors/object/object_transform.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_transform.c 2011-01-26 09:35:35 UTC (rev 34497)
+++ trunk/blender/source/blender/editors/object/object_transform.c 2011-01-26 10:25:15 UTC (rev 34498)
@@ -87,40 +87,45 @@
/* perform clamping on a component by component basis */
if (ob->rotmode == ROT_MODE_AXISANGLE) {
if ((ob->protectflag & OB_LOCK_ROTW) == 0)
- ob->rotAngle= 0.0f;
+ ob->rotAngle= ob->drotAngle= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTX) == 0)
- ob->rotAxis[0]= 0.0f;
+ ob->rotAxis[0]= ob->drotAxis[0]= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTY) == 0)
- ob->rotAxis[1]= 0.0f;
+ ob->rotAxis[1]= ob->drotAxis[1]= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTZ) == 0)
- ob->rotAxis[2]= 0.0f;
+ ob->rotAxis[2]= ob->drotAxis[2]= 0.0f;
/* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
if (IS_EQ(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQ(ob->rotAxis[1], ob->rotAxis[2]))
ob->rotAxis[1] = 1.0f;
+ if (IS_EQ(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQ(ob->drotAxis[1], ob->drotAxis[2]))
+ ob->drotAxis[1]= 1.0f;
}
else if (ob->rotmode == ROT_MODE_QUAT) {
if ((ob->protectflag & OB_LOCK_ROTW) == 0)
- ob->quat[0]= 1.0f;
+ ob->quat[0]= ob->dquat[0]= 1.0f;
if ((ob->protectflag & OB_LOCK_ROTX) == 0)
- ob->quat[1]= 0.0f;
+ ob->quat[1]= ob->dquat[1]= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTY) == 0)
- ob->quat[2]= 0.0f;
+ ob->quat[2]= ob->dquat[2]= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTZ) == 0)
- ob->quat[3]= 0.0f;
+ ob->quat[3]= ob->dquat[3]= 0.0f;
+
+ // TODO: does this quat need normalising now?
}
else {
/* the flag may have been set for the other modes, so just ignore the extra flag... */
if ((ob->protectflag & OB_LOCK_ROTX) == 0)
- ob->rot[0]= 0.0f;
+ ob->rot[0]= ob->drot[0]= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTY) == 0)
- ob->rot[1]= 0.0f;
+ ob->rot[1]= ob->drot[1]= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTZ) == 0)
- ob->rot[2]= 0.0f;
+ ob->rot[2]= ob->drot[2]= 0.0f;
}
}
else {
/* perform clamping using euler form (3-components) */
+ // FIXME: deltas are not handled for these cases yet...
float eul[3], oldeul[3], quat1[4] = {0};
if (ob->rotmode == ROT_MODE_QUAT) {
@@ -162,14 +167,22 @@
if (ob->rotmode == ROT_MODE_QUAT) {
ob->quat[1]=ob->quat[2]=ob->quat[3]= 0.0f;
ob->quat[0]= 1.0f;
+
+ ob->dquat[1]=ob->dquat[2]=ob->dquat[3]= 0.0f;
+ ob->dquat[0]= 1.0f;
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
/* by default, make rotation of 0 radians around y-axis (roll) */
ob->rotAxis[0]=ob->rotAxis[2]=ob->rotAngle= 0.0f;
ob->rotAxis[1]= 1.0f;
+
+ ob->drotAxis[0]=ob->drotAxis[2]=ob->drotAngle= 0.0f;
+ ob->drotAxis[1]= 1.0f;
}
else {
ob->rot[0]= ob->rot[1]= ob->rot[2]= 0.0f;
+
+ ob->drot[0]= ob->drot[1]= ob->drot[2]= 0.0f;
}
}
}
@@ -316,11 +329,13 @@
static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain= CTX_data_main(C);
- float *v1, *v3, mat[3][3];
- int armature_clear= 0;
+ float *v1, *v3;
+ float mat[3][3];
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob->parent) {
+ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
+ {
+ if (ob->parent) {
+ /* vectors pointed to by v1 and v3 will get modified */
v1= ob->loc;
v3= ob->parentinv[3];
@@ -332,8 +347,7 @@
}
CTX_DATA_END;
- if(armature_clear==0) /* in this case flush was done */
- DAG_ids_flush_update(bmain, 0);
+ DAG_ids_flush_update(bmain, 0);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
More information about the Bf-blender-cvs
mailing list