From ea32e1ea70e2034a88b9f08e9fd4de8da358c2c2 Mon Sep 17 00:00:00 2001 From: Fazana <52551480+FazanaJ@users.noreply.github.com> Date: Sun, 3 Oct 2021 21:05:46 +0100 Subject: [PATCH] Moved hitbox visualisation into its own func Saves around 500us in the graph --- src/game/rendering_graph_node.c | 55 ++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index e597a38e..60096e06 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -916,6 +916,33 @@ s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix) { return TRUE; } +#ifdef VISUAL_DEBUG +void visualise_object_hitbox(struct Object *node) +{ + Vec3f bnds1, bnds2; + // This will create a cylinder that visualises their hitbox. + // If they do not have a hitbox, it will be a small white cube instead. + if (node->oIntangibleTimer != -1) { + vec3f_set(bnds1, node->oPosX, node->oPosY - node->hitboxDownOffset, node->oPosZ); + vec3f_set(bnds2, node->hitboxRadius, node->hitboxHeight-node->hitboxDownOffset, node->hitboxRadius); + if (node->behavior == segmented_to_virtual(bhvWarp) || node->behavior == segmented_to_virtual(bhvDoorWarp) || node->behavior == segmented_to_virtual(bhvFadingWarp)) + debug_box_color(0x80FFA500); + else + debug_box_color(0x800000FF); + debug_box(bnds1, bnds2, DEBUG_SHAPE_CYLINDER | DEBUG_UCODE_REJ); + vec3f_set(bnds1, node->oPosX, node->oPosY - node->hitboxDownOffset, node->oPosZ); + vec3f_set(bnds2, node->hurtboxRadius, node->hurtboxHeight, node->hurtboxRadius); + debug_box_color(0x8FF00000); + debug_box(bnds1, bnds2, DEBUG_SHAPE_CYLINDER | DEBUG_UCODE_REJ); + } else { + vec3f_set(bnds1, node->oPosX, node->oPosY - 15, node->oPosZ); + vec3f_set(bnds2, 30, 30, 30); + debug_box_color(0x80FFFFFF); + debug_box(bnds1, bnds2, DEBUG_SHAPE_BOX | DEBUG_UCODE_REJ); + } +} +#endif + /** * Process an object node. */ @@ -946,31 +973,9 @@ void geo_process_object(struct Object *node) { gMatStackIndex--; inc_mat_stack(); if (node->header.gfx.sharedChild != NULL) { - #ifdef VISUAL_DEBUG - if (hitboxView) { - Vec3f bnds1, bnds2; - // This will create a cylinder that visualises their hitbox. - // If they do not have a hitbox, it will be a small white cube instead. - if (node->oIntangibleTimer != -1) { - vec3f_set(bnds1, node->oPosX, node->oPosY - node->hitboxDownOffset, node->oPosZ); - vec3f_set(bnds2, node->hitboxRadius, node->hitboxHeight-node->hitboxDownOffset, node->hitboxRadius); - if (node->behavior == segmented_to_virtual(bhvWarp) || node->behavior == segmented_to_virtual(bhvDoorWarp) || node->behavior == segmented_to_virtual(bhvFadingWarp)) - debug_box_color(0x80FFA500); - else - debug_box_color(0x800000FF); - debug_box(bnds1, bnds2, DEBUG_SHAPE_CYLINDER | DEBUG_UCODE_REJ); - vec3f_set(bnds1, node->oPosX, node->oPosY - node->hitboxDownOffset, node->oPosZ); - vec3f_set(bnds2, node->hurtboxRadius, node->hurtboxHeight, node->hurtboxRadius); - debug_box_color(0x8FF00000); - debug_box(bnds1, bnds2, DEBUG_SHAPE_CYLINDER | DEBUG_UCODE_REJ); - } else { - vec3f_set(bnds1, node->oPosX, node->oPosY - 15, node->oPosZ); - vec3f_set(bnds2, 30, 30, 30); - debug_box_color(0x80FFFFFF); - debug_box(bnds1, bnds2, DEBUG_SHAPE_BOX | DEBUG_UCODE_REJ); - } - } - #endif +#ifdef VISUAL_DEBUG + if (hitboxView) visualise_object_hitbox(node); +#endif gCurGraphNodeObject = (struct GraphNodeObject *) node; node->header.gfx.sharedChild->parent = &node->header.gfx.node; geo_process_node_and_siblings(node->header.gfx.sharedChild);