diff --git a/src/collision/shapes/CollisionShape.h b/src/collision/shapes/CollisionShape.h index 0e041e0f..e18532b1 100644 --- a/src/collision/shapes/CollisionShape.h +++ b/src/collision/shapes/CollisionShape.h @@ -40,8 +40,9 @@ namespace reactphysics3d { /// Type of the collision shape -enum CollisionShapeType {TRIANGLE, BOX, SPHERE, CONE, CYLINDER, CAPSULE, CONVEX_MESH, CONCAVE_MESH}; -const int NB_COLLISION_SHAPE_TYPES = 8; +enum CollisionShapeType {TRIANGLE, BOX, SPHERE, CONE, CYLINDER, + CAPSULE, CONVEX_MESH, CONCAVE_MESH, HEIGHTFIELD}; +const int NB_COLLISION_SHAPE_TYPES = 9; // Declarations class ProxyShape; @@ -135,7 +136,7 @@ inline CollisionShapeType CollisionShape::getType() const { // Return true if the collision shape type is a convex shape inline bool CollisionShape::isConvex(CollisionShapeType shapeType) { - return shapeType != CONCAVE_MESH; + return shapeType != CONCAVE_MESH && shapeType != HEIGHTFIELD; } // Return the scaling vector of the collision shape diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index eee86c2e..3443ab70 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -42,7 +42,7 @@ using namespace reactphysics3d; HeightFieldShape::HeightFieldShape(int nbWidthGridPoints, int nbLengthGridPoints, decimal minHeight, decimal maxHeight, const void* heightFieldData, HeightDataType dataType, int upAxis, decimal integerHeightScale) - : ConcaveShape(CONCAVE_MESH), mNbWidthGridPoints(nbWidthGridPoints), mNbLengthGridPoints(nbLengthGridPoints), + : ConcaveShape(HEIGHTFIELD), mNbWidthGridPoints(nbWidthGridPoints), mNbLengthGridPoints(nbLengthGridPoints), mWidth(nbWidthGridPoints - 1), mLength(nbLengthGridPoints - 1), mMinHeight(minHeight), mMaxHeight(maxHeight), mUpAxis(upAxis), mIntegerHeightScale(integerHeightScale), mHeightDataType(dataType) { @@ -171,7 +171,7 @@ void HeightFieldShape::computeMinMaxGridCoordinates(int* minCoords, int* maxCoor // Translate the min/max points such that the we compute grid points from [0 ... mNbWidthGridPoints] // and from [0 ... mNbLengthGridPoints] because the AABB coordinates range are [-mWdith/2 ... mWidth/2] // and [-mLength/2 ... mLength/2] - const Vector3 translateVec = mAABB.getExtent(); + const Vector3 translateVec = mAABB.getExtent() * decimal(0.5); minPoint += translateVec; maxPoint += translateVec;