mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
BulletSim: Add axis locking enabled through the ExtendedPhysics module.
Allows locking of prim/linkset relative moving in each of the linear and angular axis. Limits on movement or rotation can be set.
This commit is contained in:
@@ -66,6 +66,7 @@ public class ExtendedPhysics : INonSharedRegionModule
|
||||
public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType";
|
||||
public const string PhysFunctGetLinkType = "BulletSim.GetLinkType";
|
||||
public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams";
|
||||
public const string PhysFunctAxisLockLimits = "BulletSim.AxisLockLimits";
|
||||
|
||||
// =============================================================
|
||||
|
||||
@@ -176,6 +177,71 @@ public class ExtendedPhysics : INonSharedRegionModule
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Code for specifying params.
|
||||
// The choice if 14700 is arbitrary and only serves to catch parameter code misuse.
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LOCK_LINEAR = 14700;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LOCK_LINEAR_X = 14701;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LIMIT_LINEAR_X = 14702;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LOCK_LINEAR_Y = 14703;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LIMIT_LINEAR_Y = 14704;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LOCK_LINEAR_Z = 14705;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LIMIT_LINEAR_Z = 14706;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LOCK_ANGULAR = 14707;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LOCK_ANGULAR_X = 14708;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LIMIT_ANGULAR_X = 14709;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LOCK_ANGULAR_Y = 14710;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LIMIT_ANGULAR_Y = 14711;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LOCK_ANGULAR_Z = 14712;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_LIMIT_ANGULAR_Z = 14713;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK_LINEAR = 14714;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK_LINEAR_X = 14715;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK_LINEAR_Y = 14716;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK_LINEAR_Z = 14717;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK_ANGULAR = 14718;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK_ANGULAR_X = 14719;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK_ANGULAR_Y = 14720;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK_ANGULAR_Z = 14721;
|
||||
[ScriptConstant]
|
||||
public const int PHYS_AXIS_UNLOCK = 14722;
|
||||
// physAxisLockLimits()
|
||||
[ScriptInvocation]
|
||||
public int physAxisLock(UUID hostID, UUID scriptID, object[] parms)
|
||||
{
|
||||
int ret = -1;
|
||||
if (!Enabled) return ret;
|
||||
|
||||
PhysicsActor rootPhysActor;
|
||||
if (GetRootPhysActor(hostID, out rootPhysActor))
|
||||
{
|
||||
object[] parms2 = AddToBeginningOfArray(rootPhysActor, null, parms);
|
||||
ret = MakeIntError(rootPhysActor.Extension(PhysFunctAxisLockLimits, parms2));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
[ScriptConstant]
|
||||
public const int PHYS_LINKSET_TYPE_CONSTRAINT = 0;
|
||||
[ScriptConstant]
|
||||
@@ -187,7 +253,6 @@ public class ExtendedPhysics : INonSharedRegionModule
|
||||
public int physSetLinksetType(UUID hostID, UUID scriptID, int linksetType)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!Enabled) return ret;
|
||||
|
||||
// The part that is requesting the change.
|
||||
@@ -259,34 +324,11 @@ public class ExtendedPhysics : INonSharedRegionModule
|
||||
int ret = -1;
|
||||
if (!Enabled) return ret;
|
||||
|
||||
// The part that is requesting the change.
|
||||
SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID);
|
||||
|
||||
if (requestingPart != null)
|
||||
PhysicsActor rootPhysActor;
|
||||
if (GetRootPhysActor(hostID, out rootPhysActor))
|
||||
{
|
||||
// The type is is always on the root of a linkset.
|
||||
SceneObjectGroup containingGroup = requestingPart.ParentGroup;
|
||||
SceneObjectPart rootPart = containingGroup.RootPart;
|
||||
|
||||
if (rootPart != null)
|
||||
{
|
||||
PhysicsActor rootPhysActor = rootPart.PhysActor;
|
||||
if (rootPhysActor != null)
|
||||
{
|
||||
object[] parms2 = { rootPhysActor, null };
|
||||
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType, parms2));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} physGetLinksetType: root part does not have a physics actor. rootName={1}, hostID={2}",
|
||||
LogHeader, rootPart.Name, hostID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("{0} physGetLinksetType: root part does not exist. RequestingPartName={1}, hostID={2}",
|
||||
LogHeader, requestingPart.Name, hostID);
|
||||
}
|
||||
object[] parms2 = { rootPhysActor, null };
|
||||
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType, parms2));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user