Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added 'bxt_show_monster_bbox' and optimized code for 'bxt_show_player_bbox' #439

Merged
merged 4 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BunnymodXT/cvars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
X(bxt_show_triggers_legacy_alpha, "120") \
X(bxt_show_pickup_bbox, "0") \
X(bxt_show_player_bbox, "0") \
X(bxt_show_monster_bbox, "0") \
X(bxt_disable_autosave, "0") \
X(bxt_disable_changelevel, "0") \
X(bxt_force_duck, "0") \
Expand Down
1 change: 1 addition & 0 deletions BunnymodXT/modules/ClientDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ void ClientDLL::RegisterCVarsAndCommands()
REG(bxt_show_nodes);
REG(bxt_show_pickup_bbox);
REG(bxt_show_player_bbox);
REG(bxt_show_monster_bbox);
REG(bxt_show_displacer_earth_targets);
REG(bxt_hud_useables);
REG(bxt_hud_useables_radius);
Expand Down
36 changes: 31 additions & 5 deletions BunnymodXT/triangle_drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,31 @@ namespace TriangleDrawing

pTriAPI->CullFace(TRI_NONE);

const auto& hw = HwDLL::GetInstance();
if (hw.sv_player)
{
if (CVars::bxt_show_player_bbox.GetInt() == 2)
{
pTriAPI->RenderMode(kRenderTransAdd);
pTriAPI->Color4f(0.0f, 1.0f, 0.0f, 0.1f);
TriangleUtils::DrawAACuboid(pTriAPI, (*hw.sv_player)->v.absmin, (*hw.sv_player)->v.absmax);
}
else
{
pTriAPI->RenderMode(kRenderTransColor);
pTriAPI->Color4f(0.0f, 1.0f, 0.0f, 1.0f);
TriangleUtils::DrawAACuboidWireframe(pTriAPI, (*hw.sv_player)->v.absmin, (*hw.sv_player)->v.absmax);
}
}
}

static void DrawMonsterAbsMinMax(triangleapi_s *pTriAPI)
{
if (!CVars::bxt_show_monster_bbox.GetBool())
return;

pTriAPI->CullFace(TRI_NONE);

const auto& hw = HwDLL::GetInstance();
const auto& server = ServerDLL::GetInstance();
const enginefuncs_t* engfuncs = server.pEngfuncs;
Expand All @@ -317,14 +342,14 @@ namespace TriangleDrawing
continue;
}

const char* classname = hw.GetString(ent->v.classname);
if (strcmp(classname, "player") == 0) {
if (ent->v.flags & FL_MONSTER)
{
pTriAPI->RenderMode(kRenderTransColor);
pTriAPI->Color4f(0.0f, 1.0f, 0.0f, 1.0f);
pTriAPI->Color4f(1.0f, 0.75f, 0.8f, 1.0f);
TriangleUtils::DrawAACuboidWireframe(pTriAPI, ent->v.absmin, ent->v.absmax);
if (CVars::bxt_show_player_bbox.GetInt() == 2) {
if (CVars::bxt_show_monster_bbox.GetInt() == 2) {
pTriAPI->RenderMode(kRenderTransAdd);
pTriAPI->Color4f(0.0f, 1.0f, 0.0f, 0.1f);
pTriAPI->Color4f(1.0f, 0.75f, 0.8f, 0.1f);
TriangleUtils::DrawAACuboid(pTriAPI, ent->v.absmin, ent->v.absmax);
}
continue;
Expand Down Expand Up @@ -2345,6 +2370,7 @@ namespace TriangleDrawing
DrawCustomTriggers(pTriAPI);
DrawAbsMinMax(pTriAPI);
DrawPlayerAbsMinMax(pTriAPI);
DrawMonsterAbsMinMax(pTriAPI);
DrawBulletsEnemyTrace(pTriAPI);
DrawBulletsPlayerTrace(pTriAPI);
DrawSplits(pTriAPI);
Expand Down