From 5558ecbd4e71912f03840740e1c38f9b06773424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= Date: Sun, 17 May 2020 02:15:11 -0300 Subject: [PATCH] Fixes billboarding-related problems --- data/behavior_data.c | 5 +---- src/engine/behavior_script.c | 10 ---------- src/engine/graph_node.h | 1 - src/engine/math_util.c | 25 ------------------------- src/engine/math_util.h | 1 - src/game/behaviors/cannon.inc.c | 10 ++++------ src/game/object_helpers.c | 4 ---- src/game/object_helpers.h | 1 - src/game/rendering_graph_node.c | 3 --- 9 files changed, 5 insertions(+), 55 deletions(-) diff --git a/data/behavior_data.c b/data/behavior_data.c index 3b4af5a0..82692466 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -219,9 +219,6 @@ #define BILLBOARD() \ BC_B(0x21) -#define CYLBOARD() \ - BC_B(0x38) - // Hides the current object. #define HIDE() \ BC_B(0x22) @@ -3183,7 +3180,7 @@ const BehaviorScript bhvFloorTrapInCastle[] = { const BehaviorScript bhvTree[] = { BEGIN(OBJ_LIST_POLELIKE), - CYLBOARD(), + BILLBOARD(), OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE), SET_INT(oInteractType, INTERACT_POLE), SET_HITBOX(/*Radius*/ 80, /*Height*/ 500), diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index 539f3a32..03c267cd 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -133,15 +133,6 @@ static s32 bhv_cmd_disable_rendering(void) { // Usage: BILLBOARD() static s32 bhv_cmd_billboard(void) { gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_BILLBOARD; - - gCurBhvCommand++; - return BHV_PROC_CONTINUE; -} - -// Command 0x -static s32 bhv_cmd_cylboard(void) { - gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_CYLBOARD; - gCurBhvCommand++; return BHV_PROC_CONTINUE; } @@ -906,7 +897,6 @@ static BhvCommandProc BehaviorCmdTable[] = { bhv_cmd_disable_rendering, //35 bhv_cmd_set_int_unused, //36 bhv_cmd_spawn_water_droplet, //37 - bhv_cmd_cylboard //38 }; // Execute the behavior script of the current object, process the object flags, and other miscellaneous code for updating objects. diff --git a/src/engine/graph_node.h b/src/engine/graph_node.h index c99e5f32..2778cc97 100644 --- a/src/engine/graph_node.h +++ b/src/engine/graph_node.h @@ -30,7 +30,6 @@ extern Vec3s gVec3sOne; #define GRAPH_RENDER_Z_BUFFER (1 << 3) #define GRAPH_RENDER_INVISIBLE (1 << 4) #define GRAPH_RENDER_HAS_ANIMATION (1 << 5) -#define GRAPH_RENDER_CYLBOARD (1 << 6) // Whether the node type has a function pointer of type GraphNodeFunc #define GRAPH_NODE_TYPE_FUNCTIONAL 0x100 diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 3f027ed5..8643f5e0 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -377,31 +377,6 @@ void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) { dest[3][3] = 1; } -void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) { //straight up mtxf_billboard but minus the dest[1][n] lines. transform for cylindrical billboards - dest[0][0] = coss(angle); - dest[0][1] = sins(angle); - dest[0][2] = 0; - dest[0][3] = 0; - - dest[1][0] = mtx[1][0]; - dest[1][1] = mtx[1][1]; - dest[1][2] = mtx[1][2]; - dest[1][3] = 0; - - dest[2][0] = 0; - dest[2][1] = 0; - dest[2][2] = 1; - dest[2][3] = 0; - - dest[3][0] = - mtx[0][0] * position[0] + mtx[1][0] * position[1] + mtx[2][0] * position[2] + mtx[3][0]; - dest[3][1] = - mtx[0][1] * position[0] + mtx[1][1] * position[1] + mtx[2][1] * position[2] + mtx[3][1]; - dest[3][2] = - mtx[0][2] * position[0] + mtx[1][2] * position[1] + mtx[2][2] * position[2] + mtx[3][2]; - dest[3][3] = 1; -} - /** * Set 'dest' to a transformation matrix that aligns an object with the terrain * based on the normal. Used for enemies. diff --git a/src/engine/math_util.h b/src/engine/math_util.h index b8b7f1b8..650fe973 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -56,7 +56,6 @@ void mtxf_lookat(f32 mtx[4][4], Vec3f b, Vec3f c, s16 d); void mtxf_rotate_zxy_and_translate(f32 mtx[4][4], Vec3f b, Vec3s c); void mtxf_rotate_xyz_and_translate(f32 mtx[4][4], Vec3f b, Vec3s c); void mtxf_billboard(f32 mtx1[4][4], f32 mtx2[4][4], Vec3f c, s16 d); -void mtxf_cylboard(f32 mtx1[4][4], f32 mtx2[4][4], Vec3f c, s16 d); void mtxf_align_terrain_normal(f32 mtx[4][4], Vec3f b, Vec3f c, s16 d); void mtxf_align_terrain_triangle(f32 mtx[4][4], Vec3f b, s16 c, f32 d); void mtxf_mul(f32 dest[4][4], f32 a[4][4], f32 b[4][4]); diff --git a/src/game/behaviors/cannon.inc.c b/src/game/behaviors/cannon.inc.c index a8cfcab3..5f55ca83 100644 --- a/src/game/behaviors/cannon.inc.c +++ b/src/game/behaviors/cannon.inc.c @@ -17,11 +17,9 @@ void opened_cannon_act_0(void) { cur_obj_enable_rendering(); cur_obj_become_tangible(); } - cur_obj_become_tangible(); - cur_obj_enable_rendering(); if (o->oDistanceToMario < 500.0f) { - //cur_obj_become_tangible(); - //cur_obj_enable_rendering(); + cur_obj_become_tangible(); + cur_obj_enable_rendering(); if (o->oInteractStatus & INT_STATUS_INTERACTED && (!(o->oInteractStatus & INT_STATUS_TOUCHED_BOB_OMB))) // bob-omb explodes when it gets into a cannon @@ -32,8 +30,8 @@ void opened_cannon_act_0(void) { } else o->oInteractStatus = 0; } else { - //cur_obj_become_intangible(); - //cur_obj_disable_rendering(); + cur_obj_become_intangible(); + cur_obj_disable_rendering(); o->oCannonUnk10C = 0; } } diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index e05f7743..c0ceb4b8 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -1595,10 +1595,6 @@ void obj_set_billboard(struct Object *obj) { obj->header.gfx.node.flags |= GRAPH_RENDER_BILLBOARD; } -void obj_set_cylboard(struct Object *obj) { - obj->header.gfx.node.flags |= GRAPH_RENDER_CYLBOARD; -} - void cur_obj_set_hitbox_radius_and_height(f32 radius, f32 height) { o->hitboxRadius = radius; o->hitboxHeight = height; diff --git a/src/game/object_helpers.h b/src/game/object_helpers.h index 577f8f66..80806bde 100644 --- a/src/game/object_helpers.h +++ b/src/game/object_helpers.h @@ -292,7 +292,6 @@ extern void cur_obj_shake_y(f32); void cur_obj_start_cam_event(struct Object *obj, s32 cameraEvent); // extern ? set_mario_interact_hoot_if_in_range(?); void obj_set_billboard(struct Object *a0); -void obj_set_cylboard(struct Object *a0); void cur_obj_set_hitbox_radius_and_height(f32,f32); void cur_obj_set_hurtbox_radius_and_height(f32,f32); // extern ? obj_spawn_loot_coins(?); diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index a96eafbf..d83616d5 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -796,9 +796,6 @@ static void geo_process_object(struct Object *node) { if (node->header.gfx.throwMatrix != NULL) { mtxf_mul(gMatStack[gMatStackIndex + 1], (void *) node->header.gfx.throwMatrix, gMatStack[gMatStackIndex]); - } else if (node->header.gfx.node.flags & GRAPH_RENDER_CYLBOARD) { - mtxf_cylboard(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex], - node->header.gfx.pos, gCurGraphNodeCamera->roll); } else if (node->header.gfx.node.flags & GRAPH_RENDER_BILLBOARD) { mtxf_billboard(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex], node->header.gfx.pos, gCurGraphNodeCamera->roll);