Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong scaling in ConcaveMeshShape #50

Closed
andreasdr opened this issue May 24, 2018 · 1 comment
Closed

Wrong scaling in ConcaveMeshShape #50

andreasdr opened this issue May 24, 2018 · 1 comment
Assignees
Labels

Comments

@andreasdr
Copy link

Hi,

scaling seems to be wrong in ConcaveMeshShape. Please see attached a patch:

diff --git a/ext/reactphysics3d/src/collision/shapes/ConcaveMeshShape.cpp b/ext/reactphysics3d/src/collision/shapes/ConcaveMeshShape.cpp
index 79c431e0..4864e56d 100644
--- a/ext/reactphysics3d/src/collision/shapes/ConcaveMeshShape.cpp
+++ b/ext/reactphysics3d/src/collision/shapes/ConcaveMeshShape.cpp
@@ -64,9 +64,15 @@ void ConcaveMeshShape::initBVHTree() {
             triangleVertexArray->getTriangleVertices(triangleIndex, trianglePoints);
 
             // Apply the scaling factor to the vertices
-            trianglePoints[0] *= mScaling.x;
-            trianglePoints[1] *= mScaling.y;
-            trianglePoints[2] *= mScaling.z;
+            trianglePoints[0][0] *= mScaling.x;
+            trianglePoints[0][1] *= mScaling.y;
+            trianglePoints[0][2] *= mScaling.z;
+            trianglePoints[1][0] *= mScaling.x;
+            trianglePoints[1][1] *= mScaling.y;
+            trianglePoints[1][2] *= mScaling.z;
+            trianglePoints[2][0] *= mScaling.x;
+            trianglePoints[2][1] *= mScaling.y;
+            trianglePoints[2][2] *= mScaling.z;
 
             // Create the AABB for the triangle
             AABB aabb = AABB::createAABBForTriangle(trianglePoints);
@@ -88,9 +94,15 @@ void ConcaveMeshShape::getTriangleVertices(uint subPart, uint triangleIndex,
     triangleVertexArray->getTriangleVertices(triangleIndex, outTriangleVertices);
 
     // Apply the scaling factor to the vertices
-    outTriangleVertices[0] *= mScaling.x;
-    outTriangleVertices[1] *= mScaling.y;
-    outTriangleVertices[2] *= mScaling.z;
+    outTriangleVertices[0][0] *= mScaling.x;
+    outTriangleVertices[0][1] *= mScaling.y;
+    outTriangleVertices[0][2] *= mScaling.z;
+    outTriangleVertices[1][0] *= mScaling.x;
+    outTriangleVertices[1][1] *= mScaling.y;
+    outTriangleVertices[1][2] *= mScaling.z;
+    outTriangleVertices[2][0] *= mScaling.x;
+    outTriangleVertices[2][1] *= mScaling.y;
+    outTriangleVertices[2][2] *= mScaling.z;
 }
 
 // Return the three vertex normals (in the array outVerticesNormals) of a triangle

Best regards
Andreas

@DanielChappuis DanielChappuis self-assigned this May 24, 2018
@DanielChappuis
Copy link
Owner

Thanks a lot for reporting this. The issue is now fixed in the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants