Terrain with no material causes unhandled crash - RESOLVED
by Andreas Johansen · in Torque 3D Professional · 06/22/2010 (7:45 am) · 1 replies
I created a new terrain from importing a heightmap, and as I had no terrain materials defined in my game (created a new project from the empty template), no material was applied to the terrain. After saving out the terrain and then trying to load it later on the game crashes without any error message.
Tracked the issue down to ..EnginesourceterrainterrCellMaterial.cpp lines 276-283:
The mat pointer in my case turned out to be a null pointer, and therefor the game crashes when the pointer is used with mat->getDetailSize()
Depending on the code design here (ie. should it be possible to get null pointers out of that materials array?), either add an assertion for null pointer, or handle when the pointer is null (by continuing the loop for example).
Tracked the issue down to ..EnginesourceterrainterrCellMaterial.cpp lines 276-283:
TerrainMaterial *mat = (*materials)[i]->mat;
// We only include materials that
// have more than a base texture.
if ( mat->getDetailSize() <= 0 ||
mat->getDetailDistance() <= 0 ||
mat->getDetailMap().isEmpty() )
continue;The mat pointer in my case turned out to be a null pointer, and therefor the game crashes when the pointer is used with mat->getDetailSize()
Depending on the code design here (ie. should it be possible to get null pointers out of that materials array?), either add an assertion for null pointer, or handle when the pointer is null (by continuing the loop for example).
Associate Fyodor -bank- Osokin
Dedicated Logic
The other two issues related:
Torque 3D Beta 3,4,5 Bug: crash on multiple terrains with different mat count
[BUG 1.1BETA1] Remove Terrain Tex Crash