diff options
author | Robert Adams | 2013-08-01 17:43:06 -0700 |
---|---|---|
committer | Robert Adams | 2013-08-02 09:47:12 -0700 |
commit | 24df15dab7befd50f7a45eb54f001e6e481f0ec4 (patch) | |
tree | f3502a9782d68848c00fe3cb9b4b2a04dfa91f61 /OpenSim/Region/Physics | |
parent | BulletSim: add BSLinkInfo structure to remember link specific information (diff) | |
download | opensim-SC-24df15dab7befd50f7a45eb54f001e6e481f0ec4.zip opensim-SC-24df15dab7befd50f7a45eb54f001e6e481f0ec4.tar.gz opensim-SC-24df15dab7befd50f7a45eb54f001e6e481f0ec4.tar.bz2 opensim-SC-24df15dab7befd50f7a45eb54f001e6e481f0ec4.tar.xz |
BulletSim: add implementation of 'physSetLinksetType' and 'physGetLinksetType'
and processing routines in BulletSim.
Add linkset rebuild/conversion routine in BSLinkset.
Diffstat (limited to 'OpenSim/Region/Physics')
8 files changed, 99 insertions, 2 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 9613fe0..3afd52e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -79,6 +79,8 @@ public abstract class BSLinkset | |||
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | public LinksetImplementation LinksetImpl { get; protected set; } | ||
83 | |||
82 | public BSPrimLinkable LinksetRoot { get; protected set; } | 84 | public BSPrimLinkable LinksetRoot { get; protected set; } |
83 | 85 | ||
84 | protected BSScene m_physicsScene { get; private set; } | 86 | protected BSScene m_physicsScene { get; private set; } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 53c3584..085d195 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -42,6 +42,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
42 | public BSLinksetCompound(BSScene scene, BSPrimLinkable parent) | 42 | public BSLinksetCompound(BSScene scene, BSPrimLinkable parent) |
43 | : base(scene, parent) | 43 | : base(scene, parent) |
44 | { | 44 | { |
45 | LinksetImpl = LinksetImplementation.Compound; | ||
45 | } | 46 | } |
46 | 47 | ||
47 | // ================================================================ | 48 | // ================================================================ |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index d98bf77..4bac222 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | |||
@@ -107,6 +107,7 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
107 | 107 | ||
108 | public BSLinksetConstraints(BSScene scene, BSPrimLinkable parent) : base(scene, parent) | 108 | public BSLinksetConstraints(BSScene scene, BSPrimLinkable parent) : base(scene, parent) |
109 | { | 109 | { |
110 | LinksetImpl = LinksetImplementation.Constraint; | ||
110 | } | 111 | } |
111 | 112 | ||
112 | // When physical properties are changed the linkset needs to recalculate | 113 | // When physical properties are changed the linkset needs to recalculate |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index e92a1d2..a0b6abc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -1541,6 +1541,50 @@ public class BSPrim : BSPhysObject | |||
1541 | PhysicalActors.RemoveDependencies(); | 1541 | PhysicalActors.RemoveDependencies(); |
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | #region Extension | ||
1545 | public override object Extension(string pFunct, params object[] pParams) | ||
1546 | { | ||
1547 | object ret = null; | ||
1548 | switch (pFunct) | ||
1549 | { | ||
1550 | case BSScene.PhysFunctGetLinksetType: | ||
1551 | { | ||
1552 | BSPrimLinkable myHandle = this as BSPrimLinkable; | ||
1553 | if (myHandle != null) | ||
1554 | { | ||
1555 | ret = (object)myHandle.LinksetType; | ||
1556 | } | ||
1557 | m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret); | ||
1558 | break; | ||
1559 | } | ||
1560 | case BSScene.PhysFunctSetLinksetType: | ||
1561 | { | ||
1562 | if (pParams.Length > 0) | ||
1563 | { | ||
1564 | BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[0]; | ||
1565 | BSPrimLinkable myHandle = this as BSPrimLinkable; | ||
1566 | if (myHandle != null && myHandle.Linkset.IsRoot(myHandle)) | ||
1567 | { | ||
1568 | PhysScene.TaintedObject("BSPrim.PhysFunctSetLinksetType", delegate() | ||
1569 | { | ||
1570 | // Cause the linkset type to change | ||
1571 | m_log.DebugFormat("{0} Extension.physSetLinksetType, oldType={1}, newType={2}", | ||
1572 | LogHeader, myHandle.Linkset.LinksetImpl, linksetType); | ||
1573 | myHandle.ConvertLinkset(linksetType); | ||
1574 | }); | ||
1575 | } | ||
1576 | ret = (object)(int)linksetType; | ||
1577 | } | ||
1578 | break; | ||
1579 | } | ||
1580 | default: | ||
1581 | ret = base.Extension(pFunct, pParams); | ||
1582 | break; | ||
1583 | } | ||
1584 | return ret; | ||
1585 | } | ||
1586 | #endregion // Extension | ||
1587 | |||
1544 | // The physics engine says that properties have updated. Update same and inform | 1588 | // The physics engine says that properties have updated. Update same and inform |
1545 | // the world that things have changed. | 1589 | // the world that things have changed. |
1546 | // NOTE: BSPrim.UpdateProperties is overloaded by BSPrimLinkable which modifies updates from root and children prims. | 1590 | // NOTE: BSPrim.UpdateProperties is overloaded by BSPrimLinkable which modifies updates from root and children prims. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 2f392da..c565998 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | |||
@@ -233,5 +233,35 @@ 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 | BSLinkset oldLinkset = Linkset; | ||
244 | BSLinkset newLinkset = BSLinkset.Factory(PhysScene, this); | ||
245 | |||
246 | // Pick up any physical dependencies this linkset might have in the physics engine. | ||
247 | oldLinkset.RemoveDependencies(this); | ||
248 | |||
249 | // Copy the linkset children from the old linkset to the new (will be a new instance from the factory) | ||
250 | oldLinkset.ForEachLinkInfo((li) => | ||
251 | { | ||
252 | oldLinkset.RemoveMeFromLinkset(li.member); | ||
253 | newLinkset.AddMeToLinkset(li.member); | ||
254 | li.member.Linkset = newLinkset; | ||
255 | return false; | ||
256 | }); | ||
257 | |||
258 | this.Linkset = newLinkset; | ||
259 | |||
260 | // Force the shape and linkset to get reconstructed | ||
261 | newLinkset.Refresh(this); | ||
262 | this.ForceBodyShapeRebuild(true); | ||
263 | } | ||
264 | return ret; | ||
265 | } | ||
236 | } | 266 | } |
237 | } | 267 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 41aca3b..79ac5a5 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -862,6 +862,23 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
862 | 862 | ||
863 | public override bool IsThreaded { get { return false; } } | 863 | public override bool IsThreaded { get { return false; } } |
864 | 864 | ||
865 | #region Extensions | ||
866 | // ============================================================= | ||
867 | // Per scene functions. See below. | ||
868 | |||
869 | // Per avatar functions. See BSCharacter. | ||
870 | |||
871 | // Per prim functions. See BSPrim. | ||
872 | public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; | ||
873 | public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; | ||
874 | // ============================================================= | ||
875 | |||
876 | public override object Extension(string pFunct, params object[] pParams) | ||
877 | { | ||
878 | return base.Extension(pFunct, pParams); | ||
879 | } | ||
880 | #endregion // Extensions | ||
881 | |||
865 | #region Taints | 882 | #region Taints |
866 | // The simulation execution order is: | 883 | // The simulation execution order is: |
867 | // Simulate() | 884 | // Simulate() |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 2500f27..1750853 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -317,7 +317,8 @@ namespace OpenSim.Region.Physics.Manager | |||
317 | // Extendable interface for new, physics engine specific operations | 317 | // Extendable interface for new, physics engine specific operations |
318 | public virtual object Extension(string pFunct, params object[] pParams) | 318 | public virtual object Extension(string pFunct, params object[] pParams) |
319 | { | 319 | { |
320 | throw new NotImplementedException(); | 320 | // A NOP of the physics engine does not implement this feature |
321 | return null; | ||
321 | } | 322 | } |
322 | } | 323 | } |
323 | 324 | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 07a1d36..c93206d 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs | |||
@@ -338,7 +338,8 @@ namespace OpenSim.Region.Physics.Manager | |||
338 | // Extendable interface for new, physics engine specific operations | 338 | // Extendable interface for new, physics engine specific operations |
339 | public virtual object Extension(string pFunct, params object[] pParams) | 339 | public virtual object Extension(string pFunct, params object[] pParams) |
340 | { | 340 | { |
341 | throw new NotImplementedException(); | 341 | // A NOP if the extension thing is not implemented by the physics engine |
342 | return null; | ||
342 | } | 343 | } |
343 | } | 344 | } |
344 | } | 345 | } |