[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57997] trunk/blender/source/blender/ editors: Fix #35997: add armature > single bone, then change location or rotation would

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Jul 4 16:59:27 CEST 2013


Revision: 57997
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57997
Author:   blendix
Date:     2013-07-04 14:59:26 +0000 (Thu, 04 Jul 2013)
Log Message:
-----------
Fix #35997: add armature > single bone, then change location or rotation would
move only the origin and not the bone. It doesn't need to use any object
matrices to add the bone, the only reason this worked before is because they
were still unit matrices due to depsgraph not running immediately on add.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/armature_add.c
    trunk/blender/source/blender/editors/include/ED_armature.h
    trunk/blender/source/blender/editors/object/object_add.c

Modified: trunk/blender/source/blender/editors/armature/armature_add.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_add.c	2013-07-04 14:37:38 UTC (rev 57996)
+++ trunk/blender/source/blender/editors/armature/armature_add.c	2013-07-04 14:59:26 UTC (rev 57997)
@@ -84,39 +84,25 @@
 	return bone;
 }
 
-/* v3d and rv3d are allowed to be NULL */
-void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
+void add_primitive_bone(Object *obedit_arm, bool view_aligned)
 {
-	Object *obedit = scene->obedit; // XXX get from context
-	bArmature *arm = obedit->data;
-	float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
-	EditBone    *bone;
+	bArmature *arm = obedit_arm->data;
+	EditBone *bone;
 
-	/* Get inverse point for head and orientation for tail */
-	invert_m4_m4(obedit->imat, obedit->obmat);
-	mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
-
-	if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
-		copy_m3_m4(obmat, rv3d->viewmat);
-	else unit_m3(obmat);
+	ED_armature_deselect_all(obedit_arm, 0);
 	
-	copy_m3_m4(viewmat, obedit->obmat);
-	mul_m3_m3m3(totmat, obmat, viewmat);
-	invert_m3_m3(imat, totmat);
-	
-	ED_armature_deselect_all(obedit, 0);
-	
 	/* Create a bone */
 	bone = ED_armature_edit_bone_add(arm, "Bone");
 
 	arm->act_edbone = bone;
 
-	copy_v3_v3(bone->head, curs);
-	
-	if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
-		add_v3_v3v3(bone->tail, bone->head, imat[1]);   // bone with unit length 1
+	zero_v3(bone->head);
+	zero_v3(bone->tail);
+
+	if (view_aligned)
+		bone->tail[1] = 1.0f;
 	else
-		add_v3_v3v3(bone->tail, bone->head, imat[2]);   // bone with unit length 1, pointing up Z
+		bone->tail[2] = 1.0f;
 }
 
 

Modified: trunk/blender/source/blender/editors/include/ED_armature.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_armature.h	2013-07-04 14:37:38 UTC (rev 57996)
+++ trunk/blender/source/blender/editors/include/ED_armature.h	2013-07-04 14:59:26 UTC (rev 57997)
@@ -132,7 +132,7 @@
 void ED_armature_sync_selection(struct ListBase *edbo);
 void ED_armature_validate_active(struct bArmature *arm);
 
-void add_primitive_bone(struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d);
+void add_primitive_bone(struct Object *obedit_arm, bool view_aligned);
 struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
 void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
 bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);

Modified: trunk/blender/source/blender/editors/object/object_add.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_add.c	2013-07-04 14:37:38 UTC (rev 57996)
+++ trunk/blender/source/blender/editors/object/object_add.c	2013-07-04 14:59:26 UTC (rev 57997)
@@ -657,12 +657,12 @@
 static int object_armature_add_exec(bContext *C, wmOperator *op)
 {
 	Object *obedit = CTX_data_edit_object(C);
-	View3D *v3d = CTX_wm_view3d(C);
 	RegionView3D *rv3d = CTX_wm_region_view3d(C);
 	bool newob = false;
 	bool enter_editmode;
 	unsigned int layer;
 	float loc[3], rot[3];
+	bool view_aligned = rv3d && (U.flag & USER_ADD_VIEWALIGNED);
 
 	if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
 		return OPERATOR_CANCELLED;
@@ -681,8 +681,7 @@
 		return OPERATOR_CANCELLED;
 	}
 
-	/* v3d and rv3d are allowed to be NULL */
-	add_primitive_bone(CTX_data_scene(C), v3d, rv3d);
+	add_primitive_bone(obedit, view_aligned);
 
 	/* userdef */
 	if (newob && !enter_editmode)




More information about the Bf-blender-cvs mailing list