58 s32 overhead, s32 startIdx) {
66 if (handle->
ttl < 0) {
74 handle->
addr = bufferMem;
79 nodeVtxList = &node->
fcData.vtxList[startIdx];
82 i = ((s32)buffer & 0xFFFFFF);
86 for (i = 0; i < vtxCount; i++) {
87 *bufferMem = *nodeVtxList;
88 bufferMem->v.ob[0] = buffer->
x;
89 bufferMem->v.ob[1] = buffer->
y;
90 bufferMem->v.ob[2] = buffer->
z;
178 if (node->
fcData.modelID == modelId) {
239 (*gCurrentAnimMeshListPtr)[i] = NULL;
308 (*gCurrentAnimMeshListPtr)[i] = NULL;
330 (*gCurrentAnimMeshListPtr)[i] = animator =
heap_malloc(
sizeof(*animator));
341 if (animPos == NULL) {
378 (*gCurrentAnimMeshListPtr)[i] = animator =
heap_malloc(
sizeof(*animator));
392 animPos = (s16*)(((s32)animPos & 0xFFFFFF) + (s32)animator->
animationBuffer);
441 nextUniqueID = nextUniqueID + 1;
443 if (parentNodeID == 0) {
444 s32 nullRootNode = animator->
rootNode == NULL;
491 animatorID &= ~BATTLE_ID_BIT;
492 animator = (*gCurrentAnimMeshListPtr)[animatorID];
494 if (animator == NULL || animator->
flags == 0) {
502 animator->
flags &= ~MODEL_ANIMATOR_FLAG_UPDATE_PENDING;
555 animatorID &= ~BATTLE_ID_BIT;
556 animator = (*gCurrentAnimMeshListPtr)[animatorID];
558 if (animator == NULL || animator->
flags == 0) {
566 animator->
flags &= ~MODEL_ANIMATOR_FLAG_UPDATE_PENDING;
648 node->
flags &= ~flags;
657 x = (f32)*args++ * 180.0 / 32767.0;
658 y = (f32)*args++ * 180.0 / 32767.0;
659 z = (f32)*args++ * 180.0 / 32767.0;
670 x = (f32)*args++ * 180.0 / 32767.0;
671 y = (f32)*args++ * 180.0 / 32767.0;
672 z = (f32)*args++ * 180.0 / 32767.0;
695 x = (f32)*args++ * 180.0 / 32767.0;
696 y = (f32)*args++ * 180.0 / 32767.0;
697 z = (f32)*args++ * 180.0 / 32767.0;
733 Mtx* rootTransform) {
753 guMtxL2F(sp10, rootTransform);
774 animatorID &= ~BATTLE_ID_BIT;
775 animator = (*gCurrentAnimMeshListPtr)[animatorID];
777 if (animator == NULL || animator->
flags == 0) {
785 animator->
mtx = *rootTransform;
804 animatorID &= ~BATTLE_ID_BIT;
805 animator = (*gCurrentAnimMeshListPtr)[animatorID];
807 if (animator == NULL || animator->
flags == 0) {
815 animator->
mtx = *rootTransform;
893 guMtxL2F(sp10, &animator->
mtx);
919 gSPTexture(
gMainGfxPos++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
927 gDPSetCombineMode(
gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
946 if ((node->
displayList[0].words.w0 >> 0x18) != G_ENDDL) {
951 w0 = gfxPtr->words.w0;
962 if (bufferHandle->
ttl < 0) {
970 bufferHandle->
ttl = 3;
979 if (cmd == G_ENDDL) {
983 s32 startIdx = _SHIFTR(w0,1,7);
984 s32 vtxCount = _SHIFTR(w0,12,8);
987 startIdx -= vtxCount;
989 if (node->
fcData.vtxList == NULL) {
991 gSPVertex(gfxPos++, newBuffer, vtxCount, startIdx);
1001 gSPVertex(gfxPos++, newBuffer, vtxCount, startIdx);
1005 Gfx* temp[1] = {gfxPos++};
1006 temp[0]->words.w0 = w0;
1007 temp[0]->words.w1 = w1;
1011 gSPEndDisplayList(gfxPos++);
1035 for (i = 0; i < count; i++) {
1046 ModelAnimator* ret = (*gCurrentAnimMeshListPtr)[animModelID & ~BATTLE_ID_BIT];
1090 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[index & ~BATTLE_ID_BIT];
1092 animator->
flags |= bits;
1096 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[index & ~BATTLE_ID_BIT];
1098 animator->
flags &= ~bits;
1102 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[index & ~BATTLE_ID_BIT];
1105 animPos = (s16*) (((s32)animPos & 0xFFFFFF) + (s32)animator->
animationBuffer);
1114 s32 indexMasked = index & ~BATTLE_ID_BIT;
1115 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[indexMasked];
1119 animPos = (s16*) (((s32)animPos & 0xFFFFFF) + (s32)animator->
animationBuffer);
1127 for (i = 0; i < framesToSkip; i++) {
1143 bpPtr->
rot.
x = ((f32) node->
rot.
x * 180.0) / 32767.0;
1144 bpPtr->
rot.
y = ((f32) node->
rot.
y * 180.0) / 32767.0;
1145 bpPtr->
rot.
z = ((f32) node->
rot.
z * 180.0) / 32767.0;
1161 if (node->
child != NULL) {
1172 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[index & ~BATTLE_ID_BIT];
1175 if (animator == NULL || animator->
flags == 0) {
1186 if (node->
child != NULL && parentNodeID == 0) {
1193 }
while (node != NULL);
1199 s32 indexMasked = index & ~BATTLE_ID_BIT;
1200 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[indexMasked];
1204 if (animator == NULL || animator->
flags == 0) {
1208 if ((*tree)->vertexStartOffset == 0) {
1237 bpPtr->
rot.
x = ((f32) node->
rot.
x * 180.0) / 32767.0;
1238 bpPtr->
rot.
y = ((f32) node->
rot.
y * 180.0) / 32767.0;
1239 bpPtr->
rot.
z = ((f32) node->
rot.
z * 180.0) / 32767.0;
1252 if (node->
child != NULL) {
1320 node->
flags &= ~flags;
1329 x = (f32)*args++ * 180.0 / 32767.0;
1330 y = (f32)*args++ * 180.0 / 32767.0;
1331 z = (f32)*args++ * 180.0 / 32767.0;
1333 if (nodeId != 0xFF) {
1349 x = (f32)*args++ * 180.0 / 32767.0;
1350 y = (f32)*args++ * 180.0 / 32767.0;
1351 z = (f32)*args++ * 180.0 / 32767.0;
1353 if (nodeId != 0xFF) {
1373 if (nodeId != 0xFF) {
1389 x = (f32)*args++ * 180.0 / 32767.0;
1390 y = (f32)*args++ * 180.0 / 32767.0;
1391 z = (f32)*args++ * 180.0 / 32767.0;
1393 if (nodeId != 0xFF) {
BSS Matrix4f gAnimRotScaleMtx
void play_model_animation(s32 index, s16 *animPos)
BSS AnimatedMeshVertexCopyList D_801536C0
void clear_animator_list(void)
BSS AnimatedMeshList D_801539C0
void render_animated_model_with_vertices(s32 animatorID, Mtx *rootTransform, s32 segment, void *baseAddr)
void set_anim_model_fog_color(s32 r, s32 g, s32 b, s32 a)
void set_animator_tree_to_node_map(ModelAnimator *animator, s32 *nodeIDs, s32 count)
Gfx Gfx_RM3_SURFACE_OPA[]
void reset_animator_list(void)
BSS AnimatedMeshList D_80153A00
AnimatorNode * add_anim_node(ModelAnimator *animator, s32 parentNodeID, AnimatorNodeBlueprint *nodeBP)
void get_anim_model_fog_distance(s32 *start, s32 *end)
ModelAnimator * set_animator_render_callback(s32 animModelID, void *callbackArg, void(*callbackFunc)(void *))
void disable_anim_model_fog(void)
void render_animated_model(s32 animatorID, Mtx *rootTransform)
void enable_anim_model_fog(void)
BSS s32 gAnimModelFogStart
void set_animator_flags(s32 index, s32 bits)
void appendGfx_animator_node(ModelAnimator *, AnimatorNode *, Matrix4f)
AnimatorNode * get_animator_node_with_id(ModelAnimator *animator, s32 id)
void animator_node_update_model_transform(ModelAnimator *animator, f32(*flipMtx)[4], AnimatorNode *node, Mtx *rootTransform)
void reload_mesh_animator_tree(ModelAnimator *animator)
void delete_model_animator_nodes(ModelAnimator *animator)
void get_anim_model_fog_color(s32 *r, s32 *g, s32 *b, s32 *a)
void delete_model_animator(ModelAnimator *animator)
void clear_animator_flags(s32 index, s32 bits)
void play_model_animation_starting_from(s32 index, s16 *animPos, s32 framesToSkip)
void load_mesh_animator_node(StaticAnimatorNode *node, ModelAnimator *animator, s32 parentNodeID, s32 *treeIndexToNodeIDs)
void delete_model_animator_node(AnimatorNode *node)
ModelAnimator * get_animator_by_index(s32 animModelID)
BSS Matrix4f gAnimTranslateMtx
AnimatorNode * get_animator_child_for_model(AnimatorNode *node, s32 modelId)
void animator_make_identity(Matrix4f mtx)
Vtx * animator_copy_vertices_to_buffer(ModelAnimator *animator, AnimatorNode *node, Vec3s *buffer, s32 vtxCount, s32 overhead, s32 startIdx)
Gfx Gfx_RM1_INTERSECTING_OPA[]
void animator_make_mirrorX(Matrix4f mtx)
Gfx Gfx_RM1_INTERSECTING_XLU[]
DisplayListBufferHandle AnimatedMeshVertexCopyList[0x60]
void load_mesh_animator_tree(s32 index, StaticAnimatorNode **tree)
s32 create_model_animator(s16 *animPos)
s32 is_anim_model_fog_enabled(void)
void free_animator_nodes(ModelAnimator *animator)
void update_model_animator(s32 animatorID)
void appendGfx_animator(ModelAnimator *animator)
Gfx Gfx_RM1_SURFACE_XLU[]
void load_model_animator_tree(s32 index, StaticAnimatorNode **tree)
void animator_make_mirrorY(Matrix4f mtx)
void load_model_animator_node(StaticAnimatorNode *node, ModelAnimator *animator, s32 parentNodeID, s32 *treeIndexToNodeIDs)
s32 step_mesh_animator(ModelAnimator *animator)
s32 step_model_animator(ModelAnimator *animator)
void update_model_animator_with_transform(s32 animatorID, Mtx *mtx)
Gfx Gfx_RM3_INTERSECTING_OPA[]
AnimatorNode * get_animator_child_with_id_helper(AnimatorNode *node, s32 id)
void reload_mesh_animator_node(StaticAnimatorNode *node, ModelAnimator *animator, s32 parentNodeID, s32 *treeIndexToNodeIDs)
s32 create_mesh_animator(s16 *animPos, s16 *animBuffer)
BSS AnimatedMeshVertexCopyList D_801533C0
void free_animator_nodes_helper(AnimatorNode *node)
void animator_make_mirrorZ(Matrix4f mtx)
Gfx Gfx_RM3_INTERSECTING_XLU[]
Gfx Gfx_RM1_SURFACE_OPA[]
AnimatorNode * get_animator_node_for_tree_index(ModelAnimator *animator, s32 arg1)
BSS StaticAnimatorNode ** gAnimTreeRoot
void set_anim_model_fog_dist(s32 start, s32 end)
void animator_update_model_transforms(ModelAnimator *animator, Mtx *rootTransform)
AnimScript gAnimScriptDefault
BSS Matrix4f gAnimScaleMtx
AnimatorNode * get_animator_child_with_id(ModelAnimator *animator, s32 id)
Gfx Gfx_RM3_SURFACE_XLU[]
BSS AnimatedMeshList * gCurrentAnimMeshListPtr
BSS s32 gAnimModelFogEnabled
struct StaticAnimatorNode * child
struct StaticAnimatorNode * sibling
union AnimatorNode::@29 fcData
struct AnimatorNode * children[32]
ModelAnimator * AnimatedMeshList[16]
#define general_heap_malloc
#define queue_render_task
#define ASSERT(condition)
@ MODEL_FLAG_MATRIX_DIRTY
@ MODEL_ANIMATOR_FLAG_CAM_2
@ MODEL_ANIMATOR_FLAG_HAS_MODEL
@ MODEL_ANIMATOR_FLAG_CULL_BACK
@ MODEL_ANIMATOR_FLAG_NO_FLIP
@ MODEL_ANIMATOR_FLAG_MESH
@ MODEL_ANIMATOR_FLAG_CAM_1
@ MODEL_ANIMATOR_FLAG_FREEZE_ANIMATION
@ MODEL_ANIMATOR_FLAG_FLIP_Y
@ MODEL_ANIMATOR_FLAG_FLIP_X
@ MODEL_ANIMATOR_FLAG_CAM_0
@ MODEL_ANIMATOR_FLAG_HIDDEN
@ MODEL_ANIMATOR_FLAG_ENABLED
@ MODEL_ANIMATOR_FLAG_FLIP_Z
@ MODEL_ANIMATOR_FLAG_UPDATE_PENDING
@ RENDER_MODE_INTERSECTING_XLU
@ RENDER_MODE_INTERSECTING_OPA
@ RENDER_MODE_SURFACE_OPA
@ RENDER_MODE_SURFACE_XLU_LAYER1
s32 get_model_list_index_from_tree_index(s32 treeIndex)
struct Model * get_model_from_list_index(s32 listIndex)
void copy_matrix(Matrix4f src, Matrix4f dest)
s32 general_heap_free(void *data)
void * heap_malloc(s32 size)
Matrix4f userTransformMtx
#define PM_CC2_MULTIPLY_SHADE
#define VIRTUAL_TO_PHYSICAL(addr)
void(* fpRenderCallback)(void *)
StaticAnimatorNode * staticNodes[0x7A]
AnimatorNode * nodeCache[0x7A]
StaticAnimatorNode ** staticRoot
void(* appendGfx)(void *)
GameStatus * gGameStatusPtr
DisplayContext * gDisplayContext