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).
parent
34ae7afe1a
commit
0dd47d88de
|
@ -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 (requestingPart != null)
|
||||
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
|
||||
{
|
||||
// The type is is always on the root of a linkset.
|
||||
SceneObjectGroup containingGroup = requestingPart.ParentGroup;
|
||||
SceneObjectPart rootPart = containingGroup.RootPart;
|
||||
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, PHYS_LINK_TYPE_FIXED));
|
||||
}
|
||||
|
||||
if (rootPart != null)
|
||||
{
|
||||
Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor;
|
||||
if (rootPhysActor != null)
|
||||
{
|
||||
SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
|
||||
if (linkPart != 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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
|
||||
LogHeader, rootPart.Name, hostID, linkNum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} physChangeLinkFixed: 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 exist. RequestingPartName={1}, hostID={2}",
|
||||
LogHeader, requestingPart.Name, hostID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
[ScriptInvocation]
|
||||
public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// 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 physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum,
|
||||
Vector3 frameInAloc, Quaternion frameInArot,
|
||||
Vector3 frameInBloc, Quaternion frameInBrot,
|
||||
Vector3 linearLimitLow, Vector3 linearLimitHigh,
|
||||
Vector3 angularLimitLow, Vector3 angularLimitHigh
|
||||
)
|
||||
public int physChangeLinkParams(UUID hostID, UUID scriptID, int linkNum, object[] parms)
|
||||
{
|
||||
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(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;
|
||||
|
||||
containingGroup = requestingPart.ParentGroup;
|
||||
if (containingGroup != null && !containingGroup.IsDeleted)
|
||||
{
|
||||
rootPart = containingGroup.RootPart;
|
||||
if (rootPart != null)
|
||||
{
|
||||
Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor;
|
||||
rootPhysActor = rootPart.PhysActor;
|
||||
if (rootPhysActor != 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
|
||||
);
|
||||
ret = true;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}",
|
||||
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 exist. RequestingPartName={1}, hostID={2}",
|
||||
m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not exist. RequestingPartName={1}, hostID={2}",
|
||||
LogHeader, requestingPart.Name, hostID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID);
|
||||
m_log.WarnFormat("{0} GetRootAndChildPhysActors: Containing group missing or deleted. hostID={1}", LogHeader, hostID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} GetRootAndChildPhysActors: cannot find script object in scene. hostID={1}", LogHeader, hostID);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
[ScriptInvocation]
|
||||
public int physChangeLinkSlider(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 0;
|
||||
bool ret = false;
|
||||
rootPhysActor = null;
|
||||
childPhysActor = null;
|
||||
|
||||
SceneObjectGroup containingGroup;
|
||||
SceneObjectPart rootPart;
|
||||
|
||||
if (GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor))
|
||||
{
|
||||
SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
|
||||
if (linkPart != null)
|
||||
{
|
||||
childPhysActor = linkPart.PhysActor;
|
||||
if (childPhysActor != null)
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
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} GetRootAndChildPhysActors: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
|
||||
LogHeader, rootPart.Name, hostID, linkNum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
|
||||
LogHeader, rootPart.Name, hostID);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Extension() returns an object. Convert that object into the integer error we expect to return.
|
||||
private int MakeIntError(object extensionRet)
|
||||
{
|
||||
int ret = -1;
|
||||
if (extensionRet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ret = (int)extensionRet;
|
||||
}
|
||||
catch
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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,10 +491,18 @@ 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;
|
||||
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)
|
||||
{
|
||||
BSPrimLinkable child = pParams[0] as BSPrimLinkable;
|
||||
if (child != null)
|
||||
{
|
||||
m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate()
|
||||
|
@ -508,6 +518,7 @@ public sealed class BSLinksetConstraints : BSLinkset
|
|||
{
|
||||
// Setting to fixed is easy. The reset state is the fixed link configuration.
|
||||
linkInfoC.ResetLink();
|
||||
linkInfoC.constraintType = (ConstraintType)requestedType;
|
||||
ret = (object)true;
|
||||
}
|
||||
}
|
||||
|
@ -516,43 +527,9 @@ public sealed class BSLinksetConstraints : BSLinkset
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
case ExtendedPhysics.PhysFunctChangeLinkParams:
|
||||
break;
|
||||
default:
|
||||
ret = base.Extension(pFunct, pParams);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1795,6 +1795,7 @@
|
|||
<Reference name="OpenSim.Framework"/>
|
||||
<Reference name="OpenSim.Region.Framework"/>
|
||||
<Reference name="OpenSim.Region.CoreModules"/>
|
||||
<Reference name="OpenSim.Region.OptionalModules"/>
|
||||
<Reference name="OpenSim.Framework.Console"/>
|
||||
<Reference name="OpenSim.Region.Physics.Manager"/>
|
||||
<Reference name="OpenSim.Region.Physics.Meshing" path="../../../../bin/Physics/"/>
|
||||
|
|
Loading…
Reference in New Issue