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).
---
.../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 265 +++++++++++++--------
.../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 --
prebuild.xml | 1 +
7 files changed, 325 insertions(+), 167 deletions(-)
create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs
create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
index 278e9e7..baf5a5b 100755
--- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
@@ -36,6 +36,7 @@ using OpenSim.Region.CoreModules;
using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Physics.Manager;
using Mono.Addins;
using Nini.Config;
@@ -62,9 +63,8 @@ public class ExtendedPhysics : INonSharedRegionModule
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 const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType";
+ public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams";
// =============================================================
@@ -200,7 +200,7 @@ public class ExtendedPhysics : INonSharedRegionModule
if (rootPart != null)
{
- Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor;
+ PhysicsActor rootPhysActor = rootPart.PhysActor;
if (rootPhysActor != null)
{
if (rootPhysActor.IsPhysical)
@@ -219,7 +219,7 @@ public class ExtendedPhysics : INonSharedRegionModule
containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition);
containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation);
- ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType);
+ ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType));
Thread.Sleep(150); // longer than one heartbeat tick
containingGroup.ScriptSetPhysicsStatus(true);
@@ -228,7 +228,7 @@ public class ExtendedPhysics : INonSharedRegionModule
{
// Non-physical linksets don't have a physical instantiation so there is no state to
// worry about being updated.
- ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType);
+ ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType));
}
}
else
@@ -267,10 +267,10 @@ public class ExtendedPhysics : INonSharedRegionModule
if (rootPart != null)
{
- Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor;
+ PhysicsActor rootPhysActor = rootPart.PhysActor;
if (rootPhysActor != null)
{
- ret = (int)rootPhysActor.Extension(PhysFunctGetLinksetType);
+ ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType));
}
else
{
@@ -291,148 +291,225 @@ public class ExtendedPhysics : INonSharedRegionModule
return ret;
}
+ [ScriptConstant]
+ public static int PHYS_LINK_TYPE_FIXED = 1234;
+ [ScriptConstant]
+ public static int PHYS_LINK_TYPE_HINGE = 4;
+ [ScriptConstant]
+ public static int PHYS_LINK_TYPE_SPRING = 9;
+ [ScriptConstant]
+ public static int PHYS_LINK_TYPE_6DOF = 6;
+ [ScriptConstant]
+ public static int PHYS_LINK_TYPE_SLIDER = 7;
+
+ // physChangeLinkType(integer linkNum, integer typeCode)
+ [ScriptInvocation]
+ public int physChangeLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode)
+ {
+ int ret = -1;
+ if (!Enabled) return ret;
+
+ PhysicsActor rootPhysActor;
+ PhysicsActor childPhysActor;
+
+ if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
+ {
+ ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, typeCode));
+ }
+
+ return ret;
+ }
+
// physChangeLinkFixed(integer linkNum)
// Change the link between the root and the linkNum into a fixed, static physical connection.
- // This needs to change 'linkNum' into the physical object because lower level code has
- // no access to the link numbers.
[ScriptInvocation]
public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum)
{
int ret = -1;
if (!Enabled) return ret;
- // The part that is requesting the change.
- SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID);
+ PhysicsActor rootPhysActor;
+ PhysicsActor childPhysActor;
+
+ if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
+ {
+ ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, PHYS_LINK_TYPE_FIXED));
+ }
+
+ return ret;
+ }
+
+ // Code for specifying params.
+ // The choice if 14400 is arbitrary and only serves to catch parameter code misuse.
+ public static int PHYS_PARAM_MIN = 14401;
+ [ScriptConstant]
+ public static int PHYS_PARAM_FRAMEINA_LOC = 14401;
+ [ScriptConstant]
+ public static int PHYS_PARAM_FRAMEINA_ROT = 14402;
+ [ScriptConstant]
+ public static int PHYS_PARAM_FRAMEINB_LOC = 14403;
+ [ScriptConstant]
+ public static int PHYS_PARAM_FRAMEINB_ROT = 14404;
+ [ScriptConstant]
+ public static int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405;
+ [ScriptConstant]
+ public static int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406;
+ [ScriptConstant]
+ public static int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407;
+ [ScriptConstant]
+ public static int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408;
+ [ScriptConstant]
+ public static int PHYS_PARAM_USE_FRAME_OFFSET = 14409;
+ [ScriptConstant]
+ public static int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410;
+ [ScriptConstant]
+ public static int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411;
+ [ScriptConstant]
+ public static int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412;
+ [ScriptConstant]
+ public static int PHYS_PARAM_CFM = 14413;
+ [ScriptConstant]
+ public static int PHYS_PARAM_ERP = 14414;
+ [ScriptConstant]
+ public static int PHYS_PARAM_SOLVER_ITERATIONS = 14415;
+ [ScriptConstant]
+ public static int PHYS_PARAM_SPRING_DAMPING = 14416;
+ [ScriptConstant]
+ public static int PHYS_PARAM_SPRING_STIFFNESS = 14417;
+ public static int PHYS_PARAM_MAX = 14417;
+ // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...])
+ [ScriptInvocation]
+ public int physChangeLinkParams(UUID hostID, UUID scriptID, int linkNum, object[] parms)
+ {
+ int ret = -1;
+ if (!Enabled) return ret;
+
+ PhysicsActor rootPhysActor;
+ PhysicsActor childPhysActor;
+
+ if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
+ {
+ ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, childPhysActor, parms));
+ }
+
+ return ret;
+ }
+
+ private bool GetRootPhysActor(UUID hostID, out PhysicsActor rootPhysActor)
+ {
+ SceneObjectGroup containingGroup;
+ SceneObjectPart rootPart;
+ return GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor);
+ }
+
+ private bool GetRootPhysActor(UUID hostID, out SceneObjectGroup containingGroup, out SceneObjectPart rootPart, out PhysicsActor rootPhysActor)
+ {
+ bool ret = false;
+ rootPhysActor = null;
+ containingGroup = null;
+ rootPart = null;
+
+ SceneObjectPart requestingPart;
+
+ requestingPart = BaseScene.GetSceneObjectPart(hostID);
if (requestingPart != null)
{
// The type is is always on the root of a linkset.
- SceneObjectGroup containingGroup = requestingPart.ParentGroup;
- SceneObjectPart rootPart = containingGroup.RootPart;
-
- if (rootPart != null)
+ containingGroup = requestingPart.ParentGroup;
+ if (containingGroup != null && !containingGroup.IsDeleted)
{
- Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor;
- if (rootPhysActor != null)
+ rootPart = containingGroup.RootPart;
+ if (rootPart != null)
{
- SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
- if (linkPart != null)
+ rootPhysActor = rootPart.PhysActor;
+ if (rootPhysActor != null)
{
- Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor;
- if (linkPhysActor != null)
- {
- ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkFixed, linkNum, linkPhysActor);
- }
- else
- {
- m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
- LogHeader, rootPart.Name, hostID, linkNum);
- }
+ ret = true;
}
else
{
- m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
- LogHeader, rootPart.Name, hostID, linkNum);
+ m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
+ LogHeader, rootPart.Name, hostID);
}
}
else
{
- m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}",
- LogHeader, rootPart.Name, hostID);
+ m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not exist. RequestingPartName={1}, hostID={2}",
+ LogHeader, requestingPart.Name, hostID);
}
}
else
{
- m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}",
- LogHeader, requestingPart.Name, hostID);
+ m_log.WarnFormat("{0} GetRootAndChildPhysActors: Containing group missing or deleted. hostID={1}", LogHeader, hostID);
}
}
else
{
- m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID);
+ m_log.WarnFormat("{0} GetRootAndChildPhysActors: cannot find script object in scene. hostID={1}", LogHeader, hostID);
}
+
return ret;
}
- [ScriptInvocation]
- public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum)
+ // Find the root and child PhysActors based on the linkNum.
+ // Return 'true' if both are found and returned.
+ private bool GetRootAndChildPhysActors(UUID hostID, int linkNum, out PhysicsActor rootPhysActor, out PhysicsActor childPhysActor)
{
- return -1;
- }
+ bool ret = false;
+ rootPhysActor = null;
+ childPhysActor = null;
- [ScriptInvocation]
- public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum,
- Vector3 frameInAloc, Quaternion frameInArot,
- Vector3 frameInBloc, Quaternion frameInBrot,
- Vector3 linearLimitLow, Vector3 linearLimitHigh,
- Vector3 angularLimitLow, Vector3 angularLimitHigh
- )
- {
- int ret = -1;
- if (!Enabled) return ret;
+ SceneObjectGroup containingGroup;
+ SceneObjectPart rootPart;
- // The part that is requesting the change.
- SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID);
-
- if (requestingPart != null)
+ if (GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor))
{
- // The type is is always on the root of a linkset.
- SceneObjectGroup containingGroup = requestingPart.ParentGroup;
- SceneObjectPart rootPart = containingGroup.RootPart;
-
- if (rootPart != null)
+ SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
+ if (linkPart != null)
{
- Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor;
- if (rootPhysActor != null)
+ childPhysActor = linkPart.PhysActor;
+ if (childPhysActor != null)
{
- SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
- if (linkPart != null)
- {
- Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor;
- if (linkPhysActor != null)
- {
- ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkSpring, linkNum, linkPhysActor,
- frameInAloc, frameInArot,
- frameInBloc, frameInBrot,
- linearLimitLow, linearLimitHigh,
- angularLimitLow, angularLimitHigh
- );
- }
- else
- {
- m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
- LogHeader, rootPart.Name, hostID, linkNum);
- }
- }
- else
- {
- m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
- LogHeader, rootPart.Name, hostID, linkNum);
- }
+ ret = true;
}
else
{
- m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}",
- LogHeader, rootPart.Name, hostID);
+ m_log.WarnFormat("{0} GetRootAndChildPhysActors: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
+ LogHeader, rootPart.Name, hostID, linkNum);
}
}
else
{
- m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}",
- LogHeader, requestingPart.Name, hostID);
+ m_log.WarnFormat("{0} GetRootAndChildPhysActors: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
+ LogHeader, rootPart.Name, hostID, linkNum);
}
}
else
{
- m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID);
+ m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
+ LogHeader, rootPart.Name, hostID);
}
+
return ret;
}
- [ScriptInvocation]
- public int physChangeLinkSlider(UUID hostID, UUID scriptID, int linkNum)
+ // Extension() returns an object. Convert that object into the integer error we expect to return.
+ private int MakeIntError(object extensionRet)
{
- return 0;
+ int ret = -1;
+ if (extensionRet != null)
+ {
+ try
+ {
+ ret = (int)extensionRet;
+ }
+ catch
+ {
+ ret = -1;
+ }
+ }
+ return ret;
}
}
}
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 571db86..7440468 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);
diff --git a/prebuild.xml b/prebuild.xml
index af8f686..585f96d 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1795,6 +1795,7 @@
+
--
cgit v1.1