diff options
author | Robert Adams | 2012-11-01 10:53:55 -0700 |
---|---|---|
committer | Robert Adams | 2012-11-03 21:15:22 -0700 |
commit | f53b4e7a21f62a84e237c4ce8d2806124c3a76d2 (patch) | |
tree | 1a815eafa4cec6e930b527fe81985b37f25f006a | |
parent | BulletSim: Remove use of shapeData in ShapeCollection and rely on the availab... (diff) | |
download | opensim-SC-f53b4e7a21f62a84e237c4ce8d2806124c3a76d2.zip opensim-SC-f53b4e7a21f62a84e237c4ce8d2806124c3a76d2.tar.gz opensim-SC-f53b4e7a21f62a84e237c4ce8d2806124c3a76d2.tar.bz2 opensim-SC-f53b4e7a21f62a84e237c4ce8d2806124c3a76d2.tar.xz |
BulletSim: Add RawPosition and RawOrientation to BSPhysObject and rename MassRaw to RawMass. Fix BSShapeCollection to use Raw* for creating the body to eliminate exception from referencing the physical body before it has been created.
5 files changed, 39 insertions, 17 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 2a634b9..9e1206a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -97,7 +97,7 @@ public sealed class BSCharacter : BSPhysObject | |||
97 | // set _avatarVolume and _mass based on capsule size, _density and Scale | 97 | // set _avatarVolume and _mass based on capsule size, _density and Scale |
98 | ComputeAvatarVolumeAndMass(); | 98 | ComputeAvatarVolumeAndMass(); |
99 | DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", | 99 | DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", |
100 | LocalID, _size, Scale, _avatarDensity, _avatarVolume, MassRaw); | 100 | LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); |
101 | 101 | ||
102 | // do actual create at taint time | 102 | // do actual create at taint time |
103 | PhysicsScene.TaintedObject("BSCharacter.create", delegate() | 103 | PhysicsScene.TaintedObject("BSCharacter.create", delegate() |
@@ -141,7 +141,7 @@ public sealed class BSCharacter : BSPhysObject | |||
141 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); | 141 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); |
142 | } | 142 | } |
143 | 143 | ||
144 | UpdatePhysicalMassProperties(MassRaw); | 144 | UpdatePhysicalMassProperties(RawMass); |
145 | 145 | ||
146 | // Make so capsule does not fall over | 146 | // Make so capsule does not fall over |
147 | BulletSimAPI.SetAngularFactorV2(PhysBody.ptr, OMV.Vector3.Zero); | 147 | BulletSimAPI.SetAngularFactorV2(PhysBody.ptr, OMV.Vector3.Zero); |
@@ -181,12 +181,12 @@ public sealed class BSCharacter : BSPhysObject | |||
181 | ComputeAvatarScale(_size); | 181 | ComputeAvatarScale(_size); |
182 | ComputeAvatarVolumeAndMass(); | 182 | ComputeAvatarVolumeAndMass(); |
183 | DetailLog("{0},BSCharacter.setSize,call,scale={1},density={2},volume={3},mass={4}", | 183 | DetailLog("{0},BSCharacter.setSize,call,scale={1},density={2},volume={3},mass={4}", |
184 | LocalID, Scale, _avatarDensity, _avatarVolume, MassRaw); | 184 | LocalID, Scale, _avatarDensity, _avatarVolume, RawMass); |
185 | 185 | ||
186 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() | 186 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() |
187 | { | 187 | { |
188 | BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); | 188 | BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); |
189 | UpdatePhysicalMassProperties(MassRaw); | 189 | UpdatePhysicalMassProperties(RawMass); |
190 | }); | 190 | }); |
191 | 191 | ||
192 | } | 192 | } |
@@ -231,6 +231,11 @@ public sealed class BSCharacter : BSPhysObject | |||
231 | 231 | ||
232 | public override void LockAngularMotion(OMV.Vector3 axis) { return; } | 232 | public override void LockAngularMotion(OMV.Vector3 axis) { return; } |
233 | 233 | ||
234 | public override OMV.Vector3 RawPosition | ||
235 | { | ||
236 | get { return _position; } | ||
237 | set { _position = value; } | ||
238 | } | ||
234 | public override OMV.Vector3 Position { | 239 | public override OMV.Vector3 Position { |
235 | get { | 240 | get { |
236 | // _position = BulletSimAPI.GetObjectPosition2(Scene.World.ptr, LocalID); | 241 | // _position = BulletSimAPI.GetObjectPosition2(Scene.World.ptr, LocalID); |
@@ -316,7 +321,7 @@ public sealed class BSCharacter : BSPhysObject | |||
316 | public override float Mass { get { return _mass; } } | 321 | public override float Mass { get { return _mass; } } |
317 | 322 | ||
318 | // used when we only want this prim's mass and not the linkset thing | 323 | // used when we only want this prim's mass and not the linkset thing |
319 | public override float MassRaw { | 324 | public override float RawMass { |
320 | get {return _mass; } | 325 | get {return _mass; } |
321 | } | 326 | } |
322 | public override void UpdatePhysicalMassProperties(float physMass) | 327 | public override void UpdatePhysicalMassProperties(float physMass) |
@@ -405,6 +410,11 @@ public sealed class BSCharacter : BSPhysObject | |||
405 | get { return _acceleration; } | 410 | get { return _acceleration; } |
406 | set { _acceleration = value; } | 411 | set { _acceleration = value; } |
407 | } | 412 | } |
413 | public override OMV.Quaternion RawOrientation | ||
414 | { | ||
415 | get { return _orientation; } | ||
416 | set { _orientation = value; } | ||
417 | } | ||
408 | public override OMV.Quaternion Orientation { | 418 | public override OMV.Quaternion Orientation { |
409 | get { return _orientation; } | 419 | get { return _orientation; } |
410 | set { | 420 | set { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index f56851f..9e0f499 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -106,7 +106,7 @@ public abstract class BSLinkset | |||
106 | PhysicsScene = scene; | 106 | PhysicsScene = scene; |
107 | LinksetRoot = parent; | 107 | LinksetRoot = parent; |
108 | m_children = new HashSet<BSPhysObject>(); | 108 | m_children = new HashSet<BSPhysObject>(); |
109 | m_mass = parent.MassRaw; | 109 | m_mass = parent.RawMass; |
110 | } | 110 | } |
111 | 111 | ||
112 | // Link to a linkset where the child knows the parent. | 112 | // Link to a linkset where the child knows the parent. |
@@ -242,14 +242,14 @@ public abstract class BSLinkset | |||
242 | // ================================================================ | 242 | // ================================================================ |
243 | protected virtual float ComputeLinksetMass() | 243 | protected virtual float ComputeLinksetMass() |
244 | { | 244 | { |
245 | float mass = LinksetRoot.MassRaw; | 245 | float mass = LinksetRoot.RawMass; |
246 | if (HasAnyChildren) | 246 | if (HasAnyChildren) |
247 | { | 247 | { |
248 | lock (m_linksetActivityLock) | 248 | lock (m_linksetActivityLock) |
249 | { | 249 | { |
250 | foreach (BSPhysObject bp in m_children) | 250 | foreach (BSPhysObject bp in m_children) |
251 | { | 251 | { |
252 | mass += bp.MassRaw; | 252 | mass += bp.RawMass; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | } | 255 | } |
@@ -261,13 +261,13 @@ public abstract class BSLinkset | |||
261 | OMV.Vector3 com; | 261 | OMV.Vector3 com; |
262 | lock (m_linksetActivityLock) | 262 | lock (m_linksetActivityLock) |
263 | { | 263 | { |
264 | com = LinksetRoot.Position * LinksetRoot.MassRaw; | 264 | com = LinksetRoot.Position * LinksetRoot.RawMass; |
265 | float totalMass = LinksetRoot.MassRaw; | 265 | float totalMass = LinksetRoot.RawMass; |
266 | 266 | ||
267 | foreach (BSPhysObject bp in m_children) | 267 | foreach (BSPhysObject bp in m_children) |
268 | { | 268 | { |
269 | com += bp.Position * bp.MassRaw; | 269 | com += bp.Position * bp.RawMass; |
270 | totalMass += bp.MassRaw; | 270 | totalMass += bp.RawMass; |
271 | } | 271 | } |
272 | if (totalMass != 0f) | 272 | if (totalMass != 0f) |
273 | com /= totalMass; | 273 | com /= totalMass; |
@@ -285,7 +285,7 @@ public abstract class BSLinkset | |||
285 | 285 | ||
286 | foreach (BSPhysObject bp in m_children) | 286 | foreach (BSPhysObject bp in m_children) |
287 | { | 287 | { |
288 | com += bp.Position * bp.MassRaw; | 288 | com += bp.Position * bp.RawMass; |
289 | } | 289 | } |
290 | com /= (m_children.Count + 1); | 290 | com /= (m_children.Count + 1); |
291 | } | 291 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 7d91468..65d7f34 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -63,7 +63,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
63 | public BSLinkset Linkset { get; set; } | 63 | public BSLinkset Linkset { get; set; } |
64 | 64 | ||
65 | // Return the object mass without calculating it or having side effects | 65 | // Return the object mass without calculating it or having side effects |
66 | public abstract float MassRaw { get; } | 66 | public abstract float RawMass { get; } |
67 | // Set the raw mass but also update physical mass properties (inertia, ...) | 67 | // Set the raw mass but also update physical mass properties (inertia, ...) |
68 | public abstract void UpdatePhysicalMassProperties(float mass); | 68 | public abstract void UpdatePhysicalMassProperties(float mass); |
69 | 69 | ||
@@ -105,8 +105,10 @@ public abstract class BSPhysObject : PhysicsActor | |||
105 | // Tell the object to clean up. | 105 | // Tell the object to clean up. |
106 | public abstract void Destroy(); | 106 | public abstract void Destroy(); |
107 | 107 | ||
108 | public abstract OMV.Vector3 RawPosition { get; set; } | ||
108 | public abstract OMV.Vector3 ForcePosition { get; set; } | 109 | public abstract OMV.Vector3 ForcePosition { get; set; } |
109 | 110 | ||
111 | public abstract OMV.Quaternion RawOrientation { get; set; } | ||
110 | public abstract OMV.Quaternion ForceOrientation { get; set; } | 112 | public abstract OMV.Quaternion ForceOrientation { get; set; } |
111 | 113 | ||
112 | public abstract OMV.Vector3 ForceVelocity { get; set; } | 114 | public abstract OMV.Vector3 ForceVelocity { get; set; } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 8ce960d..1754be6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -256,6 +256,11 @@ public sealed class BSPrim : BSPhysObject | |||
256 | return; | 256 | return; |
257 | } | 257 | } |
258 | 258 | ||
259 | public override OMV.Vector3 RawPosition | ||
260 | { | ||
261 | get { return _position; } | ||
262 | set { _position = value; } | ||
263 | } | ||
259 | public override OMV.Vector3 Position { | 264 | public override OMV.Vector3 Position { |
260 | get { | 265 | get { |
261 | if (!Linkset.IsRoot(this)) | 266 | if (!Linkset.IsRoot(this)) |
@@ -366,7 +371,7 @@ public sealed class BSPrim : BSPhysObject | |||
366 | } | 371 | } |
367 | 372 | ||
368 | // used when we only want this prim's mass and not the linkset thing | 373 | // used when we only want this prim's mass and not the linkset thing |
369 | public override float MassRaw { | 374 | public override float RawMass { |
370 | get { return _mass; } | 375 | get { return _mass; } |
371 | } | 376 | } |
372 | // Set the physical mass to the passed mass. | 377 | // Set the physical mass to the passed mass. |
@@ -530,6 +535,11 @@ public sealed class BSPrim : BSPhysObject | |||
530 | get { return _acceleration; } | 535 | get { return _acceleration; } |
531 | set { _acceleration = value; } | 536 | set { _acceleration = value; } |
532 | } | 537 | } |
538 | public override OMV.Quaternion RawOrientation | ||
539 | { | ||
540 | get { return _orientation; } | ||
541 | set { _orientation = value; } | ||
542 | } | ||
533 | public override OMV.Quaternion Orientation { | 543 | public override OMV.Quaternion Orientation { |
534 | get { | 544 | get { |
535 | if (!Linkset.IsRoot(this)) | 545 | if (!Linkset.IsRoot(this)) |
@@ -703,7 +713,7 @@ public sealed class BSPrim : BSPhysObject | |||
703 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 713 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
704 | 714 | ||
705 | // A dynamic object has mass | 715 | // A dynamic object has mass |
706 | UpdatePhysicalMassProperties(MassRaw); | 716 | UpdatePhysicalMassProperties(RawMass); |
707 | 717 | ||
708 | // Set collision detection parameters | 718 | // Set collision detection parameters |
709 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | 719 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 478924a..e131919 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -811,7 +811,7 @@ public sealed class BSShapeCollection : IDisposable | |||
811 | if (prim.IsSolid) | 811 | if (prim.IsSolid) |
812 | { | 812 | { |
813 | bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, | 813 | bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, |
814 | prim.LocalID, prim.ForcePosition, prim.ForceOrientation); | 814 | prim.LocalID, prim.RawPosition, prim.RawOrientation); |
815 | DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); | 815 | DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); |
816 | } | 816 | } |
817 | else | 817 | else |