You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We recently wanted to use dynamic casting to check if some collision shape is a btScaledBvhTriangleMeshShape but we are facing a strange crash in VS2022.
Problem description
Below a sample code we managed to consistently reproduce the issue with:
// Create our basic btTriangleMesh
btTriangleMesh* triangleMesh = new btTriangleMesh();
triangleMesh->addTriangle(btVector3(0, 0, 0), btVector3(0, 1, 0), btVector3(1, 1, 0));
// Create our btBvhTriangleMeshShape
btBvhTriangleMeshShape* triangleMeshShape = new btBvhTriangleMeshShape(triangleMesh, true, true);
// Create our btScaledBvhTriangleMeshShape
btScaledBvhTriangleMeshShape* scaledTriangleMeshShape = new btScaledBvhTriangleMeshShape(triangleMeshShape, btVector3(1, 1, 1));
// Cast the btScaledBvhTriangleMeshShapeto a btCollisionShape (works fine)
btCollisionShape* newCollisionShape = dynamic_cast<btCollisionShape*>(scaledTriangleMeshShape);
// Cast the btCollisionShape to a btBvhTriangleMeshShape (crashes)
btBvhTriangleMeshShape* newTriangleMeshShape = dynamic_cast<btBvhTriangleMeshShape*>(newCollisionShape);
This also happens if doing as follows:
// Cast the btBvhTriangleMeshShapea btCollisionShape (works fine)
btCollisionShape* newCollisionShape = dynamic_cast<btCollisionShape*>(triangleMeshShape riangleMeshShape);
// Cast the btCollisionShape to a btBvhTriangleMeshShape (crashes)
btBvhTriangleMeshShape* newTriangleMeshShape = dynamic_cast<btBvhTriangleMeshShape*>(newCollisionShape);
The screenshot below shows the resulting crash in the debugger:
Additional findings
I noticed that if I subclass btScaledBvhTriangleMeshShape, the problem vanishes:
Hi,
We recently wanted to use dynamic casting to check if some collision shape is a
btScaledBvhTriangleMeshShape
but we are facing a strange crash in VS2022.Problem description
Below a sample code we managed to consistently reproduce the issue with:
This also happens if doing as follows:
The screenshot below shows the resulting crash in the debugger:
Additional findings
I noticed that if I subclass
btScaledBvhTriangleMeshShape
, the problem vanishes:Maybe this is some alignment issues with MSVC and dynamic cast?
Thanks for helping!
System specs
In case that helps:
Intel 13600KF
AMD 6950 XT
Corsair 64 GB
Windows 11 Professional 22631.3880
VS2022 Version 17.11.2
Debug
The text was updated successfully, but these errors were encountered: