[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57526] branches/soc-2013-rigid_body_sim/ source/blender/blenkernel/intern/rigidbody.c: rigidbody: Take deformations into account when creating collision shapes

Sergej Reich sergej.reich at googlemail.com
Mon Jun 17 18:49:12 CEST 2013


Revision: 57526
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57526
Author:   sergof
Date:     2013-06-17 16:49:11 +0000 (Mon, 17 Jun 2013)
Log Message:
-----------
rigidbody: Take deformations into account when creating collision shapes

TODO: Make sure ob->derivedDeform always esists.

Modified Paths:
--------------
    branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c

Modified: branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c
===================================================================
--- branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c	2013-06-17 16:12:55 UTC (rev 57525)
+++ branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c	2013-06-17 16:49:11 UTC (rev 57526)
@@ -229,17 +229,22 @@
 static rbCollisionShape *rigidbody_get_shape_convexhull_from_mesh(Object *ob, float margin, bool *can_embed)
 {
 	rbCollisionShape *shape = NULL;
-	Mesh *me = NULL;
+	DerivedMesh *dm = NULL;
+	MVert *mvert = NULL;
+	int totvert = 0;
 
 	if (ob->type == OB_MESH && ob->data) {
-		me = ob->data;
+		BLI_assert(ob->derivedDeform != NULL); // RB_TODO need to make sure there's no case where deform derived mesh doesn't exist
+		dm = ob->derivedDeform;
+		mvert   = (dm) ? dm->getVertArray(dm) : NULL;
+		totvert = (dm) ? dm->getNumVerts(dm) : 0;
 	}
 	else {
 		printf("ERROR: cannot make Convex Hull collision shape for non-Mesh object\n");
 	}
 
-	if (me && me->totvert) {
-		shape = RB_shape_new_convex_hull((float *)me->mvert, sizeof(MVert), me->totvert, margin, can_embed);
+	if (totvert) {
+		shape = RB_shape_new_convex_hull((float *)mvert, sizeof(MVert), totvert, margin, can_embed);
 	}
 	else {
 		printf("ERROR: no vertices to define Convex Hull collision shape with\n");
@@ -256,7 +261,7 @@
 	rbCollisionShape *shape = NULL;
 
 	if (ob->type == OB_MESH) {
-		DerivedMesh *dm = CDDM_from_mesh(ob->data, ob);
+		DerivedMesh *dm = ob->derivedDeform;
 
 		MVert *mvert;
 		MFace *mface;
@@ -264,6 +269,7 @@
 		int totface;
 
 		/* ensure mesh validity, then grab data */
+		BLI_assert(dm!= NULL); // RB_TODO need to make sure there's no case where deform derived mesh doesn't exist
 		DM_ensure_tessface(dm);
 
 		mvert   = (dm) ? dm->getVertArray(dm) : NULL;




More information about the Bf-blender-cvs mailing list