From 7e6337027a38644becb60b5d2488267f578a878a Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 12 Feb 2023 12:44:24 -0700 Subject: [PATCH] bsputils: add Model_BoundsOfFaces --- common/bsputils.cc | 12 ++++++++++++ include/common/bsputils.hh | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/bsputils.cc b/common/bsputils.cc index 1ffc2a56..1aa0601e 100644 --- a/common/bsputils.cc +++ b/common/bsputils.cc @@ -566,6 +566,18 @@ void Face_DebugPrint(const mbsp_t *bsp, const mface_t *face) } } +aabb3f Model_BoundsOfFaces(const mbsp_t& bsp, const dmodelh2_t &model) +{ + aabb3f result; + for (int i = model.firstface; i < model.firstface + model.numfaces; ++i) { + auto &face = bsp.dfaces[i]; + for (int j = 0; j < face.numedges; ++j) { + result += Face_PointAtIndex(&bsp, &face, j); + } + } + return result; +} + /* =============== CompressRow diff --git a/include/common/bsputils.hh b/include/common/bsputils.hh index 94dbac94..43b2f4ed 100644 --- a/include/common/bsputils.hh +++ b/include/common/bsputils.hh @@ -98,13 +98,13 @@ int BSP_FindContentsAtPoint(const mbsp_t *bsp, hull_index_t hullnum, const dmode std::vector Leaf_Markfaces(const mbsp_t *bsp, const mleaf_t *leaf); std::vector Leaf_Brushes(const mbsp_t *bsp, const mleaf_t *leaf); -const qvec3f &Face_PointAtIndex(const mbsp_t *bsp, const mface_t *f); const qvec3f &Vertex_GetPos(const mbsp_t *bsp, int num); qvec3d Face_Normal(const mbsp_t *bsp, const mface_t *f); std::vector GLM_FacePoints(const mbsp_t *bsp, const mface_t *face); polylib::winding_t Face_Winding(const mbsp_t *bsp, const mface_t *face); qvec3f Face_Centroid(const mbsp_t *bsp, const mface_t *face); void Face_DebugPrint(const mbsp_t *bsp, const mface_t *face); +aabb3f Model_BoundsOfFaces(const mbsp_t& bsp, const dmodelh2_t &model); void CompressRow(const uint8_t *vis, const size_t numbytes, std::back_insert_iterator> it); size_t DecompressedVisSize(const mbsp_t *bsp);