icaromotta
15-05-2009 17:55:04
NxActor *createTerrain2()
{
NxHeightFieldDesc heightFieldDesc;
NxU32 nbCols, nbRows;
nbCols = nbRows = mTerrainListener->pageSize;
Ogre::Vector3 *scale = &mTerrainListener->scale;
heightFieldDesc.nbColumns = nbCols;
heightFieldDesc.nbRows = nbRows;
heightFieldDesc.verticalExtent = -1000;
heightFieldDesc.convexEdgeThreshold = 0;
heightFieldDesc.samples = new NxU32[nbCols*nbRows];
heightFieldDesc.sampleStride = sizeof(NxU32);
char* currentByte = (char*)heightFieldDesc.samples;
// preenche os samples com os dados de altura
for (NxU32 row = 0; row < nbRows; row++)
{
for (NxU32 column = 0; column < nbCols; column++)
{
NxHeightFieldSample* currentSample = (NxHeightFieldSample*)currentByte;
currentSample->height = (NxI16)(mTerrainListener->heightData[row+(column*nbRows)] * 32767.5f);
currentSample->tessFlag = 0;
currentByte += heightFieldDesc.sampleStride;
}
}
NxHeightField *heightField = gPhysicsSDK->createHeightField(heightFieldDesc);
delete [] heightFieldDesc.samples;
// shape
NxHeightFieldShapeDesc heightFieldShapeDesc;
heightFieldShapeDesc.heightField = heightField;
heightFieldShapeDesc.shapeFlags = 0;
heightFieldShapeDesc.heightScale = scale->y / 32767.5f;
heightFieldShapeDesc.rowScale = scale->z;
heightFieldShapeDesc.columnScale = scale->x;
heightFieldShapeDesc.meshFlags = NX_MESH_SMOOTH_SPHERE_COLLISIONS;
heightFieldShapeDesc.materialIndexHighBits = 0;
// ator
NxActorDesc actorTerrainDesc;
actorTerrainDesc.shapes.pushBack(&heightFieldShapeDesc);
return gScenes[gCurrentScene]->createActor(actorTerrainDesc);
}
The EXE runs, but the collision with the ground does not work in Release. Only work the collision in Debug.
How to fix this?