From 136b7e7bfcb07f90b251d8d5f915d09845a6701a Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sat, 31 Dec 2022 01:47:42 +0800 Subject: [PATCH] Renamed HalfEdgeDS to HalfEdgeStructure for clarity do not abbreviate. abbreviation are usually bad!! --- .../CollisionShapes/SHCollisionShape.h | 2 +- .../SHCollisionShapeLibrary.cpp | 4 +-- .../CollisionShapes/SHCollisionShapeLibrary.h | 2 +- .../SHConvexPolyhedronCollisionShape.cpp | 2 +- .../SHConvexPolyhedronCollisionShape.h | 10 +++--- ...HalfEdgeDS.cpp => SHHalfEdgeStructure.cpp} | 34 +++++++++---------- .../{SHHalfEdgeDS.h => SHHalfEdgeStructure.h} | 6 ++-- .../Narrowphase/SHSphereVsConvex.cpp | 8 ++--- 8 files changed, 34 insertions(+), 34 deletions(-) rename SHADE_Engine/src/Physics/Collision/CollisionShapes/{SHHalfEdgeDS.cpp => SHHalfEdgeStructure.cpp} (84%) rename SHADE_Engine/src/Physics/Collision/CollisionShapes/{SHHalfEdgeDS.h => SHHalfEdgeStructure.h} (98%) diff --git a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShape.h b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShape.h index 6a2e81e4..0a320444 100644 --- a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShape.h +++ b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShape.h @@ -131,7 +131,7 @@ namespace SHADE virtual void ComputeTransforms () noexcept = 0; [[nodiscard]] virtual SHMatrix GetInertiaTensor (float mass) const noexcept = 0; [[nodiscard]] virtual SHMatrix ComputeWorldTransform () const noexcept = 0; - [[nodiscard]] virtual SHAABB ComputeAABB () const noexcept = 0; + [[nodiscard]] virtual SHAABB ComputeAABB () const noexcept = 0; protected: /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShapeLibrary.cpp b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShapeLibrary.cpp index 58af5dc4..338083c7 100644 --- a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShapeLibrary.cpp +++ b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShapeLibrary.cpp @@ -159,7 +159,7 @@ namespace SHADE for (int i = 0; i < NUM_FACES; ++i) { - SHHalfEdgeDS::Face newFace; + SHHalfEdgeStructure::Face newFace; newFace.normal = FACE_NORMALS[i]; for (int j = 0; j < NUM_VERTICES_PER_FACE; ++j) @@ -168,7 +168,7 @@ namespace SHADE boxHalfEdgeDS.AddFace(newFace); } - boxHalfEdgeDS.BuildPolyhedron(); + boxHalfEdgeDS.Build(); } } // namespace SHADE \ No newline at end of file diff --git a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShapeLibrary.h b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShapeLibrary.h index b20abb7f..bb9c2807 100644 --- a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShapeLibrary.h +++ b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHCollisionShapeLibrary.h @@ -92,7 +92,7 @@ namespace SHADE /* Data Members */ /*---------------------------------------------------------------------------------*/ - SHHalfEdgeDS boxHalfEdgeDS; + SHHalfEdgeStructure boxHalfEdgeDS; Spheres spheres; Boxes boxes; diff --git a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHConvexPolyhedronCollisionShape.cpp b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHConvexPolyhedronCollisionShape.cpp index 586d67f4..db6d3621 100644 --- a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHConvexPolyhedronCollisionShape.cpp +++ b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHConvexPolyhedronCollisionShape.cpp @@ -93,7 +93,7 @@ namespace SHADE /* Getter Function Definitions */ /*-----------------------------------------------------------------------------------*/ - const SHHalfEdgeDS* SHConvexPolyhedronCollisionShape::GetHalfEdgeStructure() const noexcept + const SHHalfEdgeStructure* SHConvexPolyhedronCollisionShape::GetHalfEdgeStructure() const noexcept { return halfEdgeStructure; } diff --git a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHConvexPolyhedronCollisionShape.h b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHConvexPolyhedronCollisionShape.h index f459e87e..7a0f6df0 100644 --- a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHConvexPolyhedronCollisionShape.h +++ b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHConvexPolyhedronCollisionShape.h @@ -12,7 +12,7 @@ // Project Headers #include "SHCollisionShape.h" -#include "SHHalfEdgeDS.h" +#include "SHHalfEdgeStructure.h" namespace SHADE { @@ -57,16 +57,16 @@ namespace SHADE /* Getter Functions */ /*---------------------------------------------------------------------------------*/ - [[nodiscard]] const SHHalfEdgeDS* GetHalfEdgeStructure () const noexcept; - [[nodiscard]] virtual SHVec3 GetVertex (int index) const = 0; - [[nodiscard]] virtual SHVec3 GetNormal (int faceIndex) const = 0; + [[nodiscard]] const SHHalfEdgeStructure* GetHalfEdgeStructure () const noexcept; + [[nodiscard]] virtual SHVec3 GetVertex (int index) const = 0; + [[nodiscard]] virtual SHVec3 GetNormal (int faceIndex) const = 0; protected: /*---------------------------------------------------------------------------------*/ /* Data Members */ /*---------------------------------------------------------------------------------*/ - SHHalfEdgeDS* halfEdgeStructure; // Defines the polyhedron by it's half edges. + SHHalfEdgeStructure* halfEdgeStructure; // Defines the polyhedron by it's half edges. }; } // namespace SHADE diff --git a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeDS.cpp b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeStructure.cpp similarity index 84% rename from SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeDS.cpp rename to SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeStructure.cpp index 3bf48608..4c9304c4 100644 --- a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeDS.cpp +++ b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeStructure.cpp @@ -1,5 +1,5 @@ /**************************************************************************************** - * \file SHHalfEdgeDS.cpp + * \file SHHalfEdgeStructure.cpp * \author Diren D Bharwani, diren.dbharwani, 390002520 * \brief Implementation for a half-edge data structure to represent polyhedra. * @@ -11,7 +11,7 @@ #include // Primary Header -#include "SHHalfEdgeDS.h" +#include "SHHalfEdgeStructure.h" // Helper Macros @@ -23,7 +23,7 @@ namespace SHADE /* Constructors & Destructor Definitions */ /*-----------------------------------------------------------------------------------*/ - SHHalfEdgeDS::HalfEdge::HalfEdge() noexcept + SHHalfEdgeStructure::HalfEdge::HalfEdge() noexcept : tailVertexIndex { -1 } , headVertexIndex { -1 } , edgeIndex { -1 } @@ -31,7 +31,7 @@ namespace SHADE , faceIndex { -1 } {} - SHHalfEdgeDS::HalfEdge::HalfEdge(const HalfEdge& rhs) noexcept + SHHalfEdgeStructure::HalfEdge::HalfEdge(const HalfEdge& rhs) noexcept : tailVertexIndex { rhs.tailVertexIndex } , headVertexIndex { rhs.headVertexIndex } , edgeIndex { rhs.edgeIndex } @@ -39,7 +39,7 @@ namespace SHADE , faceIndex { rhs.faceIndex } {} - SHHalfEdgeDS::HalfEdge::HalfEdge(HalfEdge&& rhs) noexcept + SHHalfEdgeStructure::HalfEdge::HalfEdge(HalfEdge&& rhs) noexcept : tailVertexIndex { rhs.tailVertexIndex } , headVertexIndex { rhs.headVertexIndex } , edgeIndex { rhs.edgeIndex } @@ -47,13 +47,13 @@ namespace SHADE , faceIndex { rhs.faceIndex } {} - SHHalfEdgeDS::Face::Face(const Face& rhs) noexcept + SHHalfEdgeStructure::Face::Face(const Face& rhs) noexcept : normal { rhs.normal } { std::ranges::copy(rhs.vertexIndices.begin(), rhs.vertexIndices.end(), std::back_inserter(vertexIndices)); } - SHHalfEdgeDS::Face::Face(Face&& rhs) noexcept + SHHalfEdgeStructure::Face::Face(Face&& rhs) noexcept : normal { rhs.normal } { std::ranges::copy(rhs.vertexIndices.begin(), rhs.vertexIndices.end(), std::back_inserter(vertexIndices)); @@ -63,7 +63,7 @@ namespace SHADE /* Operator Overload Definitions */ /*-----------------------------------------------------------------------------------*/ - SHHalfEdgeDS::HalfEdge& SHHalfEdgeDS::HalfEdge::operator=(const HalfEdge& rhs) noexcept + SHHalfEdgeStructure::HalfEdge& SHHalfEdgeStructure::HalfEdge::operator=(const HalfEdge& rhs) noexcept { if (this == &rhs) return *this; @@ -77,7 +77,7 @@ namespace SHADE return *this; } - SHHalfEdgeDS::HalfEdge& SHHalfEdgeDS::HalfEdge::operator=(HalfEdge&& rhs) noexcept + SHHalfEdgeStructure::HalfEdge& SHHalfEdgeStructure::HalfEdge::operator=(HalfEdge&& rhs) noexcept { tailVertexIndex = rhs.tailVertexIndex; headVertexIndex = rhs.headVertexIndex; @@ -88,7 +88,7 @@ namespace SHADE return *this; } - SHHalfEdgeDS::Face& SHHalfEdgeDS::Face::operator=(const Face& rhs) noexcept + SHHalfEdgeStructure::Face& SHHalfEdgeStructure::Face::operator=(const Face& rhs) noexcept { if (this == &rhs) return *this; @@ -101,7 +101,7 @@ namespace SHADE return *this; } - SHHalfEdgeDS::Face& SHHalfEdgeDS::Face::operator=(Face&& rhs) noexcept + SHHalfEdgeStructure::Face& SHHalfEdgeStructure::Face::operator=(Face&& rhs) noexcept { normal = rhs.normal; @@ -115,17 +115,17 @@ namespace SHADE /* Getter Function Definitions */ /*-----------------------------------------------------------------------------------*/ - int32_t SHHalfEdgeDS::GetFaceCount() const noexcept + int32_t SHHalfEdgeStructure::GetFaceCount() const noexcept { return static_cast(faces.size()); } - int32_t SHHalfEdgeDS::GetHalfEdgeCount() const noexcept + int32_t SHHalfEdgeStructure::GetHalfEdgeCount() const noexcept { return static_cast(halfEdges.size()); } - const SHHalfEdgeDS::Face& SHHalfEdgeDS::GetFace(int32_t index) const + const SHHalfEdgeStructure::Face& SHHalfEdgeStructure::GetFace(int32_t index) const { if (index < 0 || index >= static_cast(faces.size())) throw std::invalid_argument("Index out-of-range!"); @@ -133,7 +133,7 @@ namespace SHADE return faces[index]; } - const SHHalfEdgeDS::HalfEdge& SHHalfEdgeDS::GetHalfEdge(int32_t index) const + const SHHalfEdgeStructure::HalfEdge& SHHalfEdgeStructure::GetHalfEdge(int32_t index) const { if (index < 0 || index >= static_cast(halfEdges.size())) throw std::invalid_argument("Index out-of-range!"); @@ -145,12 +145,12 @@ namespace SHADE /* Public Member Function Definitions */ /*-----------------------------------------------------------------------------------*/ - void SHHalfEdgeDS::AddFace(const Face& face) + void SHHalfEdgeStructure::AddFace(const Face& face) { faces.emplace_back(face); } - void SHHalfEdgeDS::BuildPolyhedron() noexcept + void SHHalfEdgeStructure::Build() noexcept { // We use the pair of vertex IDs on a half-edge to prevent duplicates std::unordered_map edgeMap; diff --git a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeDS.h b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeStructure.h similarity index 98% rename from SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeDS.h rename to SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeStructure.h index 272d893c..c08803ce 100644 --- a/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeDS.h +++ b/SHADE_Engine/src/Physics/Collision/CollisionShapes/SHHalfEdgeStructure.h @@ -1,5 +1,5 @@ /**************************************************************************************** - * \file SHHalfEdgeDS.h + * \file SHHalfEdgeStructure.h * \author Diren D Bharwani, diren.dbharwani, 390002520 * \brief Interface for a half-edge data structure to represent polyhedra. * @@ -25,7 +25,7 @@ namespace SHADE * @brief * Encapsulates data for a convex polyhedron's geometry represented as faces & half edges. */ - class SH_API SHHalfEdgeDS + class SH_API SHHalfEdgeStructure { public: /*---------------------------------------------------------------------------------*/ @@ -127,7 +127,7 @@ namespace SHADE * Before this method is invoked, there must be some faces. * @return */ - void BuildPolyhedron() noexcept; + void Build() noexcept; private: /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Physics/Collision/Narrowphase/SHSphereVsConvex.cpp b/SHADE_Engine/src/Physics/Collision/Narrowphase/SHSphereVsConvex.cpp index 314e3ff9..e62bc241 100644 --- a/SHADE_Engine/src/Physics/Collision/Narrowphase/SHSphereVsConvex.cpp +++ b/SHADE_Engine/src/Physics/Collision/Narrowphase/SHSphereVsConvex.cpp @@ -61,7 +61,7 @@ namespace SHADE int32_t closestPointIndex = -1; float bestDistance = std::numeric_limits::lowest(); - const SHHalfEdgeDS* HALF_EDGE_STRUCTURE = CONVEX.GetHalfEdgeStructure(); + const SHHalfEdgeStructure* HALF_EDGE_STRUCTURE = CONVEX.GetHalfEdgeStructure(); /* * Test against each face. @@ -72,7 +72,7 @@ namespace SHADE */ for (int32_t i = 0; i < HALF_EDGE_STRUCTURE->GetFaceCount(); ++i) { - const SHHalfEdgeDS::Face& FACE = HALF_EDGE_STRUCTURE->GetFace(i); + const SHHalfEdgeStructure::Face& FACE = HALF_EDGE_STRUCTURE->GetFace(i); // Build plane equation @@ -128,8 +128,8 @@ namespace SHADE * / / regionC */ - const SHHalfEdgeDS::Face& FACE = HALF_EDGE_STRUCTURE->GetFace(closestFaceIndex); - const SHVec3& NORMAL = CONVEX.GetNormal(closestFaceIndex); + const SHHalfEdgeStructure::Face& FACE = HALF_EDGE_STRUCTURE->GetFace(closestFaceIndex); + const SHVec3& NORMAL = CONVEX.GetNormal(closestFaceIndex); const int32_t NUM_VERTICES_ON_FACE = static_cast(FACE.vertexIndices.size());