BulletSim: extend BSActorLockAxis to allow locking linear movement in
addition to angular movement. Not enabled by anything yet.user_profiles
parent
90f03ccd42
commit
f9fb1484aa
|
@ -64,9 +64,9 @@ public class BSActorLockAxis : BSActor
|
||||||
public override void Refresh()
|
public override void Refresh()
|
||||||
{
|
{
|
||||||
m_physicsScene.DetailLog("{0},BSActorLockAxis,refresh,lockedAxis={1},enabled={2},pActive={3}",
|
m_physicsScene.DetailLog("{0},BSActorLockAxis,refresh,lockedAxis={1},enabled={2},pActive={3}",
|
||||||
m_controllingPrim.LocalID, m_controllingPrim.LockedAxis, Enabled, m_controllingPrim.IsPhysicallyActive);
|
m_controllingPrim.LocalID, m_controllingPrim.LockedAngularAxis, Enabled, m_controllingPrim.IsPhysicallyActive);
|
||||||
// If all the axis are free, we don't need to exist
|
// If all the axis are free, we don't need to exist
|
||||||
if (m_controllingPrim.LockedAxis == m_controllingPrim.LockedAxisFree)
|
if (m_controllingPrim.LockedAngularAxis == m_controllingPrim.LockedAxisFree)
|
||||||
{
|
{
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
}
|
}
|
||||||
|
@ -123,23 +123,38 @@ public class BSActorLockAxis : BSActor
|
||||||
// Free to move linearly in the region
|
// Free to move linearly in the region
|
||||||
OMV.Vector3 linearLow = OMV.Vector3.Zero;
|
OMV.Vector3 linearLow = OMV.Vector3.Zero;
|
||||||
OMV.Vector3 linearHigh = m_physicsScene.TerrainManager.DefaultRegionSize;
|
OMV.Vector3 linearHigh = m_physicsScene.TerrainManager.DefaultRegionSize;
|
||||||
|
if (m_controllingPrim.LockedLinearAxis.X != BSPhysObject.FreeAxis)
|
||||||
|
{
|
||||||
|
linearLow.X = m_controllingPrim.RawPosition.X;
|
||||||
|
linearHigh.X = m_controllingPrim.RawPosition.X;
|
||||||
|
}
|
||||||
|
if (m_controllingPrim.LockedLinearAxis.Y != BSPhysObject.FreeAxis)
|
||||||
|
{
|
||||||
|
linearLow.Y = m_controllingPrim.RawPosition.Y;
|
||||||
|
linearHigh.Y = m_controllingPrim.RawPosition.Y;
|
||||||
|
}
|
||||||
|
if (m_controllingPrim.LockedLinearAxis.Z != BSPhysObject.FreeAxis)
|
||||||
|
{
|
||||||
|
linearLow.Z = m_controllingPrim.RawPosition.Z;
|
||||||
|
linearHigh.Z = m_controllingPrim.RawPosition.Z;
|
||||||
|
}
|
||||||
axisConstrainer.SetLinearLimits(linearLow, linearHigh);
|
axisConstrainer.SetLinearLimits(linearLow, linearHigh);
|
||||||
|
|
||||||
// Angular with some axis locked
|
// Angular with some axis locked
|
||||||
float fPI = (float)Math.PI;
|
float fPI = (float)Math.PI;
|
||||||
OMV.Vector3 angularLow = new OMV.Vector3(-fPI, -fPI, -fPI);
|
OMV.Vector3 angularLow = new OMV.Vector3(-fPI, -fPI, -fPI);
|
||||||
OMV.Vector3 angularHigh = new OMV.Vector3(fPI, fPI, fPI);
|
OMV.Vector3 angularHigh = new OMV.Vector3(fPI, fPI, fPI);
|
||||||
if (m_controllingPrim.LockedAxis.X != 1f)
|
if (m_controllingPrim.LockedAngularAxis.X != BSPhysObject.FreeAxis)
|
||||||
{
|
{
|
||||||
angularLow.X = 0f;
|
angularLow.X = 0f;
|
||||||
angularHigh.X = 0f;
|
angularHigh.X = 0f;
|
||||||
}
|
}
|
||||||
if (m_controllingPrim.LockedAxis.Y != 1f)
|
if (m_controllingPrim.LockedAngularAxis.Y != BSPhysObject.FreeAxis)
|
||||||
{
|
{
|
||||||
angularLow.Y = 0f;
|
angularLow.Y = 0f;
|
||||||
angularHigh.Y = 0f;
|
angularHigh.Y = 0f;
|
||||||
}
|
}
|
||||||
if (m_controllingPrim.LockedAxis.Z != 1f)
|
if (m_controllingPrim.LockedAngularAxis.Z != BSPhysObject.FreeAxis)
|
||||||
{
|
{
|
||||||
angularLow.Z = 0f;
|
angularLow.Z = 0f;
|
||||||
angularHigh.Z = 0f;
|
angularHigh.Z = 0f;
|
||||||
|
|
|
@ -108,7 +108,8 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
CollisionScore = 0;
|
CollisionScore = 0;
|
||||||
|
|
||||||
// All axis free.
|
// All axis free.
|
||||||
LockedAxis = LockedAxisFree;
|
LockedLinearAxis = LockedAxisFree;
|
||||||
|
LockedAngularAxis = LockedAxisFree;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the object to clean up.
|
// Tell the object to clean up.
|
||||||
|
@ -265,8 +266,10 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
// Note this is a displacement from the root's coordinates. Zero means use the root prim as center-of-mass.
|
// Note this is a displacement from the root's coordinates. Zero means use the root prim as center-of-mass.
|
||||||
public OMV.Vector3? UserSetCenterOfMassDisplacement { get; set; }
|
public OMV.Vector3? UserSetCenterOfMassDisplacement { get; set; }
|
||||||
|
|
||||||
public OMV.Vector3 LockedAxis { get; set; } // zero means locked. one means free.
|
public OMV.Vector3 LockedLinearAxis { get; set; } // zero means locked. one means free.
|
||||||
public readonly OMV.Vector3 LockedAxisFree = new OMV.Vector3(1f, 1f, 1f); // All axis are free
|
public OMV.Vector3 LockedAngularAxis { get; set; } // zero means locked. one means free.
|
||||||
|
public const float FreeAxis = 1f;
|
||||||
|
public readonly OMV.Vector3 LockedAxisFree = new OMV.Vector3(FreeAxis, FreeAxis, FreeAxis); // All axis are free
|
||||||
|
|
||||||
// Enable physical actions. Bullet will keep sleeping non-moving physical objects so
|
// Enable physical actions. Bullet will keep sleeping non-moving physical objects so
|
||||||
// they need waking up when parameters are changed.
|
// they need waking up when parameters are changed.
|
||||||
|
|
|
@ -256,9 +256,9 @@ public class BSPrim : BSPhysObject
|
||||||
if (axis.X != 1) locking.X = 0f;
|
if (axis.X != 1) locking.X = 0f;
|
||||||
if (axis.Y != 1) locking.Y = 0f;
|
if (axis.Y != 1) locking.Y = 0f;
|
||||||
if (axis.Z != 1) locking.Z = 0f;
|
if (axis.Z != 1) locking.Z = 0f;
|
||||||
LockedAxis = locking;
|
LockedAngularAxis = locking;
|
||||||
|
|
||||||
EnableActor(LockedAxis != LockedAxisFree, LockedAxisActorName, delegate()
|
EnableActor(LockedAngularAxis != LockedAxisFree, LockedAxisActorName, delegate()
|
||||||
{
|
{
|
||||||
return new BSActorLockAxis(PhysScene, this, LockedAxisActorName);
|
return new BSActorLockAxis(PhysScene, this, LockedAxisActorName);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue