BulletSim: another round of conversion: dynamics world and collision object functions.
parent
9fd0e1b080
commit
9218748321
File diff suppressed because it is too large
Load Diff
|
@ -137,7 +137,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
|
|
||||||
private void SetPhysicalProperties()
|
private void SetPhysicalProperties()
|
||||||
{
|
{
|
||||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr);
|
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody);
|
||||||
|
|
||||||
ZeroMotion(true);
|
ZeroMotion(true);
|
||||||
ForcePosition = _position;
|
ForcePosition = _position;
|
||||||
|
@ -152,14 +152,14 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
// Needs to be reset especially when an avatar is recreated after crossing a region boundry.
|
// Needs to be reset especially when an avatar is recreated after crossing a region boundry.
|
||||||
Flying = _flying;
|
Flying = _flying;
|
||||||
|
|
||||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, BSParam.AvatarRestitution);
|
PhysicsScene.PE.SetRestitution(PhysBody, BSParam.AvatarRestitution);
|
||||||
BulletSimAPI.SetMargin2(PhysShape.ptr, PhysicsScene.Params.collisionMargin);
|
BulletSimAPI.SetMargin2(PhysShape.ptr, PhysicsScene.Params.collisionMargin);
|
||||||
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
||||||
BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, BSParam.ContactProcessingThreshold);
|
PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
|
||||||
if (BSParam.CcdMotionThreshold > 0f)
|
if (BSParam.CcdMotionThreshold > 0f)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold);
|
PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
|
||||||
BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius);
|
PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePhysicalMassProperties(RawMass, false);
|
UpdatePhysicalMassProperties(RawMass, false);
|
||||||
|
@ -167,13 +167,13 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
// Make so capsule does not fall over
|
// Make so capsule does not fall over
|
||||||
BulletSimAPI.SetAngularFactorV2(PhysBody.ptr, OMV.Vector3.Zero);
|
BulletSimAPI.SetAngularFactorV2(PhysBody.ptr, OMV.Vector3.Zero);
|
||||||
|
|
||||||
BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT);
|
PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT);
|
||||||
|
|
||||||
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr);
|
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody);
|
||||||
|
|
||||||
// BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG);
|
// PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
|
||||||
BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_DEACTIVATION);
|
PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION);
|
||||||
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr);
|
PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody);
|
||||||
|
|
||||||
// Do this after the object has been added to the world
|
// Do this after the object has been added to the world
|
||||||
PhysBody.collisionType = CollisionType.Avatar;
|
PhysBody.collisionType = CollisionType.Avatar;
|
||||||
|
@ -320,7 +320,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
{
|
{
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, OMV.Vector3.Zero);
|
||||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
||||||
// The next also get rid of applied linear force but the linear velocity is untouched.
|
// The next also get rid of applied linear force but the linear velocity is untouched.
|
||||||
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
||||||
|
@ -350,19 +350,19 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override OMV.Vector3 ForcePosition {
|
public override OMV.Vector3 ForcePosition {
|
||||||
get {
|
get {
|
||||||
_position = BulletSimAPI.GetPosition2(PhysBody.ptr);
|
_position = PhysicsScene.PE.GetPosition(PhysBody);
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
_position = value;
|
_position = value;
|
||||||
PositionSanityCheck();
|
PositionSanityCheck();
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||||
});
|
});
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
{
|
{
|
||||||
_currentFriction = BSParam.AvatarStandingFriction;
|
_currentFriction = BSParam.AvatarStandingFriction;
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -529,12 +529,12 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
{
|
{
|
||||||
_currentFriction = BSParam.AvatarFriction;
|
_currentFriction = BSParam.AvatarFriction;
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
|
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
|
||||||
BulletSimAPI.Activate2(PhysBody.ptr, true);
|
PhysicsScene.PE.Activate(PhysBody, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override OMV.Vector3 Torque {
|
public override OMV.Vector3 Torque {
|
||||||
|
@ -576,7 +576,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr);
|
_orientation = PhysicsScene.PE.GetOrientation(PhysBody);
|
||||||
return _orientation;
|
return _orientation;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
@ -584,8 +584,8 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
_orientation = value;
|
_orientation = value;
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
// _position = BulletSimAPI.GetPosition2(BSBody.ptr);
|
// _position = PhysicsScene.PE.GetPosition(BSBody);
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -636,9 +636,9 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
if (_floatOnWater)
|
if (_floatOnWater)
|
||||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||||
else
|
else
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
private static string LogHeader = "[BULLETSIM CONSTRAINT]";
|
private static string LogHeader = "[BULLETSIM CONSTRAINT]";
|
||||||
|
|
||||||
protected BulletWorld m_world;
|
protected BulletWorld m_world;
|
||||||
|
protected BSScene PhysicsScene;
|
||||||
protected BulletBody m_body1;
|
protected BulletBody m_body1;
|
||||||
protected BulletBody m_body2;
|
protected BulletBody m_body2;
|
||||||
protected BulletConstraint m_constraint;
|
protected BulletConstraint m_constraint;
|
||||||
|
@ -48,8 +49,10 @@ public abstract class BSConstraint : IDisposable
|
||||||
public abstract ConstraintType Type { get; }
|
public abstract ConstraintType Type { get; }
|
||||||
public bool IsEnabled { get { return m_enabled; } }
|
public bool IsEnabled { get { return m_enabled; } }
|
||||||
|
|
||||||
public BSConstraint()
|
public BSConstraint(BulletWorld world)
|
||||||
{
|
{
|
||||||
|
m_world = world;
|
||||||
|
PhysicsScene = m_world.physicsScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Dispose()
|
public virtual void Dispose()
|
||||||
|
@ -59,7 +62,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
if (m_constraint.HasPhysicalConstraint)
|
if (m_constraint.HasPhysicalConstraint)
|
||||||
{
|
{
|
||||||
bool success = BulletSimAPI.DestroyConstraint2(m_world.ptr, m_constraint.ptr);
|
bool success = PhysicsScene.PE.DestroyConstraint(m_world, m_constraint);
|
||||||
m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}",
|
m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}",
|
||||||
BSScene.DetailLogZero,
|
BSScene.DetailLogZero,
|
||||||
m_body1.ID, m_body1.ptr.ToString("X"),
|
m_body1.ID, m_body1.ptr.ToString("X"),
|
||||||
|
@ -74,7 +77,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
ret = BulletSimAPI.SetLinearLimits2(m_constraint.ptr, low, high);
|
ret = PhysicsScene.PE.SetLinearLimits(m_constraint, low, high);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +85,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
ret = BulletSimAPI.SetAngularLimits2(m_constraint.ptr, low, high);
|
ret = PhysicsScene.PE.SetAngularLimits(m_constraint, low, high);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +94,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetConstraintNumSolverIterations2(m_constraint.ptr, cnt);
|
PhysicsScene.PE.SetConstraintNumSolverIterations(m_constraint, cnt);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -103,7 +106,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
// Recompute the internal transforms
|
// Recompute the internal transforms
|
||||||
BulletSimAPI.CalculateTransforms2(m_constraint.ptr);
|
PhysicsScene.PE.CalculateTransforms(m_constraint);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -122,7 +125,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
// Setting an object's mass to zero (making it static like when it's selected)
|
// Setting an object's mass to zero (making it static like when it's selected)
|
||||||
// automatically disables the constraints.
|
// automatically disables the constraints.
|
||||||
// If the link is enabled, be sure to set the constraint itself to enabled.
|
// If the link is enabled, be sure to set the constraint itself to enabled.
|
||||||
BulletSimAPI.SetConstraintEnable2(m_constraint.ptr, BSParam.NumericBool(true));
|
PhysicsScene.PE.SetConstraintEnable(m_constraint, BSParam.NumericBool(true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,15 +43,14 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
Vector3 frame1, Quaternion frame1rot,
|
Vector3 frame1, Quaternion frame1rot,
|
||||||
Vector3 frame2, Quaternion frame2rot,
|
Vector3 frame2, Quaternion frame2rot,
|
||||||
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
|
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
|
||||||
|
: base(world)
|
||||||
{
|
{
|
||||||
m_world = world;
|
|
||||||
m_body1 = obj1;
|
m_body1 = obj1;
|
||||||
m_body2 = obj2;
|
m_body2 = obj2;
|
||||||
m_constraint = new BulletConstraint(
|
m_constraint = PhysicsScene.PE.Create6DofConstraint(m_world, m_body1, m_body2,
|
||||||
BulletSimAPI.Create6DofConstraint2(m_world.ptr, m_body1.ptr, m_body2.ptr,
|
|
||||||
frame1, frame1rot,
|
frame1, frame1rot,
|
||||||
frame2, frame2rot,
|
frame2, frame2rot,
|
||||||
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
|
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
|
world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
|
||||||
BSScene.DetailLogZero, world.worldID,
|
BSScene.DetailLogZero, world.worldID,
|
||||||
|
@ -61,8 +60,8 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2,
|
public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2,
|
||||||
Vector3 joinPoint,
|
Vector3 joinPoint,
|
||||||
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
|
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
|
||||||
|
: base(world)
|
||||||
{
|
{
|
||||||
m_world = world;
|
|
||||||
m_body1 = obj1;
|
m_body1 = obj1;
|
||||||
m_body2 = obj2;
|
m_body2 = obj2;
|
||||||
if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody)
|
if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody)
|
||||||
|
@ -76,11 +75,10 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_constraint = new BulletConstraint(
|
m_constraint = PhysicsScene.PE.Create6DofConstraintToPoint(m_world, m_body1, m_body2,
|
||||||
BulletSimAPI.Create6DofConstraintToPoint2(m_world.ptr, m_body1.ptr, m_body2.ptr,
|
|
||||||
joinPoint,
|
joinPoint,
|
||||||
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
|
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
|
||||||
world.physicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}",
|
PhysicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}",
|
||||||
BSScene.DetailLogZero, world.worldID, m_constraint.ptr.ToString("X"),
|
BSScene.DetailLogZero, world.worldID, m_constraint.ptr.ToString("X"),
|
||||||
obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X"));
|
obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X"));
|
||||||
if (!m_constraint.HasPhysicalConstraint)
|
if (!m_constraint.HasPhysicalConstraint)
|
||||||
|
@ -101,7 +99,7 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetFrames2(m_constraint.ptr, frameA, frameArot, frameB, frameBrot);
|
PhysicsScene.PE.SetFrames(m_constraint, frameA, frameArot, frameB, frameBrot);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -112,9 +110,9 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
|
PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
|
||||||
BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL);
|
PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL);
|
||||||
BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
|
PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -125,7 +123,7 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
|
float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
ret = BulletSimAPI.UseFrameOffset2(m_constraint.ptr, onOff);
|
ret = PhysicsScene.PE.UseFrameOffset(m_constraint, onOff);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +133,7 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
|
float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.ptr, onOff, targetVelocity, maxMotorForce);
|
ret = PhysicsScene.PE.TranslationalLimitMotor(m_constraint, onOff, targetVelocity, maxMotorForce);
|
||||||
m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}",
|
m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}",
|
||||||
BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce);
|
BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +144,7 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
ret = BulletSimAPI.SetBreakingImpulseThreshold2(m_constraint.ptr, threshold);
|
ret = PhysicsScene.PE.SetBreakingImpulseThreshold(m_constraint, threshold);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,15 +40,13 @@ public sealed class BSConstraintHinge : BSConstraint
|
||||||
Vector3 pivotInA, Vector3 pivotInB,
|
Vector3 pivotInA, Vector3 pivotInB,
|
||||||
Vector3 axisInA, Vector3 axisInB,
|
Vector3 axisInA, Vector3 axisInB,
|
||||||
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
|
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
|
||||||
|
: base(world)
|
||||||
{
|
{
|
||||||
m_world = world;
|
|
||||||
m_body1 = obj1;
|
m_body1 = obj1;
|
||||||
m_body2 = obj2;
|
m_body2 = obj2;
|
||||||
m_constraint = new BulletConstraint(
|
m_constraint = PhysicsScene.PE.CreateHingeConstraint(world, obj1, obj2,
|
||||||
BulletSimAPI.CreateHingeConstraint2(m_world.ptr, m_body1.ptr, m_body2.ptr,
|
pivotInA, pivotInB, axisInA, axisInB,
|
||||||
pivotInA, pivotInB,
|
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
|
||||||
axisInA, axisInB,
|
|
||||||
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
|
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -558,7 +558,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
|
|
||||||
// Friction affects are handled by this vehicle code
|
// Friction affects are handled by this vehicle code
|
||||||
float friction = 0f;
|
float friction = 0f;
|
||||||
BulletSimAPI.SetFriction2(Prim.PhysBody.ptr, friction);
|
PhysicsScene.PE.SetFriction(Prim.PhysBody, friction);
|
||||||
|
|
||||||
// Moderate angular movement introduced by Bullet.
|
// Moderate angular movement introduced by Bullet.
|
||||||
// TODO: possibly set AngularFactor and LinearFactor for the type of vehicle.
|
// TODO: possibly set AngularFactor and LinearFactor for the type of vehicle.
|
||||||
|
@ -567,7 +567,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
BulletSimAPI.SetAngularDamping2(Prim.PhysBody.ptr, angularDamping);
|
BulletSimAPI.SetAngularDamping2(Prim.PhysBody.ptr, angularDamping);
|
||||||
|
|
||||||
// Vehicles report collision events so we know when it's on the ground
|
// Vehicles report collision events so we know when it's on the ground
|
||||||
BulletSimAPI.AddToCollisionFlags2(Prim.PhysBody.ptr, CollisionFlags.BS_VEHICLE_COLLISIONS);
|
PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
|
||||||
|
|
||||||
Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(Prim.PhysShape.ptr, m_vehicleMass);
|
Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(Prim.PhysShape.ptr, m_vehicleMass);
|
||||||
BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia);
|
BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia);
|
||||||
|
@ -581,7 +581,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BulletSimAPI.RemoveFromCollisionFlags2(Prim.PhysBody.ptr, CollisionFlags.BS_VEHICLE_COLLISIONS);
|
PhysicsScene.PE.RemoveFromCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +651,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
if ((m_knownChanged & m_knownChangedVelocity) != 0)
|
if ((m_knownChanged & m_knownChangedVelocity) != 0)
|
||||||
{
|
{
|
||||||
Prim.ForceVelocity = m_knownVelocity;
|
Prim.ForceVelocity = m_knownVelocity;
|
||||||
BulletSimAPI.SetInterpolationLinearVelocity2(Prim.PhysBody.ptr, VehicleVelocity);
|
PhysicsScene.PE.SetInterpolationLinearVelocity(Prim.PhysBody, VehicleVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_knownChanged & m_knownChangedForce) != 0)
|
if ((m_knownChanged & m_knownChangedForce) != 0)
|
||||||
|
@ -661,7 +661,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
{
|
{
|
||||||
Prim.ForceRotationalVelocity = m_knownRotationalVelocity;
|
Prim.ForceRotationalVelocity = m_knownRotationalVelocity;
|
||||||
// Fake out Bullet by making it think the velocity is the same as last time.
|
// Fake out Bullet by making it think the velocity is the same as last time.
|
||||||
BulletSimAPI.SetInterpolationAngularVelocity2(Prim.PhysBody.ptr, m_knownRotationalVelocity);
|
PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_knownChanged & m_knownChangedRotationalForce) != 0)
|
if ((m_knownChanged & m_knownChangedRotationalForce) != 0)
|
||||||
|
|
|
@ -131,10 +131,10 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
{
|
{
|
||||||
// The origional prims are removed from the world as the shape of the root compound
|
// The origional prims are removed from the world as the shape of the root compound
|
||||||
// shape takes over.
|
// shape takes over.
|
||||||
BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
PhysicsScene.PE.AddToCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
||||||
BulletSimAPI.ForceActivationState2(child.PhysBody.ptr, ActivationState.DISABLE_SIMULATION);
|
PhysicsScene.PE.ForceActivationState(child.PhysBody, ActivationState.DISABLE_SIMULATION);
|
||||||
// We don't want collisions from the old linkset children.
|
// We don't want collisions from the old linkset children.
|
||||||
BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
PhysicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
|
|
||||||
child.PhysBody.collisionType = CollisionType.LinksetChild;
|
child.PhysBody.collisionType = CollisionType.LinksetChild;
|
||||||
|
|
||||||
|
@ -159,12 +159,12 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The non-physical children can come back to life.
|
// The non-physical children can come back to life.
|
||||||
BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
PhysicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
||||||
|
|
||||||
child.PhysBody.collisionType = CollisionType.LinksetChild;
|
child.PhysBody.collisionType = CollisionType.LinksetChild;
|
||||||
|
|
||||||
// Don't force activation so setting of DISABLE_SIMULATION can stay if used.
|
// Don't force activation so setting of DISABLE_SIMULATION can stay if used.
|
||||||
BulletSimAPI.Activate2(child.PhysBody.ptr, false);
|
PhysicsScene.PE.Activate(child.PhysBody, false);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -371,7 +371,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}",
|
PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}",
|
||||||
LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape);
|
LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape);
|
||||||
}
|
}
|
||||||
PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, lci.OffsetPos, lci.OffsetRot);
|
PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, lci.OffsetPos, lci.OffsetRot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false; // 'false' says to move onto the next child in the list
|
return false; // 'false' says to move onto the next child in the list
|
||||||
|
|
|
@ -300,7 +300,7 @@ public static class BSParam
|
||||||
(s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); },
|
||||||
(s) => { return DeactivationTime; },
|
(s) => { return DeactivationTime; },
|
||||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{DeactivationTime=x;}, p, l, v); },
|
(s,p,l,v) => { s.UpdateParameterObject((x)=>{DeactivationTime=x;}, p, l, v); },
|
||||||
(s,o,v) => { BulletSimAPI.SetDeactivationTime2(o.PhysBody.ptr, v); } ),
|
(s,o,v) => { s.PE.SetDeactivationTime(o.PhysBody, v); } ),
|
||||||
new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static",
|
new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static",
|
||||||
0.8f,
|
0.8f,
|
||||||
(s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); },
|
||||||
|
@ -318,19 +318,19 @@ public static class BSParam
|
||||||
(s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
|
||||||
(s) => { return CcdMotionThreshold; },
|
(s) => { return CcdMotionThreshold; },
|
||||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); },
|
(s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); },
|
||||||
(s,o,v) => { BulletSimAPI.SetCcdMotionThreshold2(o.PhysBody.ptr, v); } ),
|
(s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ),
|
||||||
new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" ,
|
new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" ,
|
||||||
0f,
|
0f,
|
||||||
(s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); },
|
||||||
(s) => { return CcdSweptSphereRadius; },
|
(s) => { return CcdSweptSphereRadius; },
|
||||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); },
|
(s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); },
|
||||||
(s,o,v) => { BulletSimAPI.SetCcdSweptSphereRadius2(o.PhysBody.ptr, v); } ),
|
(s,o,v) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, v); } ),
|
||||||
new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" ,
|
new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" ,
|
||||||
0.1f,
|
0.1f,
|
||||||
(s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); },
|
||||||
(s) => { return ContactProcessingThreshold; },
|
(s) => { return ContactProcessingThreshold; },
|
||||||
(s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); },
|
(s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); },
|
||||||
(s,o,v) => { BulletSimAPI.SetContactProcessingThreshold2(o.PhysBody.ptr, v); } ),
|
(s,o,v) => { s.PE.SetContactProcessingThreshold(o.PhysBody, v); } ),
|
||||||
|
|
||||||
new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
|
new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
|
||||||
(float)BSTerrainPhys.TerrainImplementation.Mesh,
|
(float)BSTerrainPhys.TerrainImplementation.Mesh,
|
||||||
|
|
|
@ -308,7 +308,7 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate()
|
PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate()
|
||||||
{
|
{
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -324,7 +324,7 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
{
|
{
|
||||||
// Make sure there is a body there because sometimes destruction happens in an un-ideal order.
|
// Make sure there is a body there because sometimes destruction happens in an un-ideal order.
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Return 'true' if the simulator wants collision events
|
// Return 'true' if the simulator wants collision events
|
||||||
|
|
|
@ -120,7 +120,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
CreateGeomAndObject(true);
|
CreateGeomAndObject(true);
|
||||||
|
|
||||||
CurrentCollisionFlags = BulletSimAPI.GetCollisionFlags2(PhysBody.ptr);
|
CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
|
// DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
|
||||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -318,14 +318,14 @@ public sealed class BSPrim : BSPhysObject
|
||||||
}
|
}
|
||||||
public override OMV.Vector3 ForcePosition {
|
public override OMV.Vector3 ForcePosition {
|
||||||
get {
|
get {
|
||||||
_position = BulletSimAPI.GetPosition2(PhysBody.ptr);
|
_position = PhysicsScene.PE.GetPosition(PhysBody);
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
_position = value;
|
_position = value;
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// Changing interesting properties doesn't change proxy and collision cache
|
// Changing interesting properties doesn't change proxy and collision cache
|
||||||
// information. The Bullet solution is to re-add the object to the world
|
// information. The Bullet solution is to re-add the object to the world
|
||||||
// after parameters are changed.
|
// after parameters are changed.
|
||||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr);
|
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The computation of mass props requires gravity to be set on the object.
|
// The computation of mass props requires gravity to be set on the object.
|
||||||
|
@ -649,9 +649,9 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
// _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
|
// _position = PhysicsScene.PE.GetObjectPosition(PhysicsScene.World, BSBody);
|
||||||
// DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
// DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -661,13 +661,13 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr);
|
_orientation = PhysicsScene.PE.GetOrientation(PhysBody);
|
||||||
return _orientation;
|
return _orientation;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_orientation = value;
|
_orientation = value;
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override int PhysicsActorType {
|
public override int PhysicsActorType {
|
||||||
|
@ -723,7 +723,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
|
|
||||||
// Mangling all the physical properties requires the object not be in the physical world.
|
// Mangling all the physical properties requires the object not be in the physical world.
|
||||||
// This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found).
|
// This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found).
|
||||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr);
|
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody);
|
||||||
|
|
||||||
// Set up the object physicalness (does gravity and collisions move this object)
|
// Set up the object physicalness (does gravity and collisions move this object)
|
||||||
MakeDynamic(IsStatic);
|
MakeDynamic(IsStatic);
|
||||||
|
@ -740,7 +740,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
AddObjectToPhysicalWorld();
|
AddObjectToPhysicalWorld();
|
||||||
|
|
||||||
// Rebuild its shape
|
// Rebuild its shape
|
||||||
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr);
|
PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody);
|
||||||
|
|
||||||
// Recompute any linkset parameters.
|
// Recompute any linkset parameters.
|
||||||
// When going from non-physical to physical, this re-enables the constraints that
|
// When going from non-physical to physical, this re-enables the constraints that
|
||||||
|
@ -762,28 +762,28 @@ public sealed class BSPrim : BSPhysObject
|
||||||
if (makeStatic)
|
if (makeStatic)
|
||||||
{
|
{
|
||||||
// Become a Bullet 'static' object type
|
// Become a Bullet 'static' object type
|
||||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
|
CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT);
|
||||||
// Stop all movement
|
// Stop all movement
|
||||||
ZeroMotion(true);
|
ZeroMotion(true);
|
||||||
|
|
||||||
// Set various physical properties so other object interact properly
|
// Set various physical properties so other object interact properly
|
||||||
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
|
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction);
|
PhysicsScene.PE.SetFriction(PhysBody, matAttrib.friction);
|
||||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution);
|
PhysicsScene.PE.SetRestitution(PhysBody, matAttrib.restitution);
|
||||||
|
|
||||||
// Mass is zero which disables a bunch of physics stuff in Bullet
|
// Mass is zero which disables a bunch of physics stuff in Bullet
|
||||||
UpdatePhysicalMassProperties(0f, false);
|
UpdatePhysicalMassProperties(0f, false);
|
||||||
// Set collision detection parameters
|
// Set collision detection parameters
|
||||||
if (BSParam.CcdMotionThreshold > 0f)
|
if (BSParam.CcdMotionThreshold > 0f)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold);
|
PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
|
||||||
BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius);
|
PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The activation state is 'disabled' so Bullet will not try to act on it.
|
// The activation state is 'disabled' so Bullet will not try to act on it.
|
||||||
// BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_SIMULATION);
|
// PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_SIMULATION);
|
||||||
// Start it out sleeping and physical actions could wake it up.
|
// Start it out sleeping and physical actions could wake it up.
|
||||||
BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ISLAND_SLEEPING);
|
PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING);
|
||||||
|
|
||||||
// This collides like a static object
|
// This collides like a static object
|
||||||
PhysBody.collisionType = CollisionType.Static;
|
PhysBody.collisionType = CollisionType.Static;
|
||||||
|
@ -794,22 +794,22 @@ public sealed class BSPrim : BSPhysObject
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Not a Bullet static object
|
// Not a Bullet static object
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
|
CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT);
|
||||||
|
|
||||||
// Set various physical properties so other object interact properly
|
// Set various physical properties so other object interact properly
|
||||||
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true);
|
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true);
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction);
|
PhysicsScene.PE.SetFriction(PhysBody, matAttrib.friction);
|
||||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution);
|
PhysicsScene.PE.SetRestitution(PhysBody, matAttrib.restitution);
|
||||||
|
|
||||||
// per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
|
// per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
|
||||||
// Since this can be called multiple times, only zero forces when becoming physical
|
// Since this can be called multiple times, only zero forces when becoming physical
|
||||||
// BulletSimAPI.ClearAllForces2(BSBody.ptr);
|
// PhysicsScene.PE.ClearAllForces(BSBody);
|
||||||
|
|
||||||
// For good measure, make sure the transform is set through to the motion state
|
// For good measure, make sure the transform is set through to the motion state
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
|
||||||
|
|
||||||
// Center of mass is at the center of the object
|
// Center of mass is at the center of the object
|
||||||
// DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody.ptr, _position, _orientation);
|
// DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody, _position, _orientation);
|
||||||
|
|
||||||
// A dynamic object has mass
|
// A dynamic object has mass
|
||||||
UpdatePhysicalMassProperties(RawMass, false);
|
UpdatePhysicalMassProperties(RawMass, false);
|
||||||
|
@ -817,22 +817,22 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// Set collision detection parameters
|
// Set collision detection parameters
|
||||||
if (BSParam.CcdMotionThreshold > 0f)
|
if (BSParam.CcdMotionThreshold > 0f)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold);
|
PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
|
||||||
BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius);
|
PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Various values for simulation limits
|
// Various values for simulation limits
|
||||||
BulletSimAPI.SetDamping2(PhysBody.ptr, BSParam.LinearDamping, BSParam.AngularDamping);
|
BulletSimAPI.SetDamping2(PhysBody.ptr, BSParam.LinearDamping, BSParam.AngularDamping);
|
||||||
BulletSimAPI.SetDeactivationTime2(PhysBody.ptr, BSParam.DeactivationTime);
|
PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime);
|
||||||
BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold);
|
BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold);
|
||||||
BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, BSParam.ContactProcessingThreshold);
|
PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
|
||||||
|
|
||||||
// This collides like an object.
|
// This collides like an object.
|
||||||
PhysBody.collisionType = CollisionType.Dynamic;
|
PhysBody.collisionType = CollisionType.Dynamic;
|
||||||
|
|
||||||
// Force activation of the object so Bullet will act on it.
|
// Force activation of the object so Bullet will act on it.
|
||||||
// Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects.
|
// Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects.
|
||||||
BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ACTIVE_TAG);
|
PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
|
||||||
|
|
||||||
// There might be special things needed for implementing linksets.
|
// There might be special things needed for implementing linksets.
|
||||||
Linkset.MakeDynamic(this);
|
Linkset.MakeDynamic(this);
|
||||||
|
@ -853,7 +853,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType);
|
m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType);
|
||||||
}
|
}
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -861,7 +861,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType);
|
m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType);
|
||||||
}
|
}
|
||||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
||||||
|
|
||||||
// Change collision info from a static object to a ghosty collision object
|
// Change collision info from a static object to a ghosty collision object
|
||||||
PhysBody.collisionType = CollisionType.VolumeDetect;
|
PhysBody.collisionType = CollisionType.VolumeDetect;
|
||||||
|
@ -874,7 +874,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
private void ActivateIfPhysical(bool forceIt)
|
private void ActivateIfPhysical(bool forceIt)
|
||||||
{
|
{
|
||||||
if (IsPhysical && PhysBody.HasPhysicalBody)
|
if (IsPhysical && PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.Activate2(PhysBody.ptr, forceIt);
|
PhysicsScene.PE.Activate(PhysBody, forceIt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn on or off the flag controlling whether collision events are returned to the simulator.
|
// Turn on or off the flag controlling whether collision events are returned to the simulator.
|
||||||
|
@ -882,11 +882,11 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
if (wantsCollisionEvents)
|
if (wantsCollisionEvents)
|
||||||
{
|
{
|
||||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +897,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr);
|
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody);
|
||||||
|
|
||||||
// TODO: Fix this. Total kludge because adding object to world resets its gravity to default.
|
// TODO: Fix this. Total kludge because adding object to world resets its gravity to default.
|
||||||
// Replace this when the new AddObjectToWorld function is complete.
|
// Replace this when the new AddObjectToWorld function is complete.
|
||||||
|
@ -941,9 +941,9 @@ public sealed class BSPrim : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate()
|
PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate()
|
||||||
{
|
{
|
||||||
if (_floatOnWater)
|
if (_floatOnWater)
|
||||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||||
else
|
else
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
{
|
{
|
||||||
if (!BulletSimAPI.IsInWorld2(body.ptr))
|
if (!BulletSimAPI.IsInWorld2(body.ptr))
|
||||||
{
|
{
|
||||||
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, body.ptr);
|
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body);
|
||||||
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
|
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -168,12 +168,12 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
|
|
||||||
if (BulletSimAPI.IsInWorld2(body.ptr))
|
if (BulletSimAPI.IsInWorld2(body.ptr))
|
||||||
{
|
{
|
||||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, body.ptr);
|
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
|
||||||
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
|
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zero any reference to the shape so it is not freed when the body is deleted.
|
// Zero any reference to the shape so it is not freed when the body is deleted.
|
||||||
BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, body.ptr, IntPtr.Zero);
|
PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, new BulletShape());
|
||||||
PhysicsScene.PE.DestroyObject(PhysicsScene.World, body);
|
PhysicsScene.PE.DestroyObject(PhysicsScene.World, body);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,13 +91,12 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
|
||||||
// Using the information in m_mapInfo, create the physical representation of the heightmap.
|
// Using the information in m_mapInfo, create the physical representation of the heightmap.
|
||||||
private void BuildHeightmapTerrain()
|
private void BuildHeightmapTerrain()
|
||||||
{
|
{
|
||||||
m_mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, m_mapInfo.ID,
|
m_mapInfo.Ptr = PhysicsScene.PE.CreateHeightMapInfo(PhysicsScene.World, m_mapInfo.ID,
|
||||||
m_mapInfo.minCoords, m_mapInfo.maxCoords,
|
m_mapInfo.minCoords, m_mapInfo.maxCoords,
|
||||||
m_mapInfo.heightMap, BSParam.TerrainCollisionMargin);
|
m_mapInfo.heightMap, BSParam.TerrainCollisionMargin);
|
||||||
|
|
||||||
// Create the terrain shape from the mapInfo
|
// Create the terrain shape from the mapInfo
|
||||||
m_mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(m_mapInfo.Ptr),
|
m_mapInfo.terrainShape = PhysicsScene.PE.CreateTerrainShape(m_mapInfo.Ptr);
|
||||||
BSPhysicsShapeType.SHAPE_TERRAIN);
|
|
||||||
|
|
||||||
// The terrain object initial position is at the center of the object
|
// The terrain object initial position is at the center of the object
|
||||||
Vector3 centerPos;
|
Vector3 centerPos;
|
||||||
|
@ -109,22 +108,22 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
|
||||||
m_mapInfo.ID, centerPos, Quaternion.Identity);
|
m_mapInfo.ID, centerPos, Quaternion.Identity);
|
||||||
|
|
||||||
// Set current terrain attributes
|
// Set current terrain attributes
|
||||||
BulletSimAPI.SetFriction2(m_mapInfo.terrainBody.ptr, BSParam.TerrainFriction);
|
PhysicsScene.PE.SetFriction(m_mapInfo.terrainBody, BSParam.TerrainFriction);
|
||||||
BulletSimAPI.SetHitFraction2(m_mapInfo.terrainBody.ptr, BSParam.TerrainHitFraction);
|
PhysicsScene.PE.SetHitFraction(m_mapInfo.terrainBody, BSParam.TerrainHitFraction);
|
||||||
BulletSimAPI.SetRestitution2(m_mapInfo.terrainBody.ptr, BSParam.TerrainRestitution);
|
PhysicsScene.PE.SetRestitution(m_mapInfo.terrainBody, BSParam.TerrainRestitution);
|
||||||
BulletSimAPI.SetCollisionFlags2(m_mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
|
PhysicsScene.PE.SetCollisionFlags(m_mapInfo.terrainBody, CollisionFlags.CF_STATIC_OBJECT);
|
||||||
|
|
||||||
// Return the new terrain to the world of physical objects
|
// Return the new terrain to the world of physical objects
|
||||||
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
|
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_mapInfo.terrainBody);
|
||||||
|
|
||||||
// redo its bounding box now that it is in the world
|
// redo its bounding box now that it is in the world
|
||||||
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
|
PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_mapInfo.terrainBody);
|
||||||
|
|
||||||
m_mapInfo.terrainBody.collisionType = CollisionType.Terrain;
|
m_mapInfo.terrainBody.collisionType = CollisionType.Terrain;
|
||||||
m_mapInfo.terrainBody.ApplyCollisionMask();
|
m_mapInfo.terrainBody.ApplyCollisionMask();
|
||||||
|
|
||||||
// Make it so the terrain will not move or be considered for movement.
|
// Make it so the terrain will not move or be considered for movement.
|
||||||
BulletSimAPI.ForceActivationState2(m_mapInfo.terrainBody.ptr, ActivationState.DISABLE_SIMULATION);
|
PhysicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -136,10 +135,10 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
|
||||||
{
|
{
|
||||||
if (m_mapInfo.terrainBody.HasPhysicalBody)
|
if (m_mapInfo.terrainBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
|
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_mapInfo.terrainBody);
|
||||||
// Frees both the body and the shape.
|
// Frees both the body and the shape.
|
||||||
PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_mapInfo.terrainBody);
|
PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_mapInfo.terrainBody);
|
||||||
BulletSimAPI.ReleaseHeightMapInfo2(m_mapInfo.Ptr);
|
PhysicsScene.PE.ReleaseHeightMapInfo(m_mapInfo.Ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_mapInfo = null;
|
m_mapInfo = null;
|
||||||
|
|
|
@ -133,17 +133,14 @@ public sealed class BSTerrainManager : IDisposable
|
||||||
public void CreateInitialGroundPlaneAndTerrain()
|
public void CreateInitialGroundPlaneAndTerrain()
|
||||||
{
|
{
|
||||||
// The ground plane is here to catch things that are trying to drop to negative infinity
|
// The ground plane is here to catch things that are trying to drop to negative infinity
|
||||||
BulletShape groundPlaneShape = new BulletShape(
|
BulletShape groundPlaneShape = PhysicsScene.PE.CreateGroundPlaneShape(BSScene.GROUNDPLANE_ID, 1f, BSParam.TerrainCollisionMargin);
|
||||||
BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f,
|
|
||||||
BSParam.TerrainCollisionMargin),
|
|
||||||
BSPhysicsShapeType.SHAPE_GROUNDPLANE);
|
|
||||||
m_groundPlane = PhysicsScene.PE.CreateBodyWithDefaultMotionState(groundPlaneShape,
|
m_groundPlane = PhysicsScene.PE.CreateBodyWithDefaultMotionState(groundPlaneShape,
|
||||||
BSScene.GROUNDPLANE_ID, Vector3.Zero, Quaternion.Identity);
|
BSScene.GROUNDPLANE_ID, Vector3.Zero, Quaternion.Identity);
|
||||||
|
|
||||||
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr);
|
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_groundPlane);
|
||||||
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_groundPlane.ptr);
|
PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_groundPlane);
|
||||||
// Ground plane does not move
|
// Ground plane does not move
|
||||||
BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION);
|
PhysicsScene.PE.ForceActivationState(m_groundPlane, ActivationState.DISABLE_SIMULATION);
|
||||||
// Everything collides with the ground plane.
|
// Everything collides with the ground plane.
|
||||||
m_groundPlane.collisionType = CollisionType.Groundplane;
|
m_groundPlane.collisionType = CollisionType.Groundplane;
|
||||||
m_groundPlane.ApplyCollisionMask();
|
m_groundPlane.ApplyCollisionMask();
|
||||||
|
@ -158,7 +155,7 @@ public sealed class BSTerrainManager : IDisposable
|
||||||
{
|
{
|
||||||
if (m_groundPlane.HasPhysicalBody)
|
if (m_groundPlane.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr))
|
if (PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_groundPlane))
|
||||||
{
|
{
|
||||||
PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_groundPlane);
|
PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_groundPlane);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,32 +114,32 @@ public sealed class BSTerrainMesh : BSTerrainPhys
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current terrain attributes
|
// Set current terrain attributes
|
||||||
BulletSimAPI.SetFriction2(m_terrainBody.ptr, BSParam.TerrainFriction);
|
PhysicsScene.PE.SetFriction(m_terrainBody, BSParam.TerrainFriction);
|
||||||
BulletSimAPI.SetHitFraction2(m_terrainBody.ptr, BSParam.TerrainHitFraction);
|
PhysicsScene.PE.SetHitFraction(m_terrainBody, BSParam.TerrainHitFraction);
|
||||||
BulletSimAPI.SetRestitution2(m_terrainBody.ptr, BSParam.TerrainRestitution);
|
PhysicsScene.PE.SetRestitution(m_terrainBody, BSParam.TerrainRestitution);
|
||||||
BulletSimAPI.SetCollisionFlags2(m_terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
|
PhysicsScene.PE.SetCollisionFlags(m_terrainBody, CollisionFlags.CF_STATIC_OBJECT);
|
||||||
|
|
||||||
// Static objects are not very massive.
|
// Static objects are not very massive.
|
||||||
BulletSimAPI.SetMassProps2(m_terrainBody.ptr, 0f, Vector3.Zero);
|
BulletSimAPI.SetMassProps2(m_terrainBody.ptr, 0f, Vector3.Zero);
|
||||||
|
|
||||||
// Put the new terrain to the world of physical objects
|
// Put the new terrain to the world of physical objects
|
||||||
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr);
|
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_terrainBody);
|
||||||
|
|
||||||
// Redo its bounding box now that it is in the world
|
// Redo its bounding box now that it is in the world
|
||||||
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_terrainBody.ptr);
|
PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_terrainBody);
|
||||||
|
|
||||||
m_terrainBody.collisionType = CollisionType.Terrain;
|
m_terrainBody.collisionType = CollisionType.Terrain;
|
||||||
m_terrainBody.ApplyCollisionMask();
|
m_terrainBody.ApplyCollisionMask();
|
||||||
|
|
||||||
// Make it so the terrain will not move or be considered for movement.
|
// Make it so the terrain will not move or be considered for movement.
|
||||||
BulletSimAPI.ForceActivationState2(m_terrainBody.ptr, ActivationState.DISABLE_SIMULATION);
|
PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
if (m_terrainBody.HasPhysicalBody)
|
if (m_terrainBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr);
|
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_terrainBody);
|
||||||
// Frees both the body and the shape.
|
// Frees both the body and the shape.
|
||||||
PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_terrainBody);
|
PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_terrainBody);
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,7 +367,6 @@ public abstract void ReleaseBodyInfo(IntPtr obj);
|
||||||
|
|
||||||
public abstract void DestroyObject(BulletWorld sim, BulletBody obj);
|
public abstract void DestroyObject(BulletWorld sim, BulletBody obj);
|
||||||
|
|
||||||
/*
|
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
// Terrain creation and helper routines
|
// Terrain creation and helper routines
|
||||||
public abstract IntPtr CreateHeightMapInfo(BulletWorld sim, uint id, Vector3 minCoords, Vector3 maxCoords,
|
public abstract IntPtr CreateHeightMapInfo(BulletWorld sim, uint id, Vector3 minCoords, Vector3 maxCoords,
|
||||||
|
@ -378,9 +377,9 @@ public abstract IntPtr FillHeightMapInfo(BulletWorld sim, IntPtr mapInfo, uint i
|
||||||
|
|
||||||
public abstract bool ReleaseHeightMapInfo(IntPtr heightMapInfo);
|
public abstract bool ReleaseHeightMapInfo(IntPtr heightMapInfo);
|
||||||
|
|
||||||
public abstract BulletBody CreateGroundPlaneShape(uint id, float height, float collisionMargin);
|
public abstract BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin);
|
||||||
|
|
||||||
public abstract BulletBody CreateTerrainShape(IntPtr mapInfo);
|
public abstract BulletShape CreateTerrainShape(IntPtr mapInfo);
|
||||||
|
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
// Constraint creation and helper routines
|
// Constraint creation and helper routines
|
||||||
|
@ -460,7 +459,7 @@ public abstract bool IsStaticOrKinematicObject(BulletBody obj);
|
||||||
|
|
||||||
public abstract bool HasContactResponse(BulletBody obj);
|
public abstract bool HasContactResponse(BulletBody obj);
|
||||||
|
|
||||||
public abstract void SetCollisionShape(BulletWorld sim, BulletBody obj, BulletBody shape);
|
public abstract void SetCollisionShape(BulletWorld sim, BulletBody obj, BulletShape shape);
|
||||||
|
|
||||||
public abstract BulletShape GetCollisionShape(BulletBody obj);
|
public abstract BulletShape GetCollisionShape(BulletBody obj);
|
||||||
|
|
||||||
|
@ -526,6 +525,7 @@ public abstract IntPtr GetUserPointer(BulletBody obj);
|
||||||
|
|
||||||
public abstract void SetUserPointer(BulletBody obj, IntPtr val);
|
public abstract void SetUserPointer(BulletBody obj, IntPtr val);
|
||||||
|
|
||||||
|
/*
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
// btRigidBody entries
|
// btRigidBody entries
|
||||||
public abstract void ApplyGravity(BulletBody obj);
|
public abstract void ApplyGravity(BulletBody obj);
|
||||||
|
|
Loading…
Reference in New Issue