[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33036] trunk/blender/source/blender: take delta's into account when applying the objects matrix (dloc, drot, dsize).

Campbell Barton ideasman42 at gmail.com
Fri Nov 12 12:16:04 CET 2010


Revision: 33036
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33036
Author:   campbellbarton
Date:     2010-11-12 12:16:04 +0100 (Fri, 12 Nov 2010)

Log Message:
-----------
take delta's into account when applying the objects matrix (dloc, drot, dsize).
Now object_apply_mat4() can be used as the reverse of object_to_mat4().

Noticeable result is fly mode and 'Apply Visual Transform' dont jump when deltas are used, also means setting matrix from python works as expected.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_vector_inline.c

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2010-11-12 09:06:50 UTC (rev 33035)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2010-11-12 11:16:04 UTC (rev 33036)
@@ -1682,13 +1682,17 @@
 	switch(ob->rotmode) {
 	case ROT_MODE_QUAT:
 		mat3_to_quat(ob->quat, mat);
+		sub_v4_v4(ob->quat, ob->dquat);
 		break;
 	case ROT_MODE_AXISANGLE:
 		mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat);
+		sub_v3_v3(ob->rotAxis, ob->drotAxis);
+		ob->rotAngle -= ob->drotAngle;
 		break;
 	default: /* euler */
 		if(use_compat)	mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, mat);
 		else			mat3_to_eulO(ob->rot, ob->rotmode, mat);
+		sub_v3_v3(ob->rot, ob->drot);
 	}
 }
 
@@ -1712,6 +1716,10 @@
 		mat4_to_loc_rot_size(ob->loc, rot, ob->size, mat);
 		object_mat3_to_rot(ob, rot, use_compat);
 	}
+	
+	sub_v3_v3(ob->loc, ob->dloc);
+	sub_v3_v3(ob->size, ob->dsize);
+	/* object_mat3_to_rot handles delta rotations */
 }
 
 void object_to_mat3(Object *ob, float mat[][3])	/* no parent */

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2010-11-12 09:06:50 UTC (rev 33035)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2010-11-12 11:16:04 UTC (rev 33036)
@@ -63,6 +63,8 @@
 MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2]);
 MINLINE void sub_v3_v3(float r[3], const float a[3]);
 MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3]);
+MINLINE void sub_v4_v4(float r[4], const float a[4]);
+MINLINE void sub_v4_v4v4(float r[4], const float a[4], const float b[4]);
 
 MINLINE void mul_v2_fl(float r[2], float f);
 MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f);

Modified: trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2010-11-12 09:06:50 UTC (rev 33035)
+++ trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2010-11-12 11:16:04 UTC (rev 33036)
@@ -149,6 +149,23 @@
 	r[2]= a[2] - b[2];
 }
 
+MINLINE void sub_v4_v4(float r[4], const float a[4])
+{
+	r[0] -= a[0];
+	r[1] -= a[1];
+	r[2] -= a[2];
+	r[3] -= a[3];
+}
+
+MINLINE void sub_v4_v4v4(float r[3], const float a[3], const float b[3])
+{
+	r[0]= a[0] - b[0];
+	r[1]= a[1] - b[1];
+	r[2]= a[2] - b[2];
+	r[3]= a[3] - b[3];
+}
+
+
 MINLINE void mul_v2_fl(float *v1, float f)
 {
 	v1[0]*= f;





More information about the Bf-blender-cvs mailing list