- Code: Select all
NewtonMesh* CreateVisualMesh (NewtonBody* const body, char* const name, int maxNameSize) const
{
NewtonCollision* collision = NewtonBodyGetCollision(body);
mesh = NewtonMeshCreateFromCollision(collision);
return mesh;
}
you have to write a name of the mesh, something like this
- Code: Select all
NewtonMesh* CreateVisualMesh (NewtonBody* const body, char* const name, int maxNameSize) const
{
Strcpy (name, “myMeshName”);
NewtonCollision* collision = NewtonBodyGetCollision(body);
mesh = NewtonMeshCreateFromCollision(collision);
return mesh;
}
If you do not, then the variable name is undefined and it will write until in find a zero
This is whe the funtion is call from.
- Code: Select all
void dScene::NewtonWorldToScene (const NewtonWorld* const world, dSceneExportCallback* const visualContext)
{
// search for all collision mesh and create make a dictionary
dTree<dSceneNodeCollisionPair, NewtonCollision*> dictionary;
dScene::dTreeNode* const materialNode = CreateMaterialNode (GetRootNode(), 0);
for (NewtonBody* body = NewtonWorldGetFirstBody(world); body; body = NewtonWorldGetNextBody(world, body)) {
NewtonCollision* const collision = NewtonBodyGetCollision(body);
dTree<dSceneNodeCollisionPair, NewtonCollision*>::dTreeNode* node = dictionary.Find(collision);
if (!node) {
//NewtonMesh* const mesh = NewtonMeshCreateFromCollision(collision);
char meshName[256];
NewtonMesh* const mesh = visualContext->CreateVisualMesh(body, meshName, sizeof (meshName));
As you can see mesName is a local variable that is not initialized,
This is my fault because I probably has to initialize it with some default value.
Or better break the call back into two, one for getting the name and one for getting the mesh, that way there is not confusion.
Can you try input a null terminated string on the name field, just to see and see if it works.
I will try to run the demo with a gravity of -30. And see what happens.