BulletSim: nearly complete in conversion from BulletSimAPI to BSAPITemplate. Only initialization and debug fuctions left.
parent
5379d6d112
commit
c2a7af18b6
|
@ -34,7 +34,7 @@ using OpenMetaverse;
|
|||
|
||||
namespace OpenSim.Region.Physics.BulletSPlugin
|
||||
{
|
||||
public sealed class BSAPIUnman : BulletSimAPITemplate
|
||||
public sealed class BSAPIUnman : BSAPITemplate
|
||||
{
|
||||
/*
|
||||
// Initialization and simulation
|
||||
|
@ -55,8 +55,11 @@ public int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float
|
|||
out int collidersCount,
|
||||
out IntPtr collidersPtr);
|
||||
|
||||
public bool PushUpdate(BulletBody obj);
|
||||
*/
|
||||
public override bool PushUpdate(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.PushUpdate2(obj.ptr);
|
||||
}
|
||||
|
||||
// =====================================================================================
|
||||
// Mesh, hull, shape and body creation helper routines
|
||||
|
@ -569,146 +572,332 @@ public override void SetUserPointer(BulletBody obj, IntPtr val)
|
|||
BSAPICPP.SetUserPointer2(obj.ptr, val);
|
||||
}
|
||||
|
||||
/*
|
||||
// =====================================================================================
|
||||
// btRigidBody entries
|
||||
public override void ApplyGravity(BulletBody obj);
|
||||
public override void ApplyGravity(BulletBody obj)
|
||||
{
|
||||
BSAPICPP.ApplyGravity2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void SetGravity(BulletBody obj, Vector3 val);
|
||||
public override void SetGravity(BulletBody obj, Vector3 val)
|
||||
{
|
||||
BSAPICPP.SetGravity2(obj.ptr, val);
|
||||
}
|
||||
|
||||
public override Vector3 GetGravity(BulletBody obj);
|
||||
public override Vector3 GetGravity(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetGravity2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void SetDamping(BulletBody obj, float lin_damping, float ang_damping);
|
||||
public override void SetDamping(BulletBody obj, float lin_damping, float ang_damping)
|
||||
{
|
||||
BSAPICPP.SetDamping2(obj.ptr, lin_damping, ang_damping);
|
||||
}
|
||||
|
||||
public override void SetLinearDamping(BulletBody obj, float lin_damping);
|
||||
public override void SetLinearDamping(BulletBody obj, float lin_damping)
|
||||
{
|
||||
BSAPICPP.SetLinearDamping2(obj.ptr, lin_damping);
|
||||
}
|
||||
|
||||
public override void SetAngularDamping(BulletBody obj, float ang_damping);
|
||||
public override void SetAngularDamping(BulletBody obj, float ang_damping)
|
||||
{
|
||||
BSAPICPP.SetAngularDamping2(obj.ptr, ang_damping);
|
||||
}
|
||||
|
||||
public override float GetLinearDamping(BulletBody obj);
|
||||
public override float GetLinearDamping(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetLinearDamping2(obj.ptr);
|
||||
}
|
||||
|
||||
public override float GetAngularDamping(BulletBody obj);
|
||||
public override float GetAngularDamping(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetAngularDamping2(obj.ptr);
|
||||
}
|
||||
|
||||
public override float GetLinearSleepingThreshold(BulletBody obj);
|
||||
public override float GetLinearSleepingThreshold(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetLinearSleepingThreshold2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void ApplyDamping(BulletBody obj, float timeStep)
|
||||
{
|
||||
BSAPICPP.ApplyDamping2(obj.ptr, timeStep);
|
||||
}
|
||||
|
||||
public override void ApplyDamping(BulletBody obj, float timeStep);
|
||||
public override void SetMassProps(BulletBody obj, float mass, Vector3 inertia)
|
||||
{
|
||||
BSAPICPP.SetMassProps2(obj.ptr, mass, inertia);
|
||||
}
|
||||
|
||||
public override void SetMassProps(BulletBody obj, float mass, Vector3 inertia);
|
||||
public override Vector3 GetLinearFactor(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetLinearFactor2(obj.ptr);
|
||||
}
|
||||
|
||||
public override Vector3 GetLinearFactor(BulletBody obj);
|
||||
public override void SetLinearFactor(BulletBody obj, Vector3 factor)
|
||||
{
|
||||
BSAPICPP.SetLinearFactor2(obj.ptr, factor);
|
||||
}
|
||||
|
||||
public override void SetLinearFactor(BulletBody obj, Vector3 factor);
|
||||
|
||||
public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot);
|
||||
public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot)
|
||||
{
|
||||
BSAPICPP.SetCenterOfMassByPosRot2(obj.ptr, pos, rot);
|
||||
}
|
||||
|
||||
// Add a force to the object as if its mass is one.
|
||||
public override void ApplyCentralForce(BulletBody obj, Vector3 force);
|
||||
public override void ApplyCentralForce(BulletBody obj, Vector3 force)
|
||||
{
|
||||
BSAPICPP.ApplyCentralForce2(obj.ptr, force);
|
||||
}
|
||||
|
||||
// Set the force being applied to the object as if its mass is one.
|
||||
public override void SetObjectForce(BulletBody obj, Vector3 force);
|
||||
public override void SetObjectForce(BulletBody obj, Vector3 force)
|
||||
{
|
||||
BSAPICPP.SetObjectForce2(obj.ptr, force);
|
||||
}
|
||||
|
||||
public override Vector3 GetTotalForce(BulletBody obj);
|
||||
public override Vector3 GetTotalForce(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetTotalForce2(obj.ptr);
|
||||
}
|
||||
|
||||
public override Vector3 GetTotalTorque(BulletBody obj);
|
||||
public override Vector3 GetTotalTorque(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetTotalTorque2(obj.ptr);
|
||||
}
|
||||
|
||||
public override Vector3 GetInvInertiaDiagLocal(BulletBody obj);
|
||||
public override Vector3 GetInvInertiaDiagLocal(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetInvInertiaDiagLocal2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert);
|
||||
public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert)
|
||||
{
|
||||
BSAPICPP.SetInvInertiaDiagLocal2(obj.ptr, inert);
|
||||
}
|
||||
|
||||
public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold);
|
||||
public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold)
|
||||
{
|
||||
BSAPICPP.SetSleepingThresholds2(obj.ptr, lin_threshold, ang_threshold);
|
||||
}
|
||||
|
||||
public override void ApplyTorque(BulletBody obj, Vector3 torque);
|
||||
public override void ApplyTorque(BulletBody obj, Vector3 torque)
|
||||
{
|
||||
BSAPICPP.ApplyTorque2(obj.ptr, torque);
|
||||
}
|
||||
|
||||
// Apply force at the given point. Will add torque to the object.
|
||||
public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos);
|
||||
public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos)
|
||||
{
|
||||
BSAPICPP.ApplyForce2(obj.ptr, force, pos);
|
||||
}
|
||||
|
||||
// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
|
||||
public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp);
|
||||
public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp)
|
||||
{
|
||||
BSAPICPP.ApplyCentralImpulse2(obj.ptr, imp);
|
||||
}
|
||||
|
||||
// Apply impulse to the object's torque. Force is scaled by object's mass.
|
||||
public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp);
|
||||
public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp)
|
||||
{
|
||||
BSAPICPP.ApplyTorqueImpulse2(obj.ptr, imp);
|
||||
}
|
||||
|
||||
// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
|
||||
public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos);
|
||||
public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos)
|
||||
{
|
||||
BSAPICPP.ApplyImpulse2(obj.ptr, imp, pos);
|
||||
}
|
||||
|
||||
public override void ClearForces(BulletBody obj);
|
||||
public override void ClearForces(BulletBody obj)
|
||||
{
|
||||
BSAPICPP.ClearForces2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void ClearAllForces(BulletBody obj);
|
||||
public override void ClearAllForces(BulletBody obj)
|
||||
{
|
||||
BSAPICPP.ClearAllForces2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void UpdateInertiaTensor(BulletBody obj);
|
||||
public override void UpdateInertiaTensor(BulletBody obj)
|
||||
{
|
||||
BSAPICPP.UpdateInertiaTensor2(obj.ptr);
|
||||
}
|
||||
|
||||
public override Vector3 GetLinearVelocity(BulletBody obj);
|
||||
public override Vector3 GetLinearVelocity(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetLinearVelocity2(obj.ptr);
|
||||
}
|
||||
|
||||
public override Vector3 GetAngularVelocity(BulletBody obj);
|
||||
public override Vector3 GetAngularVelocity(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetAngularVelocity2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void SetLinearVelocity(BulletBody obj, Vector3 val);
|
||||
public override void SetLinearVelocity(BulletBody obj, Vector3 vel)
|
||||
{
|
||||
BSAPICPP.SetLinearVelocity2(obj.ptr, vel);
|
||||
}
|
||||
|
||||
public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity);
|
||||
public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity)
|
||||
{
|
||||
BSAPICPP.SetAngularVelocity2(obj.ptr, angularVelocity);
|
||||
}
|
||||
|
||||
public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos);
|
||||
public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos)
|
||||
{
|
||||
return BSAPICPP.GetVelocityInLocalPoint2(obj.ptr, pos);
|
||||
}
|
||||
|
||||
public override void Translate(BulletBody obj, Vector3 trans);
|
||||
public override void Translate(BulletBody obj, Vector3 trans)
|
||||
{
|
||||
BSAPICPP.Translate2(obj.ptr, trans);
|
||||
}
|
||||
|
||||
public override void UpdateDeactivation(BulletBody obj, float timeStep);
|
||||
public override void UpdateDeactivation(BulletBody obj, float timeStep)
|
||||
{
|
||||
BSAPICPP.UpdateDeactivation2(obj.ptr, timeStep);
|
||||
}
|
||||
|
||||
public override bool WantsSleeping(BulletBody obj);
|
||||
public override bool WantsSleeping(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.WantsSleeping2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void SetAngularFactor(BulletBody obj, float factor);
|
||||
public override void SetAngularFactor(BulletBody obj, float factor)
|
||||
{
|
||||
BSAPICPP.SetAngularFactor2(obj.ptr, factor);
|
||||
}
|
||||
|
||||
public override void SetAngularFactorV(BulletBody obj, Vector3 factor);
|
||||
public override void SetAngularFactorV(BulletBody obj, Vector3 factor)
|
||||
{
|
||||
BSAPICPP.SetAngularFactorV2(obj.ptr, factor);
|
||||
}
|
||||
|
||||
public override Vector3 GetAngularFactor(BulletBody obj);
|
||||
public override Vector3 GetAngularFactor(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetAngularFactor2(obj.ptr);
|
||||
}
|
||||
|
||||
public override bool IsInWorld(BulletBody obj);
|
||||
public override bool IsInWorld(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.IsInWorld2(obj.ptr);
|
||||
}
|
||||
|
||||
public override void AddConstraintRef(BulletBody obj, BulletConstraint constrain);
|
||||
public override void AddConstraintRef(BulletBody obj, BulletConstraint constrain)
|
||||
{
|
||||
BSAPICPP.AddConstraintRef2(obj.ptr, constrain.ptr);
|
||||
}
|
||||
|
||||
public override void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain);
|
||||
public override void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain)
|
||||
{
|
||||
BSAPICPP.RemoveConstraintRef2(obj.ptr, constrain.ptr);
|
||||
}
|
||||
|
||||
public override BulletConstraint GetConstraintRef(BulletBody obj, int index);
|
||||
public override BulletConstraint GetConstraintRef(BulletBody obj, int index)
|
||||
{
|
||||
return new BulletConstraint(BSAPICPP.GetConstraintRef2(obj.ptr, index));
|
||||
}
|
||||
|
||||
public override int GetNumConstraintRefs(BulletBody obj);
|
||||
public override int GetNumConstraintRefs(BulletBody obj)
|
||||
{
|
||||
return BSAPICPP.GetNumConstraintRefs2(obj.ptr);
|
||||
}
|
||||
|
||||
public override bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask);
|
||||
public override bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask)
|
||||
{
|
||||
return BSAPICPP.SetCollisionGroupMask2(body.ptr, filter, mask);
|
||||
}
|
||||
|
||||
// =====================================================================================
|
||||
// btCollisionShape entries
|
||||
|
||||
public override float GetAngularMotionDisc(BulletShape shape);
|
||||
public override float GetAngularMotionDisc(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.GetAngularMotionDisc2(shape.ptr);
|
||||
}
|
||||
|
||||
public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor);
|
||||
public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor)
|
||||
{
|
||||
return BSAPICPP.GetContactBreakingThreshold2(shape.ptr, defaultFactor);
|
||||
}
|
||||
|
||||
public override bool IsPolyhedral(BulletShape shape);
|
||||
public override bool IsPolyhedral(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.IsPolyhedral2(shape.ptr);
|
||||
}
|
||||
|
||||
public override bool IsConvex2d(BulletShape shape);
|
||||
public override bool IsConvex2d(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.IsConvex2d2(shape.ptr);
|
||||
}
|
||||
|
||||
public override bool IsConvex(BulletShape shape);
|
||||
public override bool IsConvex(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.IsConvex2(shape.ptr);
|
||||
}
|
||||
|
||||
public override bool IsNonMoving(BulletShape shape);
|
||||
public override bool IsNonMoving(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.IsNonMoving2(shape.ptr);
|
||||
}
|
||||
|
||||
public override bool IsConcave(BulletShape shape);
|
||||
public override bool IsConcave(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.IsConcave2(shape.ptr);
|
||||
}
|
||||
|
||||
public override bool IsCompound(BulletShape shape);
|
||||
public override bool IsCompound(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.IsCompound2(shape.ptr);
|
||||
}
|
||||
|
||||
public override bool IsSoftBody(BulletShape shape);
|
||||
public override bool IsSoftBody(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.IsSoftBody2(shape.ptr);
|
||||
}
|
||||
|
||||
public override bool IsInfinite(BulletShape shape);
|
||||
public override bool IsInfinite(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.IsInfinite2(shape.ptr);
|
||||
}
|
||||
|
||||
public override void SetLocalScaling(BulletShape shape, Vector3 scale);
|
||||
public override void SetLocalScaling(BulletShape shape, Vector3 scale)
|
||||
{
|
||||
BSAPICPP.SetLocalScaling2(shape.ptr, scale);
|
||||
}
|
||||
|
||||
public override Vector3 GetLocalScaling(BulletShape shape);
|
||||
public override Vector3 GetLocalScaling(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.GetLocalScaling2(shape.ptr);
|
||||
}
|
||||
|
||||
public override Vector3 CalculateLocalInertia(BulletShape shape, float mass);
|
||||
public override Vector3 CalculateLocalInertia(BulletShape shape, float mass)
|
||||
{
|
||||
return BSAPICPP.CalculateLocalInertia2(shape.ptr, mass);
|
||||
}
|
||||
|
||||
public override int GetShapeType(BulletShape shape);
|
||||
public override int GetShapeType(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.GetShapeType2(shape.ptr);
|
||||
}
|
||||
|
||||
public override void SetMargin(BulletShape shape, float val);
|
||||
public override void SetMargin(BulletShape shape, float val)
|
||||
{
|
||||
BSAPICPP.SetMargin2(shape.ptr, val);
|
||||
}
|
||||
|
||||
public override float GetMargin(BulletShape shape);
|
||||
*/
|
||||
public override float GetMargin(BulletShape shape)
|
||||
{
|
||||
return BSAPICPP.GetMargin2(shape.ptr);
|
||||
}
|
||||
|
||||
static class BSAPICPP
|
||||
{
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern bool PushUpdate2(IntPtr obj);
|
||||
|
||||
// =====================================================================================
|
||||
// Mesh, hull, shape and body creation helper routines
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
|
@ -1029,55 +1218,6 @@ public static extern IntPtr GetUserPointer2(IntPtr obj);
|
|||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern void SetUserPointer2(IntPtr obj, IntPtr val);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
static class BulletSimAPI {
|
||||
// ===============================================================================
|
||||
// Link back to the managed code for outputting log messages
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
|
||||
|
||||
// ===============================================================================
|
||||
// Initialization and simulation
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
|
||||
int maxCollisions, IntPtr collisionArray,
|
||||
int maxUpdates, IntPtr updateArray,
|
||||
DebugLogCallback logRoutine);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern void SetHeightMap2(IntPtr world, float[] heightmap);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern void Shutdown2(IntPtr sim);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
|
||||
out int updatedEntityCount,
|
||||
out IntPtr updatedEntitiesPtr,
|
||||
out int collidersCount,
|
||||
out IntPtr collidersPtr);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern bool PushUpdate2(IntPtr obj);
|
||||
|
||||
// =====================================================================================
|
||||
// btRigidBody entries
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
|
@ -1291,6 +1431,52 @@ public static extern void SetMargin2(IntPtr shape, float val);
|
|||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern float GetMargin2(IntPtr shape);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
// ===============================================================================
|
||||
static class BulletSimAPI {
|
||||
// ===============================================================================
|
||||
// Link back to the managed code for outputting log messages
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
|
||||
|
||||
// ===============================================================================
|
||||
// Initialization and simulation
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
|
||||
int maxCollisions, IntPtr collisionArray,
|
||||
int maxUpdates, IntPtr updateArray,
|
||||
DebugLogCallback logRoutine);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern void SetHeightMap2(IntPtr world, float[] heightmap);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern void Shutdown2(IntPtr sim);
|
||||
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
|
||||
out int updatedEntityCount,
|
||||
out IntPtr updatedEntitiesPtr,
|
||||
out int collidersCount,
|
||||
out IntPtr collidersPtr);
|
||||
|
||||
// =====================================================================================
|
||||
// Debugging
|
||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
|
|
|
@ -290,7 +290,7 @@ public enum ConstraintParamAxis : int
|
|||
AXIS_ALL
|
||||
};
|
||||
|
||||
public abstract class BulletSimAPITemplate
|
||||
public abstract class BSAPITemplate
|
||||
{
|
||||
/*
|
||||
// Initialization and simulation
|
||||
|
@ -311,8 +311,8 @@ public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSte
|
|||
out int collidersCount,
|
||||
out IntPtr collidersPtr);
|
||||
|
||||
public abstract bool PushUpdate(BulletBody obj);
|
||||
*/
|
||||
public abstract bool PushUpdate(BulletBody obj);
|
||||
|
||||
// =====================================================================================
|
||||
// Mesh, hull, shape and body creation helper routines
|
||||
|
@ -525,7 +525,6 @@ public abstract IntPtr GetUserPointer(BulletBody obj);
|
|||
|
||||
public abstract void SetUserPointer(BulletBody obj, IntPtr val);
|
||||
|
||||
/*
|
||||
// =====================================================================================
|
||||
// btRigidBody entries
|
||||
public abstract void ApplyGravity(BulletBody obj);
|
||||
|
@ -546,7 +545,6 @@ public abstract float GetAngularDamping(BulletBody obj);
|
|||
|
||||
public abstract float GetLinearSleepingThreshold(BulletBody obj);
|
||||
|
||||
|
||||
public abstract void ApplyDamping(BulletBody obj, float timeStep);
|
||||
|
||||
public abstract void SetMassProps(BulletBody obj, float mass, Vector3 inertia);
|
||||
|
@ -661,7 +659,6 @@ public abstract int GetShapeType(BulletShape shape);
|
|||
public abstract void SetMargin(BulletShape shape, float val);
|
||||
|
||||
public abstract float GetMargin(BulletShape shape);
|
||||
*/
|
||||
|
||||
};
|
||||
}
|
|
@ -153,8 +153,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
Flying = _flying;
|
||||
|
||||
PhysicsScene.PE.SetRestitution(PhysBody, BSParam.AvatarRestitution);
|
||||
BulletSimAPI.SetMargin2(PhysShape.ptr, PhysicsScene.Params.collisionMargin);
|
||||
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
||||
PhysicsScene.PE.SetMargin(PhysShape, PhysicsScene.Params.collisionMargin);
|
||||
PhysicsScene.PE.SetLocalScaling(PhysShape, Scale);
|
||||
PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
|
||||
if (BSParam.CcdMotionThreshold > 0f)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
UpdatePhysicalMassProperties(RawMass, false);
|
||||
|
||||
// Make so capsule does not fall over
|
||||
BulletSimAPI.SetAngularFactorV2(PhysBody.ptr, OMV.Vector3.Zero);
|
||||
PhysicsScene.PE.SetAngularFactorV(PhysBody, OMV.Vector3.Zero);
|
||||
|
||||
PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT);
|
||||
|
||||
|
@ -177,7 +177,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
|
||||
// Do this after the object has been added to the world
|
||||
PhysBody.collisionType = CollisionType.Avatar;
|
||||
PhysBody.ApplyCollisionMask();
|
||||
PhysBody.ApplyCollisionMask(PhysicsScene);
|
||||
}
|
||||
|
||||
// The avatar's movement is controlled by this motor that speeds up and slows down
|
||||
|
@ -265,10 +265,10 @@ public sealed class BSCharacter : BSPhysObject
|
|||
{
|
||||
if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape)
|
||||
{
|
||||
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
||||
PhysicsScene.PE.SetLocalScaling(PhysShape, Scale);
|
||||
UpdatePhysicalMassProperties(RawMass, true);
|
||||
// Make sure this change appears as a property update event
|
||||
BulletSimAPI.PushUpdate2(PhysBody.ptr);
|
||||
PhysicsScene.PE.PushUpdate(PhysBody);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -309,7 +309,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
||||
{
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||
PhysicsScene.PE.ClearAllForces(PhysBody);
|
||||
});
|
||||
}
|
||||
public override void ZeroAngularMotion(bool inTaintTime)
|
||||
|
@ -321,9 +321,9 @@ public sealed class BSCharacter : BSPhysObject
|
|||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, OMV.Vector3.Zero);
|
||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
||||
PhysicsScene.PE.SetAngularVelocity(PhysBody, OMV.Vector3.Zero);
|
||||
// The next also get rid of applied linear force but the linear velocity is untouched.
|
||||
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
||||
PhysicsScene.PE.ClearForces(PhysBody);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
public override OMV.Vector3 Position {
|
||||
get {
|
||||
// Don't refetch the position because this function is called a zillion times
|
||||
// _position = BulletSimAPI.GetObjectPosition2(Scene.World.ptr, LocalID);
|
||||
// _position = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID);
|
||||
return _position;
|
||||
}
|
||||
set {
|
||||
|
@ -433,8 +433,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
}
|
||||
public override void UpdatePhysicalMassProperties(float physMass, bool inWorld)
|
||||
{
|
||||
OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass);
|
||||
BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, localInertia);
|
||||
OMV.Vector3 localInertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass);
|
||||
PhysicsScene.PE.SetMassProps(PhysBody, physMass, localInertia);
|
||||
}
|
||||
|
||||
public override OMV.Vector3 Force {
|
||||
|
@ -446,7 +446,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
{
|
||||
DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||
PhysicsScene.PE.SetObjectForce(PhysBody, _force);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
}
|
||||
}
|
||||
|
||||
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
|
||||
PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity);
|
||||
PhysicsScene.PE.Activate(PhysBody, true);
|
||||
}
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
// Buoyancy is faked by changing the gravity applied to the object
|
||||
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
||||
PhysicsScene.PE.SetGravity(PhysBody, new OMV.Vector3(0f, 0f, grav));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -737,7 +737,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
// DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce);
|
||||
PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -564,17 +564,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// TODO: possibly set AngularFactor and LinearFactor for the type of vehicle.
|
||||
// Maybe compute linear and angular factor and damping from params.
|
||||
float angularDamping = BSParam.VehicleAngularDamping;
|
||||
BulletSimAPI.SetAngularDamping2(Prim.PhysBody.ptr, angularDamping);
|
||||
PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, angularDamping);
|
||||
|
||||
// Vehicles report collision events so we know when it's on the ground
|
||||
PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
|
||||
|
||||
Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(Prim.PhysShape.ptr, m_vehicleMass);
|
||||
BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia);
|
||||
BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr);
|
||||
Vector3 localInertia = PhysicsScene.PE.CalculateLocalInertia(Prim.PhysShape, m_vehicleMass);
|
||||
PhysicsScene.PE.SetMassProps(Prim.PhysBody, m_vehicleMass, localInertia);
|
||||
PhysicsScene.PE.UpdateInertiaTensor(Prim.PhysBody);
|
||||
|
||||
Vector3 grav = PhysicsScene.DefaultGravity * (1f - Prim.Buoyancy);
|
||||
BulletSimAPI.SetGravity2(Prim.PhysBody.ptr, grav);
|
||||
PhysicsScene.PE.SetGravity(Prim.PhysBody, grav);
|
||||
|
||||
VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}",
|
||||
Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping);
|
||||
|
@ -669,7 +669,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
|
||||
// If we set one of the values (ie, the physics engine didn't do it) we must force
|
||||
// an UpdateProperties event to send the changes up to the simulator.
|
||||
BulletSimAPI.PushUpdate2(Prim.PhysBody.ptr);
|
||||
PhysicsScene.PE.PushUpdate(Prim.PhysBody);
|
||||
}
|
||||
m_knownChanged = 0;
|
||||
}
|
||||
|
|
|
@ -387,11 +387,6 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
}
|
||||
|
||||
PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape);
|
||||
|
||||
// DEBUG: see of inter-linkset collisions are causing problems for constraint linksets.
|
||||
// BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr,
|
||||
// (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -259,7 +259,7 @@ public sealed class BSLinksetConstraints : BSLinkset
|
|||
if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody))
|
||||
{
|
||||
// Make the child refresh its location
|
||||
BulletSimAPI.PushUpdate2(childPrim.PhysBody.ptr);
|
||||
PhysicsScene.PE.PushUpdate(childPrim.PhysBody);
|
||||
ret = true;
|
||||
}
|
||||
|
||||
|
@ -286,9 +286,6 @@ public sealed class BSLinksetConstraints : BSLinkset
|
|||
float linksetMass = LinksetMass;
|
||||
LinksetRoot.UpdatePhysicalMassProperties(linksetMass, true);
|
||||
|
||||
// DEBUG: see of inter-linkset collisions are causing problems
|
||||
// BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr,
|
||||
// (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
|
||||
DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}",
|
||||
LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass);
|
||||
|
||||
|
@ -307,11 +304,7 @@ public sealed class BSLinksetConstraints : BSLinkset
|
|||
}
|
||||
constrain.RecomputeConstraintVariables(linksetMass);
|
||||
|
||||
// DEBUG: see of inter-linkset collisions are causing problems
|
||||
// BulletSimAPI.SetCollisionFilterMask2(child.BSBody.ptr,
|
||||
// (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
|
||||
|
||||
// BulletSimAPI.DumpConstraint2(PhysicsScene.World.ptr, constrain.Constraint.ptr); // DEBUG DEBUG
|
||||
// PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ public static class BSParam
|
|||
(s,cf,p,v) => { s.UnmanagedParams[0].gravity = cf.GetFloat(p, v); },
|
||||
(s) => { return s.UnmanagedParams[0].gravity; },
|
||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{s.UnmanagedParams[0].gravity=x;}, p, PhysParameterEntry.APPLY_TO_NONE, v); },
|
||||
(s,o,v) => { BulletSimAPI.SetGravity2(s.World.ptr, new Vector3(0f,0f,v)); } ),
|
||||
(s,o,v) => { s.PE.SetGravity(o.PhysBody, new Vector3(0f,0f,v)); } ),
|
||||
|
||||
|
||||
new ParameterDefn("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)",
|
||||
|
@ -288,13 +288,13 @@ public static class BSParam
|
|||
(s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); },
|
||||
(s) => { return LinearDamping; },
|
||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearDamping=x;}, p, l, v); },
|
||||
(s,o,v) => { BulletSimAPI.SetDamping2(o.PhysBody.ptr, v, AngularDamping); } ),
|
||||
(s,o,v) => { s.PE.SetDamping(o.PhysBody, v, AngularDamping); } ),
|
||||
new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)",
|
||||
0f,
|
||||
(s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); },
|
||||
(s) => { return AngularDamping; },
|
||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularDamping=x;}, p, l, v); },
|
||||
(s,o,v) => { BulletSimAPI.SetDamping2(o.PhysBody.ptr, LinearDamping, v); } ),
|
||||
(s,o,v) => { s.PE.SetDamping(o.PhysBody, LinearDamping, v); } ),
|
||||
new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static",
|
||||
0.2f,
|
||||
(s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); },
|
||||
|
@ -306,13 +306,13 @@ public static class BSParam
|
|||
(s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); },
|
||||
(s) => { return LinearSleepingThreshold; },
|
||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearSleepingThreshold=x;}, p, l, v); },
|
||||
(s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.PhysBody.ptr, v, v); } ),
|
||||
(s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
|
||||
new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static",
|
||||
1.0f,
|
||||
(s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); },
|
||||
(s) => { return AngularSleepingThreshold; },
|
||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); },
|
||||
(s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.PhysBody.ptr, v, v); } ),
|
||||
(s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
|
||||
new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
|
||||
0f, // set to zero to disable
|
||||
(s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
|
||||
|
|
|
@ -253,7 +253,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
|
||||
{
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||
PhysicsScene.PE.ClearAllForces(PhysBody);
|
||||
});
|
||||
}
|
||||
public override void ZeroAngularMotion(bool inTaintTime)
|
||||
|
@ -266,7 +266,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
|
||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||
PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
*/
|
||||
|
||||
// don't do the GetObjectPosition for root elements because this function is called a zillion times.
|
||||
// _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
|
||||
// _position = PhysicsScene.PE.GetObjectPosition2(PhysicsScene.World, BSBody);
|
||||
return _position;
|
||||
}
|
||||
set {
|
||||
|
@ -405,10 +405,10 @@ public sealed class BSPrim : BSPhysObject
|
|||
{
|
||||
if (IsStatic)
|
||||
{
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, PhysicsScene.DefaultGravity);
|
||||
PhysicsScene.PE.SetGravity(PhysBody, PhysicsScene.DefaultGravity);
|
||||
Inertia = OMV.Vector3.Zero;
|
||||
BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia);
|
||||
BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr);
|
||||
PhysicsScene.PE.SetMassProps(PhysBody, 0f, Inertia);
|
||||
PhysicsScene.PE.UpdateInertiaTensor(PhysBody);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -423,14 +423,14 @@ public sealed class BSPrim : BSPhysObject
|
|||
}
|
||||
|
||||
// The computation of mass props requires gravity to be set on the object.
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, grav);
|
||||
PhysicsScene.PE.SetGravity(PhysBody, grav);
|
||||
|
||||
Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass);
|
||||
BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia);
|
||||
BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr);
|
||||
Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass);
|
||||
PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia);
|
||||
PhysicsScene.PE.UpdateInertiaTensor(PhysBody);
|
||||
|
||||
// center of mass is at the zero of the object
|
||||
// DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation);
|
||||
// DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(PhysBody, ForcePosition, ForceOrientation);
|
||||
DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld);
|
||||
|
||||
if (inWorld)
|
||||
|
@ -440,7 +440,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
|
||||
// Must set gravity after it has been added to the world because, for unknown reasons,
|
||||
// adding the object resets the object's gravity to world gravity
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, grav);
|
||||
PhysicsScene.PE.SetGravity(PhysBody, grav);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, _force);
|
||||
PhysicsScene.PE.ApplyCentralForce(PhysBody, _force);
|
||||
ActivateIfPhysical(false);
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
_velocity = value;
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
|
||||
PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity);
|
||||
ActivateIfPhysical(false);
|
||||
}
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||
|
||||
// Center of mass is at the center of the object
|
||||
// DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody, _position, _orientation);
|
||||
// DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(Linkset.LinksetRoot.PhysBody, _position, _orientation);
|
||||
|
||||
// A dynamic object has mass
|
||||
UpdatePhysicalMassProperties(RawMass, false);
|
||||
|
@ -822,9 +822,9 @@ public sealed class BSPrim : BSPhysObject
|
|||
}
|
||||
|
||||
// Various values for simulation limits
|
||||
BulletSimAPI.SetDamping2(PhysBody.ptr, BSParam.LinearDamping, BSParam.AngularDamping);
|
||||
PhysicsScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping);
|
||||
PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime);
|
||||
BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold);
|
||||
PhysicsScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold);
|
||||
PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
|
||||
|
||||
// This collides like an object.
|
||||
|
@ -901,10 +901,10 @@ public sealed class BSPrim : BSPhysObject
|
|||
|
||||
// TODO: Fix this. Total kludge because adding object to world resets its gravity to default.
|
||||
// Replace this when the new AddObjectToWorld function is complete.
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, ComputeGravity());
|
||||
PhysicsScene.PE.SetGravity(PhysBody, ComputeGravity());
|
||||
|
||||
// Collision filter can be set only when the object is in the world
|
||||
if (!PhysBody.ApplyCollisionMask())
|
||||
if (!PhysBody.ApplyCollisionMask(PhysicsScene))
|
||||
{
|
||||
m_log.ErrorFormat("{0} Failed setting object collision mask: id={1}", LogHeader, LocalID);
|
||||
DetailLog("{0},BSPrim.UpdatePhysicalParameters,failedSetMaskGroup,cType={1}", LocalID, PhysBody.collisionType);
|
||||
|
@ -969,7 +969,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
_rotationalVelocity = value;
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||
PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
|
||||
ActivateIfPhysical(false);
|
||||
}
|
||||
}
|
||||
|
@ -1061,7 +1061,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce);
|
||||
PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce);
|
||||
ActivateIfPhysical(false);
|
||||
}
|
||||
});
|
||||
|
@ -1085,7 +1085,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
{
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.ApplyTorque2(PhysBody.ptr, angForce);
|
||||
PhysicsScene.PE.ApplyTorque(PhysBody, angForce);
|
||||
ActivateIfPhysical(false);
|
||||
}
|
||||
});
|
||||
|
@ -1108,7 +1108,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
{
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse);
|
||||
PhysicsScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse);
|
||||
ActivateIfPhysical(false);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -51,7 +51,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
|||
public string BulletSimVersion = "?";
|
||||
|
||||
// The handle to the underlying managed or unmanaged version of Bullet being used.
|
||||
public BulletSimAPITemplate PE;
|
||||
public BSAPITemplate PE;
|
||||
|
||||
public Dictionary<uint, BSPhysObject> PhysObjects;
|
||||
public BSShapeCollection Shapes;
|
||||
|
|
|
@ -141,7 +141,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body);
|
||||
PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate()
|
||||
{
|
||||
if (!BulletSimAPI.IsInWorld2(body.ptr))
|
||||
if (!PhysicsScene.PE.IsInWorld(body))
|
||||
{
|
||||
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body);
|
||||
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
|
||||
|
@ -166,7 +166,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// If the caller needs to know the old body is going away, pass the event up.
|
||||
if (bodyCallback != null) bodyCallback(body);
|
||||
|
||||
if (BulletSimAPI.IsInWorld2(body.ptr))
|
||||
if (PhysicsScene.PE.IsInWorld(body))
|
||||
{
|
||||
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
|
||||
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
|
||||
|
@ -332,7 +332,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// Called at taint-time.
|
||||
private void DereferenceCompound(BulletShape shape, ShapeDestructionCallback shapeCallback)
|
||||
{
|
||||
if (!BulletSimAPI.IsCompound2(shape.ptr))
|
||||
if (!PhysicsScene.PE.IsCompound(shape))
|
||||
{
|
||||
// Failed the sanity check!!
|
||||
PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}",
|
||||
|
@ -376,7 +376,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
}
|
||||
else
|
||||
{
|
||||
if (BulletSimAPI.IsCompound2(cShape))
|
||||
if (PhysicsScene.PE.IsCompound(shapeInfo))
|
||||
{
|
||||
shapeInfo.type = BSPhysicsShapeType.SHAPE_COMPOUND;
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// Get the scale of any existing shape so we can see if the new shape is same native type and same size.
|
||||
OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero;
|
||||
if (prim.PhysShape.HasPhysicalShape)
|
||||
scaleOfExistingShape = BulletSimAPI.GetLocalScaling2(prim.PhysShape.ptr);
|
||||
scaleOfExistingShape = PhysicsScene.PE.GetLocalScaling(prim.PhysShape);
|
||||
|
||||
if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}",
|
||||
prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type);
|
||||
|
|
|
@ -151,12 +151,12 @@ public class BSShapeNative : BSShape
|
|||
/*
|
||||
if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
|
||||
{
|
||||
ptr = BulletSimAPI.BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale);
|
||||
ptr = PhysicsScene.PE.BuildCapsuleShape(physicsScene.World, 1f, 1f, prim.Scale);
|
||||
physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = BulletSimAPI.BuildNativeShape2(physicsScene.World.ptr, nativeShapeData);
|
||||
ptr = PhysicsScene.PE.BuildNativeShape(physicsScene.World, nativeShapeData);
|
||||
}
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ public class BSShapeNative : BSShape
|
|||
/*
|
||||
// Native shapes are not tracked and are released immediately
|
||||
physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this);
|
||||
BulletSimAPI.DeleteCollisionShape2(physicsScene.World.ptr, ptr);
|
||||
PhysicsScene.PE.DeleteCollisionShape(physicsScene.World, this);
|
||||
ptr = IntPtr.Zero;
|
||||
// Garbage collection will free up this instance.
|
||||
*/
|
||||
|
|
|
@ -120,7 +120,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
|
|||
PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_mapInfo.terrainBody);
|
||||
|
||||
m_mapInfo.terrainBody.collisionType = CollisionType.Terrain;
|
||||
m_mapInfo.terrainBody.ApplyCollisionMask();
|
||||
m_mapInfo.terrainBody.ApplyCollisionMask(PhysicsScene);
|
||||
|
||||
// Make it so the terrain will not move or be considered for movement.
|
||||
PhysicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION);
|
||||
|
|
|
@ -143,7 +143,7 @@ public sealed class BSTerrainManager : IDisposable
|
|||
PhysicsScene.PE.ForceActivationState(m_groundPlane, ActivationState.DISABLE_SIMULATION);
|
||||
// Everything collides with the ground plane.
|
||||
m_groundPlane.collisionType = CollisionType.Groundplane;
|
||||
m_groundPlane.ApplyCollisionMask();
|
||||
m_groundPlane.ApplyCollisionMask(PhysicsScene);
|
||||
|
||||
// Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain.
|
||||
BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize);
|
||||
|
|
|
@ -120,7 +120,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
|
|||
PhysicsScene.PE.SetCollisionFlags(m_terrainBody, CollisionFlags.CF_STATIC_OBJECT);
|
||||
|
||||
// Static objects are not very massive.
|
||||
BulletSimAPI.SetMassProps2(m_terrainBody.ptr, 0f, Vector3.Zero);
|
||||
PhysicsScene.PE.SetMassProps(m_terrainBody, 0f, Vector3.Zero);
|
||||
|
||||
// Put the new terrain to the world of physical objects
|
||||
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_terrainBody);
|
||||
|
@ -129,7 +129,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
|
|||
PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_terrainBody);
|
||||
|
||||
m_terrainBody.collisionType = CollisionType.Terrain;
|
||||
m_terrainBody.ApplyCollisionMask();
|
||||
m_terrainBody.ApplyCollisionMask(PhysicsScene);
|
||||
|
||||
// Make it so the terrain will not move or be considered for movement.
|
||||
PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION);
|
||||
|
|
|
@ -72,12 +72,12 @@ public class BulletBody
|
|||
public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } }
|
||||
|
||||
// Apply the specificed collision mask into the physical world
|
||||
public bool ApplyCollisionMask()
|
||||
public bool ApplyCollisionMask(BSScene physicsScene)
|
||||
{
|
||||
// Should assert the body has been added to the physical world.
|
||||
// (The collision masks are stored in the collision proxy cache which only exists for
|
||||
// a collision body that is in the world.)
|
||||
return BulletSimAPI.SetCollisionGroupMask2(ptr,
|
||||
return physicsScene.PE.SetCollisionGroupMask(this,
|
||||
BulletSimData.CollisionTypeMasks[collisionType].group,
|
||||
BulletSimData.CollisionTypeMasks[collisionType].mask);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue