[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59255] trunk/blender/source/blender/ editors/transform/transform_snap.c: add support for snapping to empty centers during transform.

Campbell Barton ideasman42 at gmail.com
Mon Aug 19 06:22:06 CEST 2013


Revision: 59255
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59255
Author:   campbellbarton
Date:     2013-08-19 04:22:05 +0000 (Mon, 19 Aug 2013)
Log Message:
-----------
add support for snapping to empty centers during transform.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/transform/transform_snap.c

Modified: trunk/blender/source/blender/editors/transform/transform_snap.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_snap.c	2013-08-19 01:48:44 UTC (rev 59254)
+++ trunk/blender/source/blender/editors/transform/transform_snap.c	2013-08-19 04:22:05 UTC (rev 59255)
@@ -1147,7 +1147,7 @@
 	}
 }
 
-static bool snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], float obmat[4][4], float timat[3][3],
+static bool snapEdge(ARegion *ar, const float v1co[3], const short v1no[3], const float v2co[3], const short v2no[3], float obmat[4][4], float timat[3][3],
                      const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval_fl[2],
                      float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
 {
@@ -1234,7 +1234,7 @@
 	return retval;
 }
 
-static bool snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[4][4], float timat[3][3],
+static bool snapVertex(ARegion *ar, const float vco[3], const short vno[3], float obmat[4][4], float timat[3][3],
                        const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval_fl[2],
                        float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
 {
@@ -1518,6 +1518,41 @@
 	return retval;
 } 
 
+/* may extend later (for now just snaps to empty center) */
+static bool snapEmpty(short snap_mode, ARegion *ar, Object *ob, float obmat[4][4],
+                      const float ray_start[3], const float ray_normal[3], const float mval[2],
+                      float r_loc[3], float *UNUSED(r_no), float *r_dist_px, float *r_depth)
+{
+	float imat[4][4];
+	float ray_start_local[3], ray_normal_local[3];
+	bool retval = false;
+
+	invert_m4_m4(imat, obmat);
+
+	copy_v3_v3(ray_start_local, ray_start);
+	copy_v3_v3(ray_normal_local, ray_normal);
+
+	mul_m4_v3(imat, ray_start_local);
+	mul_mat3_m4_v3(imat, ray_normal_local);
+
+	if (ob->transflag & OB_DUPLI) {
+		return retval;
+	}
+
+	switch (snap_mode) {
+		case SCE_SNAP_MODE_VERTEX:
+		{
+			const float zero_co[3] = {0.0f};
+			retval |= snapVertex(ar, zero_co, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+			break;
+		}
+		default:
+			break;
+	}
+
+	return retval;
+}
+
 static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, float obmat[4][4], bool use_obedit,
                        Object **r_ob, float r_obmat[4][4],
                        const float ray_start[3], const float ray_normal[3], const float mval[2],
@@ -1545,6 +1580,9 @@
 	else if (ob->type == OB_ARMATURE) {
 		retval = snapArmature(snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
 	}
+	else if (ob->type == OB_EMPTY) {
+		retval = snapEmpty(snap_mode, ar, ob, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
+	}
 	
 	if (retval) {
 		if (r_ob) {




More information about the Bf-blender-cvs mailing list