Revision: 31226 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31226 Author: aligorith Date: 2010-08-11 03:59:10 +0200 (Wed, 11 Aug 2010)
Log Message: ----------- Bullet SoC - Collision shapes are now updated when object data (i.e. geometry) changes, so they don't need to be manually rebuilt anymore. Also while testing this, I noticed a few things: - it seems that the GImpact concave meshes handle collision detection much better for certain test cases, whereas BVH-Triangle Shapes would just let the shapes fall through/no tumbling. Funnily, enough, this didn't happen last time I tried - got a crash the first time I tested after making these changes, but haven't been able to repeat it yet Modified Paths: -------------- branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/depsgraph.c branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c branches/soc-2010-aligorith-2/source/blender/makesdna/DNA_rigidbody_types.h Modified: branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/depsgraph.c =================================================================== --- branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/depsgraph.c 2010-08-11 00:38:12 UTC (rev 31225) +++ branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/depsgraph.c 2010-08-11 01:59:10 UTC (rev 31226) @@ -2282,17 +2282,30 @@ ob= (Object*)id; ob->recalc |= (flag & OB_RECALC); BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH); - + if(flag & OB_RECALC_DATA) { /* all users of this ob->data should be checked */ id= ob->data; - + /* no point in trying in this cases */ if(!id || id->us <= 1) id= NULL; /* for locked shape keys we make an exception */ else if(ob_get_key(ob) && (ob->shapeflag & OB_SHAPE_LOCK)) id= NULL; + + /* for Rigid Bodies, force update if shape depends on the data */ + if (ob->rigidbodySettings) { + RigidBodyOb *rbo = ob->rigidbodySettings; + + /* While strictly only the mesh-shapes really need rebuilding, + * the other shapes also do since they use the bounds. + * + * Also, this only really applies for geometry bodies (hence the check) + */ + if (ELEM(rbo->type, RBO_TYPE_ACTIVE, RBO_TYPE_PASSIVE)) + rbo->flag |= RBO_FLAG_NEEDS_RESHAPE; + } } } Modified: branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c =================================================================== --- branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c 2010-08-11 00:38:12 UTC (rev 31225) +++ branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c 2010-08-11 01:59:10 UTC (rev 31226) @@ -775,15 +775,29 @@ rbo = ob->rigidbodySettings; } - else if (rbo->flag & RBO_FLAG_NEEDS_VALIDATE) { - /* there are settings, but the object(s) must be rebuilt (i.e. after being duplicated) */ - BKE_rigidbody_validate_sim_object(rbw, ob, 1); - rbo->flag &= ~RBO_FLAG_NEEDS_VALIDATE; + else { + /* perform simulation data updates as tagged */ + /* refresh object... */ + if (rbo->flag & RBO_FLAG_NEEDS_VALIDATE) { + /* there are settings, but the object(s) must be rebuilt (i.e. after being duplicated) */ + BKE_rigidbody_validate_sim_object(rbw, ob, 1); + } + else if (rbw->recalc & RBW_RECALC_REBUILD) { + /* there are settings, but the object(s) must be rebuilt (i.e. after file-reload) */ + BKE_rigidbody_validate_sim_object(rbw, ob, 1); + } + /* refresh shape... */ + else if (rbo->flag & RBO_FLAG_NEEDS_RESHAPE) { + /* mesh/shape data changed, so force shape refresh */ + BKE_rigidbody_validate_sim_shape(ob, 1); + + /* now tell RB sim about it */ + // XXX: we assume that this can only get applied for active/passive shapes that will be included as rigidbodies + rbBodySetCollisionShape(rbo->physics_object, rbo->physics_shape); + } + + rbo->flag &= ~(RBO_FLAG_NEEDS_VALIDATE|RBO_FLAG_NEEDS_RESHAPE); } - else if (rbw->recalc & RBW_RECALC_REBUILD) { - /* there are settings, but the object(s) must be rebuilt (i.e. after file-reload) */ - BKE_rigidbody_validate_sim_object(rbw, ob, 1); - } /* update simulation object... */ rigidbody_update_sim_ob(scene, rbw, ob, rbo); Modified: branches/soc-2010-aligorith-2/source/blender/makesdna/DNA_rigidbody_types.h =================================================================== --- branches/soc-2010-aligorith-2/source/blender/makesdna/DNA_rigidbody_types.h 2010-08-11 00:38:12 UTC (rev 31225) +++ branches/soc-2010-aligorith-2/source/blender/makesdna/DNA_rigidbody_types.h 2010-08-11 01:59:10 UTC (rev 31226) @@ -144,6 +144,8 @@ RBO_FLAG_DYNAMIC_EVAL = (1<<0), /* rigidbody needs to be validated (usually set after duplicating and not hooked up yet) */ RBO_FLAG_NEEDS_VALIDATE = (1<<1), + /* rigidbody shape needs refreshing (usually after exiting editmode) */ + RBO_FLAG_NEEDS_RESHAPE = (1<<2), } eRigidBodyOb_Flag; /* RigidBody Collision Shape */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs