Game Development Community

Legacy Collision Fails when TerrainBlock is positioned with negative Z

by Jeremiah Fulbright · in Torque Game Engine Advanced · 04/29/2009 (7:55 pm) · 4 replies

Topic says it all actually.

After some initial testing, it seems that if a TerrainBlock is positioned below 0, it can lead to collision failing.

if (box.maxExtents.z < -TerrainThickness || box.minExtents.z > fixedToFloat(gridMap[BlockShift]->maxHeight))
      return;

The box.maxExtents.z < -TerrainThickness is the culprit, as when the TerrainBlock is below 0, the maxExtents is also coming back lower than the thickness, which is causing it to fail.

The easy fix is to just remove the first portion of the check, but maybe it just needs to be modified to handle position differently

#1
04/29/2009 (8:18 pm)
I have also noticed the TerrainBlock will lose collision at extreme Z scales. With a black and white hightmap and height scale above 500 collision is lost at HIGH and LOW elevations. Location of terrain block origin dont seem to matter. But I thought it was mu own fault because I have been using the terrain blocks in unkosher ways.
#2
04/29/2009 (9:16 pm)
Nope, it would be that check that is to blame and yes, I suppose really high values would also cause it to fail, as you said.

#3
05/04/2009 (1:40 pm)
The terrain has a lot of places where it assumes that it's z position will only scale from 0 to the maximum height in the heightmap. If you disable tiling so you can move the terrain around and fiddle with the height scale you can easily violate those assumptions, unfortunately. Both features were added after terrain had been written and I don't think these assumptions had been noticed at that time.

It'd probably be a fairly in depth process to actually find all of the places where that assumption is made and resolve them. I think it's explicitly made in a couple dozen places, and I have no idea where it'd be implicit.
#4
05/04/2009 (2:56 pm)
I found 2 places like what I posted above and disabled those, and so far no other issues, but keeping my eye out