diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 29 |
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 | } |