diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 2f392da..7179a6d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | |||
@@ -233,5 +233,46 @@ public class BSPrimLinkable : BSPrimDisplaced | |||
233 | base.HasSomeCollision = value; | 233 | base.HasSomeCollision = value; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | |||
237 | // Convert the existing linkset of this prim into a new type. | ||
238 | public bool ConvertLinkset(BSLinkset.LinksetImplementation newType) | ||
239 | { | ||
240 | bool ret = false; | ||
241 | if (LinksetType != newType) | ||
242 | { | ||
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; | ||
247 | BSLinkset newLinkset = BSLinkset.Factory(PhysScene, this); | ||
248 | |||
249 | this.Linkset = newLinkset; | ||
250 | |||
251 | // Pick up any physical dependencies this linkset might have in the physics engine. | ||
252 | oldLinkset.RemoveDependencies(this); | ||
253 | |||
254 | // Create a list of the children (mainly because can't interate through a list that's changing) | ||
255 | List<BSPrimLinkable> children = new List<BSPrimLinkable>(); | ||
256 | oldLinkset.ForEachMember((child) => | ||
257 | { | ||
258 | if (!oldLinkset.IsRoot(child)) | ||
259 | children.Add(child); | ||
260 | return false; // 'false' says to continue to next member | ||
261 | }); | ||
262 | |||
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 | } | ||
270 | |||
271 | // Force the shape and linkset to get reconstructed | ||
272 | newLinkset.Refresh(this); | ||
273 | this.ForceBodyShapeRebuild(true /* inTaintTime */); | ||
274 | } | ||
275 | return ret; | ||
276 | } | ||
236 | } | 277 | } |
237 | } | 278 | } |