From d835f83e517f2b5a9b33aff5e04360c702bcafc4 Mon Sep 17 00:00:00 2001 From: Foxar Date: Mon, 21 Dec 2020 18:48:11 +0100 Subject: [PATCH] Added: New BoundingBox infrastructure into mesh_material, analogous to mesh_frame. --- src/engine/include/models/mesh_material.hpp | 13 +++++++++++-- src/engine/models/mesh_material.cpp | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/engine/include/models/mesh_material.hpp b/src/engine/include/models/mesh_material.hpp index 0b5447e..976a32b 100644 --- a/src/engine/include/models/mesh_material.hpp +++ b/src/engine/include/models/mesh_material.hpp @@ -12,6 +12,7 @@ #define _TYRA_MESH_MATERIAL_ #include +#include "bounding_box.hpp" #include "./math/vector3.hpp" #include "./math/plane.hpp" @@ -65,13 +66,20 @@ public: * Returns bounding box (AABB). * Total length: 8 */ - Vector3 *getBoundingBox() { return boundingBox; }; + //Vector3 *getBoundingBox() { return boundingBox; }; + Vector3 *getBoundingBox() { return boundingBoxObj->getVertices(); }; /** * Returns bounding box (AABB) vertex. * Total length: 8 */ - Vector3 &getBoundingBoxVertex(const u8 &i) { return boundingBox[i]; }; + //Vector3 &getBoundingBoxVertex(const u8 &i) { return boundingBox[i]; }; + Vector3 &getBoundingBoxVertex(const u8 &i) { return boundingBoxObj->getVertex(i); }; + + /** + * Returns bounding box (AABB) object pointer. + */ + BoundingBox *getBoundingBoxP() { return boundingBoxObj; }; // ---- // Setters @@ -120,6 +128,7 @@ public: private: Vector3 boundingBox[8]; + BoundingBox *boundingBoxObj; u32 facesCount, id; u32 *vertexFaces, *stFaces, *normalFaces; u8 _isNameSet, _areFacesAllocated, _isBoundingBoxCalculated; diff --git a/src/engine/models/mesh_material.cpp b/src/engine/models/mesh_material.cpp index f435ce6..bf4667e 100644 --- a/src/engine/models/mesh_material.cpp +++ b/src/engine/models/mesh_material.cpp @@ -9,6 +9,7 @@ */ #include "../include/models/mesh_material.hpp" +#include "../include/models/bounding_box.hpp" #include "../include/utils/debug.hpp" #include "../include/utils/string.hpp" #include @@ -132,4 +133,5 @@ void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount) boundingBox[6].set(hiX, hiY, lowZ); boundingBox[7].set(hiX, hiY, hiZ); _isBoundingBoxCalculated = true; + boundingBoxObj = new BoundingBox(boundingBox); }