mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-22 15:43:18 -05:00
optional mat4 fields
This commit is contained in:
parent
348ee3d614
commit
25166483a6
3 changed files with 81 additions and 17 deletions
|
@ -49,6 +49,22 @@ VEC_TYPES = {
|
||||||
"field_c_type": "f32",
|
"field_c_type": "f32",
|
||||||
"field_lua_type": "number",
|
"field_lua_type": "number",
|
||||||
"fields_mapping": {
|
"fields_mapping": {
|
||||||
|
"m00": "[0][0]",
|
||||||
|
"m01": "[0][1]",
|
||||||
|
"m02": "[0][2]",
|
||||||
|
"m03": "[0][3]",
|
||||||
|
"m10": "[1][0]",
|
||||||
|
"m11": "[1][1]",
|
||||||
|
"m12": "[1][2]",
|
||||||
|
"m13": "[1][3]",
|
||||||
|
"m20": "[2][0]",
|
||||||
|
"m21": "[2][1]",
|
||||||
|
"m22": "[2][2]",
|
||||||
|
"m23": "[2][3]",
|
||||||
|
"m30": "[3][0]",
|
||||||
|
"m31": "[3][1]",
|
||||||
|
"m32": "[3][2]",
|
||||||
|
"m33": "[3][3]",
|
||||||
"a": "[0][0]",
|
"a": "[0][0]",
|
||||||
"b": "[0][1]",
|
"b": "[0][1]",
|
||||||
"c": "[0][2]",
|
"c": "[0][2]",
|
||||||
|
|
|
@ -69,24 +69,40 @@ static struct LuaObjectField sVec4sFields[LUA_VEC4S_FIELD_COUNT] = {
|
||||||
{ "w", LVT_S16, sizeof(s16) * 3, false, LOT_NONE },
|
{ "w", LVT_S16, sizeof(s16) * 3, false, LOT_NONE },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LUA_MAT4_FIELD_COUNT 16
|
#define LUA_MAT4_FIELD_COUNT 32
|
||||||
static struct LuaObjectField sMat4Fields[LUA_MAT4_FIELD_COUNT] = {
|
static struct LuaObjectField sMat4Fields[LUA_MAT4_FIELD_COUNT] = {
|
||||||
{ "a", LVT_F32, sizeof(f32) * 0, false, LOT_NONE },
|
{ "m00", LVT_F32, sizeof(f32) * 0, false, LOT_NONE },
|
||||||
{ "b", LVT_F32, sizeof(f32) * 1, false, LOT_NONE },
|
{ "m01", LVT_F32, sizeof(f32) * 1, false, LOT_NONE },
|
||||||
{ "c", LVT_F32, sizeof(f32) * 2, false, LOT_NONE },
|
{ "m02", LVT_F32, sizeof(f32) * 2, false, LOT_NONE },
|
||||||
{ "d", LVT_F32, sizeof(f32) * 3, false, LOT_NONE },
|
{ "m03", LVT_F32, sizeof(f32) * 3, false, LOT_NONE },
|
||||||
{ "e", LVT_F32, sizeof(f32) * 4, false, LOT_NONE },
|
{ "m10", LVT_F32, sizeof(f32) * 4, false, LOT_NONE },
|
||||||
{ "f", LVT_F32, sizeof(f32) * 5, false, LOT_NONE },
|
{ "m11", LVT_F32, sizeof(f32) * 5, false, LOT_NONE },
|
||||||
{ "g", LVT_F32, sizeof(f32) * 6, false, LOT_NONE },
|
{ "m12", LVT_F32, sizeof(f32) * 6, false, LOT_NONE },
|
||||||
{ "h", LVT_F32, sizeof(f32) * 7, false, LOT_NONE },
|
{ "m13", LVT_F32, sizeof(f32) * 7, false, LOT_NONE },
|
||||||
{ "i", LVT_F32, sizeof(f32) * 8, false, LOT_NONE },
|
{ "m20", LVT_F32, sizeof(f32) * 8, false, LOT_NONE },
|
||||||
{ "j", LVT_F32, sizeof(f32) * 9, false, LOT_NONE },
|
{ "m21", LVT_F32, sizeof(f32) * 9, false, LOT_NONE },
|
||||||
{ "k", LVT_F32, sizeof(f32) * 10, false, LOT_NONE },
|
{ "m22", LVT_F32, sizeof(f32) * 10, false, LOT_NONE },
|
||||||
{ "l", LVT_F32, sizeof(f32) * 11, false, LOT_NONE },
|
{ "m23", LVT_F32, sizeof(f32) * 11, false, LOT_NONE },
|
||||||
{ "m", LVT_F32, sizeof(f32) * 12, false, LOT_NONE },
|
{ "m30", LVT_F32, sizeof(f32) * 12, false, LOT_NONE },
|
||||||
{ "n", LVT_F32, sizeof(f32) * 13, false, LOT_NONE },
|
{ "m31", LVT_F32, sizeof(f32) * 13, false, LOT_NONE },
|
||||||
{ "o", LVT_F32, sizeof(f32) * 14, false, LOT_NONE },
|
{ "m32", LVT_F32, sizeof(f32) * 14, false, LOT_NONE },
|
||||||
{ "p", LVT_F32, sizeof(f32) * 15, false, LOT_NONE },
|
{ "m33", LVT_F32, sizeof(f32) * 15, false, LOT_NONE },
|
||||||
|
{ "a", LVT_F32, sizeof(f32) * 16, false, LOT_NONE },
|
||||||
|
{ "b", LVT_F32, sizeof(f32) * 17, false, LOT_NONE },
|
||||||
|
{ "c", LVT_F32, sizeof(f32) * 18, false, LOT_NONE },
|
||||||
|
{ "d", LVT_F32, sizeof(f32) * 19, false, LOT_NONE },
|
||||||
|
{ "e", LVT_F32, sizeof(f32) * 20, false, LOT_NONE },
|
||||||
|
{ "f", LVT_F32, sizeof(f32) * 21, false, LOT_NONE },
|
||||||
|
{ "g", LVT_F32, sizeof(f32) * 22, false, LOT_NONE },
|
||||||
|
{ "h", LVT_F32, sizeof(f32) * 23, false, LOT_NONE },
|
||||||
|
{ "i", LVT_F32, sizeof(f32) * 24, false, LOT_NONE },
|
||||||
|
{ "j", LVT_F32, sizeof(f32) * 25, false, LOT_NONE },
|
||||||
|
{ "k", LVT_F32, sizeof(f32) * 26, false, LOT_NONE },
|
||||||
|
{ "l", LVT_F32, sizeof(f32) * 27, false, LOT_NONE },
|
||||||
|
{ "m", LVT_F32, sizeof(f32) * 28, false, LOT_NONE },
|
||||||
|
{ "n", LVT_F32, sizeof(f32) * 29, false, LOT_NONE },
|
||||||
|
{ "o", LVT_F32, sizeof(f32) * 30, false, LOT_NONE },
|
||||||
|
{ "p", LVT_F32, sizeof(f32) * 31, false, LOT_NONE },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LUA_COLOR_FIELD_COUNT 3
|
#define LUA_COLOR_FIELD_COUNT 3
|
||||||
|
|
|
@ -120,6 +120,22 @@ static void smlua_push_vec4s(Vec4s src, int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void smlua_get_mat4(Mat4 dest, int index) {
|
static void smlua_get_mat4(Mat4 dest, int index) {
|
||||||
|
dest[0][0] = smlua_get_number_field(index, "m00");
|
||||||
|
dest[0][1] = smlua_get_number_field(index, "m01");
|
||||||
|
dest[0][2] = smlua_get_number_field(index, "m02");
|
||||||
|
dest[0][3] = smlua_get_number_field(index, "m03");
|
||||||
|
dest[1][0] = smlua_get_number_field(index, "m10");
|
||||||
|
dest[1][1] = smlua_get_number_field(index, "m11");
|
||||||
|
dest[1][2] = smlua_get_number_field(index, "m12");
|
||||||
|
dest[1][3] = smlua_get_number_field(index, "m13");
|
||||||
|
dest[2][0] = smlua_get_number_field(index, "m20");
|
||||||
|
dest[2][1] = smlua_get_number_field(index, "m21");
|
||||||
|
dest[2][2] = smlua_get_number_field(index, "m22");
|
||||||
|
dest[2][3] = smlua_get_number_field(index, "m23");
|
||||||
|
dest[3][0] = smlua_get_number_field(index, "m30");
|
||||||
|
dest[3][1] = smlua_get_number_field(index, "m31");
|
||||||
|
dest[3][2] = smlua_get_number_field(index, "m32");
|
||||||
|
dest[3][3] = smlua_get_number_field(index, "m33");
|
||||||
dest[0][0] = smlua_get_number_field(index, "a");
|
dest[0][0] = smlua_get_number_field(index, "a");
|
||||||
dest[0][1] = smlua_get_number_field(index, "b");
|
dest[0][1] = smlua_get_number_field(index, "b");
|
||||||
dest[0][2] = smlua_get_number_field(index, "c");
|
dest[0][2] = smlua_get_number_field(index, "c");
|
||||||
|
@ -139,6 +155,22 @@ static void smlua_get_mat4(Mat4 dest, int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void smlua_push_mat4(Mat4 src, int index) {
|
static void smlua_push_mat4(Mat4 src, int index) {
|
||||||
|
smlua_push_number_field(index, "m00", src[0][0]);
|
||||||
|
smlua_push_number_field(index, "m01", src[0][1]);
|
||||||
|
smlua_push_number_field(index, "m02", src[0][2]);
|
||||||
|
smlua_push_number_field(index, "m03", src[0][3]);
|
||||||
|
smlua_push_number_field(index, "m10", src[1][0]);
|
||||||
|
smlua_push_number_field(index, "m11", src[1][1]);
|
||||||
|
smlua_push_number_field(index, "m12", src[1][2]);
|
||||||
|
smlua_push_number_field(index, "m13", src[1][3]);
|
||||||
|
smlua_push_number_field(index, "m20", src[2][0]);
|
||||||
|
smlua_push_number_field(index, "m21", src[2][1]);
|
||||||
|
smlua_push_number_field(index, "m22", src[2][2]);
|
||||||
|
smlua_push_number_field(index, "m23", src[2][3]);
|
||||||
|
smlua_push_number_field(index, "m30", src[3][0]);
|
||||||
|
smlua_push_number_field(index, "m31", src[3][1]);
|
||||||
|
smlua_push_number_field(index, "m32", src[3][2]);
|
||||||
|
smlua_push_number_field(index, "m33", src[3][3]);
|
||||||
smlua_push_number_field(index, "a", src[0][0]);
|
smlua_push_number_field(index, "a", src[0][0]);
|
||||||
smlua_push_number_field(index, "b", src[0][1]);
|
smlua_push_number_field(index, "b", src[0][1]);
|
||||||
smlua_push_number_field(index, "c", src[0][2]);
|
smlua_push_number_field(index, "c", src[0][2]);
|
||||||
|
|
Loading…
Reference in a new issue