From e5582939fd8d78b61c6f1eeda6de45d94f4b4926 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 28 Apr 2013 14:44:21 -0700 Subject: BulletSim: massive refactor of shape classes. Removed shape specific code from BSShapeCollection. Using BSShape* classes to hold references to shape. Simplified shape dependency callbacks. Remove 'PreferredShape' methods and have each class specify shape type. Disable compound shape linkset for a later commit that will simplify linkset implementation. --- OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 6d252ca..1811772 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -93,11 +93,11 @@ public sealed class BSLinksetConstraints : BSLinkset // up to rebuild the constraints before the next simulation step. // Returns 'true' of something was actually removed and would need restoring // Called at taint-time!! - public override bool RemoveBodyDependencies(BSPrimLinkable child) + public override bool RemoveDependencies(BSPrimLinkable child) { bool ret = false; - DetailLog("{0},BSLinksetConstraint.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}", + DetailLog("{0},BSLinksetConstraint.RemoveDependencies,removeChildrenForRoot,rID={1},rBody={2}", child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString); lock (m_linksetActivityLock) -- cgit v1.1 From ad1787770ed02f71feaa002ab689467e187803bb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 28 Apr 2013 21:50:47 -0700 Subject: BulletSim: rename variable 'PhysicsScene' to be either 'PhysScene' or 'm_physicsScene' to match coding conventions and reduce confusion. --- .../Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 1811772..a06a44d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -51,7 +51,7 @@ public sealed class BSLinksetConstraints : BSLinkset if (HasAnyChildren && IsRoot(requestor)) { // Queue to happen after all the other taint processing - PhysicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() + m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() { if (HasAnyChildren && IsRoot(requestor)) RecomputeLinksetConstraints(); @@ -142,7 +142,7 @@ public sealed class BSLinksetConstraints : BSLinkset rootx.LocalID, rootx.PhysBody.AddrString, childx.LocalID, childx.PhysBody.AddrString); - PhysicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() + m_physicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() { PhysicallyUnlinkAChildFromRoot(rootx, childx); }); @@ -187,7 +187,7 @@ public sealed class BSLinksetConstraints : BSLinkset // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 BSConstraint6Dof constrain = new BSConstraint6Dof( - PhysicsScene.World, rootPrim.PhysBody, childPrim.PhysBody, midPoint, true, true ); + m_physicsScene.World, rootPrim.PhysBody, childPrim.PhysBody, midPoint, true, true ); // PhysicsScene.World, childPrim.BSBody, rootPrim.BSBody, midPoint, true, true ); /* NOTE: below is an attempt to build constraint with full frame computation, etc. @@ -216,7 +216,7 @@ public sealed class BSLinksetConstraints : BSLinkset // ================================================================================== */ - PhysicsScene.Constraints.AddConstraint(constrain); + m_physicsScene.Constraints.AddConstraint(constrain); // zero linear and angular limits makes the objects unable to move in relation to each other constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); @@ -248,10 +248,10 @@ public sealed class BSLinksetConstraints : BSLinkset childPrim.LocalID, childPrim.PhysBody.AddrString); // Find the constraint for this link and get rid of it from the overall collection and from my list - if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) + if (m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) { // Make the child refresh its location - PhysicsScene.PE.PushUpdate(childPrim.PhysBody); + m_physicsScene.PE.PushUpdate(childPrim.PhysBody); ret = true; } @@ -265,7 +265,7 @@ public sealed class BSLinksetConstraints : BSLinkset { DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID); - return PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody); + return m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody); } // Call each of the constraints that make up this linkset and recompute the @@ -289,7 +289,7 @@ public sealed class BSLinksetConstraints : BSLinkset child.UpdatePhysicalMassProperties(linksetMass, true); BSConstraint constrain; - if (!PhysicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) { // If constraint doesn't exist yet, create it. constrain = BuildConstraint(LinksetRoot, child); -- cgit v1.1 From 803632f8f32d91bb4aec678d8b45a8430c2703e1 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 9 Jul 2013 16:26:17 -0700 Subject: BulletSim: freshen up the code for constraint based linksets. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 82 ++++++++++++++++------ 1 file changed, 61 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index a06a44d..f17d698 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -48,12 +48,22 @@ public sealed class BSLinksetConstraints : BSLinkset { base.Refresh(requestor); - if (HasAnyChildren && IsRoot(requestor)) + } + + private void ScheduleRebuild(BSPrimLinkable requestor) + { + DetailLog("{0},BSLinksetConstraint.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", + requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); + + // When rebuilding, it is possible to set properties that would normally require a rebuild. + // If already rebuilding, don't request another rebuild. + // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. + if (!Rebuilding && HasAnyChildren) { // Queue to happen after all the other taint processing m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() { - if (HasAnyChildren && IsRoot(requestor)) + if (HasAnyChildren) RecomputeLinksetConstraints(); }); } @@ -67,8 +77,14 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeDynamic(BSPrimLinkable child) { - // What is done for each object in BSPrim is what we want. - return false; + bool ret = false; + DetailLog("{0},BSLinksetConstraints.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); + if (IsRoot(child)) + { + // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. + ScheduleRebuild(LinksetRoot); + } + return ret; } // The object is going static (non-physical). Do any setup necessary for a static linkset. @@ -78,8 +94,16 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeStatic(BSPrimLinkable child) { - // What is done for each object in BSPrim is what we want. - return false; + bool ret = false; + + DetailLog("{0},BSLinksetConstraint.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); + child.ClearDisplacement(); + if (IsRoot(child)) + { + // Schedule a rebuild to verify that the root shape is set to the real shape. + ScheduleRebuild(LinksetRoot); + } + return ret; } // Called at taint-time!! @@ -105,7 +129,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Just undo all the constraints for this linkset. Rebuild at the end of the step. ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); // Cause the constraints, et al to be rebuilt before the next simulation step. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } return ret; } @@ -123,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Cause constraints and assorted properties to be recomputed before the next simulation step. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } return; } @@ -147,7 +171,7 @@ public sealed class BSLinksetConstraints : BSLinkset PhysicallyUnlinkAChildFromRoot(rootx, childx); }); // See that the linkset parameters are recomputed at the end of the taint time. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } else { @@ -165,6 +189,7 @@ public sealed class BSLinksetConstraints : BSLinkset Refresh(rootPrim); } + // Create a static constraint between the two passed objects private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim) { // Zero motion for children so they don't interpolate @@ -281,24 +306,39 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); - foreach (BSPrimLinkable child in m_children) + try { - // A child in the linkset physically shows the mass of the whole linkset. - // This allows Bullet to apply enough force on the child to move the whole linkset. - // (Also do the mass stuff before recomputing the constraint so mass is not zero.) - child.UpdatePhysicalMassProperties(linksetMass, true); + Rebuilding = true; - BSConstraint constrain; - if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + // There is no reason to build all this physical stuff for a non-physical linkset. + if (!LinksetRoot.IsPhysicallyActive) { - // If constraint doesn't exist yet, create it. - constrain = BuildConstraint(LinksetRoot, child); + DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); + return; // Note the 'finally' clause at the botton which will get executed. } - constrain.RecomputeConstraintVariables(linksetMass); - // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG - } + foreach (BSPrimLinkable child in m_children) + { + // A child in the linkset physically shows the mass of the whole linkset. + // This allows Bullet to apply enough force on the child to move the whole linkset. + // (Also do the mass stuff before recomputing the constraint so mass is not zero.) + child.UpdatePhysicalMassProperties(linksetMass, true); + + BSConstraint constrain; + if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + { + // If constraint doesn't exist yet, create it. + constrain = BuildConstraint(LinksetRoot, child); + } + constrain.RecomputeConstraintVariables(linksetMass); + // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG + } + } + finally + { + Rebuilding = false; + } } } } -- cgit v1.1 From 44543ebe638f391fc1c7ff532fe4470006dec55a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 22 Jul 2013 12:10:23 -0700 Subject: Revert "BulletSim: freshen up the code for constraint based linksets." The changes don't seem to be ready for prime time. This reverts commit 803632f8f32d91bb4aec678d8b45a8430c2703e1. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 82 ++++++---------------- 1 file changed, 21 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index f17d698..a06a44d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -48,22 +48,12 @@ public sealed class BSLinksetConstraints : BSLinkset { base.Refresh(requestor); - } - - private void ScheduleRebuild(BSPrimLinkable requestor) - { - DetailLog("{0},BSLinksetConstraint.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", - requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); - - // When rebuilding, it is possible to set properties that would normally require a rebuild. - // If already rebuilding, don't request another rebuild. - // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. - if (!Rebuilding && HasAnyChildren) + if (HasAnyChildren && IsRoot(requestor)) { // Queue to happen after all the other taint processing m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() { - if (HasAnyChildren) + if (HasAnyChildren && IsRoot(requestor)) RecomputeLinksetConstraints(); }); } @@ -77,14 +67,8 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeDynamic(BSPrimLinkable child) { - bool ret = false; - DetailLog("{0},BSLinksetConstraints.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); - if (IsRoot(child)) - { - // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. - ScheduleRebuild(LinksetRoot); - } - return ret; + // What is done for each object in BSPrim is what we want. + return false; } // The object is going static (non-physical). Do any setup necessary for a static linkset. @@ -94,16 +78,8 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeStatic(BSPrimLinkable child) { - bool ret = false; - - DetailLog("{0},BSLinksetConstraint.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); - child.ClearDisplacement(); - if (IsRoot(child)) - { - // Schedule a rebuild to verify that the root shape is set to the real shape. - ScheduleRebuild(LinksetRoot); - } - return ret; + // What is done for each object in BSPrim is what we want. + return false; } // Called at taint-time!! @@ -129,7 +105,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Just undo all the constraints for this linkset. Rebuild at the end of the step. ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); // Cause the constraints, et al to be rebuilt before the next simulation step. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -147,7 +123,7 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Cause constraints and assorted properties to be recomputed before the next simulation step. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return; } @@ -171,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset PhysicallyUnlinkAChildFromRoot(rootx, childx); }); // See that the linkset parameters are recomputed at the end of the taint time. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } else { @@ -189,7 +165,6 @@ public sealed class BSLinksetConstraints : BSLinkset Refresh(rootPrim); } - // Create a static constraint between the two passed objects private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim) { // Zero motion for children so they don't interpolate @@ -306,39 +281,24 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); - try + foreach (BSPrimLinkable child in m_children) { - Rebuilding = true; + // A child in the linkset physically shows the mass of the whole linkset. + // This allows Bullet to apply enough force on the child to move the whole linkset. + // (Also do the mass stuff before recomputing the constraint so mass is not zero.) + child.UpdatePhysicalMassProperties(linksetMass, true); - // There is no reason to build all this physical stuff for a non-physical linkset. - if (!LinksetRoot.IsPhysicallyActive) + BSConstraint constrain; + if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) { - DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); - return; // Note the 'finally' clause at the botton which will get executed. + // If constraint doesn't exist yet, create it. + constrain = BuildConstraint(LinksetRoot, child); } + constrain.RecomputeConstraintVariables(linksetMass); - foreach (BSPrimLinkable child in m_children) - { - // A child in the linkset physically shows the mass of the whole linkset. - // This allows Bullet to apply enough force on the child to move the whole linkset. - // (Also do the mass stuff before recomputing the constraint so mass is not zero.) - child.UpdatePhysicalMassProperties(linksetMass, true); - - BSConstraint constrain; - if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) - { - // If constraint doesn't exist yet, create it. - constrain = BuildConstraint(LinksetRoot, child); - } - constrain.RecomputeConstraintVariables(linksetMass); - - // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG - } - } - finally - { - Rebuilding = false; + // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG } + } } } -- cgit v1.1 From af9deed13593a85aef64205f9ca616a06711963c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 08:11:21 -0700 Subject: Revert "Revert "BulletSim: freshen up the code for constraint based linksets."" Found that the vehicle movement problem was not caused by these physics changes. This reverts commit 44543ebe638f391fc1c7ff532fe4470006dec55a. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 82 ++++++++++++++++------ 1 file changed, 61 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index a06a44d..f17d698 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -48,12 +48,22 @@ public sealed class BSLinksetConstraints : BSLinkset { base.Refresh(requestor); - if (HasAnyChildren && IsRoot(requestor)) + } + + private void ScheduleRebuild(BSPrimLinkable requestor) + { + DetailLog("{0},BSLinksetConstraint.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", + requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); + + // When rebuilding, it is possible to set properties that would normally require a rebuild. + // If already rebuilding, don't request another rebuild. + // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. + if (!Rebuilding && HasAnyChildren) { // Queue to happen after all the other taint processing m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() { - if (HasAnyChildren && IsRoot(requestor)) + if (HasAnyChildren) RecomputeLinksetConstraints(); }); } @@ -67,8 +77,14 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeDynamic(BSPrimLinkable child) { - // What is done for each object in BSPrim is what we want. - return false; + bool ret = false; + DetailLog("{0},BSLinksetConstraints.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); + if (IsRoot(child)) + { + // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. + ScheduleRebuild(LinksetRoot); + } + return ret; } // The object is going static (non-physical). Do any setup necessary for a static linkset. @@ -78,8 +94,16 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeStatic(BSPrimLinkable child) { - // What is done for each object in BSPrim is what we want. - return false; + bool ret = false; + + DetailLog("{0},BSLinksetConstraint.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); + child.ClearDisplacement(); + if (IsRoot(child)) + { + // Schedule a rebuild to verify that the root shape is set to the real shape. + ScheduleRebuild(LinksetRoot); + } + return ret; } // Called at taint-time!! @@ -105,7 +129,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Just undo all the constraints for this linkset. Rebuild at the end of the step. ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); // Cause the constraints, et al to be rebuilt before the next simulation step. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } return ret; } @@ -123,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Cause constraints and assorted properties to be recomputed before the next simulation step. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } return; } @@ -147,7 +171,7 @@ public sealed class BSLinksetConstraints : BSLinkset PhysicallyUnlinkAChildFromRoot(rootx, childx); }); // See that the linkset parameters are recomputed at the end of the taint time. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } else { @@ -165,6 +189,7 @@ public sealed class BSLinksetConstraints : BSLinkset Refresh(rootPrim); } + // Create a static constraint between the two passed objects private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim) { // Zero motion for children so they don't interpolate @@ -281,24 +306,39 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); - foreach (BSPrimLinkable child in m_children) + try { - // A child in the linkset physically shows the mass of the whole linkset. - // This allows Bullet to apply enough force on the child to move the whole linkset. - // (Also do the mass stuff before recomputing the constraint so mass is not zero.) - child.UpdatePhysicalMassProperties(linksetMass, true); + Rebuilding = true; - BSConstraint constrain; - if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + // There is no reason to build all this physical stuff for a non-physical linkset. + if (!LinksetRoot.IsPhysicallyActive) { - // If constraint doesn't exist yet, create it. - constrain = BuildConstraint(LinksetRoot, child); + DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); + return; // Note the 'finally' clause at the botton which will get executed. } - constrain.RecomputeConstraintVariables(linksetMass); - // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG - } + foreach (BSPrimLinkable child in m_children) + { + // A child in the linkset physically shows the mass of the whole linkset. + // This allows Bullet to apply enough force on the child to move the whole linkset. + // (Also do the mass stuff before recomputing the constraint so mass is not zero.) + child.UpdatePhysicalMassProperties(linksetMass, true); + + BSConstraint constrain; + if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + { + // If constraint doesn't exist yet, create it. + constrain = BuildConstraint(LinksetRoot, child); + } + constrain.RecomputeConstraintVariables(linksetMass); + // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG + } + } + finally + { + Rebuilding = false; + } } } } -- cgit v1.1 From 5bcccfc305ae4f5a74b9b816781a2a643daa23b3 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 1 Aug 2013 12:35:22 -0700 Subject: BulletSim: add BSLinkInfo structure to remember link specific information for each link in a linkset. Extend BSLinksetConstraint to create and use BSLinkInfo with the default static constraint. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 205 ++++++++++++++------- 1 file changed, 138 insertions(+), 67 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index f17d698..d98bf77 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -36,6 +36,75 @@ public sealed class BSLinksetConstraints : BSLinkset { // private static string LogHeader = "[BULLETSIM LINKSET CONSTRAINTS]"; + public class BSLinkInfoConstraint : BSLinkInfo + { + public ConstraintType constraintType; + public BSConstraint constraint; + public OMV.Vector3 linearLimitLow; + public OMV.Vector3 linearLimitHigh; + public OMV.Vector3 angularLimitLow; + public OMV.Vector3 angularLimitHigh; + public bool useFrameOffset; + public bool enableTransMotor; + public float transMotorMaxVel; + public float transMotorMaxForce; + public float cfm; + public float erp; + public float solverIterations; + + public BSLinkInfoConstraint(BSPrimLinkable pMember) + : base(pMember) + { + constraint = null; + ResetToFixedConstraint(); + } + + // Set all the parameters for this constraint to a fixed, non-movable constraint. + public void ResetToFixedConstraint() + { + constraintType = ConstraintType.D6_CONSTRAINT_TYPE; + linearLimitLow = OMV.Vector3.Zero; + linearLimitHigh = OMV.Vector3.Zero; + angularLimitLow = OMV.Vector3.Zero; + angularLimitHigh = OMV.Vector3.Zero; + useFrameOffset = BSParam.LinkConstraintUseFrameOffset; + enableTransMotor = BSParam.LinkConstraintEnableTransMotor; + transMotorMaxVel = BSParam.LinkConstraintTransMotorMaxVel; + transMotorMaxForce = BSParam.LinkConstraintTransMotorMaxForce; + cfm = BSParam.LinkConstraintCFM; + erp = BSParam.LinkConstraintERP; + solverIterations = BSParam.LinkConstraintSolverIterations; + } + + // Given a constraint, apply the current constraint parameters to same. + public void SetConstraintParameters(BSConstraint constrain) + { + switch (constraintType) + { + case ConstraintType.D6_CONSTRAINT_TYPE: + BSConstraint6Dof constrain6dof = constrain as BSConstraint6Dof; + if (constrain6dof != null) + { + // zero linear and angular limits makes the objects unable to move in relation to each other + constrain6dof.SetLinearLimits(linearLimitLow, linearLimitHigh); + constrain6dof.SetAngularLimits(angularLimitLow, angularLimitHigh); + + // tweek the constraint to increase stability + constrain6dof.UseFrameOffset(useFrameOffset); + constrain6dof.TranslationalLimitMotor(enableTransMotor, transMotorMaxVel, transMotorMaxForce); + constrain6dof.SetCFMAndERP(cfm, erp); + if (solverIterations != 0f) + { + constrain6dof.SetSolverIterations(solverIterations); + } + } + break; + default: + break; + } + } + } + public BSLinksetConstraints(BSScene scene, BSPrimLinkable parent) : base(scene, parent) { } @@ -142,7 +211,7 @@ public sealed class BSLinksetConstraints : BSLinkset { if (!HasChild(child)) { - m_children.Add(child); + m_children.Add(child, new BSLinkInfoConstraint(child)); DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); @@ -190,73 +259,74 @@ public sealed class BSLinksetConstraints : BSLinkset } // Create a static constraint between the two passed objects - private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim) + private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSLinkInfo li) { + BSLinkInfoConstraint liConstraint = li as BSLinkInfoConstraint; + if (liConstraint == null) + return null; + // Zero motion for children so they don't interpolate - childPrim.ZeroMotion(true); - - // Relative position normalized to the root prim - // Essentually a vector pointing from center of rootPrim to center of childPrim - OMV.Vector3 childRelativePosition = childPrim.Position - rootPrim.Position; - - // real world coordinate of midpoint between the two objects - OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); - - DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", - rootPrim.LocalID, - rootPrim.LocalID, rootPrim.PhysBody.AddrString, - childPrim.LocalID, childPrim.PhysBody.AddrString, - rootPrim.Position, childPrim.Position, midPoint); - - // create a constraint that allows no freedom of movement between the two objects - // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 - - BSConstraint6Dof constrain = new BSConstraint6Dof( - m_physicsScene.World, rootPrim.PhysBody, childPrim.PhysBody, midPoint, true, true ); - // PhysicsScene.World, childPrim.BSBody, rootPrim.BSBody, midPoint, true, true ); - - /* NOTE: below is an attempt to build constraint with full frame computation, etc. - * Using the midpoint is easier since it lets the Bullet code manipulate the transforms - * of the objects. - * Code left for future programmers. - // ================================================================================== - // relative position normalized to the root prim - OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation); - OMV.Vector3 childRelativePosition = (childPrim.Position - rootPrim.Position) * invThisOrientation; - - // relative rotation of the child to the parent - OMV.Quaternion childRelativeRotation = invThisOrientation * childPrim.Orientation; - OMV.Quaternion inverseChildRelativeRotation = OMV.Quaternion.Inverse(childRelativeRotation); - - DetailLog("{0},BSLinksetConstraint.PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); - BS6DofConstraint constrain = new BS6DofConstraint( - PhysicsScene.World, rootPrim.Body, childPrim.Body, - OMV.Vector3.Zero, - OMV.Quaternion.Inverse(rootPrim.Orientation), - OMV.Vector3.Zero, - OMV.Quaternion.Inverse(childPrim.Orientation), - true, - true - ); - // ================================================================================== - */ + li.member.ZeroMotion(true); - m_physicsScene.Constraints.AddConstraint(constrain); + BSConstraint constrain = null; - // zero linear and angular limits makes the objects unable to move in relation to each other - constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); - constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); - - // tweek the constraint to increase stability - constrain.UseFrameOffset(BSParam.LinkConstraintUseFrameOffset); - constrain.TranslationalLimitMotor(BSParam.LinkConstraintEnableTransMotor, - BSParam.LinkConstraintTransMotorMaxVel, - BSParam.LinkConstraintTransMotorMaxForce); - constrain.SetCFMAndERP(BSParam.LinkConstraintCFM, BSParam.LinkConstraintERP); - if (BSParam.LinkConstraintSolverIterations != 0f) + switch (liConstraint.constraintType) { - constrain.SetSolverIterations(BSParam.LinkConstraintSolverIterations); + case ConstraintType.D6_CONSTRAINT_TYPE: + // Relative position normalized to the root prim + // Essentually a vector pointing from center of rootPrim to center of li.member + OMV.Vector3 childRelativePosition = liConstraint.member.Position - rootPrim.Position; + + // real world coordinate of midpoint between the two objects + OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); + + DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", + rootPrim.LocalID, + rootPrim.LocalID, rootPrim.PhysBody.AddrString, + liConstraint.member.LocalID, liConstraint.member.PhysBody.AddrString, + rootPrim.Position, liConstraint.member.Position, midPoint); + + // create a constraint that allows no freedom of movement between the two objects + // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 + + constrain = new BSConstraint6Dof( + m_physicsScene.World, rootPrim.PhysBody, liConstraint.member.PhysBody, midPoint, true, true ); + + /* NOTE: below is an attempt to build constraint with full frame computation, etc. + * Using the midpoint is easier since it lets the Bullet code manipulate the transforms + * of the objects. + * Code left for future programmers. + // ================================================================================== + // relative position normalized to the root prim + OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation); + OMV.Vector3 childRelativePosition = (liConstraint.member.Position - rootPrim.Position) * invThisOrientation; + + // relative rotation of the child to the parent + OMV.Quaternion childRelativeRotation = invThisOrientation * liConstraint.member.Orientation; + OMV.Quaternion inverseChildRelativeRotation = OMV.Quaternion.Inverse(childRelativeRotation); + + DetailLog("{0},BSLinksetConstraint.PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, liConstraint.member.LocalID); + constrain = new BS6DofConstraint( + PhysicsScene.World, rootPrim.Body, liConstraint.member.Body, + OMV.Vector3.Zero, + OMV.Quaternion.Inverse(rootPrim.Orientation), + OMV.Vector3.Zero, + OMV.Quaternion.Inverse(liConstraint.member.Orientation), + true, + true + ); + // ================================================================================== + */ + + break; + default: + break; } + + liConstraint.SetConstraintParameters(constrain); + + m_physicsScene.Constraints.AddConstraint(constrain); + return constrain; } @@ -317,23 +387,24 @@ public sealed class BSLinksetConstraints : BSLinkset return; // Note the 'finally' clause at the botton which will get executed. } - foreach (BSPrimLinkable child in m_children) + ForEachLinkInfo((li) => { // A child in the linkset physically shows the mass of the whole linkset. // This allows Bullet to apply enough force on the child to move the whole linkset. // (Also do the mass stuff before recomputing the constraint so mass is not zero.) - child.UpdatePhysicalMassProperties(linksetMass, true); + li.member.UpdatePhysicalMassProperties(linksetMass, true); BSConstraint constrain; - if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, li.member.PhysBody, out constrain)) { // If constraint doesn't exist yet, create it. - constrain = BuildConstraint(LinksetRoot, child); + constrain = BuildConstraint(LinksetRoot, li); } constrain.RecomputeConstraintVariables(linksetMass); // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG - } + return false; // 'false' says to keep processing other members + }); } finally { -- cgit v1.1 From 24df15dab7befd50f7a45eb54f001e6e481f0ec4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 1 Aug 2013 17:43:06 -0700 Subject: BulletSim: add implementation of 'physSetLinksetType' and 'physGetLinksetType' and processing routines in BulletSim. Add linkset rebuild/conversion routine in BSLinkset. --- OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') 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 public BSLinksetConstraints(BSScene scene, BSPrimLinkable parent) : base(scene, parent) { + LinksetImpl = LinksetImplementation.Constraint; } // When physical properties are changed the linkset needs to recalculate -- cgit v1.1 From 725751fd6c0101b8610e84716d28b6af91e20b61 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 6 Aug 2013 10:32:56 -0700 Subject: BulletSim: fixes for change linkset implementation of physical linksets. --- OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 4bac222..d4ee27d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -224,7 +224,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Remove the specified child from the linkset. // Safe to call even if the child is not really in my linkset. - protected override void RemoveChildFromLinkset(BSPrimLinkable child) + protected override void RemoveChildFromLinkset(BSPrimLinkable child, bool inTaintTime) { if (m_children.Remove(child)) { @@ -236,7 +236,7 @@ public sealed class BSLinksetConstraints : BSLinkset rootx.LocalID, rootx.PhysBody.AddrString, childx.LocalID, childx.PhysBody.AddrString); - m_physicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() + m_physicsScene.TaintedObject(inTaintTime, "BSLinksetConstraints.RemoveChildFromLinkset", delegate() { PhysicallyUnlinkAChildFromRoot(rootx, childx); }); @@ -382,9 +382,9 @@ public sealed class BSLinksetConstraints : BSLinkset Rebuilding = true; // There is no reason to build all this physical stuff for a non-physical linkset. - if (!LinksetRoot.IsPhysicallyActive) + if (!LinksetRoot.IsPhysicallyActive || !HasAnyChildren) { - DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); + DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysicalOrNoChildren", LinksetRoot.LocalID); return; // Note the 'finally' clause at the botton which will get executed. } -- cgit v1.1 From 0971c7ae77cae3d238be31f46994b4692af949e3 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 07:56:37 -0700 Subject: BulletSim: complete linkage of spring constraint into linkset constraint. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 81 ++++++++++++++++++---- 1 file changed, 67 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index d4ee27d..f3b70c3 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -51,16 +51,26 @@ public sealed class BSLinksetConstraints : BSLinkset public float cfm; public float erp; public float solverIterations; + // + public OMV.Vector3 frameInAloc; + public OMV.Quaternion frameInArot; + public OMV.Vector3 frameInBloc; + public OMV.Quaternion frameInBrot; + // Spring + public float springDamping; + public float springStiffness; + + public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) { constraint = null; - ResetToFixedConstraint(); + ResetLink(); } // Set all the parameters for this constraint to a fixed, non-movable constraint. - public void ResetToFixedConstraint() + public override void ResetLink() { constraintType = ConstraintType.D6_CONSTRAINT_TYPE; linearLimitLow = OMV.Vector3.Zero; @@ -74,10 +84,16 @@ public sealed class BSLinksetConstraints : BSLinkset cfm = BSParam.LinkConstraintCFM; erp = BSParam.LinkConstraintERP; solverIterations = BSParam.LinkConstraintSolverIterations; + frameInAloc = OMV.Vector3.Zero; + frameInArot = OMV.Quaternion.Identity; + frameInBloc = OMV.Vector3.Zero; + frameInBrot = OMV.Quaternion.Identity; + springDamping = -1f; + springStiffness = -1f; } // Given a constraint, apply the current constraint parameters to same. - public void SetConstraintParameters(BSConstraint constrain) + public override void SetLinkParameters(BSConstraint constrain) { switch (constraintType) { @@ -85,6 +101,7 @@ public sealed class BSLinksetConstraints : BSLinkset BSConstraint6Dof constrain6dof = constrain as BSConstraint6Dof; if (constrain6dof != null) { + // NOTE: D6_SPRING_CONSTRAINT_TYPE should be updated if you change any of this code. // zero linear and angular limits makes the objects unable to move in relation to each other constrain6dof.SetLinearLimits(linearLimitLow, linearLimitHigh); constrain6dof.SetAngularLimits(angularLimitLow, angularLimitHigh); @@ -99,6 +116,31 @@ public sealed class BSLinksetConstraints : BSLinkset } } break; + case ConstraintType.D6_SPRING_CONSTRAINT_TYPE: + BSConstraintSpring constrainSpring = constrain as BSConstraintSpring; + if (constrainSpring != null) + { + // zero linear and angular limits makes the objects unable to move in relation to each other + constrainSpring.SetLinearLimits(linearLimitLow, linearLimitHigh); + constrainSpring.SetAngularLimits(angularLimitLow, angularLimitHigh); + + // tweek the constraint to increase stability + constrainSpring.UseFrameOffset(useFrameOffset); + constrainSpring.TranslationalLimitMotor(enableTransMotor, transMotorMaxVel, transMotorMaxForce); + constrainSpring.SetCFMAndERP(cfm, erp); + if (solverIterations != 0f) + { + constrainSpring.SetSolverIterations(solverIterations); + } + for (int ii = 0; ii < 6; ii++) + { + if (springDamping != -1) + constrainSpring.SetDamping(ii, springDamping); + if (springStiffness != -1) + constrainSpring.SetStiffness(ii, springStiffness); + } + } + break; default: break; } @@ -262,8 +304,8 @@ public sealed class BSLinksetConstraints : BSLinkset // Create a static constraint between the two passed objects private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSLinkInfo li) { - BSLinkInfoConstraint liConstraint = li as BSLinkInfoConstraint; - if (liConstraint == null) + BSLinkInfoConstraint linkInfo = li as BSLinkInfoConstraint; + if (linkInfo == null) return null; // Zero motion for children so they don't interpolate @@ -271,27 +313,25 @@ public sealed class BSLinksetConstraints : BSLinkset BSConstraint constrain = null; - switch (liConstraint.constraintType) + switch (linkInfo.constraintType) { case ConstraintType.D6_CONSTRAINT_TYPE: // Relative position normalized to the root prim // Essentually a vector pointing from center of rootPrim to center of li.member - OMV.Vector3 childRelativePosition = liConstraint.member.Position - rootPrim.Position; + OMV.Vector3 childRelativePosition = linkInfo.member.Position - rootPrim.Position; // real world coordinate of midpoint between the two objects OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); - DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", - rootPrim.LocalID, - rootPrim.LocalID, rootPrim.PhysBody.AddrString, - liConstraint.member.LocalID, liConstraint.member.PhysBody.AddrString, - rootPrim.Position, liConstraint.member.Position, midPoint); + DetailLog("{0},BSLinksetConstraint.BuildConstraint,6Dof,rBody={1},cBody={2},rLoc={3},cLoc={4},midLoc={7}", + rootPrim.LocalID, rootPrim.PhysBody, linkInfo.member.PhysBody, + rootPrim.Position, linkInfo.member.Position, midPoint); // create a constraint that allows no freedom of movement between the two objects // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 constrain = new BSConstraint6Dof( - m_physicsScene.World, rootPrim.PhysBody, liConstraint.member.PhysBody, midPoint, true, true ); + m_physicsScene.World, rootPrim.PhysBody, linkInfo.member.PhysBody, midPoint, true, true ); /* NOTE: below is an attempt to build constraint with full frame computation, etc. * Using the midpoint is easier since it lets the Bullet code manipulate the transforms @@ -320,11 +360,23 @@ public sealed class BSLinksetConstraints : BSLinkset */ break; + case ConstraintType.D6_SPRING_CONSTRAINT_TYPE: + constrain = new BSConstraintSpring(m_physicsScene.World, rootPrim.PhysBody, linkInfo.member.PhysBody, + linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot, + true /*useLinearReferenceFrameA*/, + true /*disableCollisionsBetweenLinkedBodies*/); + DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", + rootPrim.LocalID, + rootPrim.LocalID, rootPrim.PhysBody.AddrString, + linkInfo.member.LocalID, linkInfo.member.PhysBody.AddrString, + rootPrim.Position, linkInfo.member.Position); + + break; default: break; } - liConstraint.SetConstraintParameters(constrain); + linkInfo.SetLinkParameters(constrain); m_physicsScene.Constraints.AddConstraint(constrain); @@ -401,6 +453,7 @@ public sealed class BSLinksetConstraints : BSLinkset // If constraint doesn't exist yet, create it. constrain = BuildConstraint(LinksetRoot, li); } + li.SetLinkParameters(constrain); constrain.RecomputeConstraintVariables(linksetMass); // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG -- cgit v1.1 From dff0fb56902f62b070ec6fd05769babfad32ed2e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 11:18:23 -0700 Subject: BulletSim: Linkset.Refresh() calls internal ScheduleRebuild() to recreate the linkset physics at next PostTaint time. Replace the existing calls to ScheduleRebuild to be calls to Refresh(). This allows external routines to make changes to parameters and then cause the linkset to rebuild. --- OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index f3b70c3..db323c2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -158,6 +158,7 @@ public sealed class BSLinksetConstraints : BSLinkset // refresh will happen once after all the other taints are applied. public override void Refresh(BSPrimLinkable requestor) { + ScheduleRebuild(requestor); base.Refresh(requestor); } @@ -194,7 +195,7 @@ public sealed class BSLinksetConstraints : BSLinkset if (IsRoot(child)) { // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -213,7 +214,7 @@ public sealed class BSLinksetConstraints : BSLinkset if (IsRoot(child)) { // Schedule a rebuild to verify that the root shape is set to the real shape. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -241,7 +242,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Just undo all the constraints for this linkset. Rebuild at the end of the step. ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); // Cause the constraints, et al to be rebuilt before the next simulation step. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -259,7 +260,7 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Cause constraints and assorted properties to be recomputed before the next simulation step. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return; } @@ -283,7 +284,7 @@ public sealed class BSLinksetConstraints : BSLinkset PhysicallyUnlinkAChildFromRoot(rootx, childx); }); // See that the linkset parameters are recomputed at the end of the taint time. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } else { -- cgit v1.1 From 6aee08ac3c48b55ebd8e945c8b11f17dc1ab3151 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 8 Aug 2013 08:36:36 -0700 Subject: BulletSim: add physChangeLinkSpring to change linkset link to be a spring constraint. Add implementation to create spring constraint. Send up property updates for linkset children at the end of flexible linkset links. The simulator probably doesn't do the right thing yet. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 102 ++++++++++++++++++++- 1 file changed, 99 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index db323c2..17fec9d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -60,8 +60,6 @@ public sealed class BSLinksetConstraints : BSLinkset public float springDamping; public float springStiffness; - - public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) { @@ -72,7 +70,8 @@ public sealed class BSLinksetConstraints : BSLinkset // Set all the parameters for this constraint to a fixed, non-movable constraint. public override void ResetLink() { - constraintType = ConstraintType.D6_CONSTRAINT_TYPE; + // constraintType = ConstraintType.D6_CONSTRAINT_TYPE; + constraintType = ConstraintType.FIXED_CONSTRAINT_TYPE; linearLimitLow = OMV.Vector3.Zero; linearLimitHigh = OMV.Vector3.Zero; angularLimitLow = OMV.Vector3.Zero; @@ -97,6 +96,7 @@ public sealed class BSLinksetConstraints : BSLinkset { switch (constraintType) { + case ConstraintType.FIXED_CONSTRAINT_TYPE: case ConstraintType.D6_CONSTRAINT_TYPE: BSConstraint6Dof constrain6dof = constrain as BSConstraint6Dof; if (constrain6dof != null) @@ -145,6 +145,20 @@ public sealed class BSLinksetConstraints : BSLinkset break; } } + + // Return 'true' if the property updates from the physics engine should be reported + // to the simulator. + // If the constraint is fixed, we don't need to report as the simulator and viewer will + // report the right things. + public override bool ShouldUpdateChildProperties() + { + bool ret = true; + + if (constraintType == ConstraintType.FIXED_CONSTRAINT_TYPE) + ret = false; + + return ret; + } } public BSLinksetConstraints(BSScene scene, BSPrimLinkable parent) : base(scene, parent) @@ -316,6 +330,7 @@ public sealed class BSLinksetConstraints : BSLinkset switch (linkInfo.constraintType) { + case ConstraintType.FIXED_CONSTRAINT_TYPE: case ConstraintType.D6_CONSTRAINT_TYPE: // Relative position normalized to the root prim // Essentually a vector pointing from center of rootPrim to center of li.member @@ -466,5 +481,86 @@ public sealed class BSLinksetConstraints : BSLinkset Rebuilding = false; } } + + #region Extension + public override object Extension(string pFunct, params object[] pParams) + { + object ret = null; + switch (pFunct) + { + // pParams = (int linkNUm, PhysActor linkChild) + case BSScene.PhysFunctChangeLinkFixed: + if (pParams.Length > 1) + { + BSPrimLinkable child = pParams[1] as BSPrimLinkable; + if (child != null) + { + m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() + { + // Pick up all the constraints currently created. + RemoveDependencies(child); + + BSLinkInfo linkInfo = null; + if (m_children.TryGetValue(child, out linkInfo)) + { + BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; + if (linkInfoC != null) + { + // Setting to fixed is easy. The reset state is the fixed link configuration. + linkInfoC.ResetLink(); + ret = (object)true; + } + } + // Cause the whole linkset to be rebuilt in post-taint time. + Refresh(child); + }); + } + } + break; + case BSScene.PhysFunctChangeLinkSpring: + if (pParams.Length > 11) + { + BSPrimLinkable child = pParams[1] as BSPrimLinkable; + if (child != null) + { + m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() + { + // Pick up all the constraints currently created. + RemoveDependencies(child); + + BSLinkInfo linkInfo = null; + if (m_children.TryGetValue(child, out linkInfo)) + { + BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; + if (linkInfoC != null) + { + // Start with a reset link definition + linkInfoC.ResetLink(); + linkInfoC.constraintType = ConstraintType.D6_SPRING_CONSTRAINT_TYPE; + linkInfoC.frameInAloc = (OMV.Vector3)pParams[2]; + linkInfoC.frameInArot = (OMV.Quaternion)pParams[3]; + linkInfoC.frameInBloc = (OMV.Vector3)pParams[4]; + linkInfoC.frameInBrot = (OMV.Quaternion)pParams[5]; + linkInfoC.linearLimitLow = (OMV.Vector3)pParams[6]; + linkInfoC.linearLimitHigh = (OMV.Vector3)pParams[7]; + linkInfoC.angularLimitLow = (OMV.Vector3)pParams[8]; + linkInfoC.angularLimitHigh = (OMV.Vector3)pParams[9]; + ret = (object)true; + } + } + // Cause the whole linkset to be rebuilt in post-taint time. + Refresh(child); + }); + } + } + break; + default: + ret = base.Extension(pFunct, pParams); + break; + } + return ret; + } + #endregion // Extension + } } -- cgit v1.1 From 455d36c4c70a55c5d48dc1410b8729929fafedf6 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 9 Aug 2013 10:59:10 -0700 Subject: BulletSim: add physChangeLinkParams to set individual parameters on link constraints. Not fully functional. Remove double definition of ExtendedPhysics parameters by having BulletSim reference the optional module (addition to prebuild.xml and usings). --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 85 ++++++++-------------- 1 file changed, 31 insertions(+), 54 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 17fec9d..c09dd42 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -28,6 +28,8 @@ using System; using System.Collections.Generic; using System.Text; +using OpenSim.Region.OptionalModules.Scripting; + using OMV = OpenMetaverse; namespace OpenSim.Region.Physics.BulletSPlugin @@ -489,71 +491,46 @@ public sealed class BSLinksetConstraints : BSLinkset switch (pFunct) { // pParams = (int linkNUm, PhysActor linkChild) - case BSScene.PhysFunctChangeLinkFixed: + case ExtendedPhysics.PhysFunctChangeLinkType: if (pParams.Length > 1) { - BSPrimLinkable child = pParams[1] as BSPrimLinkable; - if (child != null) + int requestedType = (int)pParams[1]; + if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.HINGE_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.CONETWIST_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.SLIDER_CONSTRAINT_TYPE) { - m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() + BSPrimLinkable child = pParams[0] as BSPrimLinkable; + if (child != null) { - // Pick up all the constraints currently created. - RemoveDependencies(child); - - BSLinkInfo linkInfo = null; - if (m_children.TryGetValue(child, out linkInfo)) + m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() { - BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; - if (linkInfoC != null) - { - // Setting to fixed is easy. The reset state is the fixed link configuration. - linkInfoC.ResetLink(); - ret = (object)true; - } - } - // Cause the whole linkset to be rebuilt in post-taint time. - Refresh(child); - }); - } - } - break; - case BSScene.PhysFunctChangeLinkSpring: - if (pParams.Length > 11) - { - BSPrimLinkable child = pParams[1] as BSPrimLinkable; - if (child != null) - { - m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() - { - // Pick up all the constraints currently created. - RemoveDependencies(child); + // Pick up all the constraints currently created. + RemoveDependencies(child); - BSLinkInfo linkInfo = null; - if (m_children.TryGetValue(child, out linkInfo)) - { - BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; - if (linkInfoC != null) + BSLinkInfo linkInfo = null; + if (m_children.TryGetValue(child, out linkInfo)) { - // Start with a reset link definition - linkInfoC.ResetLink(); - linkInfoC.constraintType = ConstraintType.D6_SPRING_CONSTRAINT_TYPE; - linkInfoC.frameInAloc = (OMV.Vector3)pParams[2]; - linkInfoC.frameInArot = (OMV.Quaternion)pParams[3]; - linkInfoC.frameInBloc = (OMV.Vector3)pParams[4]; - linkInfoC.frameInBrot = (OMV.Quaternion)pParams[5]; - linkInfoC.linearLimitLow = (OMV.Vector3)pParams[6]; - linkInfoC.linearLimitHigh = (OMV.Vector3)pParams[7]; - linkInfoC.angularLimitLow = (OMV.Vector3)pParams[8]; - linkInfoC.angularLimitHigh = (OMV.Vector3)pParams[9]; - ret = (object)true; + BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; + if (linkInfoC != null) + { + // Setting to fixed is easy. The reset state is the fixed link configuration. + linkInfoC.ResetLink(); + linkInfoC.constraintType = (ConstraintType)requestedType; + ret = (object)true; + } } - } - // Cause the whole linkset to be rebuilt in post-taint time. - Refresh(child); - }); + // Cause the whole linkset to be rebuilt in post-taint time. + Refresh(child); + }); + } } } break; + case ExtendedPhysics.PhysFunctChangeLinkParams: + break; default: ret = base.Extension(pFunct, pParams); break; -- cgit v1.1 From f6fdfd16f55c3e1bd55775f1f21e0ac9e44ff2ee Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 9 Aug 2013 17:01:35 -0700 Subject: BulletSim: change ExtendedPhysics constants to 'const' so they can be used as case variables in switch statements. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index c09dd42..b72afc0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -530,6 +530,28 @@ public sealed class BSLinksetConstraints : BSLinkset } break; case ExtendedPhysics.PhysFunctChangeLinkParams: + int setParam = 2; + switch (setParam) + { + case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: + case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: + case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: + case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: + case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: + case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: + case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: + case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: + case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: + case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: + case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: + case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: + case ExtendedPhysics.PHYS_PARAM_CFM: + case ExtendedPhysics.PHYS_PARAM_ERP: + case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: + case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: + case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: + break; + } break; default: ret = base.Extension(pFunct, pParams); -- cgit v1.1 From e1120cb74db9092cc0f9a7fc245d2f2ed6160b7a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Aug 2013 13:44:31 -0700 Subject: BulletSim: add extended physics function physGetLinkType(linkNum). Add implementation of physChangeLinkParams() in BSLinksetConstraint. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 145 ++++++++++++++++++--- 1 file changed, 124 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index b72afc0..92df84e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -168,6 +168,8 @@ public sealed class BSLinksetConstraints : BSLinkset LinksetImpl = LinksetImplementation.Constraint; } + private static string LogHeader = "[BULLETSIM LINKSET CONSTRAINT]"; + // When physical properties are changed the linkset needs to recalculate // its internal properties. // This is queued in the 'post taint' queue so the @@ -511,7 +513,7 @@ public sealed class BSLinksetConstraints : BSLinkset RemoveDependencies(child); BSLinkInfo linkInfo = null; - if (m_children.TryGetValue(child, out linkInfo)) + if (TryGetLinkInfo(child, out linkInfo)) { BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; if (linkInfoC != null) @@ -529,28 +531,129 @@ public sealed class BSLinksetConstraints : BSLinkset } } break; + case ExtendedPhysics.PhysFunctGetLinkType: + if (pParams.Length > 0) + { + BSPrimLinkable child = pParams[0] as BSPrimLinkable; + if (child != null) + { + BSLinkInfo linkInfo = null; + if (TryGetLinkInfo(child, out linkInfo)) + { + BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; + if (linkInfoC != null) + { + ret = (object)(int)linkInfoC.constraintType; + } + } + } + } + break; case ExtendedPhysics.PhysFunctChangeLinkParams: - int setParam = 2; - switch (setParam) + // There should be two parameters: the childActor and a list of parameters to set + try + { + if (pParams.Length > 1) + { + BSPrimLinkable child = pParams[0] as BSPrimLinkable; + object[] setOps = (object[])pParams[1]; + BSLinkInfo baseLinkInfo = null; + if (TryGetLinkInfo(child, out baseLinkInfo)) + { + BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; + if (linkInfo != null) + { + float valueFloat; + bool valueBool; + OMV.Vector3 valueVector; + OMV.Quaternion valueQuaternion; + + int opIndex = 0; + while (opIndex < setOps.Length) + { + int thisOp = (int)setOps[opIndex]; + switch (thisOp) + { + case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.frameInAloc = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: + valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; + linkInfo.frameInArot = valueQuaternion; + break; + case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.frameInBloc = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: + valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; + linkInfo.frameInBrot = valueQuaternion; + break; + case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.linearLimitLow = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.linearLimitHigh = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.angularLimitLow = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.angularLimitHigh = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: + valueBool = (bool)setOps[opIndex + 1]; + linkInfo.useFrameOffset = valueBool; + break; + case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: + valueBool = (bool)setOps[opIndex + 1]; + linkInfo.enableTransMotor = valueBool; + break; + case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.transMotorMaxVel = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.transMotorMaxForce = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_CFM: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.cfm = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_ERP: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.erp = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.solverIterations = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.springDamping = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.springStiffness = valueFloat; + break; + default: + break; + } + } + } + } + } + } + catch (Exception e) { - case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: - case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: - case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: - case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: - case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: - case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: - case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: - case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: - case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: - case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: - case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: - case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: - case ExtendedPhysics.PHYS_PARAM_CFM: - case ExtendedPhysics.PHYS_PARAM_ERP: - case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: - case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: - case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: - break; + // There are many ways to mess up the parameters. If not just right don't fail without some error. + m_physicsScene.Logger.WarnFormat("{0} bad parameters in physSetLinksetParams: {1}", LogHeader, e); } break; default: -- cgit v1.1 From 4781297b4ee5908b76039ce3b38291eb2e89e157 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 20 Aug 2013 08:14:08 -0700 Subject: BulletSim: Extension parameters passed through the classes made to pass just and array of objects rather than a mixture of parameters and array. Makes understanding and parsing what is being passed much easier. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 93 ++++++++++++++++------ 1 file changed, 69 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 92df84e..87716b4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -343,7 +343,7 @@ public sealed class BSLinksetConstraints : BSLinkset // real world coordinate of midpoint between the two objects OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); - DetailLog("{0},BSLinksetConstraint.BuildConstraint,6Dof,rBody={1},cBody={2},rLoc={3},cLoc={4},midLoc={7}", + DetailLog("{0},BSLinksetConstraint.BuildConstraint,6Dof,rBody={1},cBody={2},rLoc={3},cLoc={4},midLoc={5}", rootPrim.LocalID, rootPrim.PhysBody, linkInfo.member.PhysBody, rootPrim.Position, linkInfo.member.Position, midPoint); @@ -492,11 +492,12 @@ public sealed class BSLinksetConstraints : BSLinkset object ret = null; switch (pFunct) { - // pParams = (int linkNUm, PhysActor linkChild) + // pParams = [ BSPhysObject child, integer linkType ] case ExtendedPhysics.PhysFunctChangeLinkType: if (pParams.Length > 1) { int requestedType = (int)pParams[1]; + DetailLog("{0},BSLinksetConstraint.SetLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType); if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE @@ -507,7 +508,7 @@ public sealed class BSLinksetConstraints : BSLinkset BSPrimLinkable child = pParams[0] as BSPrimLinkable; if (child != null) { - m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() + m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkType", delegate() { // Pick up all the constraints currently created. RemoveDependencies(child); @@ -522,15 +523,35 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfoC.ResetLink(); linkInfoC.constraintType = (ConstraintType)requestedType; ret = (object)true; + DetailLog("{0},BSLinksetConstraint.SetLinkType,link={1},type={2}", + linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType); + } + else + { + DetailLog("{0},BSLinksetConstraint.SetLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID); } } + else + { + DetailLog("{0},BSLinksetConstraint.SetLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID); + } // Cause the whole linkset to be rebuilt in post-taint time. Refresh(child); }); } + else + { + DetailLog("{0},BSLinksetConstraint.SetLinkType,childNotBSPrimLinkable", LinksetRoot.LocalID); + } + } + else + { + DetailLog("{0},BSLinksetConstraint.SetLinkType,illegalRequestedType,reqested={1},spring={2}", + LinksetRoot.LocalID, requestedType, ((int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE)); } } break; + // pParams = [] case ExtendedPhysics.PhysFunctGetLinkType: if (pParams.Length > 0) { @@ -544,11 +565,15 @@ public sealed class BSLinksetConstraints : BSLinkset if (linkInfoC != null) { ret = (object)(int)linkInfoC.constraintType; + DetailLog("{0},BSLinksetConstraint.GetLinkType,link={1},type={2}", + linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType); + } } } } break; + // pParams = [ BSPhysObject child, int op, object opParams, int op, object opParams, ... ] case ExtendedPhysics.PhysFunctChangeLinkParams: // There should be two parameters: the childActor and a list of parameters to set try @@ -556,7 +581,6 @@ public sealed class BSLinksetConstraints : BSLinkset if (pParams.Length > 1) { BSPrimLinkable child = pParams[0] as BSPrimLinkable; - object[] setOps = (object[])pParams[1]; BSLinkInfo baseLinkInfo = null; if (TryGetLinkInfo(child, out baseLinkInfo)) { @@ -568,85 +592,106 @@ public sealed class BSLinksetConstraints : BSLinkset OMV.Vector3 valueVector; OMV.Quaternion valueQuaternion; - int opIndex = 0; - while (opIndex < setOps.Length) + int opIndex = 1; + while (opIndex < pParams.Length) { - int thisOp = (int)setOps[opIndex]; + int thisOp = (int)pParams[opIndex]; + DetailLog("{0},BSLinksetConstraint.ChangeLinkParams2,op={1},val={2}", + linkInfo.member.LocalID, thisOp, pParams[opIndex+1]); switch (thisOp) { case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInAloc = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: - valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; + valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1]; linkInfo.frameInArot = valueQuaternion; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInBloc = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: - valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; + valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1]; linkInfo.frameInBrot = valueQuaternion; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.linearLimitLow = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.linearLimitHigh = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.angularLimitLow = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.angularLimitHigh = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: - valueBool = (bool)setOps[opIndex + 1]; + valueBool = (bool)pParams[opIndex + 1]; linkInfo.useFrameOffset = valueBool; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: - valueBool = (bool)setOps[opIndex + 1]; + valueBool = (bool)pParams[opIndex + 1]; linkInfo.enableTransMotor = valueBool; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.transMotorMaxVel = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.transMotorMaxForce = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_CFM: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.cfm = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ERP: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.erp = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.solverIterations = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.springDamping = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.springStiffness = valueFloat; + opIndex += 2; break; default: break; } } } + // Something changed so a rebuild is in order + Refresh(child); } } } -- cgit v1.1 From 995314f91f72eef0048a58f30e8dd8051f6bf14e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 20 Aug 2013 09:20:48 -0700 Subject: BulletSim: add ID parameter to TaintedObject calls so logging will include LocalID of object which created the taint. --- OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 87716b4..b2a9501 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -297,7 +297,7 @@ public sealed class BSLinksetConstraints : BSLinkset rootx.LocalID, rootx.PhysBody.AddrString, childx.LocalID, childx.PhysBody.AddrString); - m_physicsScene.TaintedObject(inTaintTime, "BSLinksetConstraints.RemoveChildFromLinkset", delegate() + m_physicsScene.TaintedObject(inTaintTime, childx.LocalID, "BSLinksetConstraints.RemoveChildFromLinkset", delegate() { PhysicallyUnlinkAChildFromRoot(rootx, childx); }); @@ -508,7 +508,7 @@ public sealed class BSLinksetConstraints : BSLinkset BSPrimLinkable child = pParams[0] as BSPrimLinkable; if (child != null) { - m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkType", delegate() + m_physicsScene.TaintedObject(child.LocalID, "BSLinksetConstraint.PhysFunctChangeLinkType", delegate() { // Pick up all the constraints currently created. RemoveDependencies(child); -- cgit v1.1 From d09c35f5063114880aecb94a938bfc49f5af5f7d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 20 Aug 2013 13:09:40 -0700 Subject: BulletSim: pass both root and child BSPhysObjects to Extension function. Update routines to use the new parameters list from above change. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index b2a9501..a9ae89d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -385,7 +385,7 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot, true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/); - DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", + DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6}", rootPrim.LocalID, rootPrim.LocalID, rootPrim.PhysBody.AddrString, linkInfo.member.LocalID, linkInfo.member.PhysBody.AddrString, @@ -492,12 +492,12 @@ public sealed class BSLinksetConstraints : BSLinkset object ret = null; switch (pFunct) { - // pParams = [ BSPhysObject child, integer linkType ] + // pParams = [ BSPhysObject root, BSPhysObject child, integer linkType ] case ExtendedPhysics.PhysFunctChangeLinkType: - if (pParams.Length > 1) + if (pParams.Length > 2) { - int requestedType = (int)pParams[1]; - DetailLog("{0},BSLinksetConstraint.SetLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType); + int requestedType = (int)pParams[2]; + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType); if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE @@ -505,9 +505,11 @@ public sealed class BSLinksetConstraints : BSLinkset || requestedType == (int)ConstraintType.CONETWIST_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.SLIDER_CONSTRAINT_TYPE) { - BSPrimLinkable child = pParams[0] as BSPrimLinkable; + BSPrimLinkable child = pParams[1] as BSPrimLinkable; if (child != null) { + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,rootID={1},childID={2},type={3}", + LinksetRoot.LocalID, LinksetRoot.LocalID, child.LocalID, requestedType); m_physicsScene.TaintedObject(child.LocalID, "BSLinksetConstraint.PhysFunctChangeLinkType", delegate() { // Pick up all the constraints currently created. @@ -523,17 +525,17 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfoC.ResetLink(); linkInfoC.constraintType = (ConstraintType)requestedType; ret = (object)true; - DetailLog("{0},BSLinksetConstraint.SetLinkType,link={1},type={2}", + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,link={1},type={2}", linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType); } else { - DetailLog("{0},BSLinksetConstraint.SetLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID); + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID); } } else { - DetailLog("{0},BSLinksetConstraint.SetLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID); + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID); } // Cause the whole linkset to be rebuilt in post-taint time. Refresh(child); @@ -551,11 +553,11 @@ public sealed class BSLinksetConstraints : BSLinkset } } break; - // pParams = [] + // pParams = [ BSPhysObject root, BSPhysObject child ] case ExtendedPhysics.PhysFunctGetLinkType: if (pParams.Length > 0) { - BSPrimLinkable child = pParams[0] as BSPrimLinkable; + BSPrimLinkable child = pParams[1] as BSPrimLinkable; if (child != null) { BSLinkInfo linkInfo = null; @@ -573,14 +575,14 @@ public sealed class BSLinksetConstraints : BSLinkset } } break; - // pParams = [ BSPhysObject child, int op, object opParams, int op, object opParams, ... ] + // pParams = [ BSPhysObject root, BSPhysObject child, int op, object opParams, int op, object opParams, ... ] case ExtendedPhysics.PhysFunctChangeLinkParams: // There should be two parameters: the childActor and a list of parameters to set try { - if (pParams.Length > 1) + if (pParams.Length > 2) { - BSPrimLinkable child = pParams[0] as BSPrimLinkable; + BSPrimLinkable child = pParams[1] as BSPrimLinkable; BSLinkInfo baseLinkInfo = null; if (TryGetLinkInfo(child, out baseLinkInfo)) { @@ -592,7 +594,7 @@ public sealed class BSLinksetConstraints : BSLinkset OMV.Vector3 valueVector; OMV.Quaternion valueQuaternion; - int opIndex = 1; + int opIndex = 2; while (opIndex < pParams.Length) { int thisOp = (int)pParams[opIndex]; -- cgit v1.1 From 30b3657a66e5a4012b96baae2c0424ec13409f83 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 09:08:58 -0700 Subject: BulletSim: implementation of setting spring specific physical parameters. Add setting of linkset type to physChangeLinkParams. Lots of detail logging for setting of linkset constraint parameters. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 52 +++++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index a9ae89d..be97c29 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -67,6 +67,7 @@ public sealed class BSLinksetConstraints : BSLinkset { constraint = null; ResetLink(); + member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.creation", member.LocalID); } // Set all the parameters for this constraint to a fixed, non-movable constraint. @@ -91,11 +92,13 @@ public sealed class BSLinksetConstraints : BSLinkset frameInBrot = OMV.Quaternion.Identity; springDamping = -1f; springStiffness = -1f; + member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID); } // Given a constraint, apply the current constraint parameters to same. public override void SetLinkParameters(BSConstraint constrain) { + member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.SetLinkParameters,type={1}", member.LocalID, constraintType); switch (constraintType) { case ConstraintType.FIXED_CONSTRAINT_TYPE: @@ -139,7 +142,7 @@ public sealed class BSLinksetConstraints : BSLinkset if (springDamping != -1) constrainSpring.SetDamping(ii, springDamping); if (springStiffness != -1) - constrainSpring.SetStiffness(ii, springStiffness); + constrainSpring.SetStiffness(ii, springStiffness); } } break; @@ -155,7 +158,6 @@ public sealed class BSLinksetConstraints : BSLinkset public override bool ShouldUpdateChildProperties() { bool ret = true; - if (constraintType == ConstraintType.FIXED_CONSTRAINT_TYPE) ret = false; @@ -193,10 +195,16 @@ public sealed class BSLinksetConstraints : BSLinkset { // Queue to happen after all the other taint processing m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() + { + if (HasAnyChildren) { - if (HasAnyChildren) - RecomputeLinksetConstraints(); - }); + // Constraints that have not been changed are not rebuild but make sure + // the constraint of the requestor is rebuilt. + PhysicallyUnlinkAChildFromRoot(LinksetRoot, requestor); + // Rebuild the linkset and all its constraints. + RecomputeLinksetConstraints(); + } + }); } } @@ -415,13 +423,22 @@ public sealed class BSLinksetConstraints : BSLinkset rootPrim.LocalID, rootPrim.PhysBody.AddrString, childPrim.LocalID, childPrim.PhysBody.AddrString); - // Find the constraint for this link and get rid of it from the overall collection and from my list - if (m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) + // If asked to unlink root from root, just remove all the constraints + if (rootPrim == childPrim || childPrim == LinksetRoot) { - // Make the child refresh its location - m_physicsScene.PE.PushUpdate(childPrim.PhysBody); + PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); ret = true; } + else + { + // Find the constraint for this link and get rid of it from the overall collection and from my list + if (m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) + { + // Make the child refresh its location + m_physicsScene.PE.PushUpdate(childPrim.PhysBody); + ret = true; + } + } return ret; } @@ -521,8 +538,6 @@ public sealed class BSLinksetConstraints : BSLinkset BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; if (linkInfoC != null) { - // Setting to fixed is easy. The reset state is the fixed link configuration. - linkInfoC.ResetLink(); linkInfoC.constraintType = (ConstraintType)requestedType; ret = (object)true; DetailLog("{0},BSLinksetConstraint.ChangeLinkType,link={1},type={2}", @@ -589,6 +604,7 @@ public sealed class BSLinksetConstraints : BSLinkset BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; if (linkInfo != null) { + int valueInt; float valueFloat; bool valueBool; OMV.Vector3 valueVector; @@ -602,6 +618,20 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.member.LocalID, thisOp, pParams[opIndex+1]); switch (thisOp) { + case ExtendedPhysics.PHYS_PARAM_LINK_TYPE: + valueInt = (int)pParams[opIndex + 1]; + ConstraintType valueType = (ConstraintType)valueInt; + if (valueType == ConstraintType.FIXED_CONSTRAINT_TYPE + || valueType == ConstraintType.D6_CONSTRAINT_TYPE + || valueType == ConstraintType.D6_SPRING_CONSTRAINT_TYPE + || valueType == ConstraintType.HINGE_CONSTRAINT_TYPE + || valueType == ConstraintType.CONETWIST_CONSTRAINT_TYPE + || valueType == ConstraintType.SLIDER_CONSTRAINT_TYPE) + { + linkInfo.constraintType = valueType; + } + opIndex += 2; + break; case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInAloc = valueVector; -- cgit v1.1 From 7c54630a2dde768e92b3034d76314cb1e061c348 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 16:31:17 -0700 Subject: BulletSim: add axis parameter for specifying enable, damping, and stiffness for spring constraints. Renumber parameter ops since I can as no one is using them yet. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 51 +++++++++++++++------- 1 file changed, 36 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index be97c29..f623231 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -59,8 +59,9 @@ public sealed class BSLinksetConstraints : BSLinkset public OMV.Vector3 frameInBloc; public OMV.Quaternion frameInBrot; // Spring - public float springDamping; - public float springStiffness; + public bool[] springAxisEnable; + public float[] springDamping; + public float[] springStiffness; public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) @@ -90,8 +91,15 @@ public sealed class BSLinksetConstraints : BSLinkset frameInArot = OMV.Quaternion.Identity; frameInBloc = OMV.Vector3.Zero; frameInBrot = OMV.Quaternion.Identity; - springDamping = -1f; - springStiffness = -1f; + springAxisEnable = new bool[6]; + springDamping = new float[6]; + springStiffness = new float[6]; + for (int ii = 0; ii < springAxisEnable.Length; ii++) + { + springAxisEnable[ii] = false; + springDamping[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; + springStiffness[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; + } member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID); } @@ -139,11 +147,13 @@ public sealed class BSLinksetConstraints : BSLinkset } for (int ii = 0; ii < 6; ii++) { - if (springDamping != -1) - constrainSpring.SetDamping(ii, springDamping); - if (springStiffness != -1) - constrainSpring.SetStiffness(ii, springStiffness); + constrainSpring.SetAxisEnable(ii, springAxisEnable[ii]); + if (springDamping[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) + constrainSpring.SetDamping(ii, springDamping[ii]); + if (springStiffness[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) + constrainSpring.SetStiffness(ii, springStiffness[ii]); } + constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED); } break; default: @@ -707,15 +717,26 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.solverIterations = valueFloat; opIndex += 2; break; + case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE: + valueInt = (int)pParams[opIndex + 1]; + valueBool = ((int)pParams[opIndex + 2] != 0); + if (valueInt >=0 && valueInt < linkInfo.springAxisEnable.Length) + linkInfo.springAxisEnable[valueInt] = valueBool; + opIndex += 3; + break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: - valueFloat = (float)pParams[opIndex + 1]; - linkInfo.springDamping = valueFloat; - opIndex += 2; + valueInt = (int)pParams[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 2]; + if (valueInt >=0 && valueInt < linkInfo.springDamping.Length) + linkInfo.springDamping[valueInt] = valueFloat; + opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: - valueFloat = (float)pParams[opIndex + 1]; - linkInfo.springStiffness = valueFloat; - opIndex += 2; + valueInt = (int)pParams[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 2]; + if (valueInt >=0 && valueInt < linkInfo.springStiffness.Length) + linkInfo.springStiffness[valueInt] = valueFloat; + opIndex += 3; break; default: break; -- cgit v1.1 From cf2cdc191d0a93860da1ff4c42d34138e8f369fb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 24 Aug 2013 08:33:28 -0700 Subject: BulletSim: ability to specify groups of axis to modify in constraint parameters that control multiple axis. Add useLinearReferenceFrameA constraint parameter. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 53 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index f623231..ff5ac0e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -58,6 +58,7 @@ public sealed class BSLinksetConstraints : BSLinkset public OMV.Quaternion frameInArot; public OMV.Vector3 frameInBloc; public OMV.Quaternion frameInBrot; + public bool useLinearReferenceFrameA; // Spring public bool[] springAxisEnable; public float[] springDamping; @@ -91,6 +92,7 @@ public sealed class BSLinksetConstraints : BSLinkset frameInArot = OMV.Quaternion.Identity; frameInBloc = OMV.Vector3.Zero; frameInBrot = OMV.Quaternion.Identity; + useLinearReferenceFrameA = true; springAxisEnable = new bool[6]; springDamping = new float[6]; springStiffness = new float[6]; @@ -145,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset { constrainSpring.SetSolverIterations(solverIterations); } - for (int ii = 0; ii < 6; ii++) + for (int ii = 0; ii < springAxisEnable.Length; ii++) { constrainSpring.SetAxisEnable(ii, springAxisEnable[ii]); if (springDamping[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) @@ -401,7 +403,7 @@ public sealed class BSLinksetConstraints : BSLinkset case ConstraintType.D6_SPRING_CONSTRAINT_TYPE: constrain = new BSConstraintSpring(m_physicsScene.World, rootPrim.PhysBody, linkInfo.member.PhysBody, linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot, - true /*useLinearReferenceFrameA*/, + linkInfo.useLinearReferenceFrameA, true /*disableCollisionsBetweenLinkedBodies*/); DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6}", rootPrim.LocalID, @@ -619,6 +621,7 @@ public sealed class BSLinksetConstraints : BSLinkset bool valueBool; OMV.Vector3 valueVector; OMV.Quaternion valueQuaternion; + int axisLow, axisHigh; int opIndex = 2; while (opIndex < pParams.Length) @@ -720,24 +723,32 @@ public sealed class BSLinksetConstraints : BSLinkset case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE: valueInt = (int)pParams[opIndex + 1]; valueBool = ((int)pParams[opIndex + 2] != 0); - if (valueInt >=0 && valueInt < linkInfo.springAxisEnable.Length) - linkInfo.springAxisEnable[valueInt] = valueBool; + GetAxisRange(valueInt, out axisLow, out axisHigh); + for (int ii = axisLow; ii <= axisHigh; ii++) + linkInfo.springAxisEnable[ii] = valueBool; opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: valueInt = (int)pParams[opIndex + 1]; valueFloat = (float)pParams[opIndex + 2]; - if (valueInt >=0 && valueInt < linkInfo.springDamping.Length) - linkInfo.springDamping[valueInt] = valueFloat; + GetAxisRange(valueInt, out axisLow, out axisHigh); + for (int ii = axisLow; ii <= axisHigh; ii++) + linkInfo.springDamping[ii] = valueFloat; opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: valueInt = (int)pParams[opIndex + 1]; valueFloat = (float)pParams[opIndex + 2]; - if (valueInt >=0 && valueInt < linkInfo.springStiffness.Length) - linkInfo.springStiffness[valueInt] = valueFloat; + GetAxisRange(valueInt, out axisLow, out axisHigh); + for (int ii = axisLow; ii <= axisHigh; ii++) + linkInfo.springStiffness[ii] = valueFloat; opIndex += 3; break; + case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA: + valueBool = (bool)pParams[opIndex + 1]; + linkInfo.useLinearReferenceFrameA = valueBool; + opIndex += 2; + break; default: break; } @@ -760,6 +771,32 @@ public sealed class BSLinksetConstraints : BSLinkset } return ret; } + + // Bullet constraints keep some limit parameters for each linear and angular axis. + // Setting same is easier if there is an easy way to see all or types. + // This routine returns the array limits for the set of axis. + private void GetAxisRange(int rangeSpec, out int low, out int high) + { + switch (rangeSpec) + { + case ExtendedPhysics.PHYS_AXIS_ALL_LINEAR: + low = 0; + high = 2; + break; + case ExtendedPhysics.PHYS_AXIS_ALL_ANGULAR: + low = 3; + high = 5; + break; + case ExtendedPhysics.PHYS_AXIS_ALL: + low = 0; + high = 5; + break; + default: + low = high = rangeSpec; + break; + } + return; + } #endregion // Extension } -- cgit v1.1 From 5827b6e1aabf2e19624faf0141b9611917fb84c5 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 4 Sep 2013 07:56:59 -0700 Subject: BulletSim: add extended physics LSL constants for axis specification. Add specific error warnings for mis-matched parameter types in extended physics functions. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 89 ++++++++++++++-------- 1 file changed, 57 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index ff5ac0e..b3347bf 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -605,30 +605,32 @@ public sealed class BSLinksetConstraints : BSLinkset // pParams = [ BSPhysObject root, BSPhysObject child, int op, object opParams, int op, object opParams, ... ] case ExtendedPhysics.PhysFunctChangeLinkParams: // There should be two parameters: the childActor and a list of parameters to set - try + if (pParams.Length > 2) { - if (pParams.Length > 2) + BSPrimLinkable child = pParams[1] as BSPrimLinkable; + BSLinkInfo baseLinkInfo = null; + if (TryGetLinkInfo(child, out baseLinkInfo)) { - BSPrimLinkable child = pParams[1] as BSPrimLinkable; - BSLinkInfo baseLinkInfo = null; - if (TryGetLinkInfo(child, out baseLinkInfo)) + BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; + if (linkInfo != null) { - BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; - if (linkInfo != null) + int valueInt; + float valueFloat; + bool valueBool; + OMV.Vector3 valueVector; + OMV.Quaternion valueQuaternion; + int axisLow, axisHigh; + + int opIndex = 2; + while (opIndex < pParams.Length) { - int valueInt; - float valueFloat; - bool valueBool; - OMV.Vector3 valueVector; - OMV.Quaternion valueQuaternion; - int axisLow, axisHigh; - - int opIndex = 2; - while (opIndex < pParams.Length) + int thisOp = 0; + string errMsg = ""; + try { - int thisOp = (int)pParams[opIndex]; + thisOp = (int)pParams[opIndex]; DetailLog("{0},BSLinksetConstraint.ChangeLinkParams2,op={1},val={2}", - linkInfo.member.LocalID, thisOp, pParams[opIndex+1]); + linkInfo.member.LocalID, thisOp, pParams[opIndex + 1]); switch (thisOp) { case ExtendedPhysics.PHYS_PARAM_LINK_TYPE: @@ -646,89 +648,106 @@ public sealed class BSLinksetConstraints : BSLinkset opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: + errMsg = "PHYS_PARAM_FRAMEINA_LOC takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInAloc = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: + errMsg = "PHYS_PARAM_FRAMEINA_ROT takes one parameter of type rotation"; valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1]; linkInfo.frameInArot = valueQuaternion; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: + errMsg = "PHYS_PARAM_FRAMEINB_LOC takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInBloc = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: + errMsg = "PHYS_PARAM_FRAMEINB_ROT takes one parameter of type rotation"; valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1]; linkInfo.frameInBrot = valueQuaternion; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: + errMsg = "PHYS_PARAM_LINEAR_LIMIT_LOW takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.linearLimitLow = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: + errMsg = "PHYS_PARAM_LINEAR_LIMIT_HIGH takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.linearLimitHigh = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: + errMsg = "PHYS_PARAM_ANGULAR_LIMIT_LOW takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.angularLimitLow = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: + errMsg = "PHYS_PARAM_ANGULAR_LIMIT_HIGH takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.angularLimitHigh = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: - valueBool = (bool)pParams[opIndex + 1]; + errMsg = "PHYS_PARAM_USE_FRAME_OFFSET takes one parameter of type integer (bool)"; + valueBool = ((int)pParams[opIndex + 1]) != 0; linkInfo.useFrameOffset = valueBool; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: - valueBool = (bool)pParams[opIndex + 1]; + errMsg = "PHYS_PARAM_ENABLE_TRANSMOTOR takes one parameter of type integer (bool)"; + valueBool = ((int)pParams[opIndex + 1]) != 0; linkInfo.enableTransMotor = valueBool; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: + errMsg = "PHYS_PARAM_TRANSMOTOR_MAXVEL takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.transMotorMaxVel = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: + errMsg = "PHYS_PARAM_TRANSMOTOR_MAXFORCE takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.transMotorMaxForce = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_CFM: + errMsg = "PHYS_PARAM_CFM takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.cfm = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ERP: + errMsg = "PHYS_PARAM_ERP takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.erp = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: + errMsg = "PHYS_PARAM_SOLVER_ITERATIONS takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.solverIterations = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE: + errMsg = "PHYS_PARAM_SPRING_AXIS_ENABLE takes two parameters of types integer and integer (bool)"; valueInt = (int)pParams[opIndex + 1]; - valueBool = ((int)pParams[opIndex + 2] != 0); + valueBool = ((int)pParams[opIndex + 2]) != 0; GetAxisRange(valueInt, out axisLow, out axisHigh); for (int ii = axisLow; ii <= axisHigh; ii++) linkInfo.springAxisEnable[ii] = valueBool; opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: + errMsg = "PHYS_PARAM_SPRING_DAMPING takes two parameters of types integer and float"; valueInt = (int)pParams[opIndex + 1]; valueFloat = (float)pParams[opIndex + 2]; GetAxisRange(valueInt, out axisLow, out axisHigh); @@ -737,6 +756,7 @@ public sealed class BSLinksetConstraints : BSLinkset opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: + errMsg = "PHYS_PARAM_SPRING_STIFFNESS takes two parameters of types integer and float"; valueInt = (int)pParams[opIndex + 1]; valueFloat = (float)pParams[opIndex + 2]; GetAxisRange(valueInt, out axisLow, out axisHigh); @@ -745,7 +765,8 @@ public sealed class BSLinksetConstraints : BSLinkset opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA: - valueBool = (bool)pParams[opIndex + 1]; + errMsg = "PHYS_PARAM_USE_LINEAR_FRAMEA takes one parameter of type integer (bool)"; + valueBool = ((int)pParams[opIndex + 1]) != 0; linkInfo.useLinearReferenceFrameA = valueBool; opIndex += 2; break; @@ -753,18 +774,22 @@ public sealed class BSLinksetConstraints : BSLinkset break; } } + catch (InvalidCastException e) + { + m_physicsScene.Logger.WarnFormat("{0} value of wrong type in physSetLinksetParams: {1}, err={2}", + LogHeader, errMsg, e); + } + catch (Exception e) + { + m_physicsScene.Logger.WarnFormat("{0} bad parameters in physSetLinksetParams: {1}", LogHeader, e); + } } - // Something changed so a rebuild is in order - Refresh(child); } + // Something changed so a rebuild is in order + Refresh(child); } } - catch (Exception e) - { - // There are many ways to mess up the parameters. If not just right don't fail without some error. - m_physicsScene.Logger.WarnFormat("{0} bad parameters in physSetLinksetParams: {1}", LogHeader, e); - } - break; + break; default: ret = base.Extension(pFunct, pParams); break; @@ -779,11 +804,11 @@ public sealed class BSLinksetConstraints : BSLinkset { switch (rangeSpec) { - case ExtendedPhysics.PHYS_AXIS_ALL_LINEAR: + case ExtendedPhysics.PHYS_AXIS_LINEAR_ALL: low = 0; high = 2; break; - case ExtendedPhysics.PHYS_AXIS_ALL_ANGULAR: + case ExtendedPhysics.PHYS_AXIS_ANGULAR_ALL: low = 3; high = 5; break; -- cgit v1.1 From c5eabb28b4c933cfacefa85381e290372fbc094e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 9 Sep 2013 14:53:16 -0700 Subject: BulletSim: add LSL function and plumbing for setting a spring equilibrium point in the physics engine constraint. --- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index b3347bf..aaf92c8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -63,6 +63,8 @@ public sealed class BSLinksetConstraints : BSLinkset public bool[] springAxisEnable; public float[] springDamping; public float[] springStiffness; + public OMV.Vector3 springLinearEquilibriumPoint; + public OMV.Vector3 springAngularEquilibriumPoint; public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) @@ -102,6 +104,8 @@ public sealed class BSLinksetConstraints : BSLinkset springDamping[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; springStiffness[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; } + springLinearEquilibriumPoint = OMV.Vector3.Zero; + springAngularEquilibriumPoint = OMV.Vector3.Zero; member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID); } @@ -155,7 +159,12 @@ public sealed class BSLinksetConstraints : BSLinkset if (springStiffness[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) constrainSpring.SetStiffness(ii, springStiffness[ii]); } - constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED); + constrainSpring.CalculateTransforms(); + + if (springLinearEquilibriumPoint != OMV.Vector3.Zero) + constrainSpring.SetEquilibriumPoint(springLinearEquilibriumPoint, springAngularEquilibriumPoint); + else + constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED); } break; default: @@ -618,6 +627,7 @@ public sealed class BSLinksetConstraints : BSLinkset float valueFloat; bool valueBool; OMV.Vector3 valueVector; + OMV.Vector3 valueVector2; OMV.Quaternion valueQuaternion; int axisLow, axisHigh; @@ -764,6 +774,14 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.springStiffness[ii] = valueFloat; opIndex += 3; break; + case ExtendedPhysics.PHYS_PARAM_SPRING_EQUILIBRIUM_POINT: + errMsg = "PHYS_PARAM_SPRING_EQUILIBRIUM_POINT takes two parameters of type vector"; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; + valueVector2 = (OMV.Vector3)pParams[opIndex + 2]; + linkInfo.springLinearEquilibriumPoint = valueVector; + linkInfo.springAngularEquilibriumPoint = valueVector2; + opIndex += 3; + break; case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA: errMsg = "PHYS_PARAM_USE_LINEAR_FRAMEA takes one parameter of type integer (bool)"; valueBool = ((int)pParams[opIndex + 1]) != 0; -- cgit v1.1