public BSConstraintHinge(BulletWorld world, BulletBody obj1, BulletBody obj2, Vector3 pivotInA, Vector3 pivotInB, Vector3 axisInA, Vector3 axisInB, bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) : base(world) { m_body1 = obj1; m_body2 = obj2; m_constraint = PhysicsScene.PE.CreateHingeConstraint(world, obj1, obj2, pivotInA, pivotInB, axisInA, axisInB, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); m_enabled = true; }
// Create a btGeneric6DofConstraint public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, Vector3 frame1, Quaternion frame1rot, Vector3 frame2, Quaternion frame2rot, bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) : base(world) { m_body1 = obj1; m_body2 = obj2; m_constraint = PhysicsScene.PE.Create6DofConstraint(m_world, m_body1, m_body2, frame1, frame1rot, frame2, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); m_enabled = true; world.physicsScene.DetailLog( "{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", BSScene.DetailLogZero, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); }
// 6 Dof constraint based on a midpoint between the two constrained bodies public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, Vector3 joinPoint, bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) : base(world) { m_body1 = obj1; m_body2 = obj2; if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody) { world.physicsScene.DetailLog( "{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", BSScene.DetailLogZero, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); world.physicsScene.Logger.ErrorFormat( "{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", LogHeader, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); m_enabled = false; } else { m_constraint = PhysicsScene.PE.Create6DofConstraintToPoint(m_world, m_body1, m_body2, joinPoint, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); PhysicsScene.DetailLog( "{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}", BSScene.DetailLogZero, world.worldID, m_constraint.AddrString, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); if (!m_constraint.HasPhysicalConstraint) { world.physicsScene.Logger.ErrorFormat( "{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", LogHeader, obj1.ID, obj2.ID); m_enabled = false; } else { m_enabled = true; } } }
// Remove all constraints that reference the passed body. // Return 'true' if any constraints were destroyed. public bool RemoveAndDestroyConstraint(BulletBody body1) { List<BSConstraint> toRemove = new List<BSConstraint>(); uint lookingID = body1.ID; lock (m_constraints) { foreach (BSConstraint constrain in m_constraints) { if (constrain.Body1.ID == lookingID || constrain.Body2.ID == lookingID) { toRemove.Add(constrain); } } foreach (BSConstraint constrain in toRemove) { m_constraints.Remove(constrain); constrain.Dispose(); } } return (toRemove.Count > 0); }
public abstract bool WantsSleeping(BulletBody obj);
public abstract void UpdateInertiaTensor(BulletBody obj);
public abstract void Translate(BulletBody obj, Vector3 trans);
public abstract void SetTranslation(BulletBody obj, Vector3 position, Quaternion rotation);
public abstract void SetRestitution(BulletBody obj, float val);
public abstract void SetGravity(BulletBody obj, Vector3 val);
public abstract void SetDeactivationTime(BulletBody obj, float dtime);
public abstract void SetDamping(BulletBody obj, float lin_damping, float ang_damping);
public abstract void SetContactProcessingThreshold(BulletBody obj, float val);
public abstract void SetCollisionShape(BulletWorld sim, BulletBody obj, BulletShape shape);
public abstract bool SetCollisionGroupMask(BulletBody body, UInt32 filter, UInt32 mask);
public abstract void SetMassProps(BulletBody obj, float mass, Vector3 inertia);
// Set the force being applied to the object as if its mass is one. public abstract void SetObjectForce(BulletBody obj, Vector3 force);
public abstract void SetHitFraction(BulletBody obj, float val);
public abstract void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold);
// public abstract IntPtr GetBroadphaseHandle(BulletBody obj); // public abstract void SetBroadphaseHandle(BulletBody obj, IntPtr handle); public abstract void SetInterpolationLinearVelocity(BulletBody obj, Vector3 vel);
public abstract void SetUserPointer(BulletBody obj, IntPtr val);
public abstract void SetInterpolationVelocity(BulletBody obj, Vector3 linearVel, Vector3 angularVel);
public abstract void UpdateDeactivation(BulletBody obj, float timeStep);
public abstract void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert);
// ===================================================================================== // btCollisionWorld entries public abstract void UpdateSingleAabb(BulletWorld world, BulletBody obj);
public abstract void SetLinearDamping(BulletBody obj, float lin_damping);
// Remove any constraint between the passed bodies. // Presumed there is only one such constraint possible. // Return 'true' if a constraint was found and destroyed. public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2) { bool ret = false; lock (m_constraints) { BSConstraint constrain; if (this.TryGetConstraint(body1, body2, out constrain)) { // remove the constraint from our collection ret = RemoveAndDestroyConstraint(constrain); } } return ret; }
public abstract void SetLinearFactor(BulletBody obj, Vector3 factor);
// Get the constraint between two bodies. There can be only one. // Return 'true' if a constraint was found. public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint) { bool found = false; BSConstraint foundConstraint = null; uint lookingID1 = body1.ID; uint lookingID2 = body2.ID; lock (m_constraints) { foreach (BSConstraint constrain in m_constraints) { if ((constrain.Body1.ID == lookingID1 && constrain.Body2.ID == lookingID2) || (constrain.Body1.ID == lookingID2 && constrain.Body2.ID == lookingID1)) { foundConstraint = constrain; found = true; break; } } } returnConstraint = foundConstraint; return found; }
public abstract void SetLinearVelocity(BulletBody obj, Vector3 val);