Fixed various Physics bugs #217

Merged
direnbharwani merged 14 commits from SP3-2-Physics into main 2022-11-17 17:13:02 +08:00
3 changed files with 21 additions and 4 deletions
Showing only changes of commit 7288894507 - Show all commits

View File

@ -304,6 +304,9 @@ namespace SHADE
const auto* RHS_BOX = reinterpret_cast<const SHBox*>(rhs);
shape = new SHBox{ positionOffset, RHS_BOX->GetWorldExtents() };
auto* lhsBox = reinterpret_cast<SHBox*>(shape);
lhsBox->SetRelativeExtents(RHS_BOX->GetRelativeExtents());
break;
}
case Type::SPHERE:
@ -311,6 +314,9 @@ namespace SHADE
const auto* RHS_SPHERE = reinterpret_cast<const SHSphere*>(rhs);
shape = new SHSphere{ positionOffset, RHS_SPHERE->GetWorldRadius() };
auto* lhsSphere = reinterpret_cast<SHSphere*>(shape);
lhsSphere->SetRelativeRadius(RHS_SPHERE->GetRelativeRadius());
break;
}
default: break;

View File

@ -109,14 +109,25 @@ namespace SHADE
{
// TODO(Diren): Add more collider shapes
case SHCollisionShape::Type::BOX: addBoxShape(collisionShape); break;
case SHCollisionShape::Type::SPHERE: addSphereShape(collisionShape); break;
case SHCollisionShape::Type::BOX:
{
addBoxShape(collisionShape);
break;
}
case SHCollisionShape::Type::SPHERE:
{
addSphereShape(collisionShape);
break;
}
default: break;
}
rp3dBody->updateLocalCenterOfMassFromColliders();
rp3dBody->updateLocalInertiaTensorFromColliders();
SyncColliders(*colliderComponent);
return index;
}

View File

@ -38,8 +38,8 @@ namespace SHADE
/*-------------------------------------------------------------------------------*/
SHVec3 gravity = SHVec3{ 0.0f, -9.81f, 0.0f };
uint16_t numVelocitySolverIterations = 15;
uint16_t numPositionSolverIterations = 8;
uint16_t numVelocitySolverIterations = 10;
uint16_t numPositionSolverIterations = 5;
bool sleepingEnabled = true;
};