diff --git a/physics/include/rigid_body_system.h b/physics/include/rigid_body_system.h index db8d326b..e1ff8863 100644 --- a/physics/include/rigid_body_system.h +++ b/physics/include/rigid_body_system.h @@ -17,7 +17,7 @@ namespace dphysics { class DeltaEngine; class RigidBodySystem : public ysObject { public: - static const int ResolutionIterationLimit = 128; + static const int ResolutionIterationLimit = 1024; static float ResolutionPenetrationEpsilon; struct CollisionGenerationCallData { diff --git a/physics/src/collision_detector.cpp b/physics/src/collision_detector.cpp index df654efc..f4197b8d 100644 --- a/physics/src/collision_detector.cpp +++ b/physics/src/collision_detector.cpp @@ -102,7 +102,7 @@ int dphysics::CollisionDetector::BoxBoxCollision( } int dphysics::CollisionDetector::CircleBoxCollision(Collision *collisions, RigidBody *body1, RigidBody *body2, CirclePrimitive *circle, BoxPrimitive *box) { - constexpr float epsilon = 1E-5f; + constexpr float Epsilon = 1E-5f; ysVector relativePosition = ysMath::Sub(circle->Position, box->Position); relativePosition = ysMath::QuatTransformInverse(box->Orientation, relativePosition); @@ -119,10 +119,10 @@ int dphysics::CollisionDetector::CircleBoxCollision(Collision *collisions, Rigid if (d2 > circle->Radius * circle->Radius) return 0; ysVector normal; - if (d0 <= epsilon) { + if (d0 <= Epsilon) { normal = ysMath::Mul(ysMath::Constants::XAxis, ysMath::LoadScalar(0.001f)); } - else if (d2 <= epsilon) { + else if (d2 <= Epsilon) { normal = ysMath::Mask(ysMath::Sub(circle->Position, box->Position), ysMath::Constants::MaskOffW); normal = ysMath::Mask(normal, ysMath::Constants::MaskOffZ); } diff --git a/physics/src/rigid_body_system.cpp b/physics/src/rigid_body_system.cpp index 0db7fedd..906dc58f 100644 --- a/physics/src/rigid_body_system.cpp +++ b/physics/src/rigid_body_system.cpp @@ -520,7 +520,7 @@ void dphysics::RigidBodySystem::AdjustVelocities(float timestep) { ysVector cp; // iteratively handle impacts in order of severity. - for (int velocityIterationsUsed = 0; velocityIterationsUsed < 100; ++velocityIterationsUsed) { + for (int velocityIterationsUsed = 0; velocityIterationsUsed < ResolutionIterationLimit; ++velocityIterationsUsed) { // Find contact with maximum magnitude of probable velocity change. float max = 1E-4; unsigned index = numContacts;