Rename box shape dimensions to be more clear;

This commit is contained in:
bjorn 2023-07-10 23:11:14 -07:00
parent 5210d474b8
commit 9bf2def86d
3 changed files with 17 additions and 17 deletions

View File

@ -313,11 +313,11 @@ const luaL_Reg lovrSphereShape[] = {
static int l_lovrBoxShapeGetDimensions(lua_State* L) {
BoxShape* box = luax_checktype(L, 1, BoxShape);
float x, y, z;
lovrBoxShapeGetDimensions(box, &x, &y, &z);
lua_pushnumber(L, x);
lua_pushnumber(L, y);
lua_pushnumber(L, z);
float w, h, d;
lovrBoxShapeGetDimensions(box, &w, &h, &d);
lua_pushnumber(L, w);
lua_pushnumber(L, h);
lua_pushnumber(L, d);
return 3;
}

View File

@ -956,27 +956,27 @@ void lovrSphereShapeSetRadius(SphereShape* sphere, float radius) {
dGeomSphereSetRadius(sphere->id, radius);
}
BoxShape* lovrBoxShapeCreate(float x, float y, float z) {
BoxShape* lovrBoxShapeCreate(float w, float h, float d) {
BoxShape* box = calloc(1, sizeof(BoxShape));
lovrAssert(box, "Out of memory");
box->ref = 1;
box->type = SHAPE_BOX;
box->id = dCreateBox(0, x, y, z);
box->id = dCreateBox(0, w, h, d);
dGeomSetData(box->id, box);
return box;
}
void lovrBoxShapeGetDimensions(BoxShape* box, float* x, float* y, float* z) {
void lovrBoxShapeGetDimensions(BoxShape* box, float* w, float* h, float* d) {
dReal dimensions[4];
dGeomBoxGetLengths(box->id, dimensions);
*x = dimensions[0];
*y = dimensions[1];
*z = dimensions[2];
*w = dimensions[0];
*h = dimensions[1];
*d = dimensions[2];
}
void lovrBoxShapeSetDimensions(BoxShape* box, float x, float y, float z) {
lovrCheck(x > 0.f && y > 0.f && z > 0.f, "BoxShape dimensions must be positive");
dGeomBoxSetLengths(box->id, x, y, z);
void lovrBoxShapeSetDimensions(BoxShape* box, float w, float h, float d) {
lovrCheck(w > 0.f && h > 0.f && d > 0.f, "BoxShape dimensions must be positive");
dGeomBoxSetLengths(box->id, w, h, d);
}
CapsuleShape* lovrCapsuleShapeCreate(float radius, float length) {

View File

@ -157,9 +157,9 @@ SphereShape* lovrSphereShapeCreate(float radius);
float lovrSphereShapeGetRadius(SphereShape* sphere);
void lovrSphereShapeSetRadius(SphereShape* sphere, float radius);
BoxShape* lovrBoxShapeCreate(float x, float y, float z);
void lovrBoxShapeGetDimensions(BoxShape* box, float* x, float* y, float* z);
void lovrBoxShapeSetDimensions(BoxShape* box, float x, float y, float z);
BoxShape* lovrBoxShapeCreate(float w, float h, float d);
void lovrBoxShapeGetDimensions(BoxShape* box, float* w, float* h, float* d);
void lovrBoxShapeSetDimensions(BoxShape* box, float w, float h, float d);
CapsuleShape* lovrCapsuleShapeCreate(float radius, float length);
float lovrCapsuleShapeGetRadius(CapsuleShape* capsule);