Improved Collision Viewer (#435)

* Add fishing pole as sword in save editor

Adds fishing pole as a sword to the save editor under current equipment.

* Improve Collision Viewer

Made all the values of the collision viewer persistent.
Switched all color pickers to the EnhancementColor picker.
Added a checkbox to enable/disable collision viewer.

* Update SohImGuiImpl.cpp

Probably fixed linux build error

* Update colViewer.cpp

Hopefully fixed it this time. Lets wait for jenkins.

* Fixed colors

Some color values were wrong

* Update SohImGuiImpl.cpp &  SohImGuiImpl.h
This commit is contained in:
getBrainError 2022-06-17 02:40:27 +02:00 committed by GitHub
parent bf0935a5a2
commit 3d24f3f595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 117 additions and 114 deletions

View File

@ -93,7 +93,7 @@ namespace SohImGui {
"gCCHeartsPrim","gDDCCHeartsPrim", "gCCHeartsPrim","gDDCCHeartsPrim",
"gCCABtnPrim","gCCBBtnPrim","gCCCBtnPrim","gCCStartBtnPrim", "gCCABtnPrim","gCCBBtnPrim","gCCCBtnPrim","gCCStartBtnPrim",
"gCCMagicBorderPrim","gCCMagicPrim","gCCMagicUsePrim", "gCCMagicBorderPrim","gCCMagicPrim","gCCMagicUsePrim",
"gCCMinimapPrim","gCCRupeePrim","gCCKeysPrim" "gCCMinimapPrim","gCCRupeePrim","gCCKeysPrim"
}; };
const char* filters[3] = { const char* filters[3] = {
@ -556,6 +556,20 @@ namespace SohImGui {
} }
} }
void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector<std::string>& items, int defaultValue) {
if (ImGui::BeginCombo(name.c_str(), items[static_cast<int>(CVar_GetS32(cvarName, defaultValue))].c_str())) {
for (int settingIndex = 0; settingIndex < (int) items.size(); settingIndex++) {
if (ImGui::Selectable(items[settingIndex].c_str())) {
CVar_SetS32(cvarName, settingIndex);
needs_save = true;
}
}
ImGui::EndCombo();
}
}
void RandomizeColor(const char* cvarName, ImVec4* colors) { void RandomizeColor(const char* cvarName, ImVec4* colors) {
std::string Cvar_Red = cvarName; std::string Cvar_Red = cvarName;
Cvar_Red += "R"; Cvar_Red += "R";

View File

@ -72,6 +72,7 @@ namespace SohImGui {
void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage); void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage);
void EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue); void EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue);
void EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false); void EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false);
void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector<std::string>& items, int defaultValue = 0);
void DrawMainMenuAndCalculateGameSize(void); void DrawMainMenuAndCalculateGameSize(void);

View File

