Skip to content

Commit

Permalink
bugfix: index out of range in ConstraintVsCOMChangeTest.Initialize()
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Nov 5, 2024
1 parent 76da92e commit d2bf959
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
public class ConstraintVsCOMChangeTest extends Test{
ShapeRefC mBox=new ShapeRefC();
List<Body> mBodies=new ArrayList<>();
List<ConstraintRef> mConstraints=new ArrayList<>();
List<TwoBodyConstraintRef> mConstraints=new ArrayList<>();
static final float cBoxSize = 2.0f;
float mTime = 0.0f;
int mNumShapes = -1;
Expand Down Expand Up @@ -82,10 +82,10 @@ public void Initialize()
settings.setNormalAxis1 ( settings.setNormalAxis2 ( Vec3.sAxisX()));
settings.setLimitsMin ( cMinAngle);
settings.setLimitsMax ( cMaxAngle);
Constraint constraint = settings.create(mBodies.get(i), segment);
TwoBodyConstraint constraint = settings.create(mBodies.get(mBodies.size()-1), segment);
mPhysicsSystem.addConstraint(constraint);

mConstraints.add((ConstraintRef)constraint.toRef());
mConstraints.add(constraint.toRef());
}

mBodies.add(segment);
Expand Down Expand Up @@ -145,7 +145,7 @@ void UpdateShapes()

// Notify the constraints that the shape has changed (this could be done more efficient as we know which constraints are affected)
Vec3 delta_com = Op.subtract(s.getCenterOfMass() , prev_com);
for (ConstraintRef c : mConstraints)
for (TwoBodyConstraintRef c : mConstraints)
c.getPtr().notifyShapeChanged(b.getId(), delta_com);
}
}
Expand Down

0 comments on commit d2bf959

Please sign in to comment.