Renamed HalfEdgeDS to HalfEdgeStructure for clarity
do not abbreviate. abbreviation are usually bad!!
This commit is contained in:
parent
6451ca5e95
commit
136b7e7bfc
|
@ -159,7 +159,7 @@ namespace SHADE
|
||||||
|
|
||||||
for (int i = 0; i < NUM_FACES; ++i)
|
for (int i = 0; i < NUM_FACES; ++i)
|
||||||
{
|
{
|
||||||
SHHalfEdgeDS::Face newFace;
|
SHHalfEdgeStructure::Face newFace;
|
||||||
newFace.normal = FACE_NORMALS[i];
|
newFace.normal = FACE_NORMALS[i];
|
||||||
|
|
||||||
for (int j = 0; j < NUM_VERTICES_PER_FACE; ++j)
|
for (int j = 0; j < NUM_VERTICES_PER_FACE; ++j)
|
||||||
|
@ -168,7 +168,7 @@ namespace SHADE
|
||||||
boxHalfEdgeDS.AddFace(newFace);
|
boxHalfEdgeDS.AddFace(newFace);
|
||||||
}
|
}
|
||||||
|
|
||||||
boxHalfEdgeDS.BuildPolyhedron();
|
boxHalfEdgeDS.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace SHADE
|
} // namespace SHADE
|
|
@ -92,7 +92,7 @@ namespace SHADE
|
||||||
/* Data Members */
|
/* Data Members */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
SHHalfEdgeDS boxHalfEdgeDS;
|
SHHalfEdgeStructure boxHalfEdgeDS;
|
||||||
|
|
||||||
Spheres spheres;
|
Spheres spheres;
|
||||||
Boxes boxes;
|
Boxes boxes;
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace SHADE
|
||||||
/* Getter Function Definitions */
|
/* Getter Function Definitions */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
const SHHalfEdgeDS* SHConvexPolyhedronCollisionShape::GetHalfEdgeStructure() const noexcept
|
const SHHalfEdgeStructure* SHConvexPolyhedronCollisionShape::GetHalfEdgeStructure() const noexcept
|
||||||
{
|
{
|
||||||
return halfEdgeStructure;
|
return halfEdgeStructure;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
// Project Headers
|
// Project Headers
|
||||||
#include "SHCollisionShape.h"
|
#include "SHCollisionShape.h"
|
||||||
#include "SHHalfEdgeDS.h"
|
#include "SHHalfEdgeStructure.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ namespace SHADE
|
||||||
/* Getter Functions */
|
/* Getter Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
[[nodiscard]] const SHHalfEdgeDS* GetHalfEdgeStructure () const noexcept;
|
[[nodiscard]] const SHHalfEdgeStructure* GetHalfEdgeStructure () const noexcept;
|
||||||
[[nodiscard]] virtual SHVec3 GetVertex (int index) const = 0;
|
[[nodiscard]] virtual SHVec3 GetVertex (int index) const = 0;
|
||||||
[[nodiscard]] virtual SHVec3 GetNormal (int faceIndex) const = 0;
|
[[nodiscard]] virtual SHVec3 GetNormal (int faceIndex) const = 0;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ namespace SHADE
|
||||||
/* Data Members */
|
/* Data Members */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
SHHalfEdgeDS* halfEdgeStructure; // Defines the polyhedron by it's half edges.
|
SHHalfEdgeStructure* halfEdgeStructure; // Defines the polyhedron by it's half edges.
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace SHADE
|
} // namespace SHADE
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* \file SHHalfEdgeDS.cpp
|
* \file SHHalfEdgeStructure.cpp
|
||||||
* \author Diren D Bharwani, diren.dbharwani, 390002520
|
* \author Diren D Bharwani, diren.dbharwani, 390002520
|
||||||
* \brief Implementation for a half-edge data structure to represent polyhedra.
|
* \brief Implementation for a half-edge data structure to represent polyhedra.
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
#include <SHpch.h>
|
#include <SHpch.h>
|
||||||
|
|
||||||
// Primary Header
|
// Primary Header
|
||||||
#include "SHHalfEdgeDS.h"
|
#include "SHHalfEdgeStructure.h"
|
||||||
|
|
||||||
// Helper Macros
|
// Helper Macros
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace SHADE
|
||||||
/* Constructors & Destructor Definitions */
|
/* Constructors & Destructor Definitions */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
SHHalfEdgeDS::HalfEdge::HalfEdge() noexcept
|
SHHalfEdgeStructure::HalfEdge::HalfEdge() noexcept
|
||||||
: tailVertexIndex { -1 }
|
: tailVertexIndex { -1 }
|
||||||
, headVertexIndex { -1 }
|
, headVertexIndex { -1 }
|
||||||
, edgeIndex { -1 }
|
, edgeIndex { -1 }
|
||||||
|
@ -31,7 +31,7 @@ namespace SHADE
|
||||||
, faceIndex { -1 }
|
, faceIndex { -1 }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SHHalfEdgeDS::HalfEdge::HalfEdge(const HalfEdge& rhs) noexcept
|
SHHalfEdgeStructure::HalfEdge::HalfEdge(const HalfEdge& rhs) noexcept
|
||||||
: tailVertexIndex { rhs.tailVertexIndex }
|
: tailVertexIndex { rhs.tailVertexIndex }
|
||||||
, headVertexIndex { rhs.headVertexIndex }
|
, headVertexIndex { rhs.headVertexIndex }
|
||||||
, edgeIndex { rhs.edgeIndex }
|
, edgeIndex { rhs.edgeIndex }
|
||||||
|
@ -39,7 +39,7 @@ namespace SHADE
|
||||||
, faceIndex { rhs.faceIndex }
|
, faceIndex { rhs.faceIndex }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SHHalfEdgeDS::HalfEdge::HalfEdge(HalfEdge&& rhs) noexcept
|
SHHalfEdgeStructure::HalfEdge::HalfEdge(HalfEdge&& rhs) noexcept
|
||||||
: tailVertexIndex { rhs.tailVertexIndex }
|
: tailVertexIndex { rhs.tailVertexIndex }
|
||||||
, headVertexIndex { rhs.headVertexIndex }
|
, headVertexIndex { rhs.headVertexIndex }
|
||||||
, edgeIndex { rhs.edgeIndex }
|
, edgeIndex { rhs.edgeIndex }
|
||||||
|
@ -47,13 +47,13 @@ namespace SHADE
|
||||||
, faceIndex { rhs.faceIndex }
|
, faceIndex { rhs.faceIndex }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SHHalfEdgeDS::Face::Face(const Face& rhs) noexcept
|
SHHalfEdgeStructure::Face::Face(const Face& rhs) noexcept
|
||||||
: normal { rhs.normal }
|
: normal { rhs.normal }
|
||||||
{
|
{
|
||||||
std::ranges::copy(rhs.vertexIndices.begin(), rhs.vertexIndices.end(), std::back_inserter(vertexIndices));
|
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 }
|
: normal { rhs.normal }
|
||||||
{
|
{
|
||||||
std::ranges::copy(rhs.vertexIndices.begin(), rhs.vertexIndices.end(), std::back_inserter(vertexIndices));
|
std::ranges::copy(rhs.vertexIndices.begin(), rhs.vertexIndices.end(), std::back_inserter(vertexIndices));
|
||||||
|
@ -63,7 +63,7 @@ namespace SHADE
|
||||||
/* Operator Overload Definitions */
|
/* Operator Overload Definitions */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
SHHalfEdgeDS::HalfEdge& SHHalfEdgeDS::HalfEdge::operator=(const HalfEdge& rhs) noexcept
|
SHHalfEdgeStructure::HalfEdge& SHHalfEdgeStructure::HalfEdge::operator=(const HalfEdge& rhs) noexcept
|
||||||
{
|
{
|
||||||
if (this == &rhs)
|
if (this == &rhs)
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -77,7 +77,7 @@ namespace SHADE
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHHalfEdgeDS::HalfEdge& SHHalfEdgeDS::HalfEdge::operator=(HalfEdge&& rhs) noexcept
|
SHHalfEdgeStructure::HalfEdge& SHHalfEdgeStructure::HalfEdge::operator=(HalfEdge&& rhs) noexcept
|
||||||
{
|
{
|
||||||
tailVertexIndex = rhs.tailVertexIndex;
|
tailVertexIndex = rhs.tailVertexIndex;
|
||||||
headVertexIndex = rhs.headVertexIndex;
|
headVertexIndex = rhs.headVertexIndex;
|
||||||
|
@ -88,7 +88,7 @@ namespace SHADE
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHHalfEdgeDS::Face& SHHalfEdgeDS::Face::operator=(const Face& rhs) noexcept
|
SHHalfEdgeStructure::Face& SHHalfEdgeStructure::Face::operator=(const Face& rhs) noexcept
|
||||||
{
|
{
|
||||||
if (this == &rhs)
|
if (this == &rhs)
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -101,7 +101,7 @@ namespace SHADE
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHHalfEdgeDS::Face& SHHalfEdgeDS::Face::operator=(Face&& rhs) noexcept
|
SHHalfEdgeStructure::Face& SHHalfEdgeStructure::Face::operator=(Face&& rhs) noexcept
|
||||||
{
|
{
|
||||||
normal = rhs.normal;
|
normal = rhs.normal;
|
||||||
|
|
||||||
|
@ -115,17 +115,17 @@ namespace SHADE
|
||||||
/* Getter Function Definitions */
|
/* Getter Function Definitions */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int32_t SHHalfEdgeDS::GetFaceCount() const noexcept
|
int32_t SHHalfEdgeStructure::GetFaceCount() const noexcept
|
||||||
{
|
{
|
||||||
return static_cast<int32_t>(faces.size());
|
return static_cast<int32_t>(faces.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SHHalfEdgeDS::GetHalfEdgeCount() const noexcept
|
int32_t SHHalfEdgeStructure::GetHalfEdgeCount() const noexcept
|
||||||
{
|
{
|
||||||
return static_cast<int32_t>(halfEdges.size());
|
return static_cast<int32_t>(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<int32_t>(faces.size()))
|
if (index < 0 || index >= static_cast<int32_t>(faces.size()))
|
||||||
throw std::invalid_argument("Index out-of-range!");
|
throw std::invalid_argument("Index out-of-range!");
|
||||||
|
@ -133,7 +133,7 @@ namespace SHADE
|
||||||
return faces[index];
|
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<int32_t>(halfEdges.size()))
|
if (index < 0 || index >= static_cast<int32_t>(halfEdges.size()))
|
||||||
throw std::invalid_argument("Index out-of-range!");
|
throw std::invalid_argument("Index out-of-range!");
|
||||||
|
@ -145,12 +145,12 @@ namespace SHADE
|
||||||
/* Public Member Function Definitions */
|
/* Public Member Function Definitions */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void SHHalfEdgeDS::AddFace(const Face& face)
|
void SHHalfEdgeStructure::AddFace(const Face& face)
|
||||||
{
|
{
|
||||||
faces.emplace_back(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
|
// We use the pair of vertex IDs on a half-edge to prevent duplicates
|
||||||
std::unordered_map<uint64_t, HalfEdge> edgeMap;
|
std::unordered_map<uint64_t, HalfEdge> edgeMap;
|
|
@ -1,5 +1,5 @@
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* \file SHHalfEdgeDS.h
|
* \file SHHalfEdgeStructure.h
|
||||||
* \author Diren D Bharwani, diren.dbharwani, 390002520
|
* \author Diren D Bharwani, diren.dbharwani, 390002520
|
||||||
* \brief Interface for a half-edge data structure to represent polyhedra.
|
* \brief Interface for a half-edge data structure to represent polyhedra.
|
||||||
*
|
*
|
||||||
|
@ -25,7 +25,7 @@ namespace SHADE
|
||||||
* @brief
|
* @brief
|
||||||
* Encapsulates data for a convex polyhedron's geometry represented as faces & half edges.
|
* Encapsulates data for a convex polyhedron's geometry represented as faces & half edges.
|
||||||
*/
|
*/
|
||||||
class SH_API SHHalfEdgeDS
|
class SH_API SHHalfEdgeStructure
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -127,7 +127,7 @@ namespace SHADE
|
||||||
* Before this method is invoked, there must be some faces.
|
* Before this method is invoked, there must be some faces.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void BuildPolyhedron() noexcept;
|
void Build() noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
|
@ -61,7 +61,7 @@ namespace SHADE
|
||||||
int32_t closestPointIndex = -1;
|
int32_t closestPointIndex = -1;
|
||||||
float bestDistance = std::numeric_limits<float>::lowest();
|
float bestDistance = std::numeric_limits<float>::lowest();
|
||||||
|
|
||||||
const SHHalfEdgeDS* HALF_EDGE_STRUCTURE = CONVEX.GetHalfEdgeStructure();
|
const SHHalfEdgeStructure* HALF_EDGE_STRUCTURE = CONVEX.GetHalfEdgeStructure();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test against each face.
|
* Test against each face.
|
||||||
|
@ -72,7 +72,7 @@ namespace SHADE
|
||||||
*/
|
*/
|
||||||
for (int32_t i = 0; i < HALF_EDGE_STRUCTURE->GetFaceCount(); ++i)
|
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
|
// Build plane equation
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ namespace SHADE
|
||||||
* / / regionC
|
* / / regionC
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const SHHalfEdgeDS::Face& FACE = HALF_EDGE_STRUCTURE->GetFace(closestFaceIndex);
|
const SHHalfEdgeStructure::Face& FACE = HALF_EDGE_STRUCTURE->GetFace(closestFaceIndex);
|
||||||
const SHVec3& NORMAL = CONVEX.GetNormal(closestFaceIndex);
|
const SHVec3& NORMAL = CONVEX.GetNormal(closestFaceIndex);
|
||||||
|
|
||||||
const int32_t NUM_VERTICES_ON_FACE = static_cast<int32_t>(FACE.vertexIndices.size());
|
const int32_t NUM_VERTICES_ON_FACE = static_cast<int32_t>(FACE.vertexIndices.size());
|
||||||
|
|
Loading…
Reference in New Issue