aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs59
1 files changed, 30 insertions, 29 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 0df4310..1e3e5d8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -32,6 +32,15 @@ using OMV = OpenMetaverse;
32 32
33namespace OpenSim.Region.Physics.BulletSPlugin 33namespace OpenSim.Region.Physics.BulletSPlugin
34{ 34{
35
36// A BSPrim can get individual information about its linkedness attached
37// to it through an instance of a subclass of LinksetInfo.
38// Each type of linkset will define the information needed for its type.
39public abstract class BSLinksetInfo
40{
41 public virtual void Clear() { }
42}
43
35public abstract class BSLinkset 44public abstract class BSLinkset
36{ 45{
37 // private static string LogHeader = "[BULLETSIM LINKSET]"; 46 // private static string LogHeader = "[BULLETSIM LINKSET]";
@@ -47,7 +56,7 @@ public abstract class BSLinkset
47 { 56 {
48 BSLinkset ret = null; 57 BSLinkset ret = null;
49 58
50 switch ((int)physScene.Params.linksetImplementation) 59 switch ((int)BSParam.LinksetImplementation)
51 { 60 {
52 case (int)LinksetImplementation.Constraint: 61 case (int)LinksetImplementation.Constraint:
53 ret = new BSLinksetConstraints(physScene, parent); 62 ret = new BSLinksetConstraints(physScene, parent);
@@ -87,22 +96,8 @@ public abstract class BSLinkset
87 return BSPhysicsShapeType.SHAPE_UNKNOWN; 96 return BSPhysicsShapeType.SHAPE_UNKNOWN;
88 } 97 }
89 98
90 // Linksets move around the children so the linkset might need to compute the child position
91 public virtual OMV.Vector3 Position(BSPhysObject member)
92 { return member.RawPosition; }
93 public virtual OMV.Quaternion Orientation(BSPhysObject member)
94 { return member.RawOrientation; }
95 // TODO: does this need to be done for Velocity and RotationalVelocityy?
96
97 // We keep the prim's mass in the linkset structure since it could be dependent on other prims 99 // We keep the prim's mass in the linkset structure since it could be dependent on other prims
98 protected float m_mass; 100 public float LinksetMass { get; protected set; }
99 public float LinksetMass
100 {
101 get
102 {
103 return m_mass;
104 }
105 }
106 101
107 public virtual bool LinksetIsColliding { get { return false; } } 102 public virtual bool LinksetIsColliding { get { return false; } }
108 103
@@ -116,7 +111,7 @@ public abstract class BSLinkset
116 get { return ComputeLinksetGeometricCenter(); } 111 get { return ComputeLinksetGeometricCenter(); }
117 } 112 }
118 113
119 protected void Initialize(BSScene scene, BSPhysObject parent) 114 protected BSLinkset(BSScene scene, BSPhysObject parent)
120 { 115 {
121 // A simple linkset of one (no children) 116 // A simple linkset of one (no children)
122 LinksetID = m_nextLinksetID++; 117 LinksetID = m_nextLinksetID++;
@@ -126,7 +121,8 @@ public abstract class BSLinkset
126 PhysicsScene = scene; 121 PhysicsScene = scene;
127 LinksetRoot = parent; 122 LinksetRoot = parent;
128 m_children = new HashSet<BSPhysObject>(); 123 m_children = new HashSet<BSPhysObject>();
129 m_mass = parent.RawMass; 124 LinksetMass = parent.RawMass;
125 Rebuilding = false;
130 } 126 }
131 127
132 // Link to a linkset where the child knows the parent. 128 // Link to a linkset where the child knows the parent.
@@ -140,7 +136,7 @@ public abstract class BSLinkset
140 // Don't add the root to its own linkset 136 // Don't add the root to its own linkset
141 if (!IsRoot(child)) 137 if (!IsRoot(child))
142 AddChildToLinkset(child); 138 AddChildToLinkset(child);
143 m_mass = ComputeLinksetMass(); 139 LinksetMass = ComputeLinksetMass();
144 } 140 }
145 return this; 141 return this;
146 } 142 }
@@ -156,13 +152,15 @@ public abstract class BSLinkset
156 if (IsRoot(child)) 152 if (IsRoot(child))
157 { 153 {
158 // Cannot remove the root from a linkset. 154 // Cannot remove the root from a linkset.
155 child.PositionDisplacement = OMV.Vector3.Zero;
159 return this; 156 return this;
160 } 157 }
161 RemoveChildFromLinkset(child); 158 RemoveChildFromLinkset(child);
162 m_mass = ComputeLinksetMass(); 159 LinksetMass = ComputeLinksetMass();
163 } 160 }
164 161
165 // The child is down to a linkset of just itself 162 // The child is down to a linkset of just itself
163 child.PositionDisplacement = OMV.Vector3.Zero;
166 return BSLinkset.Factory(PhysicsScene, child); 164 return BSLinkset.Factory(PhysicsScene, child);
167 } 165 }
168 166
@@ -219,7 +217,7 @@ public abstract class BSLinkset
219 // I am the root of a linkset and a new child is being added 217 // I am the root of a linkset and a new child is being added
220 // Called while LinkActivity is locked. 218 // Called while LinkActivity is locked.
221 protected abstract void AddChildToLinkset(BSPhysObject child); 219 protected abstract void AddChildToLinkset(BSPhysObject child);
222 220
223 // I am the root of a linkset and one of my children is being removed. 221 // I am the root of a linkset and one of my children is being removed.
224 // Safe to call even if the child is not really in my linkset. 222 // Safe to call even if the child is not really in my linkset.
225 protected abstract void RemoveChildFromLinkset(BSPhysObject child); 223 protected abstract void RemoveChildFromLinkset(BSPhysObject child);
@@ -227,7 +225,14 @@ public abstract class BSLinkset
227 // When physical properties are changed the linkset needs to recalculate 225 // When physical properties are changed the linkset needs to recalculate
228 // its internal properties. 226 // its internal properties.
229 // May be called at runtime or taint-time. 227 // May be called at runtime or taint-time.
230 public abstract void Refresh(BSPhysObject requestor); 228 public virtual void Refresh(BSPhysObject requestor)
229 {
230 LinksetMass = ComputeLinksetMass();
231 }
232
233 // Flag denoting the linkset is in the process of being rebuilt.
234 // Used to know not the schedule a rebuild in the middle of a rebuild.
235 protected bool Rebuilding { get; set; }
231 236
232 // The object is going dynamic (physical). Do any setup necessary 237 // The object is going dynamic (physical). Do any setup necessary
233 // for a dynamic linkset. 238 // for a dynamic linkset.
@@ -245,8 +250,9 @@ public abstract class BSLinkset
245 250
246 // Called when a parameter update comes from the physics engine for any object 251 // Called when a parameter update comes from the physics engine for any object
247 // of the linkset is received. 252 // of the linkset is received.
253 // Passed flag is update came from physics engine (true) or the user (false).
248 // Called at taint-time!! 254 // Called at taint-time!!
249 public abstract void UpdateProperties(BSPhysObject physObject); 255 public abstract void UpdateProperties(UpdatedProperties whichUpdated, BSPhysObject physObject);
250 256
251 // Routine used when rebuilding the body of the root of the linkset 257 // Routine used when rebuilding the body of the root of the linkset
252 // Destroy all the constraints have have been made to root. 258 // Destroy all the constraints have have been made to root.
@@ -255,11 +261,6 @@ public abstract class BSLinkset
255 // Called at taint-time!! 261 // Called at taint-time!!
256 public abstract bool RemoveBodyDependencies(BSPrim child); 262 public abstract bool RemoveBodyDependencies(BSPrim child);
257 263
258 // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true',
259 // this routine will restore the removed constraints.
260 // Called at taint-time!!
261 public abstract void RestoreBodyDependencies(BSPrim child);
262
263 // ================================================================ 264 // ================================================================
264 protected virtual float ComputeLinksetMass() 265 protected virtual float ComputeLinksetMass()
265 { 266 {
@@ -306,7 +307,7 @@ public abstract class BSLinkset
306 307
307 foreach (BSPhysObject bp in m_children) 308 foreach (BSPhysObject bp in m_children)
308 { 309 {
309 com += bp.Position * bp.RawMass; 310 com += bp.Position;
310 } 311 }
311 com /= (m_children.Count + 1); 312 com /= (m_children.Count + 1);
312 } 313 }