From ed2c68c53756e4d9864523312164b1d76a70e847 Mon Sep 17 00:00:00 2001 From: SmileyAG <58108407+SmileyAG@users.noreply.github.com> Date: Mon, 1 Jul 2024 07:10:13 +0400 Subject: [PATCH] triangle_drawing: added template function for drawing trigger polygons on pre and post 25th anniversary versions --- BunnymodXT/triangle_drawing.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/BunnymodXT/triangle_drawing.cpp b/BunnymodXT/triangle_drawing.cpp index 0a4c8de15..12549bd1d 100644 --- a/BunnymodXT/triangle_drawing.cpp +++ b/BunnymodXT/triangle_drawing.cpp @@ -160,6 +160,17 @@ namespace TriangleDrawing return s; } + template void DrawPolygons(triangleapi_s *pTriAPI, const model_t *model, int i) + { + const T surfs = (T)model->surfaces + model->firstmodelsurface; + pTriAPI->Begin(TRI_POLYGON); + for (int j = 0; j < surfs[i].polys->numverts; ++j) + { + pTriAPI->Vertex3fv(surfs[i].polys->verts[j]); + } + pTriAPI->End(); + } + static void DrawTriggers(triangleapi_s *pTriAPI) { if (!CVars::bxt_show_triggers.GetBool()) @@ -188,7 +199,6 @@ namespace TriangleDrawing continue; const bool active = ent->v.solid != SOLID_NOT || std::strcmp(classname, "trigger_transition") == 0; - const msurface_t *surfs = model->surfaces + model->firstmodelsurface; for (int i = 0; i < model->nummodelsurfaces; ++i) { // Offset to make each surface look slightly different const float offset = i * float(M_PI) / 7; @@ -203,10 +213,7 @@ namespace TriangleDrawing a = GetPulsatingAlpha(a, svTime + offset); pTriAPI->Color4f(r, g, b, a); - pTriAPI->Begin(TRI_POLYGON); - for (int j = 0; j < surfs[i].polys->numverts; ++j) - pTriAPI->Vertex3fv(surfs[i].polys->verts[j]); - pTriAPI->End(); + DrawPolygons(pTriAPI, model, i); } } }