aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
authorRobert Adams2013-08-02 10:32:43 -0700
committerRobert Adams2013-08-02 10:32:43 -0700
commit5bdfd55ace4b673d8aaa3f25fd4bb675b1b28263 (patch)
tree8d5ac69fdfd43b44290554bcaaed80ade52c9501 /OpenSim/Region/Physics/BulletSPlugin
parentBulletSim: add implementation of 'physSetLinksetType' and 'physGetLinksetType' (diff)
downloadopensim-SC-5bdfd55ace4b673d8aaa3f25fd4bb675b1b28263.zip
opensim-SC-5bdfd55ace4b673d8aaa3f25fd4bb675b1b28263.tar.gz
opensim-SC-5bdfd55ace4b673d8aaa3f25fd4bb675b1b28263.tar.bz2
opensim-SC-5bdfd55ace4b673d8aaa3f25fd4bb675b1b28263.tar.xz
BulletSim: When converting linkset types, don't try to change the list
of linkset children while iterating through the list.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs29
1 files changed, 20 insertions, 9 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index c565998..7179a6d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -240,26 +240,37 @@ public class BSPrimLinkable : BSPrimDisplaced
240 bool ret = false; 240 bool ret = false;
241 if (LinksetType != newType) 241 if (LinksetType != newType)
242 { 242 {
243 BSLinkset oldLinkset = Linkset; 243 // Set the implementation type first so the call to BSLinkset.Factory gets the new type.
244 this.LinksetType = newType;
245
246 BSLinkset oldLinkset = this.Linkset;
244 BSLinkset newLinkset = BSLinkset.Factory(PhysScene, this); 247 BSLinkset newLinkset = BSLinkset.Factory(PhysScene, this);
245 248
249 this.Linkset = newLinkset;
250
246 // Pick up any physical dependencies this linkset might have in the physics engine. 251 // Pick up any physical dependencies this linkset might have in the physics engine.
247 oldLinkset.RemoveDependencies(this); 252 oldLinkset.RemoveDependencies(this);
248 253
249 // Copy the linkset children from the old linkset to the new (will be a new instance from the factory) 254 // Create a list of the children (mainly because can't interate through a list that's changing)
250 oldLinkset.ForEachLinkInfo((li) => 255 List<BSPrimLinkable> children = new List<BSPrimLinkable>();
256 oldLinkset.ForEachMember((child) =>
251 { 257 {
252 oldLinkset.RemoveMeFromLinkset(li.member); 258 if (!oldLinkset.IsRoot(child))
253 newLinkset.AddMeToLinkset(li.member); 259 children.Add(child);
254 li.member.Linkset = newLinkset; 260 return false; // 'false' says to continue to next member
255 return false;
256 }); 261 });
257 262
258 this.Linkset = newLinkset; 263 // Remove the children from the old linkset and add to the new (will be a new instance from the factory)
264 foreach (BSPrimLinkable child in children)
265 {
266 oldLinkset.RemoveMeFromLinkset(child);
267 newLinkset.AddMeToLinkset(child);
268 child.Linkset = newLinkset;
269 }
259 270
260 // Force the shape and linkset to get reconstructed 271 // Force the shape and linkset to get reconstructed
261 newLinkset.Refresh(this); 272 newLinkset.Refresh(this);
262 this.ForceBodyShapeRebuild(true); 273 this.ForceBodyShapeRebuild(true /* inTaintTime */);
263 } 274 }
264 return ret; 275 return ret;
265 } 276 }