Skip to content

Commit

Permalink
Fix ConvexShape:getFace to be 1-indexed;
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornbytes committed Dec 27, 2024
1 parent c74c1c3 commit 4f16e04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/l_physics_shapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static int l_lovrConvexShapeGetFace(lua_State* L) {
uint32_t* indices = count > COUNTOF(stack) ? lovrMalloc(count * sizeof(uint32_t)) : stack;
lovrConvexShapeGetFace(convex, index, indices, count);
for (uint32_t i = 0; i < count; i++) {
lua_pushinteger(L, indices[i]);
lua_pushinteger(L, indices[i] + 1);
lua_rawseti(L, -2, i + 1);
}
if (indices != stack) {
Expand Down
5 changes: 5 additions & 0 deletions test/lovr/physics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ group('physics', function()
test('ConvexShape', function()
shape = lovr.physics.newConvexShape({ 1, 1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 1 })
expect(shape:getPointCount()).to.equal(4)
expect(shape:getFaceCount()).to.equal(4)
expect(shape:getFace(1)).to.equal({ 1, 2, 3 })
expect(shape:getFace(2)).to.equal({ 2, 4, 3 })
expect(shape:getFace(3)).to.equal({ 4, 1, 3 })
expect(shape:getFace(4)).to.equal({ 1, 4, 2 })

if lovr.graphics then
mesh = lovr.graphics.newMesh({
Expand Down

0 comments on commit 4f16e04

Please sign in to comment.