Skip to content

Commit

Permalink
bugfix: logic error in CollisionShape.nativeMargin()
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jul 25, 2024
1 parent 06fe9c6 commit 6256b87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ final protected float nativeMargin() {
float result = getMargin(shapeId);

assert result >= 0f : result;
return margin;
return result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ public void testSetMargin() { // TODO split off testSetMarginConvex()
// MinkowskiSum of sphere + cone
ConvexShape sphere1 = new SphereCollisionShape(1f);
CollisionShape sum1 = new MinkowskiSum(sphere1, cone1);
Assert.assertEquals(0.04f, sum1.getMargin(), 0f);
Assert.assertEquals(1.04f, sum1.getMargin(), 0f);
sum1.setMargin(0.195f); // cannot directly alter margin
Assert.assertEquals(0.04f, sum1.getMargin(), 0f);
Assert.assertEquals(1.04f, sum1.getMargin(), 0f);

// MinkowskiSum of sphere + capsule
ConvexShape capsule1 = new CapsuleCollisionShape(1f, 1f);
CollisionShape sum2 = new MinkowskiSum(sphere1, capsule1);
Assert.assertEquals(0f, sum2.getMargin(), 0f);
Assert.assertEquals(2f, sum2.getMargin(), 0f);
sum2.setMargin(0.196f); // cannot directly alter margin
Assert.assertEquals(0f, sum2.getMargin(), 0f);
Assert.assertEquals(2f, sum2.getMargin(), 0f);

// MultiSphere
List<Float> radii = new ArrayList<>(3);
Expand Down

0 comments on commit 6256b87

Please sign in to comment.