From 0dd47d88de49438184b2e10cc54ca051cc0d302d 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/BSConstraintConeTwist.cs | 54 ++++++++++++++ .../Physics/BulletSPlugin/BSConstraintSlider.cs | 55 ++++++++++++++ .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 85 ++++++++-------------- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 18 +++-- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 14 ---- 5 files changed, 153 insertions(+), 73 deletions(-) create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs new file mode 100755 index 0000000..7a76a9a --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyrightD + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.BulletSPlugin +{ + +public sealed class BSConstraintConeTwist : BSConstraint +{ + public override ConstraintType Type { get { return ConstraintType.CONETWIST_CONSTRAINT_TYPE; } } + + public BSConstraintConeTwist(BulletWorld world, BulletBody obj1, BulletBody obj2, + Vector3 frameInAloc, Quaternion frameInArot, + Vector3 frameInBloc, Quaternion frameInBrot, + bool disableCollisionsBetweenLinkedBodies) + : base(world) + { + m_body1 = obj1; + m_body2 = obj2; + m_constraint = PhysicsScene.PE.CreateConeTwistConstraint(world, obj1, obj2, + frameInAloc, frameInArot, frameInBloc, frameInBrot, + disableCollisionsBetweenLinkedBodies); + m_enabled = true; + } +} + +} diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs new file mode 100755 index 0000000..37cfa07 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs @@ -0,0 +1,55 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyrightD + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.BulletSPlugin +{ + +public sealed class BSConstraintSlider : BSConstraint +{ + public override ConstraintType Type { get { return ConstraintType.SLIDER_CONSTRAINT_TYPE; } } + + public BSConstraintSlider(BulletWorld world, BulletBody obj1, BulletBody obj2, + Vector3 frameInAloc, Quaternion frameInArot, + Vector3 frameInBloc, Quaternion frameInBrot, + bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) + : base(world) + { + m_body1 = obj1; + m_body2 = obj2; + m_constraint = PhysicsScene.PE.CreateSliderConstraint(world, obj1, obj2, + frameInAloc, frameInArot, frameInBloc, frameInBrot, + useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); + m_enabled = true; + } + +} + +} 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; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 4c384a6..6136257 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -30,6 +30,7 @@ using System.Linq; using System.Text; using OpenSim.Framework; +using OpenSim.Region.OptionalModules.Scripting; using OMV = OpenMetaverse; @@ -286,14 +287,14 @@ public class BSPrimLinkable : BSPrimDisplaced switch (pFunct) { // physGetLinksetType(); - case BSScene.PhysFunctGetLinksetType: + case ExtendedPhysics.PhysFunctGetLinksetType: { ret = (object)LinksetType; m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret); break; } // physSetLinksetType(type); - case BSScene.PhysFunctSetLinksetType: + case ExtendedPhysics.PhysFunctSetLinksetType: { if (pParams.Length > 0) { @@ -312,9 +313,16 @@ public class BSPrimLinkable : BSPrimDisplaced } break; } - // physChangeLinkFixed(linknum); - // Params: int linkNum, PhysActor linkedPrim - case BSScene.PhysFunctChangeLinkFixed: + // physChangeLinkType(linknum, typeCode); + // Params: PhysActor linkedPrim, int typeCode + case ExtendedPhysics.PhysFunctChangeLinkType: + { + Linkset.Extension(pFunct, pParams); + break; + } + // physChangeLinkParams(linknum, [code, value, code, value, ...]); + // Params: PhysActor linkedPrim, object[] params + case ExtendedPhysics.PhysFunctChangeLinkParams: { Linkset.Extension(pFunct, pParams); break; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index b451129..a68d382 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -867,20 +867,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters public override bool IsThreaded { get { return false; } } #region Extensions - // ============================================================= - // Per scene functions. See below. - - // Per avatar functions. See BSCharacter. - - // Per prim functions. See BSPrim. - public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; - public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; - public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; - public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; - public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; - public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider"; - // ============================================================= - public override object Extension(string pFunct, params object[] pParams) { return base.Extension(pFunct, pParams); -- cgit v1.1