T3D 1.1 Beta 3 - Decal road doesn't render at certain angles - RESOLVED
by David Wyand · in Torque 3D Professional · 01/18/2011 (8:17 pm) · 3 replies
Build: 1.1 Beta 3 Pro
Platform: Windows XP, Vista, 7
Target: In game
Issues: When looking down the length of a decal road, it renders when you look down one direction, but doesn't render when looking down the other direction.
Steps to Repeat:
1. Create a lengthy road in the Mission Editor.
2. Save the mission file.
3. Shutdown Torque and restart with the mission file you just saved.
4. Run the player into the middle of the road. Look towards one end of the road and it will render fine. Look towards the other end of the road and the road will disappear.
NOTE: This bug may only occur in client/server games. I've since forgotten if this is truly the case or not.
Suggested Fix:
The problem ended up being that the client is not placing the decal road into the correct render bins. If you look in DecalRoad::onAdd() the Parent::setTransform(mat); call sets up the render bins, but the actual road geometry is not created until _captureVerts(); at the end. So we end up with the render bins being calculated around only the first node of the road -- which causes the road to render when you look at the first node, and not render when it is clipped from view.
The fix is to copy the work done in River and apply it to DecalRoad::_captureVerts(). At the bottom of _captureVerts() replace the commented lines with those indicated:
This bug haunted me for quite a while and I was happy when I finally squashed it. :)
- Dave
Platform: Windows XP, Vista, 7
Target: In game
Issues: When looking down the length of a decal road, it renders when you look down one direction, but doesn't render when looking down the other direction.
Steps to Repeat:
1. Create a lengthy road in the Mission Editor.
2. Save the mission file.
3. Shutdown Torque and restart with the mission file you just saved.
4. Run the player into the middle of the road. Look towards one end of the road and it will render fine. Look towards the other end of the road and the road will disappear.
NOTE: This bug may only occur in client/server games. I've since forgotten if this is truly the case or not.
Suggested Fix:
The problem ended up being that the client is not placing the decal road into the correct render bins. If you look in DecalRoad::onAdd() the Parent::setTransform(mat); call sets up the render bins, but the actual road geometry is not created until _captureVerts(); at the end. So we end up with the render bins being calculated around only the first node of the road -- which causes the road to render when you look at the first node, and not render when it is clipped from view.
The fix is to copy the work done in River and apply it to DecalRoad::_captureVerts(). At the bottom of _captureVerts() replace the commented lines with those indicated:
Box3F box;
for ( U32 i = 0; i < mBatches.size(); i++ )
{
const RoadBatch &batch = mBatches[i];
if ( i == 0 )
box = batch.bounds;
else
box.intersect( batch.bounds );
}
Point3F pos = getPosition();
// DAW: START
// DAW: Replaced original mObjBox code below with that from the bottom
// of River::_generateSlices(). This makes sure that the bins
// are correct for this road.
//mObjBox = box;
//mObjBox.minExtents -= pos;
//mObjBox.maxExtents -= pos;
//resetWorldBox();
mWorldBox = box;
resetObjectBox();
// Make sure we are in the correct bins given our world box.
if (mSceneManager != NULL && mNumCurrZones != 0)
{
mSceneManager->zoneRemove(this);
mSceneManager->zoneInsert(this);
if (getContainer())
getContainer()->checkBins(this);
}
// DAW: END
}This bug haunted me for quite a while and I was happy when I finally squashed it. :)
- Dave
About the author
A long time Associate of the GarageGames' community and author of the Torque 3D Game Development Cookbook. Buy it today from Packt Publishing!
Associate David Wyand
Gnometech Inc.