@ -6,6 +6,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <cmath> #include <cmath>
#include <Cvar.h>
extern "C" { extern "C" {
#include <z64.h> #include <z64.h>
@ -15,40 +16,27 @@ extern "C" {
extern GlobalContext* gGlobalCtx; extern GlobalContext* gGlobalCtx;
} }
enum class ColRenderSetting { enum class ColRenderSetting { Disabled, Solid, Transparent };
Disabled,
Solid,
Transparent,
NumSettings
};
std::string ColRenderSettingNames[] = { std::vector<std::string> ColRenderSettingNames = {
"Disabled", "Disabled",
"Solid", "Solid",
"Transparent", "Transparent",
}; };
static ColRenderSetting showSceneColSetting = ColRenderSetting::Disabled; ImVec4 scene_col;
static ColRenderSetting showBgActorSetting = ColRenderSetting::Disabled; ImVec4 hookshot_col;
static ColRenderSetting showColCheckSetting = ColRenderSetting::Disabled; ImVec4 entrance_col;
static ColRenderSetting showWaterboxSetting = ColRenderSetting::Disabled; ImVec4 specialSurface_col;
ImVec4 interactable_col;
ImVec4 slope_col;
ImVec4 void_col;
static uint32_t sceneColor = 0xFFFFFFFF; ImVec4 oc_col;
static uint32_t hookshotColor = 0x8080FFFF; ImVec4 ac_col;
static uint32_t entranceColor = 0x00FF00FF; ImVec4 at_col;
static uint32_t specialSurfaceColor = 0xC0FFC0FF;
static uint32_t interactableColor = 0xC000C0FF;
static uint32_t slopeColor = 0xFFFF80FF;
static uint32_t voidColor = 0xFF0000FF;
static uint32_t ocColor = 0xFFFFFFFF; ImVec4 waterbox_col;
static uint32_t acColor = 0x0000FFFF;
static uint32_t atColor = 0xFF0000FF;
static uint32_t waterboxColor = 0x0000FFFF;
static bool applyAsDecal = false;
static bool isShaded = false;
static std::vector<Gfx> opaDl; static std::vector<Gfx> opaDl;
static std::vector<Gfx> xluDl; static std::vector<Gfx> xluDl;
@ -62,35 +50,6 @@ static std::vector<Vtx> cylinderVtx;
static std::vector<Gfx> sphereGfx; static std::vector<Gfx> sphereGfx;
static std::vector<Vtx> sphereVtx; static std::vector<Vtx> sphereVtx;
// Create a dropdown menu to set a ColRenderSetting
void DrawColRenderSetting(const std::string& name, ColRenderSetting& setting) {
if (ImGui::BeginCombo(name.c_str(), ColRenderSettingNames[static_cast<int>(setting)].c_str())) {
for (int32_t settingIndex = 0; settingIndex < static_cast<int>(ColRenderSetting::NumSettings); settingIndex++) {
if (ImGui::Selectable(ColRenderSettingNames[settingIndex].c_str())) {
setting = static_cast<ColRenderSetting>(settingIndex);
}
}
ImGui::EndCombo();
}
}
// Draw a color picker box
void DrawColorPicker(const std::string& name, uint32_t& color) {
float colorAsFloat[4];
colorAsFloat[0] = ((color >> 24) & 0xFF) / 255.0f;
colorAsFloat[1] = ((color >> 16) & 0xFF) / 255.0f;
colorAsFloat[2] = ((color >> 8) & 0xFF) / 255.0f;
colorAsFloat[3] = (color & 0xFF) / 255.0f;
if (ImGui::ColorEdit4(name.c_str(), colorAsFloat, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel)) {
color = static_cast<uint8_t>(colorAsFloat[3] * 255) |
static_cast<uint8_t>(colorAsFloat[2] * 255) << 8 |
static_cast<uint8_t>(colorAsFloat[1] * 255) << 16 |
static_cast<uint8_t>(colorAsFloat[0] * 255) << 24;
}
ImGui::SameLine();
ImGui::Text(name.c_str());
}
// Draws the ImGui window for the collision viewer // Draws the ImGui window for the collision viewer
void DrawColViewerWindow(bool& open) { void DrawColViewerWindow(bool& open) {
if (!open) { if (!open) {
@ -102,16 +61,17 @@ void DrawColViewerWindow(bool& open) {
ImGui::End(); ImGui::End();
return; return;
} }
SohImGui::EnhancementCheckbox("Enabled", "gColViewerEnabled");
DrawColRenderSetting("Scene", showSceneColSetting); SohImGui::EnhancementCombo("Scene", "gColViewerScene", ColRenderSettingNames);
DrawColRenderSetting("Bg Actors", showBgActorSetting); SohImGui::EnhancementCombo("Bg Actors", "gColViewerBgActors", ColRenderSettingNames);
DrawColRenderSetting("Col Check", showColCheckSetting); SohImGui::EnhancementCombo("Col Check", "gColViewerColCheck", ColRenderSettingNames);
DrawColRenderSetting("Waterbox", showWaterboxSetting); SohImGui::EnhancementCombo("Waterbox", "gColViewerWaterbox", ColRenderSettingNames);
ImGui::Checkbox("Apply as decal", &applyAsDecal); SohImGui::EnhancementCheckbox("Apply as decal", "gColViewerDecal");
InsertHelpHoverText("Applies the collision as a decal display. This can be useful if there is z-fighting occuring " InsertHelpHoverText("Applies the collision as a decal display. This can be useful if there is z-fighting occuring "
"with the scene geometry, but can cause other artifacts."); "with the scene geometry, but can cause other artifacts.");
ImGui::Checkbox("Shaded", &isShaded); SohImGui::EnhancementCheckbox("Shaded", "gColViewerShaded");
InsertHelpHoverText("Applies the scene's shading to the collision display."); InsertHelpHoverText("Applies the scene's shading to the collision display.");
// This has to be duplicated in both code paths due to the nature of ImGui::IsItemHovered() // This has to be duplicated in both code paths due to the nature of ImGui::IsItemHovered()
@ -119,17 +79,20 @@ void DrawColViewerWindow(bool& open) {
if (ImGui::TreeNode("Colors")) { if (ImGui::TreeNode("Colors")) {
InsertHelpHoverText(colorHelpText); InsertHelpHoverText(colorHelpText);
DrawColorPicker("Normal", sceneColor); SohImGui::EnhancementColor("Normal", "gColViewerColorNormal", scene_col, ImVec4(255, 255, 255, 255), false);
DrawColorPicker("Hookshot", hookshotColor); SohImGui::EnhancementColor("Hookshot", "gColViewerColorHookshot", hookshot_col, ImVec4(128, 128, 255, 255),
DrawColorPicker("Entrance", entranceColor); false);
DrawColorPicker("Special Surface (Grass/Sand/Etc)", specialSurfaceColor); SohImGui::EnhancementColor("Entrance", "gColViewerColorEntrance", entrance_col, ImVec4(0, 255, 0, 255), false);
DrawColorPicker("Interactable (Vines/Crawlspace/Etc)", interactableColor); SohImGui::EnhancementColor("Special Surface (Grass/Sand/Etc)", "gColViewerColorSpecialSurface",
DrawColorPicker("Slope", slopeColor); specialSurface_col, ImVec4(192, 255, 192, 255), false);
DrawColorPicker("Void", voidColor); SohImGui::EnhancementColor("Interactable (Vines/Crawlspace/Etc)", "gColViewerColorInteractable",
DrawColorPicker("OC", ocColor); interactable_col, ImVec4(192, 0, 192, 255), false);
DrawColorPicker("AC", acColor); SohImGui::EnhancementColor("Slope", "gColViewerColorSlope", slope_col, ImVec4(255, 255, 128, 255), false);
DrawColorPicker("AT", atColor); SohImGui::EnhancementColor("Void", "gColViewerColorVoid", void_col, ImVec4(255, 0, 0, 255), false);
DrawColorPicker("Waterbox", waterboxColor); SohImGui::EnhancementColor("OC", "gColViewerColorOC", oc_col, ImVec4(255, 255, 255, 255), false);
SohImGui::EnhancementColor("AC", "gColViewerColorAC", ac_col, ImVec4(0, 0, 255, 255), false);
SohImGui::EnhancementColor("AT", "gColViewerColorAT", at_col, ImVec4(255, 0, 0, 255), false);
SohImGui::EnhancementColor("Waterbox", "gColViewerColorWaterbox", waterbox_col, ImVec4(0, 0, 255, 255), false);
ImGui::TreePop(); ImGui::TreePop();
} else { } else {
@ -161,13 +124,12 @@ void CalcTriNorm(const Vec3f& v1, const Vec3f& v2, const Vec3f& v3, Vec3f& norm)
.n = {.ob = { x, y, z }, .tc = { qs105(s), qs105(t) }, .n = { nx, ny, nz }, .a = ca } \ .n = {.ob = { x, y, z }, .tc = { qs105(s), qs105(t) }, .n = { nx, ny, nz }, .a = ca } \
} }
void CreateCylinderData() { void CreateCylinderData() {
constexpr int32_t CYL_DIVS = 12; constexpr int32_t CYL_DIVS = 12;
cylinderGfx.reserve(5 + CYL_DIVS * 2); cylinderGfx.reserve(5 + CYL_DIVS * 2);
cylinderVtx.reserve(2 + CYL_DIVS * 2); cylinderVtx.reserve(2 + CYL_DIVS * 2);
cylinderVtx.push_back(gdSPDefVtxN(0, 0, 0, 0, 0, 0, -127, 0, 0xFF)); // Bottom center vertex cylinderVtx.push_back(gdSPDefVtxN(0, 0, 0, 0, 0, 0, -127, 0, 0xFF)); // Bottom center vertex
cylinderVtx.push_back(gdSPDefVtxN(0, 128, 0, 0, 0, 0, 127, 0, 0xFF)); // Top center vertex cylinderVtx.push_back(gdSPDefVtxN(0, 128, 0, 0, 0, 0, 127, 0, 0xFF)); // Top center vertex
// Create two rings of vertices // Create two rings of vertices
for (int i = 0; i < CYL_DIVS; ++i) { for (int i = 0; i < CYL_DIVS; ++i) {
@ -210,9 +172,10 @@ void CreateCylinderData() {
cylinderGfx.push_back(gsSPEndDisplayList()); cylinderGfx.push_back(gsSPEndDisplayList());
} }
// This subdivides a face into four tris by placing new verticies at the midpoints of the sides (Like a triforce!), then blowing up the // This subdivides a face into four tris by placing new verticies at the midpoints of the sides (Like a triforce!), then
// verticies so they are on the unit sphere // blowing up the verticies so they are on the unit sphere
void CreateSphereFace(std::vector<std::tuple<size_t, size_t, size_t>>& faces, int32_t v0Index, int32_t v1Index, int32_t v2Index) { void CreateSphereFace(std::vector<std::tuple<size_t, size_t, size_t>>& faces, int32_t v0Index, int32_t v1Index,
int32_t v2Index) {
size_t nextIndex = sphereVtx.size(); size_t nextIndex = sphereVtx.size();
size_t v01Index = nextIndex; size_t v01Index = nextIndex;
@ -248,9 +211,9 @@ void CreateSphereFace(std::vector<std::tuple<size_t, size_t, size_t>>& faces, in
} }
} }
// Creates a sphere following the idea in here: http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html // Creates a sphere following the idea in here:
// Spcifically, create a icosahedron by realizing that the points can be placed on 3 rectangles that are on each unit plane. // http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html Spcifically, create a icosahedron by
// Then, subdividing each face. // realizing that the points can be placed on 3 rectangles that are on each unit plane. Then, subdividing each face.
void CreateSphereData() { void CreateSphereData() {
std::vector<Vec3f> base; std::vector<Vec3f> base;
@ -351,7 +314,7 @@ void InitGfx(std::vector<Gfx>& gfx, ColRenderSetting setting) {
alpha = 0xFF; alpha = 0xFF;
} }
if (applyAsDecal) { if (CVar_GetS32("gColViewerDecal", 0) != 0) {
rm |= ZMODE_DEC; rm |= ZMODE_DEC;
} else if (setting == ColRenderSetting::Transparent) { } else if (setting == ColRenderSetting::Transparent) {
rm |= ZMODE_XLU; rm |= ZMODE_XLU;
@ -363,7 +326,7 @@ void InitGfx(std::vector<Gfx>& gfx, ColRenderSetting setting) {
gfx.push_back(gsDPSetCycleType(G_CYC_1CYCLE)); gfx.push_back(gsDPSetCycleType(G_CYC_1CYCLE));
gfx.push_back(gsDPSetRenderMode(rm | blc1, rm | blc2)); gfx.push_back(gsDPSetRenderMode(rm | blc1, rm | blc2));
if (isShaded) { if (CVar_GetS32("gColViewerShaded", 0) != 0) {
gfx.push_back(gsDPSetCombineMode(G_CC_MODULATERGB_PRIM_ENVA, G_CC_MODULATERGB_PRIM_ENVA)); gfx.push_back(gsDPSetCombineMode(G_CC_MODULATERGB_PRIM_ENVA, G_CC_MODULATERGB_PRIM_ENVA));
gfx.push_back(gsSPLoadGeometryMode(G_CULL_BACK | G_ZBUFFER | G_LIGHTING)); gfx.push_back(gsSPLoadGeometryMode(G_CULL_BACK | G_ZBUFFER | G_LIGHTING));
} else { } else {
@ -376,10 +339,16 @@ void InitGfx(std::vector<Gfx>& gfx, ColRenderSetting setting) {
// Draws a dynapoly structure (scenes or Bg Actors) // Draws a dynapoly structure (scenes or Bg Actors)
void DrawDynapoly(std::vector<Gfx>& dl, CollisionHeader* col, int32_t bgId) { void DrawDynapoly(std::vector<Gfx>& dl, CollisionHeader* col, int32_t bgId) {
uint32_t color = sceneColor; uint32_t colorR = CVar_GetS32("gColViewerColorNormalR", 255);
uint32_t lastColor = color; uint32_t colorG = CVar_GetS32("gColViewerColorNormalG", 255);
dl.push_back(gsDPSetPrimColor(0, 0, (color >> 24) & 0xFF, (color >> 16) & 0xFF, (color >> 8) & 0xFF, uint32_t colorB = CVar_GetS32("gColViewerColorNormalB", 255);
(color >> 0) & 0xFF)); uint32_t colorA = 255;
uint32_t lastColorR = colorR;
uint32_t lastColorG = colorG;
uint32_t lastColorB = colorB;
dl.push_back(gsDPSetPrimColor(0, 0, colorR, colorG, colorB, colorA));
// This keeps track of if we have processed a poly, but not drawn it yet so we can batch them. // This keeps track of if we have processed a poly, but not drawn it yet so we can batch them.
// This saves several hundred commands in larger scenes // This saves several hundred commands in larger scenes
@ -389,34 +358,49 @@ void DrawDynapoly(std::vector<Gfx>& dl, CollisionHeader* col, int32_t bgId) {
CollisionPoly* poly = &col->polyList[i]; CollisionPoly* poly = &col->polyList[i];
if (SurfaceType_IsHookshotSurface(&gGlobalCtx->colCtx, poly, bgId)) { if (SurfaceType_IsHookshotSurface(&gGlobalCtx->colCtx, poly, bgId)) {
color = hookshotColor; colorR = CVar_GetS32("gColViewerColorHookshotR", 128);
colorG = CVar_GetS32("gColViewerColorHookshotG", 128);
colorB = CVar_GetS32("gColViewerColorHookshotB", 255);
} else if (func_80041D94(&gGlobalCtx->colCtx, poly, bgId) > 0x01) { } else if (func_80041D94(&gGlobalCtx->colCtx, poly, bgId) > 0x01) {
color = interactableColor; colorR = CVar_GetS32("gColViewerColorInteractableR", 192);
colorG = CVar_GetS32("gColViewerColorInteractableG", 0);
colorB = CVar_GetS32("gColViewerColorInteractableB", 192);
} else if (func_80041E80(&gGlobalCtx->colCtx, poly, bgId) == 0x0C) { } else if (func_80041E80(&gGlobalCtx->colCtx, poly, bgId) == 0x0C) {
color = voidColor; colorR = CVar_GetS32("gColViewerColorVoidR", 255);
colorG = CVar_GetS32("gColViewerColorVoidG", 0);
colorB = CVar_GetS32("gColViewerColorVoidB", 0);
} else if (SurfaceType_GetSceneExitIndex(&gGlobalCtx->colCtx, poly, bgId) || } else if (SurfaceType_GetSceneExitIndex(&gGlobalCtx->colCtx, poly, bgId) ||
func_80041E80(&gGlobalCtx->colCtx, poly, bgId) == 0x05) { func_80041E80(&gGlobalCtx->colCtx, poly, bgId) == 0x05) {
color = entranceColor; colorR = CVar_GetS32("gColViewerColorEntranceR", 0);
colorG = CVar_GetS32("gColViewerColorEntranceG", 255);
colorB = CVar_GetS32("gColViewerColorEntranceB", 0);
} else if (func_80041D4C(&gGlobalCtx->colCtx, poly, bgId) != 0 || } else if (func_80041D4C(&gGlobalCtx->colCtx, poly, bgId) != 0 ||
SurfaceType_IsWallDamage(&gGlobalCtx->colCtx, poly, bgId)) { SurfaceType_IsWallDamage(&gGlobalCtx->colCtx, poly, bgId)) {
color = specialSurfaceColor; colorR = CVar_GetS32("gColViewerColorSpecialSurfaceR", 192);
colorG = CVar_GetS32("gColViewerColorSpecialSurfaceG", 255);
colorB = CVar_GetS32("gColViewerColorSpecialSurfaceB", 192);
} else if (SurfaceType_GetSlope(&gGlobalCtx->colCtx, poly, bgId) == 0x01) { } else if (SurfaceType_GetSlope(&gGlobalCtx->colCtx, poly, bgId) == 0x01) {
color = slopeColor; colorR = CVar_GetS32("gColViewerColorSlopeR", 255);
colorG = CVar_GetS32("gColViewerColorSlopeG", 255);
colorB = CVar_GetS32("gColViewerColorSlopeB", 128);
} else { } else {
color = sceneColor; colorR = CVar_GetS32("gColViewerColorNormalR", 255);
colorG = CVar_GetS32("gColViewerColorNormalG", 255);
colorB = CVar_GetS32("gColViewerColorNormalB", 255);
} }
if (lastColor != color) { if (colorR != lastColorR || colorG != lastColorG || colorB != lastColorB) {
// Color changed, flush previous poly // Color changed, flush previous poly
if (previousPoly) { if (previousPoly) {
dl.push_back(gsSPVertex((uintptr_t)&vtxDl.at(vtxDl.size() - 3), 3, 0)); dl.push_back(gsSPVertex((uintptr_t)&vtxDl.at(vtxDl.size() - 3), 3, 0));
dl.push_back(gsSP1Triangle(0, 1, 2, 0)); dl.push_back(gsSP1Triangle(0, 1, 2, 0));
previousPoly = false; previousPoly = false;
} }
dl.push_back(gsDPSetPrimColor(0, 0, (color >> 24) & 0xFF, (color >> 16) & 0xFF, (color >> 8) & 0xFF, dl.push_back(gsDPSetPrimColor(0, 0, colorR, colorG, colorB, colorA));
(color >> 0) & 0xFF));
} }
lastColor = color; lastColorR = colorR;
lastColorG = colorG;
lastColorB = colorB;
Vec3s* va = &col->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)]; Vec3s* va = &col->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)];
Vec3s* vb = &col->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)]; Vec3s* vb = &col->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)];
@ -450,7 +434,9 @@ void DrawDynapoly(std::vector<Gfx>& dl, CollisionHeader* col, int32_t bgId) {
// Draws the scene // Draws the scene
void DrawSceneCollision() { void DrawSceneCollision() {
if (showSceneColSetting == ColRenderSetting::Disabled) { ColRenderSetting showSceneColSetting = (ColRenderSetting)CVar_GetS32("gColViewerScene", 0);
if (showSceneColSetting == ColRenderSetting::Disabled || CVar_GetS32("gColViewerEnabled", 0) == 0) {
return; return;
} }
@ -463,7 +449,8 @@ void DrawSceneCollision() {
// Draws all Bg Actors // Draws all Bg Actors
void DrawBgActorCollision() { void DrawBgActorCollision() {
if (showBgActorSetting == ColRenderSetting::Disabled) { ColRenderSetting showBgActorSetting = (ColRenderSetting)CVar_GetS32("gColViewerBgActors", 0);
if (showBgActorSetting == ColRenderSetting::Disabled || CVar_GetS32("gColViewerEnabled", 0) == 0) {
return; return;
} }
@ -489,7 +476,6 @@ void DrawBgActorCollision() {
dl.push_back(gsSPPopMatrix(G_MTX_MODELVIEW)); dl.push_back(gsSPPopMatrix(G_MTX_MODELVIEW));
} }
} }
} }
// Draws a quad // Draws a quad
@ -588,7 +574,8 @@ void DrawColCheckList(std::vector<Gfx>& dl, Collider** objects, int32_t count) {
// Draws all Col Check objects // Draws all Col Check objects
void DrawColCheckCollision() { void DrawColCheckCollision() {
if (showColCheckSetting == ColRenderSetting::Disabled) { ColRenderSetting showColCheckSetting = (ColRenderSetting)CVar_GetS32("gColViewerColCheck", 0);
if (showColCheckSetting == ColRenderSetting::Disabled || CVar_GetS32("gColViewerEnabled", 0) == 0) {
return; return;
} }
@ -598,16 +585,15 @@ void DrawColCheckCollision() {
CollisionCheckContext& col = gGlobalCtx->colChkCtx; CollisionCheckContext& col = gGlobalCtx->colChkCtx;
dl.push_back(gsDPSetPrimColor(0, 0, (ocColor >> 24) & 0xFF, (ocColor >> 16) & 0xFF, (ocColor >> 8) & 0xFF, dl.push_back(gsDPSetPrimColor(0, 0, CVar_GetS32("gColViewerColorOCR", 255), CVar_GetS32("gColViewerColorOCG", 255),
(ocColor >> 0) & 0xFF)); CVar_GetS32("gColViewerColorOCB", 255), 255));
DrawColCheckList(dl, col.colOC, col.colOCCount); DrawColCheckList(dl, col.colOC, col.colOCCount);
dl.push_back(gsDPSetPrimColor(0, 0, CVar_GetS32("gColViewerColorACR", 0), CVar_GetS32("gColViewerColorACG", 0),
dl.push_back(gsDPSetPrimColor(0, 0, (acColor >> 24) & 0xFF, (acColor >> 16) & 0xFF, (acColor >> 8) & 0xFF, CVar_GetS32("gColViewerColorACB", 255), 255));
(acColor >> 0) & 0xFF));
DrawColCheckList(dl, col.colAC, col.colACCount); DrawColCheckList(dl, col.colAC, col.colACCount);
dl.push_back(gsDPSetPrimColor(0, 0, CVar_GetS32("gColViewerColorATR", 255), CVar_GetS32("gColViewerColorATG", 0),
CVar_GetS32("gColViewerColorATB", 0), 255));
dl.push_back(gsDPSetPrimColor(0, 0, (atColor >> 24) & 0xFF, (atColor >> 16) & 0xFF, (atColor >> 8) & 0xFF,
(atColor >> 0) & 0xFF));
DrawColCheckList(dl, col.colAT, col.colATCount); DrawColCheckList(dl, col.colAT, col.colATCount);
} }
@ -641,15 +627,18 @@ extern "C" f32 zdWaterBoxMinY;
// Draws all waterboxes // Draws all waterboxes
void DrawWaterboxList() { void DrawWaterboxList() {
if (showWaterboxSetting == ColRenderSetting::Disabled) { ColRenderSetting showWaterboxSetting = (ColRenderSetting)CVar_GetS32("gColViewerWaterbox", 0);
if (showWaterboxSetting == ColRenderSetting::Disabled || CVar_GetS32("gColViewerEnabled", 0) == 0) {
return; return;
} }
std::vector<Gfx>& dl = (showWaterboxSetting == ColRenderSetting::Transparent) ? xluDl : opaDl; std::vector<Gfx>& dl = (showWaterboxSetting == ColRenderSetting::Transparent) ? xluDl : opaDl;
InitGfx(dl, showWaterboxSetting); InitGfx(dl, showWaterboxSetting);
dl.push_back(gsSPMatrix(&gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH)); dl.push_back(gsSPMatrix(&gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH));
dl.push_back(gsDPSetPrimColor(0, 0, (waterboxColor >> 24) & 0xFF, (waterboxColor >> 16) & 0xFF,
(waterboxColor >> 8) & 0xFF, (waterboxColor >> 0) & 0xFF)); dl.push_back(gsDPSetPrimColor(0, 0, CVar_GetS32("gColViewerColorWaterboxR", 0),
CVar_GetS32("gColViewerColorWaterboxG", 0),
CVar_GetS32("gColViewerColorWaterboxB", 255), 255));
CollisionHeader* col = gGlobalCtx->colCtx.colHeader; CollisionHeader* col = gGlobalCtx->colCtx.colHeader;
for (int32_t waterboxIndex = 0; waterboxIndex < col->numWaterBoxes; waterboxIndex++) { for (int32_t waterboxIndex = 0; waterboxIndex < col->numWaterBoxes; waterboxIndex++) {
@ -664,8 +653,7 @@ void DrawWaterboxList() {
} }
// Resets a vector for the next frame and returns the capacity // Resets a vector for the next frame and returns the capacity
template<typename T> template <typename T> size_t ResetVector(T& vec) {
size_t ResetVector(T& vec) {
size_t oldSize = vec.size(); size_t oldSize = vec.size();
vec.clear(); vec.clear();
// Reserve slightly more space than last frame to account for variance (such as different amounts of bg actors) // Reserve slightly more space than last frame to account for variance (such as different amounts of bg actors)