[DEV] start basic renaming rework

This commit is contained in:
Edouard DUPIN 2017-06-08 21:47:01 +02:00
parent 64b20b4963
commit 562af6c0ae
39 changed files with 464 additions and 511 deletions

View File

@ -45,9 +45,9 @@ using namespace reactphysics3d;
TriangleVertexArray::TriangleVertexArray(uint nbVertices, void* verticesStart, int verticesStride,
uint nbTriangles, void* indexesStart, int indexesStride,
VertexDataType vertexDataType, IndexDataType indexDataType) {
mNbVertices = nbVertices;
mVerticesStart = reinterpret_cast<unsigned char*>(verticesStart);
mVerticesStride = verticesStride;
m_numberVertices = nbVertices;
m_verticesStart = reinterpret_cast<unsigned char*>(verticesStart);
m_verticesStride = verticesStride;
mNbTriangles = nbTriangles;
mIndicesStart = reinterpret_cast<unsigned char*>(indexesStart);
mIndicesStride = indexesStride;

View File

@ -54,14 +54,14 @@ class TriangleVertexArray {
protected:
/// Number of vertices in the array
uint mNbVertices;
uint m_numberVertices;
/// Pointer to the first vertex value in the array
unsigned char* mVerticesStart;
unsigned char* m_verticesStart;
/// Stride (number of bytes) between the beginning of two vertices
/// values in the array
int mVerticesStride;
int m_verticesStride;
/// Number of triangles in the array
uint mNbTriangles;
@ -126,7 +126,7 @@ inline TriangleVertexArray::IndexDataType TriangleVertexArray::getIndexDataType(
// Return the number of vertices
inline uint TriangleVertexArray::getNbVertices() const {
return mNbVertices;
return m_numberVertices;
}
// Return the number of triangles
@ -136,7 +136,7 @@ inline uint TriangleVertexArray::getNbTriangles() const {
// Return the vertices stride (number of bytes)
inline int TriangleVertexArray::getVerticesStride() const {
return mVerticesStride;
return m_verticesStride;
}
// Return the indices stride (number of bytes)
@ -146,7 +146,7 @@ inline int TriangleVertexArray::getIndicesStride() const {
// Return the pointer to the start of the vertices array
inline unsigned char* TriangleVertexArray::getVerticesStart() const {
return mVerticesStart;
return m_verticesStart;
}
// Return the pointer to the start of the indices array

View File

@ -33,7 +33,7 @@ using namespace reactphysics3d;
// Constructor
BroadPhaseAlgorithm::BroadPhaseAlgorithm(CollisionDetection& collisionDetection)
:mDynamicAABBTree(DYNAMIC_TREE_AABB_GAP), mNbMovedShapes(0), mNbAllocatedMovedShapes(8),
:m_dynamicAABBTree(DYNAMIC_TREE_AABB_GAP), mNbMovedShapes(0), mNbAllocatedMovedShapes(8),
mNbNonUsedMovedShapes(0), mNbPotentialPairs(0), mNbAllocatedPotentialPairs(8),
mCollisionDetection(collisionDetection) {
@ -118,7 +118,7 @@ void BroadPhaseAlgorithm::removeMovedCollisionShape(int broadPhaseID) {
void BroadPhaseAlgorithm::addProxyCollisionShape(ProxyShape* proxyShape, const AABB& aabb) {
// Add the collision shape into the dynamic AABB tree and get its broad-phase ID
int nodeId = mDynamicAABBTree.addObject(aabb, proxyShape);
int nodeId = m_dynamicAABBTree.addObject(aabb, proxyShape);
// Set the broad-phase ID of the proxy shape
proxyShape->mBroadPhaseID = nodeId;
@ -134,7 +134,7 @@ void BroadPhaseAlgorithm::removeProxyCollisionShape(ProxyShape* proxyShape) {
int broadPhaseID = proxyShape->mBroadPhaseID;
// Remove the collision shape from the dynamic AABB tree
mDynamicAABBTree.removeObject(broadPhaseID);
m_dynamicAABBTree.removeObject(broadPhaseID);
// Remove the collision shape into the array of shapes that have moved (or have been created)
// during the last simulation step
@ -150,7 +150,7 @@ void BroadPhaseAlgorithm::updateProxyCollisionShape(ProxyShape* proxyShape, cons
assert(broadPhaseID >= 0);
// Update the dynamic AABB tree according to the movement of the collision shape
bool hasBeenReInserted = mDynamicAABBTree.updateObject(broadPhaseID, aabb, displacement, forceReinsert);
bool hasBeenReInserted = m_dynamicAABBTree.updateObject(broadPhaseID, aabb, displacement, forceReinsert);
// If the collision shape has moved out of its fat AABB (and therefore has been reinserted
// into the tree).
@ -178,12 +178,12 @@ void BroadPhaseAlgorithm::computeOverlappingPairs() {
AABBOverlapCallback callback(*this, shapeID);
// Get the AABB of the shape
const AABB& shapeAABB = mDynamicAABBTree.getFatAABB(shapeID);
const AABB& shapeAABB = m_dynamicAABBTree.getFatAABB(shapeID);
// Ask the dynamic AABB tree to report all collision shapes that overlap with
// this AABB. The method BroadPhase::notifiyOverlappingPair() will be called
// by the dynamic AABB tree for each potential overlapping pair.
mDynamicAABBTree.reportAllShapesOverlappingWithAABB(shapeAABB, callback);
m_dynamicAABBTree.reportAllShapesOverlappingWithAABB(shapeAABB, callback);
}
// Reset the array of collision shapes that have move (or have been created) during the
@ -205,8 +205,8 @@ void BroadPhaseAlgorithm::computeOverlappingPairs() {
assert(pair->collisionShape1ID != pair->collisionShape2ID);
// Get the two collision shapes of the pair
ProxyShape* shape1 = static_cast<ProxyShape*>(mDynamicAABBTree.getNodeDataPointer(pair->collisionShape1ID));
ProxyShape* shape2 = static_cast<ProxyShape*>(mDynamicAABBTree.getNodeDataPointer(pair->collisionShape2ID));
ProxyShape* shape1 = static_cast<ProxyShape*>(m_dynamicAABBTree.getNodeDataPointer(pair->collisionShape1ID));
ProxyShape* shape2 = static_cast<ProxyShape*>(m_dynamicAABBTree.getNodeDataPointer(pair->collisionShape2ID));
// Notify the collision detection about the overlapping pair
mCollisionDetection.broadPhaseNotifyOverlappingPair(shape1, shape2);
@ -277,15 +277,15 @@ decimal BroadPhaseRaycastCallback::raycastBroadPhaseShape(int32 nodeId, const Ra
decimal hitFraction = decimal(-1.0);
// Get the proxy shape from the node
ProxyShape* proxyShape = static_cast<ProxyShape*>(mDynamicAABBTree.getNodeDataPointer(nodeId));
ProxyShape* proxyShape = static_cast<ProxyShape*>(m_dynamicAABBTree.getNodeDataPointer(nodeId));
// Check if the raycast filtering mask allows raycast against this shape
if ((mRaycastWithCategoryMaskBits & proxyShape->getCollisionCategoryBits()) != 0) {
if ((m_raycastWithCategoryMaskBits & proxyShape->getCollisionCategoryBits()) != 0) {
// Ask the collision detection to perform a ray cast test against
// the proxy shape of this node because the ray is overlapping
// with the shape in the broad-phase
hitFraction = mRaycastTest.raycastAgainstShape(proxyShape, ray);
hitFraction = m_raycastTest.raycastAgainstShape(proxyShape, ray);
}
return hitFraction;

View File

@ -93,19 +93,19 @@ class BroadPhaseRaycastCallback : public DynamicAABBTreeRaycastCallback {
private :
const DynamicAABBTree& mDynamicAABBTree;
const DynamicAABBTree& m_dynamicAABBTree;
unsigned short mRaycastWithCategoryMaskBits;
unsigned short m_raycastWithCategoryMaskBits;
RaycastTest& mRaycastTest;
RaycastTest& m_raycastTest;
public:
// Constructor
BroadPhaseRaycastCallback(const DynamicAABBTree& dynamicAABBTree, unsigned short raycastWithCategoryMaskBits,
RaycastTest& raycastTest)
: mDynamicAABBTree(dynamicAABBTree), mRaycastWithCategoryMaskBits(raycastWithCategoryMaskBits),
mRaycastTest(raycastTest) {
: m_dynamicAABBTree(dynamicAABBTree), m_raycastWithCategoryMaskBits(raycastWithCategoryMaskBits),
m_raycastTest(raycastTest) {
}
@ -129,7 +129,7 @@ class BroadPhaseAlgorithm {
// -------------------- Attributes -------------------- //
/// Dynamic AABB tree
DynamicAABBTree mDynamicAABBTree;
DynamicAABBTree m_dynamicAABBTree;
/// Array with the broad-phase IDs of all collision shapes that have moved (or have been
/// created) during the last simulation step. Those are the shapes that need to be tested
@ -224,8 +224,8 @@ inline bool BroadPhasePair::smallerThan(const BroadPhasePair& pair1, const Broad
inline bool BroadPhaseAlgorithm::testOverlappingShapes(const ProxyShape* shape1,
const ProxyShape* shape2) const {
// Get the two AABBs of the collision shapes
const AABB& aabb1 = mDynamicAABBTree.getFatAABB(shape1->mBroadPhaseID);
const AABB& aabb2 = mDynamicAABBTree.getFatAABB(shape2->mBroadPhaseID);
const AABB& aabb1 = m_dynamicAABBTree.getFatAABB(shape1->mBroadPhaseID);
const AABB& aabb2 = m_dynamicAABBTree.getFatAABB(shape2->mBroadPhaseID);
// Check if the two AABBs are overlapping
return aabb1.testCollision(aabb2);
@ -237,9 +237,9 @@ inline void BroadPhaseAlgorithm::raycast(const Ray& ray, RaycastTest& raycastTes
PROFILE("BroadPhaseAlgorithm::raycast()");
BroadPhaseRaycastCallback broadPhaseRaycastCallback(mDynamicAABBTree, raycastWithCategoryMaskBits, raycastTest);
BroadPhaseRaycastCallback broadPhaseRaycastCallback(m_dynamicAABBTree, raycastWithCategoryMaskBits, raycastTest);
mDynamicAABBTree.raycast(ray, broadPhaseRaycastCallback);
m_dynamicAABBTree.raycast(ray, broadPhaseRaycastCallback);
}
}

View File

@ -25,15 +25,15 @@
// Libraries
#include <ephysics/collision/shapes/ConcaveMeshShape.h>
#include <iostream>
using namespace reactphysics3d;
// Constructor
ConcaveMeshShape::ConcaveMeshShape(TriangleMesh* triangleMesh)
: ConcaveShape(CONCAVE_MESH) {
mTriangleMesh = triangleMesh;
mRaycastTestType = FRONT;
ConcaveMeshShape::ConcaveMeshShape(TriangleMesh* triangleMesh):
ConcaveShape(CONCAVE_MESH) {
m_triangleMesh = triangleMesh;
m_raycastTestType = FRONT;
// Insert all the triangles into the dynamic AABB tree
initBVHTree();
}
@ -45,117 +45,95 @@ ConcaveMeshShape::~ConcaveMeshShape() {
// Insert all the triangles into the dynamic AABB tree
void ConcaveMeshShape::initBVHTree() {
// TODO : Try to randomly add the triangles into the tree to obtain a better tree
// For each sub-part of the mesh
for (uint subPart=0; subPart<mTriangleMesh->getNbSubparts(); subPart++) {
for (uint subPart=0; subPart<m_triangleMesh->getNbSubparts(); subPart++) {
// Get the triangle vertex array of the current sub-part
TriangleVertexArray* triangleVertexArray = mTriangleMesh->getSubpart(subPart);
TriangleVertexArray* triangleVertexArray = m_triangleMesh->getSubpart(subPart);
TriangleVertexArray::VertexDataType vertexType = triangleVertexArray->getVertexDataType();
TriangleVertexArray::IndexDataType indexType = triangleVertexArray->getIndexDataType();
unsigned char* verticesStart = triangleVertexArray->getVerticesStart();
unsigned char* indicesStart = triangleVertexArray->getIndicesStart();
int vertexStride = triangleVertexArray->getVerticesStride();
int indexStride = triangleVertexArray->getIndicesStride();
// For each triangle of the concave mesh
for (uint triangleIndex=0; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) {
void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride);
Vector3 trianglePoints[3];
// For each vertex of the triangle
for (int k=0; k < 3; k++) {
// Get the index of the current vertex in the triangle
int vertexIndex = 0;
if (indexType == TriangleVertexArray::INDEX_INTEGER_TYPE) {
vertexIndex = ((uint*)vertexIndexPointer)[k];
}
else if (indexType == TriangleVertexArray::INDEX_SHORT_TYPE) {
} else if (indexType == TriangleVertexArray::INDEX_SHORT_TYPE) {
vertexIndex = ((unsigned short*)vertexIndexPointer)[k];
}
else {
} else {
assert(false);
}
// Get the vertices components of the triangle
if (vertexType == TriangleVertexArray::VERTEX_FLOAT_TYPE) {
const float* vertices = (float*)(verticesStart + vertexIndex * vertexStride);
trianglePoints[k][0] = decimal(vertices[0]) * mScaling.x;
trianglePoints[k][1] = decimal(vertices[1]) * mScaling.y;
trianglePoints[k][2] = decimal(vertices[2]) * mScaling.z;
}
else if (vertexType == TriangleVertexArray::VERTEX_DOUBLE_TYPE) {
} else if (vertexType == TriangleVertexArray::VERTEX_DOUBLE_TYPE) {
const double* vertices = (double*)(verticesStart + vertexIndex * vertexStride);
trianglePoints[k][0] = decimal(vertices[0]) * mScaling.x;
trianglePoints[k][1] = decimal(vertices[1]) * mScaling.y;
trianglePoints[k][2] = decimal(vertices[2]) * mScaling.z;
}
else {
} else {
assert(false);
}
}
// Create the AABB for the triangle
AABB aabb = AABB::createAABBForTriangle(trianglePoints);
aabb.inflate(mTriangleMargin, mTriangleMargin, mTriangleMargin);
aabb.inflate(m_triangleMargin, m_triangleMargin, m_triangleMargin);
// Add the AABB with the index of the triangle into the dynamic AABB tree
mDynamicAABBTree.addObject(aabb, subPart, triangleIndex);
m_dynamicAABBTree.addObject(aabb, subPart, triangleIndex);
}
}
}
// Return the three vertices coordinates (in the array outTriangleVertices) of a triangle
// given the start vertex index pointer of the triangle
void ConcaveMeshShape::getTriangleVerticesWithIndexPointer(int32 subPart, int32 triangleIndex,
Vector3* outTriangleVertices) const {
void ConcaveMeshShape::getTriangleVerticesWithIndexPointer(int32 subPart, int32 triangleIndex, Vector3* outTriangleVertices) const {
// Get the triangle vertex array of the current sub-part
TriangleVertexArray* triangleVertexArray = mTriangleMesh->getSubpart(subPart);
TriangleVertexArray* triangleVertexArray = m_triangleMesh->getSubpart(subPart);
if (triangleVertexArray == nullptr) {
std::cout << "get nullptr ..." << std::endl;
}
TriangleVertexArray::VertexDataType vertexType = triangleVertexArray->getVertexDataType();
TriangleVertexArray::IndexDataType indexType = triangleVertexArray->getIndexDataType();
unsigned char* verticesStart = triangleVertexArray->getVerticesStart();
unsigned char* indicesStart = triangleVertexArray->getIndicesStart();
int vertexStride = triangleVertexArray->getVerticesStride();
int indexStride = triangleVertexArray->getIndicesStride();
void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride);
// For each vertex of the triangle
for (int k=0; k < 3; k++) {
// Get the index of the current vertex in the triangle
int vertexIndex = 0;
if (indexType == TriangleVertexArray::INDEX_INTEGER_TYPE) {
vertexIndex = ((uint*)vertexIndexPointer)[k];
}
else if (indexType == TriangleVertexArray::INDEX_SHORT_TYPE) {
} else if (indexType == TriangleVertexArray::INDEX_SHORT_TYPE) {
vertexIndex = ((unsigned short*)vertexIndexPointer)[k];
}
else {
} else {
std::cout << "wrong type of array : " << int32_t(indexType) << std::endl;
assert(false);
}
// Get the vertices components of the triangle
if (vertexType == TriangleVertexArray::VERTEX_FLOAT_TYPE) {
const float* vertices = (float*)(verticesStart + vertexIndex * vertexStride);
outTriangleVertices[k][0] = decimal(vertices[0]) * mScaling.x;
outTriangleVertices[k][1] = decimal(vertices[1]) * mScaling.y;
outTriangleVertices[k][2] = decimal(vertices[2]) * mScaling.z;
}
else if (vertexType == TriangleVertexArray::VERTEX_DOUBLE_TYPE) {
} else if (vertexType == TriangleVertexArray::VERTEX_DOUBLE_TYPE) {
const double* vertices = (double*)(verticesStart + vertexIndex * vertexStride);
outTriangleVertices[k][0] = decimal(vertices[0]) * mScaling.x;
outTriangleVertices[k][1] = decimal(vertices[1]) * mScaling.y;
outTriangleVertices[k][2] = decimal(vertices[2]) * mScaling.z;
}
else {
} else {
assert(false);
}
}
@ -163,80 +141,61 @@ void ConcaveMeshShape::getTriangleVerticesWithIndexPointer(int32 subPart, int32
// Use a callback method on all triangles of the concave shape inside a given AABB
void ConcaveMeshShape::testAllTriangles(TriangleCallback& callback, const AABB& localAABB) const {
ConvexTriangleAABBOverlapCallback overlapCallback(callback, *this, mDynamicAABBTree);
ConvexTriangleAABBOverlapCallback overlapCallback(callback, *this, m_dynamicAABBTree);
// Ask the Dynamic AABB Tree to report all the triangles that are overlapping
// with the AABB of the convex shape.
mDynamicAABBTree.reportAllShapesOverlappingWithAABB(localAABB, overlapCallback);
m_dynamicAABBTree.reportAllShapesOverlappingWithAABB(localAABB, overlapCallback);
}
// Raycast method with feedback information
/// Note that only the first triangle hit by the ray in the mesh will be returned, even if
/// the ray hits many triangles.
bool ConcaveMeshShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const {
PROFILE("ConcaveMeshShape::raycast()");
// Create the callback object that will compute ray casting against triangles
ConcaveMeshRaycastCallback raycastCallback(mDynamicAABBTree, *this, proxyShape, raycastInfo, ray);
ConcaveMeshRaycastCallback raycastCallback(m_dynamicAABBTree, *this, proxyShape, raycastInfo, ray);
// Ask the Dynamic AABB Tree to report all AABB nodes that are hit by the ray.
// The raycastCallback object will then compute ray casting against the triangles
// in the hit AABBs.
mDynamicAABBTree.raycast(ray, raycastCallback);
m_dynamicAABBTree.raycast(ray, raycastCallback);
raycastCallback.raycastTriangles();
return raycastCallback.getIsHit();
}
// Collect all the AABB nodes that are hit by the ray in the Dynamic AABB Tree
decimal ConcaveMeshRaycastCallback::raycastBroadPhaseShape(int32 nodeId, const Ray& ray) {
// Add the id of the hit AABB node into
mHitAABBNodes.push_back(nodeId);
m_hitAABBNodes.push_back(nodeId);
return ray.maxFraction;
}
// Raycast all collision shapes that have been collected
void ConcaveMeshRaycastCallback::raycastTriangles() {
std::vector<int>::const_iterator it;
decimal smallestHitFraction = mRay.maxFraction;
for (it = mHitAABBNodes.begin(); it != mHitAABBNodes.end(); ++it) {
decimal smallestHitFraction = m_ray.maxFraction;
for (it = m_hitAABBNodes.begin(); it != m_hitAABBNodes.end(); ++it) {
// Get the node data (triangle index and mesh subpart index)
int32* data = mDynamicAABBTree.getNodeDataInt(*it);
int32* data = m_dynamicAABBTree.getNodeDataInt(*it);
// Get the triangle vertices for this node from the concave mesh shape
Vector3 trianglePoints[3];
mConcaveMeshShape.getTriangleVerticesWithIndexPointer(data[0], data[1], trianglePoints);
m_concaveMeshShape.getTriangleVerticesWithIndexPointer(data[0], data[1], trianglePoints);
// Create a triangle collision shape
decimal margin = mConcaveMeshShape.getTriangleMargin();
decimal margin = m_concaveMeshShape.getTriangleMargin();
TriangleShape triangleShape(trianglePoints[0], trianglePoints[1], trianglePoints[2], margin);
triangleShape.setRaycastTestType(mConcaveMeshShape.getRaycastTestType());
triangleShape.setRaycastTestType(m_concaveMeshShape.getRaycastTestType());
// Ray casting test against the collision shape
RaycastInfo raycastInfo;
bool isTriangleHit = triangleShape.raycast(mRay, raycastInfo, mProxyShape);
bool isTriangleHit = triangleShape.raycast(m_ray, raycastInfo, m_proxyShape);
// If the ray hit the collision shape
if (isTriangleHit && raycastInfo.hitFraction <= smallestHitFraction) {
assert(raycastInfo.hitFraction >= decimal(0.0));
mRaycastInfo.body = raycastInfo.body;
mRaycastInfo.proxyShape = raycastInfo.proxyShape;
mRaycastInfo.hitFraction = raycastInfo.hitFraction;
mRaycastInfo.worldPoint = raycastInfo.worldPoint;
mRaycastInfo.worldNormal = raycastInfo.worldNormal;
mRaycastInfo.meshSubpart = data[0];
mRaycastInfo.triangleIndex = data[1];
m_raycastInfo.body = raycastInfo.body;
m_raycastInfo.proxyShape = raycastInfo.proxyShape;
m_raycastInfo.hitFraction = raycastInfo.hitFraction;
m_raycastInfo.worldPoint = raycastInfo.worldPoint;
m_raycastInfo.worldNormal = raycastInfo.worldNormal;
m_raycastInfo.meshSubpart = data[0];
m_raycastInfo.triangleIndex = data[1];
smallestHitFraction = raycastInfo.hitFraction;
mIsHit = true;
}

View File

@ -42,20 +42,20 @@ class ConvexTriangleAABBOverlapCallback : public DynamicAABBTreeOverlapCallback
private:
TriangleCallback& mTriangleTestCallback;
TriangleCallback& m_triangleTestCallback;
// Reference to the concave mesh shape
const ConcaveMeshShape& mConcaveMeshShape;
const ConcaveMeshShape& m_concaveMeshShape;
// Reference to the Dynamic AABB tree
const DynamicAABBTree& mDynamicAABBTree;
const DynamicAABBTree& m_dynamicAABBTree;
public:
// Constructor
ConvexTriangleAABBOverlapCallback(TriangleCallback& triangleCallback, const ConcaveMeshShape& concaveShape,
const DynamicAABBTree& dynamicAABBTree)
: mTriangleTestCallback(triangleCallback), mConcaveMeshShape(concaveShape), mDynamicAABBTree(dynamicAABBTree) {
: m_triangleTestCallback(triangleCallback), m_concaveMeshShape(concaveShape), m_dynamicAABBTree(dynamicAABBTree) {
}
@ -70,12 +70,12 @@ class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback {
private :
std::vector<int32> mHitAABBNodes;
const DynamicAABBTree& mDynamicAABBTree;
const ConcaveMeshShape& mConcaveMeshShape;
ProxyShape* mProxyShape;
RaycastInfo& mRaycastInfo;
const Ray& mRay;
std::vector<int32> m_hitAABBNodes;
const DynamicAABBTree& m_dynamicAABBTree;
const ConcaveMeshShape& m_concaveMeshShape;
ProxyShape* m_proxyShape;
RaycastInfo& m_raycastInfo;
const Ray& m_ray;
bool mIsHit;
public:
@ -83,8 +83,8 @@ class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback {
// Constructor
ConcaveMeshRaycastCallback(const DynamicAABBTree& dynamicAABBTree, const ConcaveMeshShape& concaveMeshShape,
ProxyShape* proxyShape, RaycastInfo& raycastInfo, const Ray& ray)
: mDynamicAABBTree(dynamicAABBTree), mConcaveMeshShape(concaveMeshShape), mProxyShape(proxyShape),
mRaycastInfo(raycastInfo), mRay(ray), mIsHit(false) {
: m_dynamicAABBTree(dynamicAABBTree), m_concaveMeshShape(concaveMeshShape), m_proxyShape(proxyShape),
m_raycastInfo(raycastInfo), m_ray(ray), mIsHit(false) {
}
@ -113,10 +113,10 @@ class ConcaveMeshShape : public ConcaveShape {
// -------------------- Attributes -------------------- //
/// Triangle mesh
TriangleMesh* mTriangleMesh;
TriangleMesh* m_triangleMesh;
/// Dynamic AABB tree to accelerate collision with the triangles
DynamicAABBTree mDynamicAABBTree;
DynamicAABBTree m_dynamicAABBTree;
// -------------------- Methods -------------------- //
@ -180,7 +180,7 @@ inline size_t ConcaveMeshShape::getSizeInBytes() const {
inline void ConcaveMeshShape::getLocalBounds(Vector3& min, Vector3& max) const {
// Get the AABB of the whole tree
AABB treeAABB = mDynamicAABBTree.getRootAABB();
AABB treeAABB = m_dynamicAABBTree.getRootAABB();
min = treeAABB.getMin();
max = treeAABB.getMax();
@ -192,7 +192,7 @@ inline void ConcaveMeshShape::setLocalScaling(const Vector3& scaling) {
CollisionShape::setLocalScaling(scaling);
// Reset the Dynamic AABB Tree
mDynamicAABBTree.reset();
m_dynamicAABBTree.reset();
// Rebuild Dynamic AABB Tree here
initBVHTree();
@ -220,14 +220,14 @@ inline void ConcaveMeshShape::computeLocalInertiaTensor(Matrix3x3& tensor, decim
inline void ConvexTriangleAABBOverlapCallback::notifyOverlappingNode(int nodeId) {
// Get the node data (triangle index and mesh subpart index)
int32* data = mDynamicAABBTree.getNodeDataInt(nodeId);
int32* data = m_dynamicAABBTree.getNodeDataInt(nodeId);
// Get the triangle vertices for this node from the concave mesh shape
Vector3 trianglePoints[3];
mConcaveMeshShape.getTriangleVerticesWithIndexPointer(data[0], data[1], trianglePoints);
m_concaveMeshShape.getTriangleVerticesWithIndexPointer(data[0], data[1], trianglePoints);
// Call the callback to test narrow-phase collision with this triangle
mTriangleTestCallback.testTriangle(trianglePoints);
m_triangleTestCallback.testTriangle(trianglePoints);
}
}

View File

@ -32,8 +32,8 @@ using namespace reactphysics3d;
// Constructor
ConcaveShape::ConcaveShape(CollisionShapeType type)
: CollisionShape(type), mIsSmoothMeshCollisionEnabled(false),
mTriangleMargin(0), mRaycastTestType(FRONT) {
: CollisionShape(type), m_isSmoothMeshCollisionEnabled(false),
m_triangleMargin(0), m_raycastTestType(FRONT) {
}

View File

@ -61,13 +61,13 @@ class ConcaveShape : public CollisionShape {
// -------------------- Attributes -------------------- //
/// True if the smooth mesh collision algorithm is enabled
bool mIsSmoothMeshCollisionEnabled;
bool m_isSmoothMeshCollisionEnabled;
// Margin use for collision detection for each triangle
decimal mTriangleMargin;
decimal m_triangleMargin;
/// Raycast test type for the triangle (front, back, front-back)
TriangleRaycastSide mRaycastTestType;
TriangleRaycastSide m_raycastTestType;
// -------------------- Methods -------------------- //
@ -114,7 +114,7 @@ class ConcaveShape : public CollisionShape {
// Return the triangle margin
inline decimal ConcaveShape::getTriangleMargin() const {
return mTriangleMargin;
return m_triangleMargin;
}
/// Return true if the collision shape is convex, false if it is concave
@ -129,7 +129,7 @@ inline bool ConcaveShape::testPointInside(const Vector3& localPoint, ProxyShape*
// Return true if the smooth mesh collision is enabled
inline bool ConcaveShape::getIsSmoothMeshCollisionEnabled() const {
return mIsSmoothMeshCollisionEnabled;
return m_isSmoothMeshCollisionEnabled;
}
// Enable/disable the smooth mesh collision algorithm
@ -137,12 +137,12 @@ inline bool ConcaveShape::getIsSmoothMeshCollisionEnabled() const {
/// of the triangle mesh. If it is enabled, collsions with the mesh will be smoother
/// but collisions computation is a bit more expensive.
inline void ConcaveShape::setIsSmoothMeshCollisionEnabled(bool isEnabled) {
mIsSmoothMeshCollisionEnabled = isEnabled;
m_isSmoothMeshCollisionEnabled = isEnabled;
}
// Return the raycast test type (front, back, front-back)
inline TriangleRaycastSide ConcaveShape::getRaycastTestType() const {
return mRaycastTestType;
return m_raycastTestType;
}
// Set the raycast test type (front, back, front-back)
@ -150,7 +150,7 @@ inline TriangleRaycastSide ConcaveShape::getRaycastTestType() const {
* @param testType Raycast test type for the triangle (front, back, front-back)
*/
inline void ConcaveShape::setRaycastTestType(TriangleRaycastSide testType) {
mRaycastTestType = testType;
m_raycastTestType = testType;
}
}

View File

@ -39,17 +39,17 @@ using namespace reactphysics3d;
* @param margin Collision margin (in meters) around the collision shape
*/
ConvexMeshShape::ConvexMeshShape(const decimal* arrayVertices, uint nbVertices, int stride, decimal margin)
: ConvexShape(CONVEX_MESH, margin), mNbVertices(nbVertices), mMinBounds(0, 0, 0),
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(false) {
: ConvexShape(CONVEX_MESH, margin), m_numberVertices(nbVertices), m_minBounds(0, 0, 0),
m_maxBounds(0, 0, 0), m_isEdgesInformationUsed(false) {
assert(nbVertices > 0);
assert(stride > 0);
const unsigned char* vertexPointer = (const unsigned char*) arrayVertices;
// Copy all the vertices into the internal array
for (uint i=0; i<mNbVertices; i++) {
for (uint i=0; i<m_numberVertices; i++) {
const decimal* newPoint = (const decimal*) vertexPointer;
mVertices.push_back(Vector3(newPoint[0], newPoint[1], newPoint[2]));
m_vertices.push_back(Vector3(newPoint[0], newPoint[1], newPoint[2]));
vertexPointer += stride;
}
@ -65,8 +65,8 @@ ConvexMeshShape::ConvexMeshShape(const decimal* arrayVertices, uint nbVertices,
* @param margin Collision margin (in meters) around the collision shape
*/
ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool isEdgesInformationUsed, decimal margin)
: ConvexShape(CONVEX_MESH, margin), mMinBounds(0, 0, 0),
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(isEdgesInformationUsed) {
: ConvexShape(CONVEX_MESH, margin), m_minBounds(0, 0, 0),
m_maxBounds(0, 0, 0), m_isEdgesInformationUsed(isEdgesInformationUsed) {
TriangleVertexArray::VertexDataType vertexType = triangleVertexArray->getVertexDataType();
TriangleVertexArray::IndexDataType indexType = triangleVertexArray->getIndexDataType();
@ -84,19 +84,19 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool
Vector3 vertex(vertices[0], vertices[1], vertices[2] );
vertex = vertex * mScaling;
mVertices.push_back(vertex);
m_vertices.push_back(vertex);
}
else if (vertexType == TriangleVertexArray::VERTEX_DOUBLE_TYPE) {
const double* vertices = (double*)(verticesStart + v * vertexStride);
Vector3 vertex(vertices[0], vertices[1], vertices[2] );
vertex = vertex * mScaling;
mVertices.push_back(vertex);
m_vertices.push_back(vertex);
}
}
// If we need to use the edges information of the mesh
if (mIsEdgesInformationUsed) {
if (m_isEdgesInformationUsed) {
// For each triangle of the mesh
for (uint triangleIndex=0; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) {
@ -127,7 +127,7 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool
}
}
mNbVertices = mVertices.size();
m_numberVertices = m_vertices.size();
recalculateBounds();
}
@ -135,8 +135,8 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool
/// If you use this constructor, you will need to set the vertices manually one by one using
/// the addVertex() method.
ConvexMeshShape::ConvexMeshShape(decimal margin)
: ConvexShape(CONVEX_MESH, margin), mNbVertices(0), mMinBounds(0, 0, 0),
mMaxBounds(0, 0, 0), mIsEdgesInformationUsed(false) {
: ConvexShape(CONVEX_MESH, margin), m_numberVertices(0), m_minBounds(0, 0, 0),
m_maxBounds(0, 0, 0), m_isEdgesInformationUsed(false) {
}
@ -156,7 +156,7 @@ ConvexMeshShape::~ConvexMeshShape() {
Vector3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const Vector3& direction,
void** cachedCollisionData) const {
assert(mNbVertices == mVertices.size());
assert(m_numberVertices == m_vertices.size());
assert(cachedCollisionData != NULL);
// Allocate memory for the cached collision data if not allocated yet
@ -166,28 +166,28 @@ Vector3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const Vector3& direct
}
// If the edges information is used to speed up the collision detection
if (mIsEdgesInformationUsed) {
if (m_isEdgesInformationUsed) {
assert(mEdgesAdjacencyList.size() == mNbVertices);
assert(m_edgesAdjacencyList.size() == m_numberVertices);
uint maxVertex = *((int*)(*cachedCollisionData));
decimal maxDotProduct = direction.dot(mVertices[maxVertex]);
decimal maxDotProduct = direction.dot(m_vertices[maxVertex]);
bool isOptimal;
// Perform hill-climbing (local search)
do {
isOptimal = true;
assert(mEdgesAdjacencyList.at(maxVertex).size() > 0);
assert(m_edgesAdjacencyList.at(maxVertex).size() > 0);
// For all neighbors of the current vertex
std::set<uint>::const_iterator it;
std::set<uint>::const_iterator itBegin = mEdgesAdjacencyList.at(maxVertex).begin();
std::set<uint>::const_iterator itEnd = mEdgesAdjacencyList.at(maxVertex).end();
std::set<uint>::const_iterator itBegin = m_edgesAdjacencyList.at(maxVertex).begin();
std::set<uint>::const_iterator itEnd = m_edgesAdjacencyList.at(maxVertex).end();
for (it = itBegin; it != itEnd; ++it) {
// Compute the dot product
decimal dotProduct = direction.dot(mVertices[*it]);
decimal dotProduct = direction.dot(m_vertices[*it]);
// If the current vertex is a better vertex (larger dot product)
if (dotProduct > maxDotProduct) {
@ -203,7 +203,7 @@ Vector3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const Vector3& direct
*((int*)(*cachedCollisionData)) = maxVertex;
// Return the support vertex
return mVertices[maxVertex] * mScaling;
return m_vertices[maxVertex] * mScaling;
}
else { // If the edges information is not used
@ -211,10 +211,10 @@ Vector3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const Vector3& direct
uint indexMaxDotProduct = 0;
// For each vertex of the mesh
for (uint i=0; i<mNbVertices; i++) {
for (uint i=0; i<m_numberVertices; i++) {
// Compute the dot product of the current vertex
double dotProduct = direction.dot(mVertices[i]);
double dotProduct = direction.dot(m_vertices[i]);
// If the current dot product is larger than the maximum one
if (dotProduct > maxDotProduct) {
@ -226,7 +226,7 @@ Vector3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const Vector3& direct
assert(maxDotProduct >= decimal(0.0));
// Return the vertex with the largest dot product in the support direction
return mVertices[indexMaxDotProduct] * mScaling;
return m_vertices[indexMaxDotProduct] * mScaling;
}
}
@ -236,29 +236,29 @@ void ConvexMeshShape::recalculateBounds() {
// TODO : Only works if the local origin is inside the mesh
// => Make it more robust (init with first vertex of mesh instead)
mMinBounds.setToZero();
mMaxBounds.setToZero();
m_minBounds.setToZero();
m_maxBounds.setToZero();
// For each vertex of the mesh
for (uint i=0; i<mNbVertices; i++) {
for (uint i=0; i<m_numberVertices; i++) {
if (mVertices[i].x > mMaxBounds.x) mMaxBounds.x = mVertices[i].x;
if (mVertices[i].x < mMinBounds.x) mMinBounds.x = mVertices[i].x;
if (m_vertices[i].x > m_maxBounds.x) m_maxBounds.x = m_vertices[i].x;
if (m_vertices[i].x < m_minBounds.x) m_minBounds.x = m_vertices[i].x;
if (mVertices[i].y > mMaxBounds.y) mMaxBounds.y = mVertices[i].y;
if (mVertices[i].y < mMinBounds.y) mMinBounds.y = mVertices[i].y;
if (m_vertices[i].y > m_maxBounds.y) m_maxBounds.y = m_vertices[i].y;
if (m_vertices[i].y < m_minBounds.y) m_minBounds.y = m_vertices[i].y;
if (mVertices[i].z > mMaxBounds.z) mMaxBounds.z = mVertices[i].z;
if (mVertices[i].z < mMinBounds.z) mMinBounds.z = mVertices[i].z;
if (m_vertices[i].z > m_maxBounds.z) m_maxBounds.z = m_vertices[i].z;
if (m_vertices[i].z < m_minBounds.z) m_minBounds.z = m_vertices[i].z;
}
// Apply the local scaling factor
mMaxBounds = mMaxBounds * mScaling;
mMinBounds = mMinBounds * mScaling;
m_maxBounds = m_maxBounds * mScaling;
m_minBounds = m_minBounds * mScaling;
// Add the object margin to the bounds
mMaxBounds += Vector3(mMargin, mMargin, mMargin);
mMinBounds -= Vector3(mMargin, mMargin, mMargin);
m_maxBounds += Vector3(mMargin, mMargin, mMargin);
m_minBounds -= Vector3(mMargin, mMargin, mMargin);
}
// Raycast method with feedback information

View File

@ -65,23 +65,23 @@ class ConvexMeshShape : public ConvexShape {
// -------------------- Attributes -------------------- //
/// Array with the vertices of the mesh
std::vector<Vector3> mVertices;
std::vector<Vector3> m_vertices;
/// Number of vertices in the mesh
uint mNbVertices;
uint m_numberVertices;
/// Mesh minimum bounds in the three local x, y and z directions
Vector3 mMinBounds;
Vector3 m_minBounds;
/// Mesh maximum bounds in the three local x, y and z directions
Vector3 mMaxBounds;
Vector3 m_maxBounds;
/// True if the shape contains the edges of the convex mesh in order to
/// make the collision detection faster
bool mIsEdgesInformationUsed;
bool m_isEdgesInformationUsed;
/// Adjacency list representing the edges of the mesh
std::map<uint, std::set<uint> > mEdgesAdjacencyList;
std::map<uint, std::set<uint> > m_edgesAdjacencyList;
// -------------------- Methods -------------------- //
@ -165,8 +165,8 @@ inline size_t ConvexMeshShape::getSizeInBytes() const {
* @param max The maximum bounds of the shape in local-space coordinates
*/
inline void ConvexMeshShape::getLocalBounds(Vector3& min, Vector3& max) const {
min = mMinBounds;
max = mMaxBounds;
min = m_minBounds;
max = m_maxBounds;
}
// Return the local inertia tensor of the collision shape.
@ -179,7 +179,7 @@ inline void ConvexMeshShape::getLocalBounds(Vector3& min, Vector3& max) const {
*/
inline void ConvexMeshShape::computeLocalInertiaTensor(Matrix3x3& tensor, decimal mass) const {
decimal factor = (decimal(1.0) / decimal(3.0)) * mass;
Vector3 realExtent = decimal(0.5) * (mMaxBounds - mMinBounds);
Vector3 realExtent = decimal(0.5) * (m_maxBounds - m_minBounds);
assert(realExtent.x > 0 && realExtent.y > 0 && realExtent.z > 0);
decimal xSquare = realExtent.x * realExtent.x;
decimal ySquare = realExtent.y * realExtent.y;
@ -196,16 +196,16 @@ inline void ConvexMeshShape::computeLocalInertiaTensor(Matrix3x3& tensor, decima
inline void ConvexMeshShape::addVertex(const Vector3& vertex) {
// Add the vertex in to vertices array
mVertices.push_back(vertex);
mNbVertices++;
m_vertices.push_back(vertex);
m_numberVertices++;
// Update the bounds of the mesh
if (vertex.x * mScaling.x > mMaxBounds.x) mMaxBounds.x = vertex.x * mScaling.x;
if (vertex.x * mScaling.x < mMinBounds.x) mMinBounds.x = vertex.x * mScaling.x;
if (vertex.y * mScaling.y > mMaxBounds.y) mMaxBounds.y = vertex.y * mScaling.y;
if (vertex.y * mScaling.y < mMinBounds.y) mMinBounds.y = vertex.y * mScaling.y;
if (vertex.z * mScaling.z > mMaxBounds.z) mMaxBounds.z = vertex.z * mScaling.z;
if (vertex.z * mScaling.z < mMinBounds.z) mMinBounds.z = vertex.z * mScaling.z;
if (vertex.x * mScaling.x > m_maxBounds.x) m_maxBounds.x = vertex.x * mScaling.x;
if (vertex.x * mScaling.x < m_minBounds.x) m_minBounds.x = vertex.x * mScaling.x;
if (vertex.y * mScaling.y > m_maxBounds.y) m_maxBounds.y = vertex.y * mScaling.y;
if (vertex.y * mScaling.y < m_minBounds.y) m_minBounds.y = vertex.y * mScaling.y;
if (vertex.z * mScaling.z > m_maxBounds.z) m_maxBounds.z = vertex.z * mScaling.z;
if (vertex.z * mScaling.z < m_minBounds.z) m_minBounds.z = vertex.z * mScaling.z;
}
// Add an edge into the convex mesh by specifying the two vertex indices of the edge.
@ -219,18 +219,18 @@ inline void ConvexMeshShape::addVertex(const Vector3& vertex) {
inline void ConvexMeshShape::addEdge(uint v1, uint v2) {
// If the entry for vertex v1 does not exist in the adjacency list
if (mEdgesAdjacencyList.count(v1) == 0) {
mEdgesAdjacencyList.insert(std::make_pair(v1, std::set<uint>()));
if (m_edgesAdjacencyList.count(v1) == 0) {
m_edgesAdjacencyList.insert(std::make_pair(v1, std::set<uint>()));
}
// If the entry for vertex v2 does not exist in the adjacency list
if (mEdgesAdjacencyList.count(v2) == 0) {
mEdgesAdjacencyList.insert(std::make_pair(v2, std::set<uint>()));
if (m_edgesAdjacencyList.count(v2) == 0) {
m_edgesAdjacencyList.insert(std::make_pair(v2, std::set<uint>()));
}
// Add the edge in the adjacency list
mEdgesAdjacencyList[v1].insert(v2);
mEdgesAdjacencyList[v2].insert(v1);
m_edgesAdjacencyList[v1].insert(v2);
m_edgesAdjacencyList[v2].insert(v1);
}
// Return true if the edges information is used to speed up the collision detection
@ -238,7 +238,7 @@ inline void ConvexMeshShape::addEdge(uint v1, uint v2) {
* @return True if the edges information is used and false otherwise
*/
inline bool ConvexMeshShape::isEdgesInformationUsed() const {
return mIsEdgesInformationUsed;
return m_isEdgesInformationUsed;
}
// Set the variable to know if the edges information is used to speed up the
@ -248,7 +248,7 @@ inline bool ConvexMeshShape::isEdgesInformationUsed() const {
* the collision detection with the convex mesh shape
*/
inline void ConvexMeshShape::setIsEdgesInformationUsed(bool isEdgesUsed) {
mIsEdgesInformationUsed = isEdgesUsed;
m_isEdgesInformationUsed = isEdgesUsed;
}
// Return true if a point is inside the collision shape

View File

@ -246,20 +246,20 @@ void TriangleOverlapCallback::testTriangle(const Vector3* trianglePoints) {
// Ray casting test against the collision shape
RaycastInfo raycastInfo;
bool isTriangleHit = triangleShape.raycast(mRay, raycastInfo, mProxyShape);
bool isTriangleHit = triangleShape.raycast(m_ray, raycastInfo, m_proxyShape);
// If the ray hit the collision shape
if (isTriangleHit && raycastInfo.hitFraction <= mSmallestHitFraction) {
assert(raycastInfo.hitFraction >= decimal(0.0));
mRaycastInfo.body = raycastInfo.body;
mRaycastInfo.proxyShape = raycastInfo.proxyShape;
mRaycastInfo.hitFraction = raycastInfo.hitFraction;
mRaycastInfo.worldPoint = raycastInfo.worldPoint;
mRaycastInfo.worldNormal = raycastInfo.worldNormal;
mRaycastInfo.meshSubpart = -1;
mRaycastInfo.triangleIndex = -1;
m_raycastInfo.body = raycastInfo.body;
m_raycastInfo.proxyShape = raycastInfo.proxyShape;
m_raycastInfo.hitFraction = raycastInfo.hitFraction;
m_raycastInfo.worldPoint = raycastInfo.worldPoint;
m_raycastInfo.worldNormal = raycastInfo.worldNormal;
m_raycastInfo.meshSubpart = -1;
m_raycastInfo.triangleIndex = -1;
mSmallestHitFraction = raycastInfo.hitFraction;
mIsHit = true;

View File

@ -43,9 +43,9 @@ class TriangleOverlapCallback : public TriangleCallback {
protected:
const Ray& mRay;
ProxyShape* mProxyShape;
RaycastInfo& mRaycastInfo;
const Ray& m_ray;
ProxyShape* m_proxyShape;
RaycastInfo& m_raycastInfo;
bool mIsHit;
decimal mSmallestHitFraction;
const HeightFieldShape& mHeightFieldShape;
@ -55,10 +55,10 @@ class TriangleOverlapCallback : public TriangleCallback {
// Constructor
TriangleOverlapCallback(const Ray& ray, ProxyShape* proxyShape, RaycastInfo& raycastInfo,
const HeightFieldShape& heightFieldShape)
: mRay(ray), mProxyShape(proxyShape), mRaycastInfo(raycastInfo),
: m_ray(ray), m_proxyShape(proxyShape), m_raycastInfo(raycastInfo),
mHeightFieldShape (heightFieldShape) {
mIsHit = false;
mSmallestHitFraction = mRay.maxFraction;
mSmallestHitFraction = m_ray.maxFraction;
}
bool getIsHit() const {return mIsHit;}

View File

@ -44,7 +44,7 @@ TriangleShape::TriangleShape(const Vector3& point1, const Vector3& point2, const
mPoints[0] = point1;
mPoints[1] = point2;
mPoints[2] = point3;
mRaycastTestType = FRONT;
m_raycastTestType = FRONT;
}
// Destructor
@ -68,32 +68,32 @@ bool TriangleShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape
// product for this test.
const Vector3 m = pq.cross(pc);
decimal u = pb.dot(m);
if (mRaycastTestType == FRONT) {
if (m_raycastTestType == FRONT) {
if (u < decimal(0.0)) return false;
}
else if (mRaycastTestType == BACK) {
else if (m_raycastTestType == BACK) {
if (u > decimal(0.0)) return false;
}
decimal v = -pa.dot(m);
if (mRaycastTestType == FRONT) {
if (m_raycastTestType == FRONT) {
if (v < decimal(0.0)) return false;
}
else if (mRaycastTestType == BACK) {
else if (m_raycastTestType == BACK) {
if (v > decimal(0.0)) return false;
}
else if (mRaycastTestType == FRONT_AND_BACK) {
else if (m_raycastTestType == FRONT_AND_BACK) {
if (!sameSign(u, v)) return false;
}
decimal w = pa.dot(pq.cross(pb));
if (mRaycastTestType == FRONT) {
if (m_raycastTestType == FRONT) {
if (w < decimal(0.0)) return false;
}
else if (mRaycastTestType == BACK) {
else if (m_raycastTestType == BACK) {
if (w > decimal(0.0)) return false;
}
else if (mRaycastTestType == FRONT_AND_BACK) {
else if (m_raycastTestType == FRONT_AND_BACK) {
if (!sameSign(u, w)) return false;
}

View File

@ -61,7 +61,7 @@ class TriangleShape : public ConvexShape {
Vector3 mPoints[3];
/// Raycast test type for the triangle (front, back, front-back)
TriangleRaycastSide mRaycastTestType;
TriangleRaycastSide m_raycastTestType;
// -------------------- Methods -------------------- //
@ -198,7 +198,7 @@ inline bool TriangleShape::testPointInside(const Vector3& localPoint, ProxyShape
// Return the raycast test type (front, back, front-back)
inline TriangleRaycastSide TriangleShape::getRaycastTestType() const {
return mRaycastTestType;
return m_raycastTestType;
}
// Set the raycast test type (front, back, front-back)
@ -206,7 +206,7 @@ inline TriangleRaycastSide TriangleShape::getRaycastTestType() const {
* @param testType Raycast test type for the triangle (front, back, front-back)
*/
inline void TriangleShape::setRaycastTestType(TriangleRaycastSide testType) {
mRaycastTestType = testType;
m_raycastTestType = testType;
}
// Return the coordinates of a given vertex of the triangle

View File

@ -28,13 +28,7 @@
/// ReactPhysiscs3D namespace
namespace reactphysics3d {
#if defined(IS_DOUBLE_PRECISION_ENABLED) // If we are compiling for double precision
typedef double decimal;
#else // If we are compiling for single precision
typedef float decimal;
#endif
}
#endif

View File

@ -87,7 +87,7 @@ class TestDynamicAABBTree : public Test {
// ---------- Atributes ---------- //
OverlapCallback mOverlapCallback;
DynamicTreeRaycastCallback mRaycastCallback;
DynamicTreeRaycastCallback m_raycastCallback;
@ -377,40 +377,40 @@ class TestDynamicAABBTree : public Test {
// ---------- Tests ---------- //
// Ray with no hits
mRaycastCallback.reset();
m_raycastCallback.reset();
Ray ray1(Vector3(4.5, -10, -5), Vector3(4.5, 10, -5));
tree.raycast(ray1, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
tree.raycast(ray1, m_raycastCallback);
test(!m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 1
mRaycastCallback.reset();
m_raycastCallback.reset();
Ray ray2(Vector3(-1, -20, -2), Vector3(-1, 20, -2));
tree.raycast(ray2, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
tree.raycast(ray2, m_raycastCallback);
test(m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 1 and 2
mRaycastCallback.reset();
m_raycastCallback.reset();
Ray ray3(Vector3(-7, 6, -2), Vector3(8, 6, -2));
tree.raycast(ray3, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
tree.raycast(ray3, m_raycastCallback);
test(m_raycastCallback.isHit(object1Id));
test(m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 3
mRaycastCallback.reset();
m_raycastCallback.reset();
Ray ray4(Vector3(-7, 2, 0), Vector3(-1, 2, 0));
tree.raycast(ray4, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
tree.raycast(ray4, m_raycastCallback);
test(!m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// ---- Update the object AABBs with the initial AABBs (no reinsertion) ----- //
@ -420,36 +420,36 @@ class TestDynamicAABBTree : public Test {
tree.updateObject(object4Id, aabb4, Vector3::zero(), false);
// Ray with no hits
mRaycastCallback.reset();
tree.raycast(ray1, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray1, m_raycastCallback);
test(!m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 1
mRaycastCallback.reset();
tree.raycast(ray2, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray2, m_raycastCallback);
test(m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 1 and 2
mRaycastCallback.reset();
tree.raycast(ray3, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray3, m_raycastCallback);
test(m_raycastCallback.isHit(object1Id));
test(m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 3
mRaycastCallback.reset();
tree.raycast(ray4, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray4, m_raycastCallback);
test(!m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// ---- Update the object AABBs with the initial AABBs (with reinsertion) ----- //
@ -459,36 +459,36 @@ class TestDynamicAABBTree : public Test {
tree.updateObject(object4Id, aabb4, Vector3::zero(), true);
// Ray with no hits
mRaycastCallback.reset();
tree.raycast(ray1, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray1, m_raycastCallback);
test(!m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 1
mRaycastCallback.reset();
tree.raycast(ray2, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray2, m_raycastCallback);
test(m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 1 and 2
mRaycastCallback.reset();
tree.raycast(ray3, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray3, m_raycastCallback);
test(m_raycastCallback.isHit(object1Id));
test(m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 3
mRaycastCallback.reset();
tree.raycast(ray4, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray4, m_raycastCallback);
test(!m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// ---- Move objects 2 and 3 ----- //
@ -500,21 +500,21 @@ class TestDynamicAABBTree : public Test {
// Ray that hits object 1, 2
Ray ray5(Vector3(-4, -5, 0), Vector3(-4, 12, 0));
mRaycastCallback.reset();
tree.raycast(ray5, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray5, m_raycastCallback);
test(m_raycastCallback.isHit(object1Id));
test(m_raycastCallback.isHit(object2Id));
test(!m_raycastCallback.isHit(object3Id));
test(!m_raycastCallback.isHit(object4Id));
// Ray that hits object 3 and 4
Ray ray6(Vector3(11, -3, 1), Vector3(-2, -3, 1));
mRaycastCallback.reset();
tree.raycast(ray6, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(mRaycastCallback.isHit(object3Id));
test(mRaycastCallback.isHit(object4Id));
m_raycastCallback.reset();
tree.raycast(ray6, m_raycastCallback);
test(!m_raycastCallback.isHit(object1Id));
test(!m_raycastCallback.isHit(object2Id));
test(m_raycastCallback.isHit(object3Id));
test(m_raycastCallback.isHit(object4Id));
}
};

View File

@ -135,7 +135,7 @@ class TestRaycast : public Test {
ConvexMeshShape* mConvexMeshShapeEdgesInfo;
CylinderShape* mCylinderShape;
TriangleShape* mTriangleShape;
ConcaveShape* mConcaveMeshShape;
ConcaveShape* m_concaveMeshShape;
HeightFieldShape* mHeightFieldShape;
// Proxy Shapes
@ -299,8 +299,8 @@ class TestRaycast : public Test {
// Add the triangle vertex array of the subpart to the triangle mesh
mConcaveTriangleMesh.addSubpart(mConcaveMeshVertexArray);
mConcaveMeshShape = new ConcaveMeshShape(&mConcaveTriangleMesh);
mConcaveMeshProxyShape = mConcaveMeshBody->addCollisionShape(mConcaveMeshShape, mShapeTransform);
m_concaveMeshShape = new ConcaveMeshShape(&mConcaveTriangleMesh);
mConcaveMeshProxyShape = mConcaveMeshBody->addCollisionShape(m_concaveMeshShape, mShapeTransform);
// Heightfield shape (plane height field at height=4)
@ -333,7 +333,7 @@ class TestRaycast : public Test {
delete mConvexMeshShapeEdgesInfo;
delete mCylinderShape;
delete mTriangleShape;
delete mConcaveMeshShape;
delete m_concaveMeshShape;
delete mHeightFieldShape;
delete mConcaveMeshVertexArray;

View File

@ -145,7 +145,7 @@ Box::Box(const openglframework::Vector3& size, const openglframework::Vector3 &p
mBody = world->createCollisionBody(transform);
// Add the collision shape to the body
mProxyShape = mBody->addCollisionShape(mBoxShape, rp3d::Transform::identity());
m_proxyShape = mBody->addCollisionShape(mBoxShape, rp3d::Transform::identity());
// If the Vertex Buffer object has not been created yet
if (totalNbBoxes == 0) {
@ -194,7 +194,7 @@ Box::Box(const openglframework::Vector3& size, const openglframework::Vector3& p
rp3d::RigidBody* body = world->createRigidBody(transform);
// Add the collision shape to the body
mProxyShape = body->addCollisionShape(mBoxShape, rp3d::Transform::identity(), mass);
m_proxyShape = body->addCollisionShape(mBoxShape, rp3d::Transform::identity(), mass);
mBody = body;
@ -333,7 +333,7 @@ void Box::resetTransform(const rp3d::Transform& transform) {
void Box::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
m_proxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(mSize[0] * scaling.x, 0, 0, 0,

View File

@ -42,7 +42,7 @@ class Box : public openglframework::Object3D, public PhysicsObject {
float mSize[3];
rp3d::BoxShape* mBoxShape;
rp3d::ProxyShape* mProxyShape;
rp3d::ProxyShape* m_proxyShape;
/// Scaling matrix (applied to a cube to obtain the correct box dimensions)
openglframework::Matrix4 mScalingMatrix;

View File

@ -70,7 +70,7 @@ Capsule::Capsule(float radius, float height, const openglframework::Vector3& pos
mBody = world->createCollisionBody(transform);
// Add a collision shape to the body and specify the mass of the shape
mProxyShape = mBody->addCollisionShape(mCapsuleShape, rp3d::Transform::identity());
m_proxyShape = mBody->addCollisionShape(mCapsuleShape, rp3d::Transform::identity());
mTransformMatrix = mTransformMatrix * mScalingMatrix;
@ -117,7 +117,7 @@ Capsule::Capsule(float radius, float height, const openglframework::Vector3& pos
rp3d::RigidBody* body = dynamicsWorld->createRigidBody(transform);
// Add a collision shape to the body and specify the mass of the shape
mProxyShape = body->addCollisionShape(mCapsuleShape, rp3d::Transform::identity(), mass);
m_proxyShape = body->addCollisionShape(mCapsuleShape, rp3d::Transform::identity(), mass);
mBody = body;
@ -215,7 +215,7 @@ void Capsule::createVBOAndVAO() {
// Create the VBO for the vertices data
mVBOVertices.create();
mVBOVertices.bind();
size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
size_t sizeVertices = m_vertices.size() * sizeof(openglframework::Vector3);
mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
mVBOVertices.unbind();
@ -286,7 +286,7 @@ void Capsule::resetTransform(const rp3d::Transform& transform) {
void Capsule::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
m_proxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(mRadius * scaling.x, 0, 0, 0,

View File

@ -49,7 +49,7 @@ class Capsule : public openglframework::Mesh, public PhysicsObject {
/// Collision shape
rp3d::CapsuleShape* mCapsuleShape;
rp3d::ProxyShape* mProxyShape;
rp3d::ProxyShape* m_proxyShape;
/// Previous transform (for interpolation)
rp3d::Transform mPreviousTransform;

View File

@ -51,7 +51,7 @@ ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position,
// Vertex and Indices array for the triangle mesh (data in shared and not copied)
rp3d::TriangleVertexArray* vertexArray =
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
new rp3d::TriangleVertexArray(getNbVertices(), &(m_vertices[0]), sizeof(openglframework::Vector3),
getNbFaces(i), &(mIndices[i][0]), sizeof(int),
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
@ -75,7 +75,7 @@ ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position,
mBody = world->createCollisionBody(transform);
// Add a collision shape to the body and specify the mass of the collision shape
mProxyShape = mBody->addCollisionShape(mConcaveShape, rp3d::Transform::identity());
m_proxyShape = mBody->addCollisionShape(mConcaveShape, rp3d::Transform::identity());
// Create the VBOs and VAO
createVBOAndVAO();
@ -108,7 +108,7 @@ ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position, float mass,
// Vertex and Indices array for the triangle mesh (data in shared and not copied)
rp3d::TriangleVertexArray* vertexArray =
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
new rp3d::TriangleVertexArray(getNbVertices(), &(m_vertices[0]), sizeof(openglframework::Vector3),
getNbFaces(i), &(mIndices[i][0]), sizeof(int),
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
@ -132,7 +132,7 @@ ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position, float mass,
rp3d::RigidBody* body = dynamicsWorld->createRigidBody(transform);
// Add a collision shape to the body and specify the mass of the collision shape
mProxyShape = body->addCollisionShape(mConcaveShape, rp3d::Transform::identity(), mass);
m_proxyShape = body->addCollisionShape(mConcaveShape, rp3d::Transform::identity(), mass);
mBody = body;
@ -228,7 +228,7 @@ void ConcaveMesh::createVBOAndVAO() {
// Create the VBO for the vertices data
mVBOVertices.create();
mVBOVertices.bind();
size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
size_t sizeVertices = m_vertices.size() * sizeof(openglframework::Vector3);
mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
mVBOVertices.unbind();
@ -299,7 +299,7 @@ void ConcaveMesh::resetTransform(const rp3d::Transform& transform) {
void ConcaveMesh::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
m_proxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0,

View File

@ -43,7 +43,7 @@ class ConcaveMesh : public openglframework::Mesh, public PhysicsObject {
/// Collision shape
rp3d::ConcaveMeshShape* mConcaveShape;
rp3d::ProxyShape* mProxyShape;
rp3d::ProxyShape* m_proxyShape;
/// Scaling matrix
openglframework::Matrix4 mScalingMatrix;

View File

@ -69,7 +69,7 @@ Cone::Cone(float radius, float height, const openglframework::Vector3 &position,
mBody = world->createCollisionBody(transform);
// Add a collision shape to the body and specify the mass of the shape
mProxyShape = mBody->addCollisionShape(mConeShape, rp3d::Transform::identity());
m_proxyShape = mBody->addCollisionShape(mConeShape, rp3d::Transform::identity());
mTransformMatrix = mTransformMatrix * mScalingMatrix;
@ -115,7 +115,7 @@ Cone::Cone(float radius, float height, const openglframework::Vector3 &position,
rp3d::RigidBody* body = dynamicsWorld->createRigidBody(transform);
// Add a collision shape to the body and specify the mass of the shape
mProxyShape = body->addCollisionShape(mConeShape, rp3d::Transform::identity(), mass);
m_proxyShape = body->addCollisionShape(mConeShape, rp3d::Transform::identity(), mass);
mBody = body;
@ -212,7 +212,7 @@ void Cone::createVBOAndVAO() {
// Create the VBO for the vertices data
mVBOVertices.create();
mVBOVertices.bind();
size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
size_t sizeVertices = m_vertices.size() * sizeof(openglframework::Vector3);
mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
mVBOVertices.unbind();
@ -283,7 +283,7 @@ void Cone::resetTransform(const rp3d::Transform& transform) {
void Cone::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
m_proxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(mRadius * scaling.x, 0, 0, 0,

View File

@ -46,7 +46,7 @@ class Cone : public openglframework::Mesh, public PhysicsObject {
/// Collision shape
rp3d::ConeShape* mConeShape;
rp3d::ProxyShape* mProxyShape;
rp3d::ProxyShape* m_proxyShape;
/// Scaling matrix (applied to a sphere to obtain the correct cone dimensions)
openglframework::Matrix4 mScalingMatrix;

View File

@ -49,7 +49,7 @@ ConvexMesh::ConvexMesh(const openglframework::Vector3 &position,
// Vertex and Indices array for the triangle mesh (data in shared and not copied)
mPhysicsTriangleVertexArray =
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
new rp3d::TriangleVertexArray(getNbVertices(), &(m_vertices[0]), sizeof(openglframework::Vector3),
getNbFaces(0), &(mIndices[0][0]), sizeof(int),
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
@ -69,7 +69,7 @@ ConvexMesh::ConvexMesh(const openglframework::Vector3 &position,
mBody = world->createCollisionBody(transform);
// Add a collision shape to the body and specify the mass of the collision shape
mProxyShape = mBody->addCollisionShape(mConvexShape, rp3d::Transform::identity());
m_proxyShape = mBody->addCollisionShape(mConvexShape, rp3d::Transform::identity());
// Create the VBOs and VAO
createVBOAndVAO();
@ -99,7 +99,7 @@ ConvexMesh::ConvexMesh(const openglframework::Vector3 &position, float mass,
// Vertex and Indices array for the triangle mesh (data in shared and not copied)
mPhysicsTriangleVertexArray =
new rp3d::TriangleVertexArray(getNbVertices(), &(mVertices[0]), sizeof(openglframework::Vector3),
new rp3d::TriangleVertexArray(getNbVertices(), &(m_vertices[0]), sizeof(openglframework::Vector3),
getNbFaces(0), &(mIndices[0][0]), sizeof(int),
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
@ -117,7 +117,7 @@ ConvexMesh::ConvexMesh(const openglframework::Vector3 &position, float mass,
rp3d::RigidBody* body = dynamicsWorld->createRigidBody(transform);
// Add a collision shape to the body and specify the mass of the collision shape
mProxyShape = body->addCollisionShape(mConvexShape, rp3d::Transform::identity(), mass);
m_proxyShape = body->addCollisionShape(mConvexShape, rp3d::Transform::identity(), mass);
mBody = body;
@ -209,7 +209,7 @@ void ConvexMesh::createVBOAndVAO() {
// Create the VBO for the vertices data
mVBOVertices.create();
mVBOVertices.bind();
size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
size_t sizeVertices = m_vertices.size() * sizeof(openglframework::Vector3);
mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
mVBOVertices.unbind();
@ -280,7 +280,7 @@ void ConvexMesh::resetTransform(const rp3d::Transform& transform) {
void ConvexMesh::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
m_proxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0,

View File

@ -45,7 +45,7 @@ class ConvexMesh : public openglframework::Mesh, public PhysicsObject {
/// Collision shape
rp3d::ConvexMeshShape* mConvexShape;
rp3d::ProxyShape* mProxyShape;
rp3d::ProxyShape* m_proxyShape;
/// Scaling matrix
openglframework::Matrix4 mScalingMatrix;

View File

@ -69,7 +69,7 @@ Cylinder::Cylinder(float radius, float height, const openglframework::Vector3& p
mBody = world->createCollisionBody(transform);
// Add a collision shape to the body and specify the mass of the shape
mProxyShape = mBody->addCollisionShape(mCylinderShape, rp3d::Transform::identity());
m_proxyShape = mBody->addCollisionShape(mCylinderShape, rp3d::Transform::identity());
mTransformMatrix = mTransformMatrix * mScalingMatrix;
@ -115,7 +115,7 @@ Cylinder::Cylinder(float radius, float height, const openglframework::Vector3& p
rp3d::RigidBody* body = dynamicsWorld->createRigidBody(transform);
// Add a collision shape to the body and specify the mass of the shape
mProxyShape = body->addCollisionShape(mCylinderShape, rp3d::Transform::identity(), mass);
m_proxyShape = body->addCollisionShape(mCylinderShape, rp3d::Transform::identity(), mass);
mTransformMatrix = mTransformMatrix * mScalingMatrix;
@ -213,7 +213,7 @@ void Cylinder::createVBOAndVAO() {
// Create the VBO for the vertices data
mVBOVertices.create();
mVBOVertices.bind();
size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
size_t sizeVertices = m_vertices.size() * sizeof(openglframework::Vector3);
mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
mVBOVertices.unbind();
@ -284,7 +284,7 @@ void Cylinder::resetTransform(const rp3d::Transform& transform) {
void Cylinder::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
m_proxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(mRadius * scaling.x, 0, 0, 0,

View File

@ -52,7 +52,7 @@ class Cylinder : public openglframework::Mesh, public PhysicsObject {
/// Collision shape
rp3d::CylinderShape* mCylinderShape;
rp3d::ProxyShape* mProxyShape;
rp3d::ProxyShape* m_proxyShape;
/// Vertex Buffer Object for the vertices data
static openglframework::VertexBufferObject mVBOVertices;

View File

@ -88,9 +88,9 @@ Dumbbell::Dumbbell(const openglframework::Vector3 &position,
rp3d::RigidBody* body = dynamicsWorld->createRigidBody(transformBody);
// Add the three collision shapes to the body and specify the mass and transform of the shapes
mProxyShapeSphere1 = body->addCollisionShape(mSphereShape, transformSphereShape1, massSphere);
mProxyShapeSphere2 = body->addCollisionShape(mSphereShape, transformSphereShape2, massSphere);
mProxyShapeCylinder = body->addCollisionShape(mCylinderShape, transformCylinderShape, massCylinder);
m_proxyShapeSphere1 = body->addCollisionShape(mSphereShape, transformSphereShape1, massSphere);
m_proxyShapeSphere2 = body->addCollisionShape(mSphereShape, transformSphereShape2, massSphere);
m_proxyShapeCylinder = body->addCollisionShape(mCylinderShape, transformCylinderShape, massCylinder);
mBody = body;
@ -155,9 +155,9 @@ Dumbbell::Dumbbell(const openglframework::Vector3 &position,
mBody = world->createCollisionBody(transformBody);
// Add the three collision shapes to the body and specify the mass and transform of the shapes
mProxyShapeSphere1 = mBody->addCollisionShape(mSphereShape, transformSphereShape1);
mProxyShapeSphere2 = mBody->addCollisionShape(mSphereShape, transformSphereShape2);
mProxyShapeCylinder = mBody->addCollisionShape(mCylinderShape, transformCylinderShape);
m_proxyShapeSphere1 = mBody->addCollisionShape(mSphereShape, transformSphereShape1);
m_proxyShapeSphere2 = mBody->addCollisionShape(mSphereShape, transformSphereShape2);
m_proxyShapeCylinder = mBody->addCollisionShape(mCylinderShape, transformCylinderShape);
mTransformMatrix = mTransformMatrix * mScalingMatrix;
@ -254,7 +254,7 @@ void Dumbbell::createVBOAndVAO() {
// Create the VBO for the vertices data
mVBOVertices.create();
mVBOVertices.bind();
size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
size_t sizeVertices = m_vertices.size() * sizeof(openglframework::Vector3);
mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
mVBOVertices.unbind();
@ -326,9 +326,9 @@ void Dumbbell::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
rp3d::Vector3 newScaling(scaling.x, scaling.y, scaling.z);
mProxyShapeCylinder->setLocalScaling(newScaling);
mProxyShapeSphere1->setLocalScaling(newScaling);
mProxyShapeSphere2->setLocalScaling(newScaling);
m_proxyShapeCylinder->setLocalScaling(newScaling);
m_proxyShapeSphere1->setLocalScaling(newScaling);
m_proxyShapeSphere2->setLocalScaling(newScaling);
mDistanceBetweenSphere = (mDistanceBetweenSphere / mScalingMatrix.getValue(1, 1)) * scaling.y;
@ -338,8 +338,8 @@ void Dumbbell::setScaling(const openglframework::Vector3& scaling) {
// Initial transform of the second sphere collision shape of the dumbell (in local-space)
rp3d::Transform transformSphereShape2(rp3d::Vector3(0, -mDistanceBetweenSphere / 2.0f, 0), rp3d::Quaternion::identity());
mProxyShapeSphere1->setLocalToBodyTransform(transformSphereShape1);
mProxyShapeSphere2->setLocalToBodyTransform(transformSphereShape2);
m_proxyShapeSphere1->setLocalToBodyTransform(transformSphereShape1);
m_proxyShapeSphere2->setLocalToBodyTransform(transformSphereShape2);
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0,

View File

@ -44,9 +44,9 @@ class Dumbbell : public openglframework::Mesh, public PhysicsObject {
/// Collision shapes
rp3d::CylinderShape* mCylinderShape;
rp3d::SphereShape* mSphereShape;
rp3d::ProxyShape* mProxyShapeCylinder;
rp3d::ProxyShape* mProxyShapeSphere1;
rp3d::ProxyShape* mProxyShapeSphere2;
rp3d::ProxyShape* m_proxyShapeCylinder;
rp3d::ProxyShape* m_proxyShapeSphere1;
rp3d::ProxyShape* m_proxyShapeSphere2;
/// Scaling matrix (applied to a sphere to obtain the correct sphere dimensions)
openglframework::Matrix4 mScalingMatrix;

View File

@ -62,7 +62,7 @@ HeightField::HeightField(const openglframework::Vector3 &position,
mBody = world->createCollisionBody(transform);
// Add a collision shape to the body and specify the mass of the collision shape
mProxyShape = mBody->addCollisionShape(mHeightFieldShape, rp3d::Transform::identity());
m_proxyShape = mBody->addCollisionShape(mHeightFieldShape, rp3d::Transform::identity());
// Create the VBOs and VAO
createVBOAndVAO();
@ -103,7 +103,7 @@ HeightField::HeightField(const openglframework::Vector3 &position, float mass,
rp3d::RigidBody* body = dynamicsWorld->createRigidBody(transform);
// Add a collision shape to the body and specify the mass of the collision shape
mProxyShape = body->addCollisionShape(mHeightFieldShape, rp3d::Transform::identity(), mass);
m_proxyShape = body->addCollisionShape(mHeightFieldShape, rp3d::Transform::identity(), mass);
mBody = body;
@ -234,7 +234,7 @@ void HeightField::generateGraphicsMesh() {
float height = originHeight + mHeightData[j * NB_POINTS_WIDTH + i];
openglframework::Vector3 vertex(-(NB_POINTS_WIDTH - 1) * 0.5f + i, height, -(NB_POINTS_LENGTH - 1) * 0.5f + j);
mVertices.push_back(vertex);
m_vertices.push_back(vertex);
// Triangle indices
if ((i < NB_POINTS_WIDTH - 1) && (j < NB_POINTS_LENGTH - 1)) {
@ -271,7 +271,7 @@ void HeightField::createVBOAndVAO() {
// Create the VBO for the vertices data
mVBOVertices.create();
mVBOVertices.bind();
size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
size_t sizeVertices = m_vertices.size() * sizeof(openglframework::Vector3);
mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
mVBOVertices.unbind();
@ -342,7 +342,7 @@ void HeightField::resetTransform(const rp3d::Transform& transform) {
void HeightField::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
m_proxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0,

View File

@ -50,7 +50,7 @@ class HeightField : public openglframework::Mesh, public PhysicsObject {
/// Collision shape
rp3d::HeightFieldShape* mHeightFieldShape;
rp3d::ProxyShape* mProxyShape;
rp3d::ProxyShape* m_proxyShape;
/// Scaling matrix
openglframework::Matrix4 mScalingMatrix;

View File

@ -70,7 +70,7 @@ Sphere::Sphere(float radius, const openglframework::Vector3 &position,
mBody = world->createCollisionBody(transform);
// Add a collision shape to the body and specify the mass of the shape
mProxyShape = mBody->addCollisionShape(mCollisionShape, rp3d::Transform::identity());
m_proxyShape = mBody->addCollisionShape(mCollisionShape, rp3d::Transform::identity());
mTransformMatrix = mTransformMatrix * mScalingMatrix;
@ -117,7 +117,7 @@ Sphere::Sphere(float radius, const openglframework::Vector3 &position,
rp3d::RigidBody* body = world->createRigidBody(transform);
// Add a collision shape to the body and specify the mass of the shape
mProxyShape = body->addCollisionShape(mCollisionShape, rp3d::Transform::identity(), mass);
m_proxyShape = body->addCollisionShape(mCollisionShape, rp3d::Transform::identity(), mass);
mBody = body;
@ -214,7 +214,7 @@ void Sphere::createVBOAndVAO() {
// Create the VBO for the vertices data
mVBOVertices.create();
mVBOVertices.bind();
size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
size_t sizeVertices = m_vertices.size() * sizeof(openglframework::Vector3);
mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
mVBOVertices.unbind();
@ -285,7 +285,7 @@ void Sphere::resetTransform(const rp3d::Transform& transform) {
void Sphere::setScaling(const openglframework::Vector3& scaling) {
// Scale the collision shape
mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
m_proxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z));
// Scale the graphics object
mScalingMatrix = openglframework::Matrix4(mRadius * scaling.x, 0, 0, 0,

View File

@ -43,7 +43,7 @@ class Sphere : public openglframework::Mesh, public PhysicsObject {
/// Collision shape
rp3d::SphereShape* mCollisionShape;
rp3d::ProxyShape* mProxyShape;
rp3d::ProxyShape* m_proxyShape;
/// Scaling matrix (applied to a sphere to obtain the correct sphere dimensions)
openglframework::Matrix4 mScalingMatrix;

View File

@ -43,7 +43,7 @@ Mesh::~Mesh() {
// Destroy the mesh
void Mesh::destroy() {
mVertices.clear();
m_vertices.clear();
mNormals.clear();
mTangents.clear();
mIndices.clear();
@ -139,15 +139,15 @@ void Mesh::calculateTangents() {
void Mesh::calculateBoundingBox(Vector3& min, Vector3& max) const {
// If the mesh contains vertices
if (!mVertices.empty()) {
if (!m_vertices.empty()) {
min = mVertices[0];
max = mVertices[0];
min = m_vertices[0];
max = m_vertices[0];
std::vector<Vector3>::const_iterator it(mVertices.begin());
std::vector<Vector3>::const_iterator it(m_vertices.begin());
// For each vertex of the mesh
for (; it != mVertices.end(); ++it) {
for (; it != m_vertices.end(); ++it) {
if( (*it).x < min.x ) min.x = (*it).x;
else if ( (*it).x > max.x ) max.x = (*it).x;
@ -171,6 +171,6 @@ void Mesh::scaleVertices(float factor) {
// For each vertex
for (uint i=0; i<getNbVertices(); i++) {
mVertices.at(i) *= factor;
m_vertices.at(i) *= factor;
}
}

View File

@ -52,7 +52,7 @@ class Mesh : public Object3D {
std::vector<std::vector<unsigned int> > mIndices;
// Vertices coordinates (local space)
std::vector<Vector3> mVertices;
std::vector<Vector3> m_vertices;
// Normals coordinates
std::vector<Vector3> mNormals;
@ -209,7 +209,7 @@ inline uint Mesh::getNbFaces(uint part) const {
// Return the number of vertices
inline uint Mesh::getNbVertices() const {
return mVertices.size();
return m_vertices.size();
}
// Return the number of parts in the mesh
@ -219,12 +219,12 @@ inline uint Mesh::getNbParts() const {
// Return a reference to the vertices
inline const std::vector<Vector3>& Mesh::getVertices() const {
return mVertices;
return m_vertices;
}
// Set the vertices of the mesh
inline void Mesh::setVertices(std::vector<Vector3>& vertices) {
mVertices = vertices;
m_vertices = vertices;
}
// Return a reference to the normals
@ -260,13 +260,13 @@ inline void Mesh::setIndices(std::vector<std::vector<uint> >& indices) {
// Return the coordinates of a given vertex
inline const Vector3& Mesh::getVertex(uint i) const {
assert(i < getNbVertices());
return mVertices[i];
return m_vertices[i];
}
// Set the coordinates of a given vertex
inline void Mesh::setVertex(uint i, const Vector3& vertex) {
assert(i < getNbVertices());
mVertices[i] = vertex;
m_vertices[i] = vertex;
}
// Return the coordinates of a given normal
@ -292,10 +292,10 @@ inline void Mesh::setVertexColor(uint i, const Color& color) {
// If the color array does not have the same size as
// the vertices array
if (mColors.size() != mVertices.size()) {
if (mColors.size() != m_vertices.size()) {
// Create the color array with the same size
mColors = std::vector<Color>(mVertices.size());
mColors = std::vector<Color>(m_vertices.size());
}
mColors[i] = color;
@ -306,13 +306,13 @@ inline void Mesh::setColorToAllVertices(const Color& color) {
// If the color array does not have the same size as
// the vertices array
if (mColors.size() != mVertices.size()) {
if (mColors.size() != m_vertices.size()) {
// Create the color array with the same size
mColors = std::vector<Color>(mVertices.size());
mColors = std::vector<Color>(m_vertices.size());
}
for (size_t v=0; v<mVertices.size(); v++) {
for (size_t v=0; v<m_vertices.size(); v++) {
mColors[v] = color;
}
}
@ -336,22 +336,22 @@ inline uint Mesh::getVertexIndexInFace(uint faceIndex, uint i, uint part) const
// Return true if the mesh has normals
inline bool Mesh::hasNormals() const {
return mNormals.size() == mVertices.size();
return mNormals.size() == m_vertices.size();
}
// Return true if the mesh has tangents
inline bool Mesh::hasTangents() const {
return mTangents.size() == mVertices.size();
return mTangents.size() == m_vertices.size();
}
// Return true if the mesh has vertex colors
inline bool Mesh::hasColors() const {
return mColors.size() == mVertices.size();
return mColors.size() == m_vertices.size();
}
// Return true if the mesh has UV texture coordinates
inline bool Mesh::hasUVTextureCoordinates() const {
return mUVs.size() == mVertices.size();
return mUVs.size() == m_vertices.size();
}
// Return true if the mesh has a texture for a given part of the mesh and if it
@ -368,7 +368,7 @@ inline bool Mesh::hasTexture() const {
// Return a pointer to the vertices data
inline void* Mesh::getVerticesPointer() {
return &(mVertices[0]);
return &(m_vertices[0]);
}
// Return a pointer to the normals data

View File

@ -33,7 +33,7 @@ using namespace raycastscene;
// Constructor
RaycastScene::RaycastScene(const std::string& name)
: SceneDemo(name, SCENE_RADIUS, false), mMeshFolderPath("meshes/"),
mRaycastManager(mPhongShader, mMeshFolderPath), mCurrentBodyIndex(-1),
m_raycastManager(mPhongShader, mMeshFolderPath), mCurrentBodyIndex(-1),
mAreNormalsDisplayed(false), mVBOVertices(GL_ARRAY_BUFFER) {
mIsContactPointsDisplayed = true;
@ -278,7 +278,7 @@ RaycastScene::~RaycastScene() {
// Destroy the convex mesh
delete mHeightField;
mRaycastManager.resetPoints();
m_raycastManager.resetPoints();
// Destroy the static data for the visual contact points
VisualContactPoint::destroyStaticData();
@ -306,7 +306,7 @@ void RaycastScene::updatePhysics() {
// Take a step for the simulation
void RaycastScene::update() {
mRaycastManager.resetPoints();
m_raycastManager.resetPoints();
// For each line of the scene
for (std::vector<Line*>::iterator it = mLines.begin(); it != mLines.end();
@ -324,7 +324,7 @@ void RaycastScene::update() {
// Perform a raycast query on the physics world by passing a raycast
// callback class in argument.
mCollisionWorld->raycast(ray, &mRaycastManager);
mCollisionWorld->raycast(ray, &m_raycastManager);
}
SceneDemo::update();

View File

@ -125,7 +125,7 @@ class RaycastScene : public SceneDemo {
std::string mMeshFolderPath;
/// Raycast manager
RaycastManager mRaycastManager;
RaycastManager m_raycastManager;
/// All the raycast lines
std::vector<Line*> mLines;
@ -228,7 +228,7 @@ inline void RaycastScene::setIsContactPointsDisplayed(bool display) {
// Return all the contact points of the scene
inline std::vector<ContactPoint> RaycastScene::getContactPoints() const {
return mRaycastManager.getHitPoints();
return m_raycastManager.getHitPoints();
}
}