HackerSM64 v2.0.0
* buffers: refresh 15 and revert to base decomp * behavior script * color helper functions * extended bounds * egeo_layout * fixed model ids * camera conf improved * message panel ucode small * graph node * level script * mathutil updates * mathutil updates (allow unused funcs) * behaviors a - beta_fish * Add librtc and fix some data declarations * Move GRUCODE define to proper location in makefile * Refresh 15 * extra * Make ROM name smaller and change messages printed on build a bit * Fix console (lol) * Update UNF to latest master * Make ucode load from .o's (and also fix Super3D) * Fix crash with rumble + custom mario model * graph node and mathutil * removed behaviors * Ldtob documentation * _Putfld labeling * area * behavior actions * camera * debug updates * bubbles * envfx snow * farcall helpers * game init * geo misc * hud * only check if VC on render init * ingame menu * revert goddard to base decomp * insn disasm * interaction documentation * level geo * level update defines * macro special objects formatting changes * main.h documentation * map parser documentation & formatting * airborne documentation * mario actions automatic documentation * mario actions cutscene documentation * mario actions moving documentation and options * mario actions object documentation and options * mario stationary documentation * mario submerged documentation * mario misc documentation * mario step: ledge grab fixes and documentation * mario documentation * memory.h documentation * moving textures * object behaviors * object collision * fix flamethrower bug * object helpers * object list processor documentation * paintings * platform displacement * print / printf * puppycam absf * puppyprint updates and formatting changes * rendering graph node performance optimizations * rumble opt and doc * hqvm back to ultrasm64 * save file documentation and unlock defines * s2d engine * reset various files to ultrasm64 * file select * intro geo documentation * screen transition documentation * segment2.h * shadow overhaul * skybox refactor * sound init: clean up define usage + documentation * spawn object optimizations and documentation * spawn sound cleanup * sram to ultrasm64 * star select cleanup * title screen cleanup * dialogs / text * rename stomp smoke * stomp smoke -> small water splash * updated README * compilation flags * optimized file positions + support function/data sections * surface collision performance improvements * surface load optimizations * camera conf documentation * Allow easier command for opening puppyprint debug * Rearranged framebuffers & fixed puppyprint console printing * Fix shadow scaling and shifting * Fix SILHOUETTE, OBJECTS_REJ, and ucode loading, also clean up render phase system a bit. * Fixed build with BETTER_HANGING off * Clean up OBJECTS_REJ ifdefs * Fix duplicate comment & graph render layers/flags bitmask * Fixed build with BETTER_HANGING off * Fix Fast64 importing by reverting sSegmentTable change * Readded missing functions that caused build errors with Mario head enabled * Fixed clang compilation issues * Add INTER mode for geo_update_layer_transparency * Fix build warnings * bugfix: miscalculation in obj_turn_toward_object * Some puppytech fixes * Further Puppycamera fixes * Fix BUGFIX_DIALOG_TIME_STOP Fixes #136 * Fix sliding platform bparams * Add LEGACY_SHADOW_IDS define for Fast64 compatibility * Apply suggested changes * Better find_in_bounds_yaw_wdw_bob_thi ifdef * Fix build warnings for unused functions * Fixed stale reference bug from obj_mark_for_deletion change * Fixed incorrect digit for 100s #145 * Change groundpound-fix define and functionality to just disable bonking * Fixed puppyroll #134 * Adjust height value for terrain angle to kick in * fixed hi score flashing * Remove menudata backup (#131) Not considered important enough to keep * Fix fread() build warning * Add COURSE_NUM_TO_INDEX to save_file_get_star_flags check in bhv_unagi_init * Fix approach_s16 return value * Use boolean defines for oCapDoScaleVertically * Make the door lock a part of the key door model to eliminate z-fighting, also reduce z fighting on numbered doors with AUTO_LOD enabled. * Move flames to LAYER_TRANSPARENT_INTER * Resolved some compiler warnings and added FALL_THROUGH define (#168) * Address some more compiler warnings with different define toggles * Remove unnecessary fallthrough attribute * fixed geo_process_billboard floating point exception * Allow water to face any direction * Initialize focOffset so that BBH doesn't crash * Removed superfluous RDP commands when switching microcodes which would override scissor * Set OBJ_FLAG_DONT_CALC_COLL_DIST on bhvUkikiCage * Fix rumble build * Fixed UNLOCK_FPS strobing * Update src/game/object_helpers.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update src/game/object_helpers.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Fix LEGACY_SHADOW_IDS id conflict * Use the vanilla default value for rotating fire bars if bparam2 is 0 * START_LEVEL safeguard * Fix some drawing distance issues caused by AUTO_COLLISION_DISTANCE * Fix rumble build * Fixed spline poll code using the wrong values for keyframes * Update readme with better credits Better credits for individual contributors * add arthur * added falco and moose * add fazana * le funny typo * added S2DEX engine to credits * silhouette + axo + ratio * remove specific callouts + add auto col distance * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Revert formatting changes to match vanilla decomp * Re-implement Y buffer for find_ceil * Re-implement POWER_STARS_HEAL for normal Power Stars * Start level comment & exit course comment/collapse * utilize reonucam technique for FAST_VERTICAL_CAMERA_MOVEMENT * Fix "MAX_REFERENCED_WALLS" typo * Allow stop_and_set_height_to_floor to work at any height if Mario is teleporting (#213) * Revert stop_and_set_height_to_floor to vanilla Fixes #208 * Fixed sAudioEnabled so that it disables audio CPU processing as well * Fixed puppyprint debug RDP us calculations * Renamed sAudioEnabled to gAudioEnabled * Replaced mtxf_to_mtx_asm with an equivalent implementation that supports WORLD_SCALE * Moved extended bounds and world scale configuration to a new config_world.h file * Default all objects to non-rej (#227) Fixes #221 (Default all objects to non-rej) * Fix #221 * Fix VISUAL_DEBUG breaking/crashing when OBJECTS_REJ is disabled (#211) * Fix VISUAL_DEBUG breaking/crashing when OBJECTS_REJ is disabled * Change vtl decrement in visual_surface_display from 6 to 3 Fixes #207 * Make area in SL igloo wider to prevent a softlock (#233) Fixes #210 * Fix coin formation coins being deleted if they spawn in the middle of a floor, also fix TTM slide coin position (#232) Fixes #201 * Make UNLOCK_ALL apply to more things * Fix wrong ifdef/ifndef in bhv_invisible_objects_under_bridge_init * Change chain chomp load/unload distances depending on number of segments (#237) Fixes #192 * added WATER_PLUNGE_UPWARP define * Add reonucam patch (#239) * added reonucam patch Fixes #218 * Fix how shadows handle water/transparency/height (#228) * Fix how shadows handle water/transparency/height * Change shadow check for flying carpets from a level specific check to a oPlatformOnTrackType check Fixes #179 * added reonucam credit * delete unnecesary patches * Apply suggested changes * murdered more patches * UNLOCK_ALL unlocks the cap boxes * UNLOCK_ALL unlocks cap boxes (slightly more epic edition) * revert ceil buffer * Renamed HD_INTRO_TEXTURES define, separated intro floombas * prevent double definition of floombas * actually prevent floomba redefinition * Develop/refactor default defines (#242) * Changed default config options * Added build dir to includePaths for pngs * disable NO_SLEEP by default * Disable puppyprint by default Sorry fazana 😔 * fix typos * add comment about BETTER_REVERB console perf * disable blue coin switch retry by default * Update config_audio.h Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Mr-Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com> * revert air step line to vanilla to fix bitfs scaling platform issue (#247) Fixes #200 * Fix stuttering on thin slopes (#248) * Fix stuttering on thin slopes * Revert vec3f_find_ceil calls to vanilla * Rename vec3f_find_ceil to find_mario_ceil * Update src/engine/surface_collision.h Fixes #249 * Swap static and dynamic surface checks back to vanilla order (#253) * Swap static and dynamic surface checks back to vanilla order * re-enable DISABLE_ALL config Fixes #251 #252 * Fixed save and quitting while in widescreen (#257) * Fixed save and quitting while in widescreen * use define for the level * all my homies hate ifdefs * skip wall offsets < 0 (#255) Fixes #255 * #264: Document non-stop stars' issues (#267) * #264: Document non-stop stars' issues * Update include/config/config_game.h * nonstop vanilla comment * derive margin_radius from radius after capping at 200 (#266) Fixes #259 * Config cleanup/refactor (#269) * Moved puppyprint define to graphics / rearranged some debug defines for ease of access * Moved compatibility safeguards to config_safeguards.h * spacing and comment formatting * #272 Move GFX_POOL_SIZE to config_graphics.h * disable EASIER_DIALOG_TRIGGER by default * prevent redefining warnings * small ifdef typo * changed ifndef to undefs Fixes #262 Fixes #272 * Improved movement config documentation related to turning around (#271) Fixes #270 * rename CUSTOM_DEBUG, add comments (#275) * Update README.md (#277) * v2.0.0 Co-authored-by: CrashOveride95 <crashoveride953@gmail.com> Co-authored-by: Arceveti <73617174+Arceveti@users.noreply.github.com> Co-authored-by: n64 <n64> Co-authored-by: Fazana <52551480+FazanaJ@users.noreply.github.com> Co-authored-by: Mr-Wiseguy <mrwiseguyromhacking@gmail.com> Co-authored-by: aglab2 <aglab3@gmail.com> Co-authored-by: gheskett <gheskett@gmail.com> Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Axollyon <20480418+Axollyon@users.noreply.github.com> Co-authored-by: Mr-Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com>
This commit is contained in:
924 files changed
+44258
-30676
No files matched your search
+209
-266
@@ -1,7 +1,5 @@
|
||||
#include <ultra64.h>
|
||||
|
||||
#ifdef VISUAL_DEBUG
|
||||
|
||||
/**
|
||||
* @file debug_box.c
|
||||
* Draws 3D boxes for debugging purposes
|
||||
@@ -23,6 +21,7 @@
|
||||
#include "game/game_init.h"
|
||||
#include "game/geo_misc.h"
|
||||
#include "engine/math_util.h"
|
||||
#include "engine/colors.h"
|
||||
#include "area.h"
|
||||
#include "level_update.h"
|
||||
#include "print.h"
|
||||
@@ -33,39 +32,41 @@
|
||||
|
||||
#include "debug_box.h"
|
||||
|
||||
#ifdef VISUAL_DEBUG
|
||||
|
||||
Vtx debug_box_mesh[32] = {
|
||||
{{{0, 0, -100},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{50, 100, -87},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{50, 0, -87},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{0, 100, -100},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-50, 0, -87},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-50, 100, -87},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-87, 0, -50},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-87, 100, -50},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-100, 0, 0},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-100, 100, 0},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-87, 0, 50},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-87, 100, 50},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-50, 0, 87},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-50, 100, 87},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{0, 0, 100},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{0, 100, 100},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{50, 0, 87},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{50, 100, 87},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{87, 0, 50},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{87, 100, 50},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{100, 0, 0},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{100, 100, 0},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{87, 0, -50},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{87, 100, -50},0, {-16, 1008},{0x0, 0x0, 0x0, 0xFF}}},
|
||||
{{{-100, 0, 100},0, {-16, 1008},{0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{-100, 100, 100},0, {-16, 1008},{0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{-100, 100, -100},0, {-16, 1008},{0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{100, 0, 100},0, {-16, 1008},{0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{-100, 0, -100},0, {-16, 1008},{0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{100, 100, -100},0, {-16, 1008},{0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{100, 100, 100},0, {-16, 1008},{0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{100, 0, -100},0, {-16, 1008},{0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{ 0, 0, -100}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 50, 100, -87}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 50, 0, -87}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 0, 100, -100}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -50, 0, -87}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -50, 100, -87}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -87, 0, -50}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -87, 100, -50}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -100, 0, 0}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -100, 100, 0}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -87, 0, 50}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -87, 100, 50}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -50, 0, 87}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -50, 100, 87}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 0, 0, 100}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 0, 100, 100}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 50, 0, 87}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 50, 100, 87}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 87, 0, 50}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 87, 100, 50}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 100, 0, 0}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 100, 100, 0}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 87, 0, -50}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ 87, 100, -50}, 0, ST_B( 0, 32), {0x00, 0x00, 0x00, 0xFF}}},
|
||||
{{{ -100, 0, 100}, 0, ST_B( 0, 32), {0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{ -100, 100, 100}, 0, ST_B( 0, 32), {0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{ -100, 100, -100}, 0, ST_B( 0, 32), {0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{ 100, 0, 100}, 0, ST_B( 0, 32), {0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{ -100, 0, -100}, 0, ST_B( 0, 32), {0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{ 100, 100, -100}, 0, ST_B( 0, 32), {0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{ 100, 100, 100}, 0, ST_B( 0, 32), {0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
{{{ 100, 0, -100}, 0, ST_B( 0, 32), {0xFF, 0xFF, 0xFF, 0xFF}}},
|
||||
};
|
||||
|
||||
Gfx dl_debug_box_verts[] = {
|
||||
@@ -81,27 +82,27 @@ Gfx dl_debug_box_verts[] = {
|
||||
|
||||
Gfx dl_debug_cylinder_verts[] = {
|
||||
gsSPVertex(debug_box_mesh, 24, 0),
|
||||
gsSP2Triangles(0, 1, 2, 0, 0, 3, 1, 0),
|
||||
gsSP2Triangles(4, 3, 0, 0, 4, 5, 3, 0),
|
||||
gsSP2Triangles(6, 5, 4, 0, 6, 7, 5, 0),
|
||||
gsSP2Triangles(8, 7, 6, 0, 8, 9, 7, 0),
|
||||
gsSP2Triangles(10, 9, 8, 0, 10, 11, 9, 0),
|
||||
gsSP2Triangles(12, 11, 10, 0, 12, 13, 11, 0),
|
||||
gsSP2Triangles(14, 13, 12, 0, 14, 15, 13, 0),
|
||||
gsSP2Triangles(16, 15, 14, 0, 16, 17, 15, 0),
|
||||
gsSP2Triangles(18, 17, 16, 0, 18, 19, 17, 0),
|
||||
gsSP2Triangles(20, 19, 18, 0, 20, 21, 19, 0),
|
||||
gsSP2Triangles(22, 21, 20, 0, 22, 23, 21, 0),
|
||||
gsSP2Triangles(2, 23, 22, 0, 2, 1, 23, 0),
|
||||
gsSP2Triangles(23, 1, 3, 0, 23, 3, 7, 0),
|
||||
gsSP2Triangles(3, 5, 7, 0, 7, 15, 23, 0),
|
||||
gsSP2Triangles(7, 11, 15, 0, 7, 9, 11, 0),
|
||||
gsSP2Triangles(11, 13, 15, 0, 15, 17, 19, 0),
|
||||
gsSP2Triangles(15, 19, 23, 0, 19, 21, 23, 0),
|
||||
gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0),
|
||||
gsSP2Triangles( 4, 3, 0, 0x0, 4, 5, 3, 0x0),
|
||||
gsSP2Triangles( 6, 5, 4, 0x0, 6, 7, 5, 0x0),
|
||||
gsSP2Triangles( 8, 7, 6, 0x0, 8, 9, 7, 0x0),
|
||||
gsSP2Triangles(10, 9, 8, 0x0, 10, 11, 9, 0x0),
|
||||
gsSP2Triangles(12, 11, 10, 0x0, 12, 13, 11, 0x0),
|
||||
gsSP2Triangles(14, 13, 12, 0x0, 14, 15, 13, 0x0),
|
||||
gsSP2Triangles(16, 15, 14, 0x0, 16, 17, 15, 0x0),
|
||||
gsSP2Triangles(18, 17, 16, 0x0, 18, 19, 17, 0x0),
|
||||
gsSP2Triangles(20, 19, 18, 0x0, 20, 21, 19, 0x0),
|
||||
gsSP2Triangles(22, 21, 20, 0x0, 22, 23, 21, 0x0),
|
||||
gsSP2Triangles( 2, 23, 22, 0x0, 2, 1, 23, 0x0),
|
||||
gsSP2Triangles(23, 1, 3, 0x0, 23, 3, 7, 0x0),
|
||||
gsSP2Triangles( 3, 5, 7, 0x0, 7, 15, 23, 0x0),
|
||||
gsSP2Triangles( 7, 11, 15, 0x0, 7, 9, 11, 0x0),
|
||||
gsSP2Triangles(11, 13, 15, 0x0, 15, 17, 19, 0x0),
|
||||
gsSP2Triangles(15, 19, 23, 0x0, 19, 21, 23, 0x0),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
u8 hitboxView = FALSE;
|
||||
u8 hitboxView = FALSE;
|
||||
u8 surfaceView = FALSE;
|
||||
|
||||
/**
|
||||
@@ -115,8 +116,7 @@ struct DebugBox {
|
||||
u8 type;
|
||||
};
|
||||
|
||||
struct DebugVert
|
||||
{
|
||||
struct DebugVert {
|
||||
Vec3s pos;
|
||||
Vec3f normal;
|
||||
};
|
||||
@@ -124,7 +124,7 @@ struct DebugVert
|
||||
struct DebugBox sBoxes[MAX_DEBUG_BOXES];
|
||||
s16 sNumBoxes = 0;
|
||||
|
||||
extern Mat4 gMatStack[32]; //XXX: Hack
|
||||
extern Mat4 gMatStack[32]; // XXX: Hack
|
||||
|
||||
/**
|
||||
* The debug boxes' default transparency
|
||||
@@ -138,12 +138,12 @@ extern Mat4 gMatStack[32]; //XXX: Hack
|
||||
/**
|
||||
* The color that new boxes will be drawn with.
|
||||
*/
|
||||
u32 sCurBoxColor = DBG_BOX_ALPHA << 24 | DBG_BOX_DEF_COLOR;
|
||||
u32 sCurBoxColor = ((DBG_BOX_ALPHA << 24) | DBG_BOX_DEF_COLOR);
|
||||
|
||||
/**
|
||||
* The allocated size of a rotated box's dl
|
||||
*/
|
||||
#define DBG_BOX_DLSIZE ((s32)(6 * sizeof(Gfx) + 8 * sizeof(Vtx)))
|
||||
#define DBG_BOX_DLSIZE ((s32)((6 * sizeof(Gfx)) + (8 * sizeof(Vtx))))
|
||||
|
||||
/**
|
||||
* Sets up the RCP for drawing the boxes
|
||||
@@ -153,38 +153,28 @@ static const Gfx dl_debug_box_begin[] = {
|
||||
gsDPSetRenderMode(G_RM_ZB_XLU_SURF, G_RM_NOOP2),
|
||||
gsSPClearGeometryMode(G_CULL_BACK),
|
||||
gsSPSetGeometryMode(G_ZBUFFER),
|
||||
gsSPTexture(0, 0, 0, 0, G_OFF),
|
||||
gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_OFF),
|
||||
gsDPSetCombineLERP(0, 0, 0, ENVIRONMENT, 0, 0, 0, ENVIRONMENT, 0, 0, 0, ENVIRONMENT, 0, 0, 0, ENVIRONMENT),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
static const Gfx dl_debug_box_begin_water[] = {
|
||||
gsDPPipeSync(),
|
||||
gsDPSetRenderMode(G_RM_ZB_XLU_SURF, G_RM_NOOP2),
|
||||
gsSPClearGeometryMode(G_LIGHTING),
|
||||
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH),
|
||||
gsSPTexture(0, 0, 0, 0, G_OFF),
|
||||
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
static const Gfx dl_debug_box_end[] = {
|
||||
gsDPPipeSync(),
|
||||
gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2),
|
||||
gsSPClearGeometryMode(G_LIGHTING | G_CULL_BACK),
|
||||
gsSPTexture(0, 0, 0, 0, G_OFF),
|
||||
gsDPSetCombineMode(G_CC_FADE, G_CC_FADE),
|
||||
gsDPSetEnvColor(0xFF, 0xFF, 0xFF, 0xFF),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
static const Gfx dl_visual_surface[] = {
|
||||
gsDPPipeSync(),
|
||||
gsDPSetRenderMode(G_RM_ZB_XLU_DECAL, G_RM_NOOP2),
|
||||
gsSPClearGeometryMode(G_LIGHTING),
|
||||
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH),
|
||||
gsSPTexture(0, 0, 0, 0, G_OFF),
|
||||
gsSPSetGeometryMode(G_ZBUFFER),
|
||||
gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_OFF),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
static const Gfx dl_debug_box_end[] = {
|
||||
gsDPPipeSync(),
|
||||
gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2),
|
||||
gsSPSetGeometryMode(G_LIGHTING | G_CULL_BACK),
|
||||
gsSPClearGeometryMode(G_ZBUFFER),
|
||||
gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_OFF),
|
||||
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
|
||||
gsDPSetEnvColor(0xFF, 0xFF, 0xFF, 0xFF),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
@@ -197,8 +187,8 @@ void debug_box_input(void) {
|
||||
if (viewCycle > 3) {
|
||||
viewCycle = 0;
|
||||
}
|
||||
hitboxView = (viewCycle == 1 || viewCycle == 3);
|
||||
surfaceView = (viewCycle == 2 || viewCycle == 3);
|
||||
hitboxView = viewCycle == 1 || viewCycle == 3;
|
||||
surfaceView = viewCycle == 2 || viewCycle == 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,197 +201,168 @@ void iterate_surfaces_visual(s32 x, s32 z, Vtx *verts) {
|
||||
struct SurfaceNode *node;
|
||||
struct Surface *surf;
|
||||
s32 i = 0;
|
||||
s32 col[3] = {0xFF, 0x00, 0x00};
|
||||
ColorRGB col = COLOR_RGB_RED;
|
||||
|
||||
if (x <= -LEVEL_BOUNDARY_MAX || x >= LEVEL_BOUNDARY_MAX) {
|
||||
return;
|
||||
}
|
||||
if (z <= -LEVEL_BOUNDARY_MAX || z >= LEVEL_BOUNDARY_MAX) {
|
||||
return;
|
||||
}
|
||||
if (is_outside_level_bounds(x, z)) return;
|
||||
|
||||
s32 cellX = GET_CELL_COORD(x);
|
||||
s32 cellZ = GET_CELL_COORD(z);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (i = 0; i < (2 * NUM_SPATIAL_PARTITIONS); i++) {
|
||||
switch (i) {
|
||||
case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; col[0] = 0x00; col[1] = 0xFF; col[2] = 0x00; break;
|
||||
case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; col[0] = 0x00; col[1] = 0xFF; col[2] = 0x00; break;
|
||||
case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; col[0] = 0x00; col[1] = 0x00; col[2] = 0xFF; break;
|
||||
case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; col[0] = 0x00; col[1] = 0x00; col[2] = 0xFF; break;
|
||||
case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; col[0] = 0xFF; col[1] = 0x00; col[2] = 0x00; break;
|
||||
case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; col[0] = 0xFF; col[1] = 0x00; col[2] = 0x00; break;
|
||||
case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; col[0] = 0xFF; col[1] = 0xFF; col[2] = 0x00; break;
|
||||
case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; col[0] = 0xFF; col[1] = 0xFF; col[2] = 0x00; break;
|
||||
case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_GREEN ); break;
|
||||
case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_GREEN ); break;
|
||||
case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_BLUE ); break;
|
||||
case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_BLUE ); break;
|
||||
case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_RED ); break;
|
||||
case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_RED ); break;
|
||||
case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_YELLOW); break;
|
||||
case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_YELLOW); break;
|
||||
}
|
||||
|
||||
while (node != NULL) {
|
||||
surf = node->surface;
|
||||
node = node->next;
|
||||
|
||||
if (surf->type >= SURFACE_INSTANT_WARP_1B && surf->type <= SURFACE_INSTANT_WARP_1E)
|
||||
{
|
||||
make_vertex(verts, gVisualSurfaceCount, surf->vertex1[0], surf->vertex1[1], surf->vertex1[2], 0, 0, 0xFF, 0xA0, 0x00, 0x80);
|
||||
make_vertex(verts, gVisualSurfaceCount+1, surf->vertex2[0], surf->vertex2[1], surf->vertex2[2], 0, 0, 0xFF, 0xA0, 0x00, 0x80);
|
||||
make_vertex(verts, gVisualSurfaceCount+2, surf->vertex3[0], surf->vertex3[1], surf->vertex3[2], 0, 0, 0xFF, 0xA0, 0x00, 0x80);
|
||||
}
|
||||
else
|
||||
{
|
||||
make_vertex(verts, gVisualSurfaceCount, surf->vertex1[0], surf->vertex1[1], surf->vertex1[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, gVisualSurfaceCount+1, surf->vertex2[0], surf->vertex2[1], surf->vertex2[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, gVisualSurfaceCount+2, surf->vertex3[0], surf->vertex3[1], surf->vertex3[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
if (SURFACE_IS_INSTANT_WARP(surf->type)) {
|
||||
make_vertex(verts, (gVisualSurfaceCount + 0), surf->vertex1[0], surf->vertex1[1], surf->vertex1[2], 0, 0, 0xFF, 0xA0, 0x00, 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 1), surf->vertex2[0], surf->vertex2[1], surf->vertex2[2], 0, 0, 0xFF, 0xA0, 0x00, 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 2), surf->vertex3[0], surf->vertex3[1], surf->vertex3[2], 0, 0, 0xFF, 0xA0, 0x00, 0x80);
|
||||
} else {
|
||||
make_vertex(verts, (gVisualSurfaceCount + 0), surf->vertex1[0], surf->vertex1[1], surf->vertex1[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 1), surf->vertex2[0], surf->vertex2[1], surf->vertex2[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 2), surf->vertex3[0], surf->vertex3[1], surf->vertex3[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
}
|
||||
|
||||
gVisualSurfaceCount+=3;
|
||||
gVisualSurfaceCount += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void iterate_surfaces_envbox(Vtx *verts)
|
||||
{
|
||||
void iterate_surfaces_envbox(Vtx *verts) {
|
||||
TerrainData *p = gEnvironmentRegions;
|
||||
s32 numRegions;
|
||||
s32 col[3] = {0xFF, 0xFF, 0x00};
|
||||
ColorRGB col = COLOR_RGB_YELLOW;
|
||||
s32 i = 0;
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
numRegions = *p++;
|
||||
for (i = 0; i < numRegions; i++)
|
||||
{
|
||||
make_vertex(verts, gVisualSurfaceCount, p[1], p[5], p[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, gVisualSurfaceCount+1, p[1], p[5], p[4], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, gVisualSurfaceCount+2, p[3], p[5], p[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
if (p != NULL) {
|
||||
s32 numRegions = *p++;
|
||||
for (i = 0; i < numRegions; i++) {
|
||||
make_vertex(verts, (gVisualSurfaceCount + 0), p[1], p[5], p[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 1), p[1], p[5], p[4], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 2), p[3], p[5], p[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
|
||||
make_vertex(verts, gVisualSurfaceCount+3, p[3], p[5], p[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, gVisualSurfaceCount+4, p[1], p[5], p[4], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, gVisualSurfaceCount+5, p[3], p[5], p[4], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 3), p[3], p[5], p[2], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 4), p[1], p[5], p[4], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
make_vertex(verts, (gVisualSurfaceCount + 5), p[3], p[5], p[4], 0, 0, col[0], col[1], col[2], 0x80);
|
||||
|
||||
gVisualSurfaceCount+=6;
|
||||
gVisualOffset+=6;
|
||||
p+= 6;
|
||||
gVisualSurfaceCount += 6;
|
||||
gVisualOffset += 6;
|
||||
p += 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(F3DEX_GBI_2) || defined(F3DEX_GBI)
|
||||
// VERTCOUNT = The highest number divisible by 6, which is less than the maximum vertex buffer divided by 2.
|
||||
// The vertex buffer is 64 if OBJECTS_REJ is enabled, 32 otherwise.
|
||||
//! TODO: Why can this only use half of the vertex buffer?
|
||||
#ifdef OBJECTS_REJ
|
||||
#define VERTCOUNT 30
|
||||
#else
|
||||
#define VERTCOUNT 12
|
||||
#endif // F3DEX_GBI_2
|
||||
#endif // OBJECTS_REJ
|
||||
|
||||
void visual_surface_display(Vtx *verts, s32 iteration)
|
||||
{
|
||||
s32 vts;
|
||||
void visual_surface_display(Vtx *verts, s32 iteration) {
|
||||
s32 vts = (iteration ? gVisualOffset : gVisualSurfaceCount);
|
||||
s32 vtl = 0;
|
||||
s32 count = VERTCOUNT;
|
||||
s32 ntx = 0;
|
||||
if (!iteration)
|
||||
{
|
||||
vts = gVisualSurfaceCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
vts = gVisualOffset;
|
||||
}
|
||||
|
||||
while (vts > 0)
|
||||
{
|
||||
if (count == VERTCOUNT)
|
||||
{
|
||||
while (vts > 0) {
|
||||
if (count == VERTCOUNT) {
|
||||
ntx = MIN(VERTCOUNT, vts);
|
||||
gSPVertex(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(verts + ((gVisualSurfaceCount)-vts)), ntx, 0);
|
||||
gSPVertex(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(verts + (gVisualSurfaceCount - vts)), ntx, 0);
|
||||
count = 0;
|
||||
vtl = VERTCOUNT;
|
||||
vtl = VERTCOUNT;
|
||||
}
|
||||
|
||||
if (vtl >= 6)
|
||||
{
|
||||
gSP2Triangles(gDisplayListHead++, count + 0, count + 1, count + 2, 0, count + 3, count + 4, count + 5, 0);
|
||||
vts -= 6;
|
||||
vtl -= 6;
|
||||
count+= 6;
|
||||
}
|
||||
else
|
||||
if (vtl >= 3)
|
||||
{
|
||||
gSP1Triangle(gDisplayListHead++, count + 0, count + 1, count + 2, 0);
|
||||
vts -= 3;
|
||||
vtl -= 6;
|
||||
count+= 3;
|
||||
if (vtl >= 6) {
|
||||
gSP2Triangles(gDisplayListHead++, (count + 0),
|
||||
(count + 1),
|
||||
(count + 2), 0x0,
|
||||
(count + 3),
|
||||
(count + 4),
|
||||
(count + 5), 0x0);
|
||||
vts -= 6;
|
||||
vtl -= 6;
|
||||
count += 6;
|
||||
} else if (vtl >= 3) {
|
||||
gSP1Triangle(gDisplayListHead++, (count + 0),
|
||||
(count + 1),
|
||||
(count + 2), 0x0);
|
||||
vts -= 3;
|
||||
vtl -= 3;
|
||||
count += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s32 iterate_surface_count(s32 x, s32 z)
|
||||
{
|
||||
s32 iterate_surface_count(s32 x, s32 z) {
|
||||
struct SurfaceNode *node;
|
||||
s32 i = 0;
|
||||
s32 j = 0;
|
||||
TerrainData *p = gEnvironmentRegions;
|
||||
s32 numRegions;
|
||||
|
||||
if (x <= -LEVEL_BOUNDARY_MAX || x >= LEVEL_BOUNDARY_MAX) {
|
||||
return 0;
|
||||
}
|
||||
if (z <= -LEVEL_BOUNDARY_MAX || z >= LEVEL_BOUNDARY_MAX) {
|
||||
return 0;
|
||||
}
|
||||
if (is_outside_level_bounds(x, z)) return 0;
|
||||
|
||||
s32 cellX = GET_CELL_COORD(x);
|
||||
s32 cellZ = GET_CELL_COORD(z);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next; break;
|
||||
case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next; break;
|
||||
case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; break;
|
||||
case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; break;
|
||||
case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next; break;
|
||||
case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next; break;
|
||||
case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER].next; break;
|
||||
case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER].next; break;
|
||||
for (i = 0; i < (2 * NUM_SPATIAL_PARTITIONS); i++) {
|
||||
switch (i) {
|
||||
case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; break;
|
||||
case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; break;
|
||||
case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; break;
|
||||
case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; break;
|
||||
case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; break;
|
||||
case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; break;
|
||||
case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; break;
|
||||
case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; break;
|
||||
}
|
||||
|
||||
while (node != NULL)
|
||||
{
|
||||
while (node != NULL) {
|
||||
node = node->next;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
if (p != NULL)
|
||||
{
|
||||
if (p != NULL) {
|
||||
numRegions = *p++;
|
||||
j += numRegions*6;
|
||||
j += (numRegions * 6);
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
void visual_surface_loop(void)
|
||||
{
|
||||
Vtx *verts;
|
||||
Mtx *mtx;
|
||||
|
||||
if (!gSurfaceNodesAllocated || !gSurfacesAllocated || !gMarioState->marioObj)
|
||||
void visual_surface_loop(void) {
|
||||
if (!gSurfaceNodesAllocated
|
||||
|| !gSurfacesAllocated
|
||||
|| !gMarioState->marioObj) {
|
||||
return;
|
||||
|
||||
mtx = alloc_display_list(sizeof(Mtx));
|
||||
verts = alloc_display_list((iterate_surface_count(gMarioState->pos[0], gMarioState->pos[2])*3) * sizeof(Vtx));
|
||||
}
|
||||
Mtx *mtx = alloc_display_list(sizeof(Mtx));
|
||||
Vtx *verts = alloc_display_list((iterate_surface_count(gMarioState->pos[0], gMarioState->pos[2]) * 3) * sizeof(Vtx));
|
||||
|
||||
gVisualSurfaceCount = 0;
|
||||
gVisualOffset = 0;
|
||||
gVisualOffset = 0;
|
||||
|
||||
if (mtx == NULL || verts == NULL)
|
||||
if ((mtx == NULL) || (verts == NULL)) {
|
||||
return;
|
||||
|
||||
}
|
||||
mtxf_to_mtx(mtx, gMatStack[1]);
|
||||
|
||||
gSPDisplayList(gDisplayListHead++, dl_visual_surface);
|
||||
|
||||
gSPMatrix(gDisplayListHead++, mtx, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
gSPMatrix(gDisplayListHead++, mtx, (G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH));
|
||||
|
||||
iterate_surfaces_visual(gMarioState->pos[0], gMarioState->pos[2], verts);
|
||||
|
||||
@@ -409,7 +370,7 @@ void visual_surface_loop(void)
|
||||
|
||||
iterate_surfaces_envbox(verts);
|
||||
|
||||
gSPDisplayList(gDisplayListHead++, dl_debug_box_begin_water);
|
||||
gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_NOOP2);
|
||||
|
||||
visual_surface_display(verts, 1);
|
||||
|
||||
@@ -422,26 +383,21 @@ void visual_surface_loop(void)
|
||||
*
|
||||
* If there are already MAX_DEBUG_BOXES boxes, does nothing.
|
||||
*/
|
||||
static void append_debug_box(Vec3f center, Vec3f bounds, s16 yaw, s32 type)
|
||||
{
|
||||
if (hitboxView)
|
||||
{
|
||||
if (sNumBoxes >= MAX_DEBUG_BOXES) {
|
||||
return;
|
||||
}
|
||||
static void append_debug_box(Vec3f center, Vec3f bounds, s16 yaw, s32 type) {
|
||||
if (hitboxView) {
|
||||
if (sNumBoxes >= MAX_DEBUG_BOXES) return;
|
||||
|
||||
vec3f_to_vec3s(sBoxes[sNumBoxes].center, center);
|
||||
vec3f_to_vec3s(sBoxes[sNumBoxes].bounds, bounds);
|
||||
|
||||
sBoxes[sNumBoxes].yaw = yaw;
|
||||
sBoxes[sNumBoxes].yaw = yaw;
|
||||
sBoxes[sNumBoxes].color = sCurBoxColor;
|
||||
sBoxes[sNumBoxes].type = type;
|
||||
if (!(sBoxes[sNumBoxes].type & DEBUG_UCODE_REJ) && !(sBoxes[sNumBoxes].type & DEBUG_UCODE_DEFAULT))
|
||||
sBoxes[sNumBoxes].type = type;
|
||||
if (!(sBoxes[sNumBoxes].type & (DEBUG_UCODE_REJ | DEBUG_UCODE_DEFAULT))) {
|
||||
sBoxes[sNumBoxes].type |= DEBUG_UCODE_DEFAULT;
|
||||
|
||||
}
|
||||
++sNumBoxes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,8 +406,7 @@ static void append_debug_box(Vec3f center, Vec3f bounds, s16 yaw, s32 type)
|
||||
* If the alpha component is zero, DBG_BOX_ALPHA (0x7f) will be used instead.
|
||||
* Ex: 0xFF0000 becomes 0x7FFF0000
|
||||
*/
|
||||
void debug_box_color(u32 color)
|
||||
{
|
||||
void debug_box_color(u32 color) {
|
||||
if ((color >> 24) == 0) color |= (DBG_BOX_ALPHA << 24);
|
||||
sCurBoxColor = color;
|
||||
}
|
||||
@@ -462,16 +417,14 @@ void debug_box_color(u32 color)
|
||||
*
|
||||
* @see debug_box_rot()
|
||||
*/
|
||||
void debug_box(Vec3f center, Vec3f bounds, s32 type)
|
||||
{
|
||||
void debug_box(Vec3f center, Vec3f bounds, s32 type) {
|
||||
append_debug_box(center, bounds, 0, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a debug box from (center - bounds) to (center + bounds), rotating it by `yaw`
|
||||
*/
|
||||
void debug_box_rot(Vec3f center, Vec3f bounds, s16 yaw, s32 type)
|
||||
{
|
||||
void debug_box_rot(Vec3f center, Vec3f bounds, s16 yaw, s32 type) {
|
||||
append_debug_box(center, bounds, yaw, type);
|
||||
}
|
||||
|
||||
@@ -481,95 +434,85 @@ void debug_box_rot(Vec3f center, Vec3f bounds, s16 yaw, s32 type)
|
||||
*
|
||||
* @see debug_box_pos_rot()
|
||||
*/
|
||||
void debug_box_pos(Vec3f pMin, Vec3f pMax, s32 type)
|
||||
{
|
||||
debug_box_pos_rot(pMin, pMax, 0, type);
|
||||
void debug_box_pos(Vec3f pMin, Vec3f pMax, s32 type) {
|
||||
debug_box_pos_rot(pMin, pMax, 0x0, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a debug box from pMin to pMax, rotating it in the xz-plane by `yaw`
|
||||
*/
|
||||
void debug_box_pos_rot(Vec3f pMin, Vec3f pMax, s16 yaw, s32 type)
|
||||
{
|
||||
void debug_box_pos_rot(Vec3f pMin, Vec3f pMax, s16 yaw, s32 type) {
|
||||
Vec3f center, bounds;
|
||||
|
||||
bounds[0] = (pMax[0] - pMin[0]) / 2.0f;
|
||||
bounds[1] = (pMax[1] - pMin[1]) / 2.0f;
|
||||
bounds[2] = (pMax[2] - pMin[2]) / 2.0f;
|
||||
bounds[0] = ((pMax[0] - pMin[0]) / 2.0f);
|
||||
bounds[1] = ((pMax[1] - pMin[1]) / 2.0f);
|
||||
bounds[2] = ((pMax[2] - pMin[2]) / 2.0f);
|
||||
|
||||
center[0] = pMin[0] + bounds[0];
|
||||
center[1] = pMin[1] + bounds[1];
|
||||
center[2] = pMin[2] + bounds[2];
|
||||
vec3f_sum(center, pMin, bounds);
|
||||
|
||||
append_debug_box(center, bounds, yaw, type);
|
||||
}
|
||||
|
||||
static void render_box(int index)
|
||||
{
|
||||
Mtx *translate;
|
||||
Mtx *rotate;
|
||||
Mtx *scale;
|
||||
Mtx *mtx;
|
||||
static void render_box(int index) {
|
||||
struct DebugBox *box = &sBoxes[index];
|
||||
s32 color = box->color;
|
||||
|
||||
// Translate to the origin, rotate, then translate back, effectively rotating the box about
|
||||
// its center
|
||||
mtx = alloc_display_list(sizeof(Mtx));
|
||||
translate = alloc_display_list(sizeof(Mtx));
|
||||
rotate = alloc_display_list(sizeof(Mtx));
|
||||
scale = alloc_display_list(sizeof(Mtx));
|
||||
// Translate to the origin, rotate, then translate back, effectively rotating the box about its center
|
||||
Mtx *mtx = alloc_display_list(sizeof(Mtx));
|
||||
Mtx *translate = alloc_display_list(sizeof(Mtx));
|
||||
Mtx *rotate = alloc_display_list(sizeof(Mtx));
|
||||
Mtx *scale = alloc_display_list(sizeof(Mtx));
|
||||
|
||||
if (mtx == NULL || translate == NULL || rotate == NULL || scale == NULL)
|
||||
return;
|
||||
if ((mtx == NULL)
|
||||
|| (translate == NULL)
|
||||
|| (rotate == NULL)
|
||||
|| (scale == NULL)) return;
|
||||
|
||||
mtxf_to_mtx(mtx, gMatStack[1]);
|
||||
guTranslate(translate, box->center[0], box->center[1], box->center[2]);
|
||||
guRotate(rotate, box->yaw / (float)0x10000 * 360.0f, 0, 1.0f, 0);
|
||||
guScale(scale, (f32) box->bounds[0]*0.01f, (f32) box->bounds[1]*0.01f, (f32) box->bounds[2]*0.01f);
|
||||
guRotate(rotate, ((box->yaw / (f32)0x10000) * 360.0f), 0, 1.0f, 0);
|
||||
guScale(scale, ((f32) box->bounds[0] * 0.01f),
|
||||
((f32) box->bounds[1] * 0.01f),
|
||||
((f32) box->bounds[2] * 0.01f));
|
||||
|
||||
gSPMatrix(gDisplayListHead++, mtx, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
gSPMatrix(gDisplayListHead++, translate, G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH);
|
||||
gSPMatrix(gDisplayListHead++, rotate, G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH);
|
||||
gSPMatrix(gDisplayListHead++, scale, G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH);
|
||||
gSPMatrix(gDisplayListHead++, mtx, (G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH));
|
||||
gSPMatrix(gDisplayListHead++, translate, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH));
|
||||
gSPMatrix(gDisplayListHead++, rotate, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH));
|
||||
gSPMatrix(gDisplayListHead++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH));
|
||||
|
||||
gDPSetEnvColor(gDisplayListHead++, (color >> 16) & 0xFF, (color >> 8) & 0xFF, (color) & 0xFF, (color >> 24) & 0xFF);
|
||||
gDPSetEnvColor(gDisplayListHead++, ((color >> 16) & 0xFF),
|
||||
((color >> 8) & 0xFF),
|
||||
((color ) & 0xFF),
|
||||
((color >> 24) & 0xFF));
|
||||
|
||||
if (box->type & DEBUG_SHAPE_BOX)
|
||||
{
|
||||
if (box->type & DEBUG_SHAPE_BOX) {
|
||||
gSPDisplayList(gDisplayListHead++, dl_debug_box_verts);
|
||||
}
|
||||
if (box->type & DEBUG_SHAPE_CYLINDER)
|
||||
{
|
||||
if (box->type & DEBUG_SHAPE_CYLINDER) {
|
||||
gSPDisplayList(gDisplayListHead++, dl_debug_cylinder_verts);
|
||||
}
|
||||
|
||||
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
||||
}
|
||||
|
||||
void render_debug_boxes(s32 type)
|
||||
{
|
||||
void render_debug_boxes(s32 type) {
|
||||
s32 i;
|
||||
|
||||
debug_box_color(DBG_BOX_DEF_COLOR);
|
||||
|
||||
if (sNumBoxes == 0)
|
||||
return;
|
||||
if (gAreaUpdateCounter < 3)
|
||||
return;
|
||||
if (sNumBoxes == 0) return;
|
||||
if (gAreaUpdateCounter < 3) return;
|
||||
|
||||
gSPDisplayList(gDisplayListHead++, dl_debug_box_begin);
|
||||
|
||||
for (i = 0; i < sNumBoxes; ++i) {
|
||||
if (type & DEBUG_UCODE_DEFAULT && sBoxes[i].type & DEBUG_UCODE_DEFAULT)
|
||||
render_box(i);
|
||||
if (type & DEBUG_UCODE_REJ && sBoxes[i].type & DEBUG_UCODE_REJ)
|
||||
render_box(i);
|
||||
if ((type & DEBUG_UCODE_DEFAULT) && (sBoxes[i].type & DEBUG_UCODE_DEFAULT)) render_box(i);
|
||||
if ((type & DEBUG_UCODE_REJ ) && (sBoxes[i].type & DEBUG_UCODE_REJ )) render_box(i);
|
||||
}
|
||||
|
||||
if (type & DEBUG_BOX_CLEAR)
|
||||
if (type & DEBUG_BOX_CLEAR) {
|
||||
sNumBoxes = 0;
|
||||
|
||||
}
|
||||
gSPDisplayList(gDisplayListHead++, dl_debug_box_end);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user