diff --git a/src/game/propobj.c b/src/game/propobj.c index 7be549143..660da57cd 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -32718,7 +32718,7 @@ glabel var7f1aa978 /* f083168: 8faa0138 */ lw $t2,0x138($sp) /* f08316c: 00402825 */ or $a1,$v0,$zero /* f083170: 27a600b8 */ addiu $a2,$sp,0xb8 -/* f083174: 0c006ac3 */ jal func0001ab0c +/* f083174: 0c006ac3 */ jal modelNodeGetPosition /* f083178: 8d440018 */ lw $a0,0x18($t2) /* f08317c: 0fc1a2b5 */ jal func0f068ad4 /* f083180: 8fa400c8 */ lw $a0,0xc8($sp) @@ -32727,7 +32727,7 @@ glabel var7f1aa978 /* f08318c: 8fab00c8 */ lw $t3,0xc8($sp) /* f083190: 00402825 */ or $a1,$v0,$zero /* f083194: 27a600a8 */ addiu $a2,$sp,0xa8 -/* f083198: 0c006ac3 */ jal func0001ab0c +/* f083198: 0c006ac3 */ jal modelNodeGetPosition /* f08319c: 8d640018 */ lw $a0,0x18($t3) /* f0831a0: c7a400b8 */ lwc1 $f4,0xb8($sp) /* f0831a4: c7a600a8 */ lwc1 $f6,0xa8($sp) diff --git a/src/include/constants.h b/src/include/constants.h index 3808d3739..cc164521f 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1458,14 +1458,16 @@ #define MODEL_CETANDOORSIDE 0x01b7 #define MODEL_BUDDYBRIDGE 0x01b8 -#define MODELNODETYPE_ROOT 0x01 -#define MODELNODETYPE_DISPLAYLIST 0x18 -#define MODELNODETYPE_NEARFAR 0x08 -#define MODELNODETYPE_PARTID 0x12 -#define MODELNODETYPE_HAT 0x09 -#define MODELNODETYPE_0B 0x0b -#define MODELNODETYPE_GUNFIRE 0x0c -#define MODELNODETYPE_HEADSPOT 0x17 +#define MODELNODETYPE_ROOT 0x01 +#define MODELNODETYPE_POSITION 0x02 +#define MODELNODETYPE_NEARFAR 0x08 +#define MODELNODETYPE_HAT 0x09 +#define MODELNODETYPE_0B 0x0b +#define MODELNODETYPE_GUNFIRE 0x0c +#define MODELNODETYPE_PARTID 0x12 +#define MODELNODETYPE_POSITIONHELD 0x15 +#define MODELNODETYPE_HEADSPOT 0x17 +#define MODELNODETYPE_DISPLAYLIST 0x18 #define MODELPART_MUZZLEFLASHRIGHT 0x0002 #define MODELPART_MUZZLEFLASHLEFT 0x0003 diff --git a/src/include/lib/lib_1a500.h b/src/include/lib/lib_1a500.h index f8c35fc4d..5b0c14e23 100644 --- a/src/include/lib/lib_1a500.h +++ b/src/include/lib/lib_1a500.h @@ -18,7 +18,7 @@ struct modelnode *modelGetPart(struct model08 *arg0, s32 partnum); struct modelthing *func0001a9bc(void *modelfiledata, s32 arg1); u32 func0001a9e8(void); void *modelGetNodeData(struct model *model, struct modelnode *node); -void func0001ab0c(struct model *model, struct modelnode *node, struct coord *coord); +void modelNodeGetPosition(struct model *model, struct modelnode *node, struct coord *coord); void func0001abc4(struct model *model, struct modelnode *node, struct coord *coord); void func0001ad0c(struct model *model, struct coord *coord); void func0001ad34(struct model *model, struct coord *coord); diff --git a/src/include/types.h b/src/include/types.h index 8d8749529..57b3b42bd 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -224,6 +224,10 @@ struct modelnode_partid { // type 0x12 u16 index; }; +struct modelnode_positionheld { // type 0x15 + struct coord pos; +}; + struct modelnode_headspot { // type 0x17 u16 index; }; @@ -249,6 +253,7 @@ struct modelnode { struct modelnode_0b *unk0b; struct modelnode_gunfire *gunfire; struct modelnode_partid *partid; + struct modelnode_positionheld *positionheld; struct modelnode_headspot *headspot; struct modelnode_displaylist *displaylist; } data; @@ -303,9 +308,7 @@ struct model { struct modeldata_root { // type 0x01 u32 unk00; f32 ground; - u32 unk08; - u32 unk0c; - u32 unk10; + struct coord pos; f32 unk14; }; diff --git a/src/lib/lib_1a500.c b/src/lib/lib_1a500.c index 8084e79a3..cc0940fe6 100644 --- a/src/lib/lib_1a500.c +++ b/src/lib/lib_1a500.c @@ -488,59 +488,40 @@ void *modelGetNodeData(struct model *model, struct modelnode *node) return &datas[index]; } -GLOBAL_ASM( -glabel func0001ab0c -/* 1ab0c: 27bdffe8 */ addiu $sp,$sp,-24 -/* 1ab10: afbf0014 */ sw $ra,0x14($sp) -/* 1ab14: 94a20000 */ lhu $v0,0x0($a1) -/* 1ab18: 24010001 */ addiu $at,$zero,0x1 -/* 1ab1c: 304e00ff */ andi $t6,$v0,0xff -/* 1ab20: 11c1000b */ beq $t6,$at,.L0001ab50 -/* 1ab24: 24010002 */ addiu $at,$zero,0x2 -/* 1ab28: 11c10013 */ beq $t6,$at,.L0001ab78 -/* 1ab2c: 24010015 */ addiu $at,$zero,0x15 -/* 1ab30: 51c1001a */ beql $t6,$at,.L0001ab9c -/* 1ab34: 8ca20004 */ lw $v0,0x4($a1) -/* 1ab38: 44800000 */ mtc1 $zero,$f0 -/* 1ab3c: 00000000 */ nop -/* 1ab40: e4c00000 */ swc1 $f0,0x0($a2) -/* 1ab44: e4c00004 */ swc1 $f0,0x4($a2) -/* 1ab48: 1000001a */ b .L0001abb4 -/* 1ab4c: e4c00008 */ swc1 $f0,0x8($a2) -.L0001ab50: -/* 1ab50: 0c006a87 */ jal modelGetNodeData -/* 1ab54: afa60020 */ sw $a2,0x20($sp) -/* 1ab58: 8fa60020 */ lw $a2,0x20($sp) -/* 1ab5c: c4440008 */ lwc1 $f4,0x8($v0) -/* 1ab60: e4c40000 */ swc1 $f4,0x0($a2) -/* 1ab64: c446000c */ lwc1 $f6,0xc($v0) -/* 1ab68: e4c60004 */ swc1 $f6,0x4($a2) -/* 1ab6c: c4480010 */ lwc1 $f8,0x10($v0) -/* 1ab70: 10000010 */ b .L0001abb4 -/* 1ab74: e4c80008 */ swc1 $f8,0x8($a2) -.L0001ab78: -/* 1ab78: 8ca20004 */ lw $v0,0x4($a1) -/* 1ab7c: c44a0000 */ lwc1 $f10,0x0($v0) -/* 1ab80: e4ca0000 */ swc1 $f10,0x0($a2) -/* 1ab84: c4500004 */ lwc1 $f16,0x4($v0) -/* 1ab88: e4d00004 */ swc1 $f16,0x4($a2) -/* 1ab8c: c4520008 */ lwc1 $f18,0x8($v0) -/* 1ab90: 10000008 */ b .L0001abb4 -/* 1ab94: e4d20008 */ swc1 $f18,0x8($a2) -/* 1ab98: 8ca20004 */ lw $v0,0x4($a1) -.L0001ab9c: -/* 1ab9c: c4440000 */ lwc1 $f4,0x0($v0) -/* 1aba0: e4c40000 */ swc1 $f4,0x0($a2) -/* 1aba4: c4460004 */ lwc1 $f6,0x4($v0) -/* 1aba8: e4c60004 */ swc1 $f6,0x4($a2) -/* 1abac: c4480008 */ lwc1 $f8,0x8($v0) -/* 1abb0: e4c80008 */ swc1 $f8,0x8($a2) -.L0001abb4: -/* 1abb4: 8fbf0014 */ lw $ra,0x14($sp) -/* 1abb8: 27bd0018 */ addiu $sp,$sp,0x18 -/* 1abbc: 03e00008 */ jr $ra -/* 1abc0: 00000000 */ nop -); +void modelNodeGetPosition(struct model *model, struct modelnode *node, struct coord *pos) +{ + switch (node->type & 0xff) { + case MODELNODETYPE_ROOT: + { + struct modeldata_root *data = modelGetNodeData(model, node); + pos->x = data->pos.x; + pos->y = data->pos.y; + pos->z = data->pos.z; + } + break; + case MODELNODETYPE_POSITION: + { + struct modelnode_position *data = node->data.position; + pos->x = data->pos.x; + pos->y = data->pos.y; + pos->z = data->pos.z; + } + break; + case MODELNODETYPE_POSITIONHELD: + { + struct modelnode_positionheld *data = node->data.positionheld; + pos->x = data->pos.x; + pos->y = data->pos.y; + pos->z = data->pos.z; + } + break; + default: + pos->x = 0; + pos->y = 0; + pos->z = 0; + break; + } +} GLOBAL_ASM( glabel func0001abc4 @@ -635,7 +616,7 @@ glabel func0001abc4 void func0001ad0c(struct model *model, struct coord *coord) { - func0001ab0c(model, model->unk08->rootnode, coord); + modelNodeGetPosition(model, model->unk08->rootnode, coord); } void func0001ad34(struct model *model, struct coord *coord) @@ -678,7 +659,7 @@ glabel func0001ad5c /* 1add0: 55d50010 */ bnel $t6,$s5,.L0001ae14 /* 1add4: 8e310008 */ lw $s1,0x8($s1) .L0001add8: -/* 1add8: 0c006ac3 */ jal func0001ab0c +/* 1add8: 0c006ac3 */ jal modelNodeGetPosition /* 1addc: 02c03025 */ or $a2,$s6,$zero /* 1ade0: c6040000 */ lwc1 $f4,0x0($s0) /* 1ade4: c7a6003c */ lwc1 $f6,0x3c($sp)