Skip to content

Commit

Permalink
[#17] : Increased physics iteration limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ange-yaghi committed Jul 12, 2020
1 parent 6e4c0bd commit cdfa374
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion physics/include/rigid_body_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions physics/src/collision_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion physics/src/rigid_body_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cdfa374

Please sign in to comment.