Merge branch 'PolygonVertexArrayConst' of git://github.com/EmmeKappaErre/reactphysics3d into EmmeKappaErre-PolygonVertexArrayConst

This commit is contained in:
Daniel Chappuis 2018-09-11 07:28:41 +02:00
commit a5ee98cbbe
3 changed files with 14 additions and 14 deletions

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;