Physics objects can be implicity static if only a collider was added.
Removed the need to create an extra body. Math is great.
This commit is contained in:
parent
a0f6cd3ae7
commit
5730381302
|
@ -8,23 +8,6 @@
|
||||||
Rotate: {x: 0, y: 0, z: 0.436332315}
|
Rotate: {x: 0, y: 0, z: 0.436332315}
|
||||||
Scale: {x: 4.61070776, y: 0.99999392, z: 0.999996722}
|
Scale: {x: 4.61070776, y: 0.99999392, z: 0.999996722}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
|
||||||
Type: Static
|
|
||||||
Auto Mass: false
|
|
||||||
Mass: .inf
|
|
||||||
Drag: 0.00999999978
|
|
||||||
Angular Drag: 0.00999999978
|
|
||||||
Use Gravity: true
|
|
||||||
Gravity Scale: 1
|
|
||||||
Interpolate: true
|
|
||||||
Sleeping Enabled: true
|
|
||||||
Freeze Position X: false
|
|
||||||
Freeze Position Y: true
|
|
||||||
Freeze Position Z: false
|
|
||||||
Freeze Rotation X: false
|
|
||||||
Freeze Rotation Y: false
|
|
||||||
Freeze Rotation Z: false
|
|
||||||
IsActive: true
|
|
||||||
Collider Component:
|
Collider Component:
|
||||||
DrawColliders: false
|
DrawColliders: false
|
||||||
Colliders:
|
Colliders:
|
||||||
|
@ -62,7 +45,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: -2, y: 7.5, z: 0}
|
Translate: {x: 0, y: 7.5, z: 0}
|
||||||
Rotate: {x: -0, y: 0, z: 0.785398185}
|
Rotate: {x: -0, y: 0, z: 0.785398185}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -77,7 +60,7 @@
|
||||||
Interpolate: true
|
Interpolate: true
|
||||||
Sleeping Enabled: true
|
Sleeping Enabled: true
|
||||||
Freeze Position X: false
|
Freeze Position X: false
|
||||||
Freeze Position Y: true
|
Freeze Position Y: false
|
||||||
Freeze Position Z: false
|
Freeze Position Z: false
|
||||||
Freeze Rotation X: false
|
Freeze Rotation X: false
|
||||||
Freeze Rotation Y: false
|
Freeze Rotation Y: false
|
||||||
|
@ -107,23 +90,6 @@
|
||||||
Rotate: {x: -0, y: 0, z: -0.436332315}
|
Rotate: {x: -0, y: 0, z: -0.436332315}
|
||||||
Scale: {x: 4.61071014, y: 0.999995887, z: 1}
|
Scale: {x: 4.61071014, y: 0.999995887, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
|
||||||
Type: Static
|
|
||||||
Auto Mass: false
|
|
||||||
Mass: .inf
|
|
||||||
Drag: 0.00999999978
|
|
||||||
Angular Drag: 0.00999999978
|
|
||||||
Use Gravity: true
|
|
||||||
Gravity Scale: 1
|
|
||||||
Interpolate: true
|
|
||||||
Sleeping Enabled: true
|
|
||||||
Freeze Position X: true
|
|
||||||
Freeze Position Y: true
|
|
||||||
Freeze Position Z: true
|
|
||||||
Freeze Rotation X: false
|
|
||||||
Freeze Rotation Y: false
|
|
||||||
Freeze Rotation Z: false
|
|
||||||
IsActive: true
|
|
||||||
Collider Component:
|
Collider Component:
|
||||||
DrawColliders: false
|
DrawColliders: false
|
||||||
Colliders:
|
Colliders:
|
||||||
|
@ -148,23 +114,6 @@
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 10, y: 3, z: 10}
|
Scale: {x: 10, y: 3, z: 10}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
|
||||||
Type: Static
|
|
||||||
Auto Mass: false
|
|
||||||
Mass: .inf
|
|
||||||
Drag: 0.00999999978
|
|
||||||
Angular Drag: 0.00999999978
|
|
||||||
Use Gravity: true
|
|
||||||
Gravity Scale: 1
|
|
||||||
Interpolate: true
|
|
||||||
Sleeping Enabled: true
|
|
||||||
Freeze Position X: false
|
|
||||||
Freeze Position Y: true
|
|
||||||
Freeze Position Z: false
|
|
||||||
Freeze Rotation X: false
|
|
||||||
Freeze Rotation Y: false
|
|
||||||
Freeze Rotation Z: false
|
|
||||||
IsActive: true
|
|
||||||
Collider Component:
|
Collider Component:
|
||||||
DrawColliders: false
|
DrawColliders: false
|
||||||
Colliders:
|
Colliders:
|
||||||
|
@ -189,23 +138,6 @@
|
||||||
Rotate: {x: -0, y: 0, z: 1.57079601}
|
Rotate: {x: -0, y: 0, z: 1.57079601}
|
||||||
Scale: {x: 9.99975109, y: 0.499992192, z: 10}
|
Scale: {x: 9.99975109, y: 0.499992192, z: 10}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
|
||||||
Type: Static
|
|
||||||
Auto Mass: false
|
|
||||||
Mass: .inf
|
|
||||||
Drag: 0.00999999978
|
|
||||||
Angular Drag: 0.00999999978
|
|
||||||
Use Gravity: true
|
|
||||||
Gravity Scale: 1
|
|
||||||
Interpolate: true
|
|
||||||
Sleeping Enabled: true
|
|
||||||
Freeze Position X: false
|
|
||||||
Freeze Position Y: true
|
|
||||||
Freeze Position Z: false
|
|
||||||
Freeze Rotation X: false
|
|
||||||
Freeze Rotation Y: false
|
|
||||||
Freeze Rotation Z: false
|
|
||||||
IsActive: true
|
|
||||||
Collider Component:
|
Collider Component:
|
||||||
DrawColliders: false
|
DrawColliders: false
|
||||||
Colliders:
|
Colliders:
|
||||||
|
@ -230,23 +162,6 @@
|
||||||
Rotate: {x: -0, y: 0, z: 1.57079601}
|
Rotate: {x: -0, y: 0, z: 1.57079601}
|
||||||
Scale: {x: 9.99975109, y: 0.499992192, z: 10}
|
Scale: {x: 9.99975109, y: 0.499992192, z: 10}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
|
||||||
Type: Static
|
|
||||||
Auto Mass: false
|
|
||||||
Mass: .inf
|
|
||||||
Drag: 0.00999999978
|
|
||||||
Angular Drag: 0.00999999978
|
|
||||||
Use Gravity: true
|
|
||||||
Gravity Scale: 1
|
|
||||||
Interpolate: true
|
|
||||||
Sleeping Enabled: true
|
|
||||||
Freeze Position X: false
|
|
||||||
Freeze Position Y: true
|
|
||||||
Freeze Position Z: false
|
|
||||||
Freeze Rotation X: false
|
|
||||||
Freeze Rotation Y: false
|
|
||||||
Freeze Rotation Z: false
|
|
||||||
IsActive: true
|
|
||||||
Collider Component:
|
Collider Component:
|
||||||
DrawColliders: false
|
DrawColliders: false
|
||||||
Colliders:
|
Colliders:
|
||||||
|
@ -267,7 +182,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 0, y: 7, z: 0}
|
Translate: {x: 0, y: 2, z: 3}
|
||||||
Rotate: {x: 0, y: 0.785398185, z: 0}
|
Rotate: {x: 0, y: 0.785398185, z: 0}
|
||||||
Scale: {x: 0.999990404, y: 0.999994457, z: 0.999985337}
|
Scale: {x: 0.999990404, y: 0.999994457, z: 0.999985337}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -316,23 +231,6 @@
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
|
||||||
Type: Static
|
|
||||||
Auto Mass: false
|
|
||||||
Mass: .inf
|
|
||||||
Drag: 0.00999999978
|
|
||||||
Angular Drag: 0.00999999978
|
|
||||||
Use Gravity: true
|
|
||||||
Gravity Scale: 1
|
|
||||||
Interpolate: true
|
|
||||||
Sleeping Enabled: true
|
|
||||||
Freeze Position X: false
|
|
||||||
Freeze Position Y: true
|
|
||||||
Freeze Position Z: false
|
|
||||||
Freeze Rotation X: false
|
|
||||||
Freeze Rotation Y: false
|
|
||||||
Freeze Rotation Z: false
|
|
||||||
IsActive: true
|
|
||||||
Collider Component:
|
Collider Component:
|
||||||
DrawColliders: false
|
DrawColliders: false
|
||||||
Colliders:
|
Colliders:
|
||||||
|
|
|
@ -33,23 +33,30 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
SHVelocityState (const SHRigidBody* rigidBody) noexcept
|
SHVelocityState (const SHRigidBody* rigidBody) noexcept
|
||||||
|
: LinearVelocity { SHVec3::Zero }
|
||||||
|
, AngularVelocity { SHVec3::Zero }
|
||||||
|
, LinearLockFactor { SHVec3::Zero }
|
||||||
|
, AngularLockFactor { SHVec3::Zero }
|
||||||
{
|
{
|
||||||
LinearVelocity = rigidBody->GetLinearVelocity();
|
if (rigidBody)
|
||||||
AngularVelocity = rigidBody->GetAngularVelocity();
|
|
||||||
|
|
||||||
LinearLockFactor = SHVec3
|
|
||||||
{
|
{
|
||||||
rigidBody->GetFreezePositionX() ? 0.0f : 1.0f
|
LinearVelocity = rigidBody->GetLinearVelocity();
|
||||||
, rigidBody->GetFreezePositionY() ? 0.0f : 1.0f
|
AngularVelocity = rigidBody->GetAngularVelocity();
|
||||||
, rigidBody->GetFreezePositionZ() ? 0.0f : 1.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
AngularLockFactor = SHVec3
|
LinearLockFactor = SHVec3
|
||||||
{
|
{
|
||||||
rigidBody->GetFreezeRotationX() ? 0.0f : 1.0f
|
rigidBody->GetFreezePositionX() ? 0.0f : 1.0f
|
||||||
, rigidBody->GetFreezeRotationY() ? 0.0f : 1.0f
|
, rigidBody->GetFreezePositionY() ? 0.0f : 1.0f
|
||||||
, rigidBody->GetFreezeRotationZ() ? 0.0f : 1.0f
|
, rigidBody->GetFreezePositionZ() ? 0.0f : 1.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AngularLockFactor = SHVec3
|
||||||
|
{
|
||||||
|
rigidBody->GetFreezeRotationX() ? 0.0f : 1.0f
|
||||||
|
, rigidBody->GetFreezeRotationY() ? 0.0f : 1.0f
|
||||||
|
, rigidBody->GetFreezeRotationZ() ? 0.0f : 1.0f
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -200,11 +200,17 @@ namespace SHADE
|
||||||
const auto& STATE_A = VELOCITY_STATES.find(key.GetEntityA())->second;
|
const auto& STATE_A = VELOCITY_STATES.find(key.GetEntityA())->second;
|
||||||
const auto& STATE_B = VELOCITY_STATES.find(key.GetEntityB())->second;
|
const auto& STATE_B = VELOCITY_STATES.find(key.GetEntityB())->second;
|
||||||
|
|
||||||
bodyA->SetLinearVelocity(STATE_A.LinearVelocity);
|
if (bodyA)
|
||||||
bodyB->SetLinearVelocity(STATE_B.LinearVelocity);
|
{
|
||||||
|
bodyA->SetLinearVelocity(STATE_A.LinearVelocity);
|
||||||
|
bodyA->SetAngularVelocity(STATE_A.AngularVelocity);
|
||||||
|
}
|
||||||
|
|
||||||
bodyA->SetAngularVelocity(STATE_A.AngularVelocity);
|
if (bodyB)
|
||||||
bodyB->SetAngularVelocity(STATE_B.AngularVelocity);
|
{
|
||||||
|
bodyB->SetLinearVelocity(STATE_B.LinearVelocity);
|
||||||
|
bodyB->SetAngularVelocity(STATE_B.AngularVelocity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contactSolver.Reset();
|
contactSolver.Reset();
|
||||||
|
|
|
@ -63,13 +63,38 @@ namespace SHADE
|
||||||
|
|
||||||
// Mass data
|
// Mass data
|
||||||
|
|
||||||
newConstraint.invMassA = BODY_A->invMass;
|
// Account for implicity-static bodies
|
||||||
newConstraint.invInertiaA = BODY_A->worldInvInertia;
|
if (BODY_A)
|
||||||
newConstraint.centerOfMassA = BODY_A->worldCentroid;
|
{
|
||||||
|
newConstraint.invMassA = BODY_A->invMass;
|
||||||
|
newConstraint.centerOfMassA = BODY_A->worldCentroid;
|
||||||
|
newConstraint.invInertiaA = BODY_A->worldInvInertia;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newConstraint.invMassA = 0.0f;
|
||||||
|
newConstraint.centerOfMassA = SHVec3::Zero;
|
||||||
|
|
||||||
newConstraint.invMassB = BODY_B->invMass;
|
// Matrix needs to maintain its homogenous structure
|
||||||
newConstraint.invInertiaB = BODY_B->worldInvInertia;
|
newConstraint.invInertiaA = SHMatrix::Zero;
|
||||||
newConstraint.centerOfMassB = BODY_B->worldCentroid;
|
newConstraint.invInertiaA.m[3][3] = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BODY_B)
|
||||||
|
{
|
||||||
|
newConstraint.invMassB = BODY_B->invMass;
|
||||||
|
newConstraint.centerOfMassB = BODY_B->worldCentroid;
|
||||||
|
newConstraint.invInertiaB = BODY_B->worldInvInertia;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newConstraint.invMassB = 0.0f;
|
||||||
|
newConstraint.centerOfMassB = SHVec3::Zero;
|
||||||
|
|
||||||
|
// Matrix needs to maintain its homogenous structure
|
||||||
|
newConstraint.invInertiaB = SHMatrix::Zero;
|
||||||
|
newConstraint.invInertiaB.m[3][3] = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Collision data
|
// Collision data
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue