From 1daec26ba0355f0c7d77c790a52546db6435968a Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Thu, 17 Jul 2014 21:41:39 -0700
Subject: BulletSim: rearrange code to prevent using null pointers when a child
 mesh is not available when building a linkset.

---
 .../Physics/BulletSPlugin/BSLinksetCompound.cs      | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 5217452..5a9e9ff 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -385,6 +385,16 @@ public sealed class BSLinksetCompound : BSLinkset
                     m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot);
                     DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}",
                                 LinksetRoot.LocalID, cPrim.LinksetChildIndex, childShape, offsetPos, offsetRot);
+
+                    // Since we are borrowing the shape of the child, disable the origional child body
+                    if (!IsRoot(cPrim))
+                    {
+                        m_physicsScene.PE.AddToCollisionFlags(cPrim.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
+                        m_physicsScene.PE.ForceActivationState(cPrim.PhysBody, ActivationState.DISABLE_SIMULATION);
+                        // We don't want collisions from the old linkset children.
+                        m_physicsScene.PE.RemoveFromCollisionFlags(cPrim.PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
+                        cPrim.PhysBody.collisionType = CollisionType.LinksetChild;
+                    }
                 }
                 else
                 {
@@ -404,20 +414,9 @@ public sealed class BSLinksetCompound : BSLinkset
                         m_physicsScene.Logger.WarnFormat("{0} Linkset rebuild warning. If this happens more than one or two times, please report in Mantis 7191", LogHeader);
                         m_physicsScene.Logger.WarnFormat("{0} pName={1}, childIdx={2}, shape={3}",
                                         LogHeader, LinksetRoot.Name, cPrim.LinksetChildIndex, childShape);
-                        return false;   // 'false' says to move onto the next child in the list
                     }
                 }
 
-                // Since we are borrowing the shape of the child, disable the origional child body
-                if (!IsRoot(cPrim))
-                {
-                    m_physicsScene.PE.AddToCollisionFlags(cPrim.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
-                    m_physicsScene.PE.ForceActivationState(cPrim.PhysBody, ActivationState.DISABLE_SIMULATION);
-                    // We don't want collisions from the old linkset children.
-                    m_physicsScene.PE.RemoveFromCollisionFlags(cPrim.PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
-                    cPrim.PhysBody.collisionType = CollisionType.LinksetChild;
-                }
-
                 return false;   // 'false' says to move onto the next child in the list
             });
 
-- 
cgit v1.1