aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
diff options
context:
space:
mode:
authorRobert Adams2013-02-07 21:57:31 -0800
committerRobert Adams2013-02-08 16:29:29 -0800
commit1b203601f43662541526369f540dd04f5b485be6 (patch)
tree418bae04970c59ed4ab7653686843bc2e916b730 /OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
parentBulletSim: reclass BSPrim into layers so linkset and physical world displacem... (diff)
downloadopensim-SC_OLD-1b203601f43662541526369f540dd04f5b485be6.zip
opensim-SC_OLD-1b203601f43662541526369f540dd04f5b485be6.tar.gz
opensim-SC_OLD-1b203601f43662541526369f540dd04f5b485be6.tar.bz2
opensim-SC_OLD-1b203601f43662541526369f540dd04f5b485be6.tar.xz
BulletSim: include the linkage to the layered prim implementation. Separate layers for physical (vs simulator) location displacement and linksets.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs48
1 files changed, 23 insertions, 25 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 1e3e5d8..8e69db3 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -52,7 +52,7 @@ public abstract class BSLinkset
52 Manual = 2 // linkset tied together manually (code moves all the pieces) 52 Manual = 2 // linkset tied together manually (code moves all the pieces)
53 } 53 }
54 // Create the correct type of linkset for this child 54 // Create the correct type of linkset for this child
55 public static BSLinkset Factory(BSScene physScene, BSPhysObject parent) 55 public static BSLinkset Factory(BSScene physScene, BSPrimLinkable parent)
56 { 56 {
57 BSLinkset ret = null; 57 BSLinkset ret = null;
58 58
@@ -74,7 +74,7 @@ public abstract class BSLinkset
74 return ret; 74 return ret;
75 } 75 }
76 76
77 public BSPhysObject LinksetRoot { get; protected set; } 77 public BSPrimLinkable LinksetRoot { get; protected set; }
78 78
79 public BSScene PhysicsScene { get; private set; } 79 public BSScene PhysicsScene { get; private set; }
80 80
@@ -82,7 +82,7 @@ public abstract class BSLinkset
82 public int LinksetID { get; private set; } 82 public int LinksetID { get; private set; }
83 83
84 // The children under the root in this linkset. 84 // The children under the root in this linkset.
85 protected HashSet<BSPhysObject> m_children; 85 protected HashSet<BSPrimLinkable> m_children;
86 86
87 // We lock the diddling of linkset classes to prevent any badness. 87 // We lock the diddling of linkset classes to prevent any badness.
88 // This locks the modification of the instances of this class. Changes 88 // This locks the modification of the instances of this class. Changes
@@ -91,7 +91,7 @@ public abstract class BSLinkset
91 91
92 // Some linksets have a preferred physical shape. 92 // Some linksets have a preferred physical shape.
93 // Returns SHAPE_UNKNOWN if there is no preference. Causes the correct shape to be selected. 93 // Returns SHAPE_UNKNOWN if there is no preference. Causes the correct shape to be selected.
94 public virtual BSPhysicsShapeType PreferredPhysicalShape(BSPhysObject requestor) 94 public virtual BSPhysicsShapeType PreferredPhysicalShape(BSPrimLinkable requestor)
95 { 95 {
96 return BSPhysicsShapeType.SHAPE_UNKNOWN; 96 return BSPhysicsShapeType.SHAPE_UNKNOWN;
97 } 97 }
@@ -111,7 +111,7 @@ public abstract class BSLinkset
111 get { return ComputeLinksetGeometricCenter(); } 111 get { return ComputeLinksetGeometricCenter(); }
112 } 112 }
113 113
114 protected BSLinkset(BSScene scene, BSPhysObject parent) 114 protected BSLinkset(BSScene scene, BSPrimLinkable parent)
115 { 115 {
116 // A simple linkset of one (no children) 116 // A simple linkset of one (no children)
117 LinksetID = m_nextLinksetID++; 117 LinksetID = m_nextLinksetID++;
@@ -120,7 +120,7 @@ public abstract class BSLinkset
120 m_nextLinksetID = 1; 120 m_nextLinksetID = 1;
121 PhysicsScene = scene; 121 PhysicsScene = scene;
122 LinksetRoot = parent; 122 LinksetRoot = parent;
123 m_children = new HashSet<BSPhysObject>(); 123 m_children = new HashSet<BSPrimLinkable>();
124 LinksetMass = parent.RawMass; 124 LinksetMass = parent.RawMass;
125 Rebuilding = false; 125 Rebuilding = false;
126 } 126 }
@@ -129,7 +129,7 @@ public abstract class BSLinkset
129 // Parent changing should not happen so do some sanity checking. 129 // Parent changing should not happen so do some sanity checking.
130 // We return the parent's linkset so the child can track its membership. 130 // We return the parent's linkset so the child can track its membership.
131 // Called at runtime. 131 // Called at runtime.
132 public BSLinkset AddMeToLinkset(BSPhysObject child) 132 public BSLinkset AddMeToLinkset(BSPrimLinkable child)
133 { 133 {
134 lock (m_linksetActivityLock) 134 lock (m_linksetActivityLock)
135 { 135 {
@@ -145,14 +145,13 @@ public abstract class BSLinkset
145 // Returns a new linkset for the child which is a linkset of one (just the 145 // Returns a new linkset for the child which is a linkset of one (just the
146 // orphened child). 146 // orphened child).
147 // Called at runtime. 147 // Called at runtime.
148 public BSLinkset RemoveMeFromLinkset(BSPhysObject child) 148 public BSLinkset RemoveMeFromLinkset(BSPrimLinkable child)
149 { 149 {
150 lock (m_linksetActivityLock) 150 lock (m_linksetActivityLock)
151 { 151 {
152 if (IsRoot(child)) 152 if (IsRoot(child))
153 { 153 {
154 // Cannot remove the root from a linkset. 154 // Cannot remove the root from a linkset.
155 child.PositionDisplacement = OMV.Vector3.Zero;
156 return this; 155 return this;
157 } 156 }
158 RemoveChildFromLinkset(child); 157 RemoveChildFromLinkset(child);
@@ -160,12 +159,11 @@ public abstract class BSLinkset
160 } 159 }
161 160
162 // The child is down to a linkset of just itself 161 // The child is down to a linkset of just itself
163 child.PositionDisplacement = OMV.Vector3.Zero;
164 return BSLinkset.Factory(PhysicsScene, child); 162 return BSLinkset.Factory(PhysicsScene, child);
165 } 163 }
166 164
167 // Return 'true' if the passed object is the root object of this linkset 165 // Return 'true' if the passed object is the root object of this linkset
168 public bool IsRoot(BSPhysObject requestor) 166 public bool IsRoot(BSPrimLinkable requestor)
169 { 167 {
170 return (requestor.LocalID == LinksetRoot.LocalID); 168 return (requestor.LocalID == LinksetRoot.LocalID);
171 } 169 }
@@ -176,14 +174,14 @@ public abstract class BSLinkset
176 public bool HasAnyChildren { get { return (m_children.Count > 0); } } 174 public bool HasAnyChildren { get { return (m_children.Count > 0); } }
177 175
178 // Return 'true' if this child is in this linkset 176 // Return 'true' if this child is in this linkset
179 public bool HasChild(BSPhysObject child) 177 public bool HasChild(BSPrimLinkable child)
180 { 178 {
181 bool ret = false; 179 bool ret = false;
182 lock (m_linksetActivityLock) 180 lock (m_linksetActivityLock)
183 { 181 {
184 ret = m_children.Contains(child); 182 ret = m_children.Contains(child);
185 /* Safer version but the above should work 183 /* Safer version but the above should work
186 foreach (BSPhysObject bp in m_children) 184 foreach (BSPrimLinkable bp in m_children)
187 { 185 {
188 if (child.LocalID == bp.LocalID) 186 if (child.LocalID == bp.LocalID)
189 { 187 {
@@ -198,14 +196,14 @@ public abstract class BSLinkset
198 196
199 // Perform an action on each member of the linkset including root prim. 197 // Perform an action on each member of the linkset including root prim.
200 // Depends on the action on whether this should be done at taint time. 198 // Depends on the action on whether this should be done at taint time.
201 public delegate bool ForEachMemberAction(BSPhysObject obj); 199 public delegate bool ForEachMemberAction(BSPrimLinkable obj);
202 public virtual bool ForEachMember(ForEachMemberAction action) 200 public virtual bool ForEachMember(ForEachMemberAction action)
203 { 201 {
204 bool ret = false; 202 bool ret = false;
205 lock (m_linksetActivityLock) 203 lock (m_linksetActivityLock)
206 { 204 {
207 action(LinksetRoot); 205 action(LinksetRoot);
208 foreach (BSPhysObject po in m_children) 206 foreach (BSPrimLinkable po in m_children)
209 { 207 {
210 if (action(po)) 208 if (action(po))
211 break; 209 break;
@@ -216,16 +214,16 @@ public abstract class BSLinkset
216 214
217 // I am the root of a linkset and a new child is being added 215 // I am the root of a linkset and a new child is being added
218 // Called while LinkActivity is locked. 216 // Called while LinkActivity is locked.
219 protected abstract void AddChildToLinkset(BSPhysObject child); 217 protected abstract void AddChildToLinkset(BSPrimLinkable child);
220 218
221 // I am the root of a linkset and one of my children is being removed. 219 // I am the root of a linkset and one of my children is being removed.
222 // Safe to call even if the child is not really in my linkset. 220 // Safe to call even if the child is not really in my linkset.
223 protected abstract void RemoveChildFromLinkset(BSPhysObject child); 221 protected abstract void RemoveChildFromLinkset(BSPrimLinkable child);
224 222
225 // When physical properties are changed the linkset needs to recalculate 223 // When physical properties are changed the linkset needs to recalculate
226 // its internal properties. 224 // its internal properties.
227 // May be called at runtime or taint-time. 225 // May be called at runtime or taint-time.
228 public virtual void Refresh(BSPhysObject requestor) 226 public virtual void Refresh(BSPrimLinkable requestor)
229 { 227 {
230 LinksetMass = ComputeLinksetMass(); 228 LinksetMass = ComputeLinksetMass();
231 } 229 }
@@ -240,26 +238,26 @@ public abstract class BSLinkset
240 // has not yet been fully constructed. 238 // has not yet been fully constructed.
241 // Return 'true' if any properties updated on the passed object. 239 // Return 'true' if any properties updated on the passed object.
242 // Called at taint-time! 240 // Called at taint-time!
243 public abstract bool MakeDynamic(BSPhysObject child); 241 public abstract bool MakeDynamic(BSPrimLinkable child);
244 242
245 // The object is going static (non-physical). Do any setup necessary 243 // The object is going static (non-physical). Do any setup necessary
246 // for a static linkset. 244 // for a static linkset.
247 // Return 'true' if any properties updated on the passed object. 245 // Return 'true' if any properties updated on the passed object.
248 // Called at taint-time! 246 // Called at taint-time!
249 public abstract bool MakeStatic(BSPhysObject child); 247 public abstract bool MakeStatic(BSPrimLinkable child);
250 248
251 // Called when a parameter update comes from the physics engine for any object 249 // Called when a parameter update comes from the physics engine for any object
252 // of the linkset is received. 250 // of the linkset is received.
253 // Passed flag is update came from physics engine (true) or the user (false). 251 // Passed flag is update came from physics engine (true) or the user (false).
254 // Called at taint-time!! 252 // Called at taint-time!!
255 public abstract void UpdateProperties(UpdatedProperties whichUpdated, BSPhysObject physObject); 253 public abstract void UpdateProperties(UpdatedProperties whichUpdated, BSPrimLinkable physObject);
256 254
257 // Routine used when rebuilding the body of the root of the linkset 255 // Routine used when rebuilding the body of the root of the linkset
258 // Destroy all the constraints have have been made to root. 256 // Destroy all the constraints have have been made to root.
259 // This is called when the root body is changing. 257 // This is called when the root body is changing.
260 // Returns 'true' of something was actually removed and would need restoring 258 // Returns 'true' of something was actually removed and would need restoring
261 // Called at taint-time!! 259 // Called at taint-time!!
262 public abstract bool RemoveBodyDependencies(BSPrim child); 260 public abstract bool RemoveBodyDependencies(BSPrimLinkable child);
263 261
264 // ================================================================ 262 // ================================================================
265 protected virtual float ComputeLinksetMass() 263 protected virtual float ComputeLinksetMass()
@@ -269,7 +267,7 @@ public abstract class BSLinkset
269 { 267 {
270 lock (m_linksetActivityLock) 268 lock (m_linksetActivityLock)
271 { 269 {
272 foreach (BSPhysObject bp in m_children) 270 foreach (BSPrimLinkable bp in m_children)
273 { 271 {
274 mass += bp.RawMass; 272 mass += bp.RawMass;
275 } 273 }
@@ -286,7 +284,7 @@ public abstract class BSLinkset
286 com = LinksetRoot.Position * LinksetRoot.RawMass; 284 com = LinksetRoot.Position * LinksetRoot.RawMass;
287 float totalMass = LinksetRoot.RawMass; 285 float totalMass = LinksetRoot.RawMass;
288 286
289 foreach (BSPhysObject bp in m_children) 287 foreach (BSPrimLinkable bp in m_children)
290 { 288 {
291 com += bp.Position * bp.RawMass; 289 com += bp.Position * bp.RawMass;
292 totalMass += bp.RawMass; 290 totalMass += bp.RawMass;
@@ -305,7 +303,7 @@ public abstract class BSLinkset
305 { 303 {
306 com = LinksetRoot.Position; 304 com = LinksetRoot.Position;
307 305
308 foreach (BSPhysObject bp in m_children) 306 foreach (BSPrimLinkable bp in m_children)
309 { 307 {
310 com += bp.Position; 308 com += bp.Position;
311 } 309 }