diff options
author | Robert Adams | 2013-04-29 17:30:38 -0700 |
---|---|---|
committer | Robert Adams | 2013-04-29 17:30:38 -0700 |
commit | 15a3f80e2eb82c5e4726d5cd93cfed32da5d6768 (patch) | |
tree | 603cc242e5cce5140d559db4138f12914bf0d322 /OpenSim | |
parent | BulletSim: remove trailing white space to make git happier. No functional cha... (diff) | |
download | opensim-SC_OLD-15a3f80e2eb82c5e4726d5cd93cfed32da5d6768.zip opensim-SC_OLD-15a3f80e2eb82c5e4726d5cd93cfed32da5d6768.tar.gz opensim-SC_OLD-15a3f80e2eb82c5e4726d5cd93cfed32da5d6768.tar.bz2 opensim-SC_OLD-15a3f80e2eb82c5e4726d5cd93cfed32da5d6768.tar.xz |
BulletSim: LinksetCompound work to disable collision for root and
child prims so compound shape can do all collisions.
Don't try to build a compound linkset for non-physical linksets.
Remove and replace root body when compound shape is added so collision
cache is rebuilt.
Diffstat (limited to 'OpenSim')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 1fd541f..e967dfc 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -143,19 +143,18 @@ public sealed class BSLinksetCompound : BSLinkset | |||
143 | // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. | 143 | // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. |
144 | ScheduleRebuild(LinksetRoot); | 144 | ScheduleRebuild(LinksetRoot); |
145 | } | 145 | } |
146 | else | ||
147 | { | ||
148 | // The origional prims are removed from the world as the shape of the root compound | ||
149 | // shape takes over. | ||
150 | m_physicsScene.PE.AddToCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); | ||
151 | m_physicsScene.PE.ForceActivationState(child.PhysBody, ActivationState.DISABLE_SIMULATION); | ||
152 | // We don't want collisions from the old linkset children. | ||
153 | m_physicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | ||
154 | 146 | ||
155 | child.PhysBody.collisionType = CollisionType.LinksetChild; | 147 | // The origional prims are removed from the world as the shape of the root compound |
148 | // shape takes over. | ||
149 | m_physicsScene.PE.AddToCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); | ||
150 | m_physicsScene.PE.ForceActivationState(child.PhysBody, ActivationState.DISABLE_SIMULATION); | ||
151 | // We don't want collisions from the old linkset children. | ||
152 | m_physicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | ||
153 | |||
154 | child.PhysBody.collisionType = CollisionType.LinksetChild; | ||
155 | |||
156 | ret = true; | ||
156 | 157 | ||
157 | ret = true; | ||
158 | } | ||
159 | return ret; | 158 | return ret; |
160 | } | 159 | } |
161 | 160 | ||
@@ -190,6 +189,13 @@ public sealed class BSLinksetCompound : BSLinkset | |||
190 | // Called at taint-time. | 189 | // Called at taint-time. |
191 | public override void UpdateProperties(UpdatedProperties whichUpdated, BSPrimLinkable updated) | 190 | public override void UpdateProperties(UpdatedProperties whichUpdated, BSPrimLinkable updated) |
192 | { | 191 | { |
192 | if (!LinksetRoot.IsPhysicallyActive) | ||
193 | { | ||
194 | // No reason to do this physical stuff for static linksets. | ||
195 | DetailLog("{0},BSLinksetCompound.UpdateProperties,notPhysical", LinksetRoot.LocalID); | ||
196 | return; | ||
197 | } | ||
198 | |||
193 | // The user moving a child around requires the rebuilding of the linkset compound shape | 199 | // The user moving a child around requires the rebuilding of the linkset compound shape |
194 | // One problem is this happens when a border is crossed -- the simulator implementation | 200 | // One problem is this happens when a border is crossed -- the simulator implementation |
195 | // stores the position into the group which causes the move of the object | 201 | // stores the position into the group which causes the move of the object |
@@ -392,6 +398,13 @@ public sealed class BSLinksetCompound : BSLinkset | |||
392 | private bool disableCOM = true; // DEBUG DEBUG: disable until we get this debugged | 398 | private bool disableCOM = true; // DEBUG DEBUG: disable until we get this debugged |
393 | private void RecomputeLinksetCompound() | 399 | private void RecomputeLinksetCompound() |
394 | { | 400 | { |
401 | if (!LinksetRoot.IsPhysicallyActive) | ||
402 | { | ||
403 | // There is no reason to build all this physical stuff for a non-physical linkset | ||
404 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); | ||
405 | return; | ||
406 | } | ||
407 | |||
395 | try | 408 | try |
396 | { | 409 | { |
397 | // This replaces the physical shape of the root prim with a compound shape made up of the root | 410 | // This replaces the physical shape of the root prim with a compound shape made up of the root |
@@ -403,7 +416,8 @@ public sealed class BSLinksetCompound : BSLinkset | |||
403 | // Free up any shape we'd previously built. | 416 | // Free up any shape we'd previously built. |
404 | LinksetShape.Dereference(m_physicsScene); | 417 | LinksetShape.Dereference(m_physicsScene); |
405 | 418 | ||
406 | LinksetShape = BSShapeCompound.GetReference(m_physicsScene, LinksetRoot); | 419 | // Get a new compound shape to build the linkset shape in. |
420 | LinksetShape = BSShapeCompound.GetReference(m_physicsScene); | ||
407 | 421 | ||
408 | // The center of mass for the linkset is the geometric center of the group. | 422 | // The center of mass for the linkset is the geometric center of the group. |
409 | // Compute a displacement for each component so it is relative to the center-of-mass. | 423 | // Compute a displacement for each component so it is relative to the center-of-mass. |
@@ -431,8 +445,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
431 | cPrim.LinksetChildIndex = memberIndex; | 445 | cPrim.LinksetChildIndex = memberIndex; |
432 | } | 446 | } |
433 | 447 | ||
434 | BSShape childShape = cPrim.PhysShape; | 448 | BSShape childShape = cPrim.PhysShape.GetReference(m_physicsScene, cPrim); |
435 | childShape.IncrementReference(); | ||
436 | OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; | 449 | OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; |
437 | OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; | 450 | OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; |
438 | m_physicsScene.PE.AddChildShapeToCompoundShape(LinksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); | 451 | m_physicsScene.PE.AddChildShapeToCompoundShape(LinksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); |
@@ -446,7 +459,10 @@ public sealed class BSLinksetCompound : BSLinkset | |||
446 | 459 | ||
447 | // Sneak the built compound shape in as the shape of the root prim. | 460 | // Sneak the built compound shape in as the shape of the root prim. |
448 | // Note this doesn't touch the root prim's PhysShape so be sure the manage the difference. | 461 | // Note this doesn't touch the root prim's PhysShape so be sure the manage the difference. |
462 | // Object removed and added to world to get collision cache rebuilt for new shape. | ||
463 | m_physicsScene.PE.RemoveObjectFromWorld(m_physicsScene.World, LinksetRoot.PhysBody); | ||
449 | m_physicsScene.PE.SetCollisionShape(m_physicsScene.World, LinksetRoot.PhysBody, LinksetShape.physShapeInfo); | 464 | m_physicsScene.PE.SetCollisionShape(m_physicsScene.World, LinksetRoot.PhysBody, LinksetShape.physShapeInfo); |
465 | m_physicsScene.PE.AddObjectToWorld(m_physicsScene.World, LinksetRoot.PhysBody); | ||
450 | 466 | ||
451 | // With all of the linkset packed into the root prim, it has the mass of everyone. | 467 | // With all of the linkset packed into the root prim, it has the mass of everyone. |
452 | LinksetMass = ComputeLinksetMass(); | 468 | LinksetMass = ComputeLinksetMass(); |