Rename ModelData enums;

To better match graphics.
This commit is contained in:
bjorn 2022-08-13 21:10:03 -07:00
parent 2c4f5a13df
commit 6052ed7a95
7 changed files with 81 additions and 81 deletions

View File

@ -18,20 +18,20 @@ StringEntry lovrAnimationProperty[] = {
};
StringEntry lovrAttributeType[] = {
[I8] = ENTRY("byte"),
[U8] = ENTRY("ubyte"),
[I16] = ENTRY("short"),
[U16] = ENTRY("ushort"),
[I32] = ENTRY("int"),
[U32] = ENTRY("uint"),
[F32] = ENTRY("float"),
[I8] = ENTRY("i8"),
[U8] = ENTRY("u8"),
[I16] = ENTRY("i16"),
[U16] = ENTRY("u16"),
[I32] = ENTRY("i32"),
[U32] = ENTRY("u32"),
[F32] = ENTRY("f32"),
{ 0 }
};
StringEntry lovrDefaultAttribute[] = {
[ATTR_POSITION] = ENTRY("position"),
[ATTR_NORMAL] = ENTRY("normal"),
[ATTR_TEXCOORD] = ENTRY("texcoord"),
[ATTR_UV] = ENTRY("uv"),
[ATTR_COLOR] = ENTRY("color"),
[ATTR_TANGENT] = ENTRY("tangent"),
[ATTR_JOINTS] = ENTRY("joints"),

View File

@ -102,74 +102,6 @@ static int l_lovrModelDataGetImage(lua_State* L) {
return 1;
}
static int l_lovrModelDataGetWidth(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[1] - bounds[0]);
return 1;
}
static int l_lovrModelDataGetHeight(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[3] - bounds[2]);
return 1;
}
static int l_lovrModelDataGetDepth(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[5] - bounds[4]);
return 1;
}
static int l_lovrModelDataGetDimensions(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[1] - bounds[0]);
lua_pushnumber(L, bounds[3] - bounds[2]);
lua_pushnumber(L, bounds[5] - bounds[4]);
return 3;
}
static int l_lovrModelDataGetCenter(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, (bounds[0] + bounds[1]) / 2.f);
lua_pushnumber(L, (bounds[2] + bounds[3]) / 2.f);
lua_pushnumber(L, (bounds[4] + bounds[5]) / 2.f);
return 3;
}
static int l_lovrModelDataGetBoundingBox(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[0]);
lua_pushnumber(L, bounds[1]);
lua_pushnumber(L, bounds[2]);
lua_pushnumber(L, bounds[3]);
lua_pushnumber(L, bounds[4]);
lua_pushnumber(L, bounds[5]);
return 6;
}
static int l_lovrModelDataGetBoundingSphere(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float sphere[4];
lovrModelDataGetBoundingSphere(model, sphere);
lua_pushnumber(L, sphere[0]);
lua_pushnumber(L, sphere[1]);
lua_pushnumber(L, sphere[2]);
lua_pushnumber(L, sphere[3]);
return 4;
}
static int l_lovrModelDataGetRootNode(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
lua_pushinteger(L, model->rootNode + 1);
@ -546,6 +478,74 @@ static int l_lovrModelDataGetVertexCount(lua_State* L) {
return 1;
}
static int l_lovrModelDataGetWidth(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[1] - bounds[0]);
return 1;
}
static int l_lovrModelDataGetHeight(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[3] - bounds[2]);
return 1;
}
static int l_lovrModelDataGetDepth(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[5] - bounds[4]);
return 1;
}
static int l_lovrModelDataGetDimensions(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[1] - bounds[0]);
lua_pushnumber(L, bounds[3] - bounds[2]);
lua_pushnumber(L, bounds[5] - bounds[4]);
return 3;
}
static int l_lovrModelDataGetCenter(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, (bounds[0] + bounds[1]) / 2.f);
lua_pushnumber(L, (bounds[2] + bounds[3]) / 2.f);
lua_pushnumber(L, (bounds[4] + bounds[5]) / 2.f);
return 3;
}
static int l_lovrModelDataGetBoundingBox(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float bounds[6];
lovrModelDataGetBoundingBox(model, bounds);
lua_pushnumber(L, bounds[0]);
lua_pushnumber(L, bounds[1]);
lua_pushnumber(L, bounds[2]);
lua_pushnumber(L, bounds[3]);
lua_pushnumber(L, bounds[4]);
lua_pushnumber(L, bounds[5]);
return 6;
}
static int l_lovrModelDataGetBoundingSphere(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
float sphere[4];
lovrModelDataGetBoundingSphere(model, sphere);
lua_pushnumber(L, sphere[0]);
lua_pushnumber(L, sphere[1]);
lua_pushnumber(L, sphere[2]);
lua_pushnumber(L, sphere[3]);
return 4;
}
static int l_lovrModelDataGetMaterialCount(lua_State* L) {
ModelData* model = luax_checktype(L, 1, ModelData);
lua_pushinteger(L, model->materialCount);

View File

@ -19,7 +19,7 @@ typedef struct {
typedef enum {
ATTR_POSITION,
ATTR_NORMAL,
ATTR_TEXCOORD,
ATTR_UV,
ATTR_COLOR,
ATTR_TANGENT,
ATTR_JOINTS,

View File

@ -813,7 +813,7 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source, ModelDataIO* io
uint32_t attributeIndex = NOM_INT(json, token);
if (STR_EQ(name, "POSITION")) { attributeType = ATTR_POSITION; }
else if (STR_EQ(name, "NORMAL")) { attributeType = ATTR_NORMAL; }
else if (STR_EQ(name, "TEXCOORD_0")) { attributeType = ATTR_TEXCOORD; }
else if (STR_EQ(name, "TEXCOORD_0")) { attributeType = ATTR_UV; }
else if (STR_EQ(name, "COLOR_0")) { attributeType = ATTR_COLOR; }
else if (STR_EQ(name, "TANGENT")) { attributeType = ATTR_TANGENT; }
else if (STR_EQ(name, "JOINTS_0")) { attributeType = ATTR_JOINTS; }

View File

@ -361,7 +361,7 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source, ModelDataIO* io)
.attributes = {
[ATTR_POSITION] = &model->attributes[0],
[ATTR_NORMAL] = &model->attributes[1],
[ATTR_TEXCOORD] = &model->attributes[2]
[ATTR_UV] = &model->attributes[2]
},
.indices = &model->attributes[3 + i],
.material = group->material

View File

@ -2634,7 +2634,7 @@ Model* lovrModelCreate(const ModelInfo* info) {
lovrModelDataCopyAttribute(data, attributes[ATTR_POSITION], vertices + 0, F32, 3, false, count, stride, 0);
lovrModelDataCopyAttribute(data, attributes[ATTR_NORMAL], vertices + 12, F32, 3, false, count, stride, 0);
lovrModelDataCopyAttribute(data, attributes[ATTR_TEXCOORD], vertices + 24, F32, 2, false, count, stride, 0);
lovrModelDataCopyAttribute(data, attributes[ATTR_UV], vertices + 24, F32, 2, false, count, stride, 0);
lovrModelDataCopyAttribute(data, attributes[ATTR_COLOR], vertices + 32, U8, 4, true, count, stride, 255);
lovrModelDataCopyAttribute(data, attributes[ATTR_TANGENT], vertices + 36, F32, 3, false, count, stride, 0);
vertices += count * stride;

View File

@ -1588,7 +1588,7 @@ static ModelData* openxr_newModelData(Device device, bool animated) {
.attributes = {
[ATTR_POSITION] = &model->attributes[0],
[ATTR_NORMAL] = &model->attributes[1],
[ATTR_TEXCOORD] = &model->attributes[2],
[ATTR_UV] = &model->attributes[2],
[ATTR_JOINTS] = &model->attributes[3],
[ATTR_WEIGHTS] = &model->attributes[4]
},