diff --git a/include/reactphysics3d/collision/shapes/BoxShape.h b/include/reactphysics3d/collision/shapes/BoxShape.h index c92967b4..50f3f3d7 100644 --- a/include/reactphysics3d/collision/shapes/BoxShape.h +++ b/include/reactphysics3d/collision/shapes/BoxShape.h @@ -112,7 +112,7 @@ class BoxShape : public ConvexPolyhedronShape { virtual uint32 getNbVertices() const override; /// Return a given vertex of the polyhedron - virtual HalfEdgeStructure::Vertex getVertex(uint32 vertexIndex) const override; + virtual const HalfEdgeStructure::Vertex& getVertex(uint32 vertexIndex) const override; /// Return the number of half-edges of the polyhedron virtual uint32 getNbHalfEdges() const override; diff --git a/include/reactphysics3d/collision/shapes/ConvexMeshShape.h b/include/reactphysics3d/collision/shapes/ConvexMeshShape.h index 9f40f0e3..3139c76f 100644 --- a/include/reactphysics3d/collision/shapes/ConvexMeshShape.h +++ b/include/reactphysics3d/collision/shapes/ConvexMeshShape.h @@ -118,7 +118,7 @@ class ConvexMeshShape : public ConvexPolyhedronShape { virtual uint32 getNbVertices() const override; /// Return a given vertex of the polyhedron - virtual HalfEdgeStructure::Vertex getVertex(uint32 vertexIndex) const override; + virtual const HalfEdgeStructure::Vertex& getVertex(uint32 vertexIndex) const override; /// Return the number of half-edges of the polyhedron virtual uint32 getNbHalfEdges() const override; @@ -208,7 +208,7 @@ RP3D_FORCE_INLINE uint32 ConvexMeshShape::getNbVertices() const { } // Return a given vertex of the polyhedron -RP3D_FORCE_INLINE HalfEdgeStructure::Vertex ConvexMeshShape::getVertex(uint32 vertexIndex) const { +RP3D_FORCE_INLINE const HalfEdgeStructure::Vertex& ConvexMeshShape::getVertex(uint32 vertexIndex) const { assert(vertexIndex < getNbVertices()); return mPolyhedronMesh->getHalfEdgeStructure().getVertex(vertexIndex); } diff --git a/include/reactphysics3d/collision/shapes/ConvexPolyhedronShape.h b/include/reactphysics3d/collision/shapes/ConvexPolyhedronShape.h index a0eb8395..21dc02d8 100644 --- a/include/reactphysics3d/collision/shapes/ConvexPolyhedronShape.h +++ b/include/reactphysics3d/collision/shapes/ConvexPolyhedronShape.h @@ -68,7 +68,7 @@ class ConvexPolyhedronShape : public ConvexShape { virtual uint32 getNbVertices() const=0; /// Return a given vertex of the polyhedron - virtual HalfEdgeStructure::Vertex getVertex(uint32 vertexIndex) const=0; + virtual const HalfEdgeStructure::Vertex& getVertex(uint32 vertexIndex) const=0; /// Return the position of a given vertex virtual Vector3 getVertexPosition(uint32 vertexIndex) const=0; diff --git a/include/reactphysics3d/collision/shapes/TriangleShape.h b/include/reactphysics3d/collision/shapes/TriangleShape.h index d78fcb3b..263315d2 100644 --- a/include/reactphysics3d/collision/shapes/TriangleShape.h +++ b/include/reactphysics3d/collision/shapes/TriangleShape.h @@ -151,7 +151,7 @@ class TriangleShape : public ConvexPolyhedronShape { virtual uint32 getNbVertices() const override; /// Return a given vertex of the polyhedron - virtual HalfEdgeStructure::Vertex getVertex(uint32 vertexIndex) const override; + virtual const HalfEdgeStructure::Vertex& getVertex(uint32 vertexIndex) const override; /// Return the position of a given vertex virtual Vector3 getVertexPosition(uint32 vertexIndex) const override; @@ -244,16 +244,9 @@ RP3D_FORCE_INLINE uint32 TriangleShape::getNbVertices() const { } // Return a given vertex of the polyhedron -RP3D_FORCE_INLINE HalfEdgeStructure::Vertex TriangleShape::getVertex(uint32 vertexIndex) const { +RP3D_FORCE_INLINE const HalfEdgeStructure::Vertex& TriangleShape::getVertex(uint32 vertexIndex) const { assert(vertexIndex < 3); - - HalfEdgeStructure::Vertex vertex(vertexIndex); - switch (vertexIndex) { - case 0: vertex.edgeIndex = 0; break; - case 1: vertex.edgeIndex = 2; break; - case 2: vertex.edgeIndex = 4; break; - } - return vertex; + return mTriangleHalfEdgeStructure.getVertex(vertexIndex); } // Return the position of a given vertex diff --git a/src/collision/shapes/BoxShape.cpp b/src/collision/shapes/BoxShape.cpp index 65813ec7..e3b2d868 100644 --- a/src/collision/shapes/BoxShape.cpp +++ b/src/collision/shapes/BoxShape.cpp @@ -130,7 +130,7 @@ const HalfEdgeStructure::Face& BoxShape::getFace(uint32 faceIndex) const { } // Return a given vertex of the polyhedron -HalfEdgeStructure::Vertex BoxShape::getVertex(uint32 vertexIndex) const { +const HalfEdgeStructure::Vertex& BoxShape::getVertex(uint32 vertexIndex) const { assert(vertexIndex < getNbVertices()); return mPhysicsCommon.mBoxShapeHalfEdgeStructure.getVertex(vertexIndex); }