Merge branch 'master' into develop

This commit is contained in:
Daniel Chappuis 2018-09-13 07:12:59 +02:00
commit 26393ffca3
7 changed files with 63 additions and 27 deletions

View File

@ -2,6 +2,11 @@
## Release Candidate
### Added
- Make possible for the user to get vertices, normals and triangle indices of a ConcaveMeshShape
- Make possible for the user to get vertices and height values of the HeightFieldShape
### Fixed
- Bug [#45](https://github.com/DanielChappuis/reactphysics3d/issues/45) has been fixed.

View File

@ -43,14 +43,14 @@ using namespace reactphysics3d;
* @param vertexDataType Data type of the vertices data
* @param indexDataType Data type of the face indices data
*/
PolygonVertexArray::PolygonVertexArray(uint nbVertices, void* verticesStart, int verticesStride,
void* indexesStart, int indexesStride,
PolygonVertexArray::PolygonVertexArray(uint nbVertices, const void* verticesStart, int verticesStride,
const void* indexesStart, int indexesStride,
uint nbFaces, PolygonFace* facesStart,
VertexDataType vertexDataType, IndexDataType indexDataType) {
mNbVertices = nbVertices;
mVerticesStart = reinterpret_cast<unsigned char*>(verticesStart);
mVerticesStart = reinterpret_cast<const unsigned char*>(verticesStart);
mVerticesStride = verticesStride;
mIndicesStart = reinterpret_cast<unsigned char*>(indexesStart);
mIndicesStart = reinterpret_cast<const unsigned char*>(indexesStart);
mIndicesStride = indexesStride;
mNbFaces = nbFaces;
mPolygonFacesStart = facesStart;
@ -71,7 +71,7 @@ uint PolygonVertexArray::getVertexIndexInFace(uint faceIndex, uint noVertexInFac
assert(noVertexInFace < face->nbVertices);
void* vertexIndexPointer = mIndicesStart + (face->indexBase + noVertexInFace) * mIndicesStride;
const void* vertexIndexPointer = mIndicesStart + (face->indexBase + noVertexInFace) * mIndicesStride;
if (mIndexDataType == PolygonVertexArray::IndexDataType::INDEX_INTEGER_TYPE) {
return *((uint*)vertexIndexPointer);

View File

@ -69,14 +69,14 @@ class PolygonVertexArray {
uint mNbVertices;
/// Pointer to the first vertex value in the array
unsigned char* mVerticesStart;
const unsigned char* mVerticesStart;
/// Stride (number of bytes) between the beginning of two vertices
/// values in the array
int mVerticesStride;
/// Pointer to the first vertex index of the array
unsigned char* mIndicesStart;
const unsigned char* mIndicesStart;
/// Stride (number of bytes) between the beginning of two indices in
/// the array
@ -97,8 +97,8 @@ class PolygonVertexArray {
public:
/// Constructor
PolygonVertexArray(uint nbVertices, void* verticesStart, int verticesStride,
void* indexesStart, int indexesStride,
PolygonVertexArray(uint nbVertices, const void* verticesStart, int verticesStride,
const void* indexesStart, int indexesStride,
uint nbFaces, PolygonFace* facesStart,
VertexDataType vertexDataType, IndexDataType indexDataType);
@ -130,10 +130,10 @@ class PolygonVertexArray {
PolygonFace* getPolygonFace(uint faceIndex) const;
/// Return the pointer to the start of the vertices array
unsigned char* getVerticesStart() const;
const unsigned char* getVerticesStart() const;
/// Return the pointer to the start of the indices array
unsigned char* getIndicesStart() const;
const unsigned char* getIndicesStart() const;
};
// Return the vertex data type
@ -198,7 +198,7 @@ inline PolygonVertexArray::PolygonFace* PolygonVertexArray::getPolygonFace(uint
/**
* @return A pointer to the start of the vertex array of the polyhedron
*/
inline unsigned char* PolygonVertexArray::getVerticesStart() const {
inline const unsigned char* PolygonVertexArray::getVerticesStart() const {
return mVerticesStart;
}
@ -206,7 +206,7 @@ inline unsigned char* PolygonVertexArray::getVerticesStart() const {
/**
* @return A pointer to the start of the face indices array of the polyhedron
*/
inline unsigned char* PolygonVertexArray::getIndicesStart() const {
inline const unsigned char* PolygonVertexArray::getIndicesStart() const {
return mIndicesStart;
}

View File

@ -105,7 +105,7 @@ Vector3 PolyhedronMesh::getVertex(uint index) const {
uint vertexIndex = mHalfEdgeStructure.getVertex(index).vertexPointIndex;
PolygonVertexArray::VertexDataType vertexType = mPolygonVertexArray->getVertexDataType();
unsigned char* verticesStart = mPolygonVertexArray->getVerticesStart();
const unsigned char* verticesStart = mPolygonVertexArray->getVerticesStart();
int vertexStride = mPolygonVertexArray->getVerticesStride();
Vector3 vertex;

View File

@ -115,6 +115,28 @@ void ConcaveMeshShape::getTriangleVerticesNormals(uint subPart, uint triangleInd
triangleVertexArray->getTriangleVerticesNormals(triangleIndex, outVerticesNormals);
}
// Return the indices of the three vertices of a given triangle in the array
void ConcaveMeshShape::getTriangleVerticesIndices(uint subPart, uint triangleIndex, uint* outVerticesIndices) const {
// Get the triangle vertex array of the current sub-part
TriangleVertexArray* triangleVertexArray = mTriangleMesh->getSubpart(subPart);
// Get the vertices normals of the triangle
triangleVertexArray->getTriangleVerticesIndices(triangleIndex, outVerticesIndices);
}
// Return the number of sub parts contained in this mesh
uint ConcaveMeshShape::getNbSubparts() const
{
return mTriangleMesh->getNbSubparts();
}
// Return the number of triangles in a sub part of the mesh
uint ConcaveMeshShape::getNbTriangles(uint subPart) const
{
assert(mTriangleMesh->getSubpart(subPart));
return mTriangleMesh->getSubpart(subPart)->getNbTriangles();
}
// Use a callback method on all triangles of the concave shape inside a given AABB
void ConcaveMeshShape::testAllTriangles(TriangleCallback& callback, const AABB& localAABB) const {

View File

@ -155,12 +155,6 @@ class ConcaveMeshShape : public ConcaveShape {
/// Insert all the triangles into the dynamic AABB tree
void initBVHTree();
/// Return the three vertices coordinates (in the array outTriangleVertices) of a triangle
void getTriangleVertices(uint subPart, uint triangleIndex, Vector3* outTriangleVertices) const;
/// Return the three vertex normals (in the array outVerticesNormals) of a triangle
void getTriangleVerticesNormals(uint subPart, uint triangleIndex, Vector3* outVerticesNormals) const;
/// Compute the shape Id for a given triangle of the mesh
uint computeTriangleShapeId(uint subPart, uint triangleIndex) const;
@ -170,7 +164,7 @@ class ConcaveMeshShape : public ConcaveShape {
ConcaveMeshShape(TriangleMesh* triangleMesh, const Vector3& scaling = Vector3(1, 1, 1));
/// Destructor
virtual ~ConcaveMeshShape() = default;
virtual ~ConcaveMeshShape() override = default;
/// Deleted copy-constructor
ConcaveMeshShape(const ConcaveMeshShape& shape) = delete;
@ -180,6 +174,21 @@ class ConcaveMeshShape : public ConcaveShape {
/// Return the scaling vector
const Vector3& getScaling() const;
/// Return the number of sub parts contained in this mesh
uint getNbSubparts() const;
/// Return the number of triangles in a sub part of the mesh
uint getNbTriangles(uint subPart) const;
/// Return the indices of the three vertices of a given triangle in the array
void getTriangleVerticesIndices(uint subPart, uint triangleIndex, uint* outVerticesIndices) const;
/// Return the three vertices coordinates (in the array outTriangleVertices) of a triangle
void getTriangleVertices(uint subPart, uint triangleIndex, Vector3* outTriangleVertices) const;
/// Return the three vertex normals (in the array outVerticesNormals) of a triangle
void getTriangleVerticesNormals(uint subPart, uint triangleIndex, Vector3* outVerticesNormals) const;
/// Return the local bounds of the shape in x, y and z directions.
virtual void getLocalBounds(Vector3& min, Vector3& max) const override;

View File

@ -161,12 +161,6 @@ class HeightFieldShape : public ConcaveShape {
void getTriangleVerticesWithIndexPointer(int32 subPart, int32 triangleIndex,
Vector3* outTriangleVertices) const;
/// Return the vertex (local-coordinates) of the height field at a given (x,y) position
Vector3 getVertexAt(int x, int y) const;
/// Return the height of a given (x,y) point in the height field
decimal getHeightAt(int x, int y) const;
/// Return the closest inside integer grid value of a given floating grid value
int computeIntegerGridValue(decimal value) const;
@ -201,6 +195,12 @@ class HeightFieldShape : public ConcaveShape {
/// Return the number of columns in the height field
int getNbColumns() const;
/// Return the vertex (local-coordinates) of the height field at a given (x,y) position
Vector3 getVertexAt(int x, int y) const;
/// Return the height of a given (x,y) point in the height field
decimal getHeightAt(int x, int y) const;
/// Return the type of height value in the height field
HeightDataType getHeightDataType() const;