Revision: 30524
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30524
Author:   aligorith
Date:     2010-07-20 11:30:12 +0200 (Tue, 20 Jul 2010)

Log Message:
-----------
Bullet SoC - Bugfix - Removing Rigid Bodies causes crashes when playing back

Rigid Bodies were not getting removed from the sim scene(s) correctly, so 
Bullet was crashing when trying to simulate the non-existent sim-objects.

Modified Paths:
--------------
    
branches/soc-2010-aligorith-2/source/blender/editors/physics/rigidbody_object.c

Modified: 
branches/soc-2010-aligorith-2/source/blender/editors/physics/rigidbody_object.c
===================================================================
--- 
branches/soc-2010-aligorith-2/source/blender/editors/physics/rigidbody_object.c 
    2010-07-20 06:05:25 UTC (rev 30523)
+++ 
branches/soc-2010-aligorith-2/source/blender/editors/physics/rigidbody_object.c 
    2010-07-20 09:30:12 UTC (rev 30524)
@@ -40,6 +40,8 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 
+#include "RBI_api.h"
+
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_group.h"
@@ -130,9 +132,25 @@
 {
        RigidBodyWorld *rbw;
        
-       /* remove object's rigidbody stuff from all worlds */
+       /* remove world-sim references to object 
+        * NOTE: done as a separate pass since static objects can be 
+        * added to multiple sims at once, so doing below would miss
+        * other instances.
+        */
        RB_WORLDS_WITH_OB_LOOPER(scene, ob, rbw)
        {
+               RigidBodyOb *rbo = ob->rigidbodySettings;
+               
+               /* remove from rigidbody world too 
+                *      - free object won't do this 
+                */
+               if (rbw->physics_world && rbo->physics_object)
+                       rbDWorldRemoveBody(rbw->physics_world, 
rbo->physics_object);
+       }
+       
+       /* remove object's rigidbody settings */
+       RB_WORLDS_WITH_OB_LOOPER(scene, ob, rbw)
+       {       
                /* remove from group */
                rem_from_group(rbw->group, ob, scene, NULL);
                


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to