TGEA 1.8 Beta 1 Bug - backwards sorting of tranparent elements
by Jeff Faust · in Torque Game Engine Advanced · 11/25/2008 (3:48 pm) · 1 replies
This same bug was in TGEA 1.7.0 Beta 2 then fixed in release, but now it's back. See this post:
www.garagegames.com/mg/forums/result.thread.php?qt=73786
The distance sorting of transparent elements is exactly backwards. The farthest objects are being rendered on top of the nearest.
The problem can be fixed by changing the comparison function RenderBinManager::cmpKeyFunc() located in renderBinManager.cpp:
www.garagegames.com/mg/forums/result.thread.php?qt=73786
The distance sorting of transparent elements is exactly backwards. The farthest objects are being rendered on top of the nearest.
The problem can be fixed by changing the comparison function RenderBinManager::cmpKeyFunc() located in renderBinManager.cpp:
S32 FN_CDECL RenderBinManager::cmpKeyFunc(const void* p1, const void* p2)
{
const MainSortElem* mse1 = (const MainSortElem*) p1;
const MainSortElem* mse2 = (const MainSortElem*) p2;
[b][i]S32 test1 = S32(mse2->key) - S32(mse1->key); // <-- Reversed Comparison[/i][/b]
return ( test1 == 0 ) ? S32(mse1->key2) - S32(mse2->key2) : test1;
}However, as described in the earlier post, the real fix should probably be something like this in RenderTranslucentMgr::addElement() in renderTranslucentMgr.cpp:F32 camDist = (mParentManager->getCamPos() - inst->sortPoint).len(); camDist = smSceneState.visibleDist - camDist; // Invert camera distance elem.key = *((U32*)&camDist);But at the moment I'm unsure of how to find the visibleDist from that context.
About the author
Jeff Faust creates special effects indie middleware and games for Faust Logic. --- Blog: Effectronica.com --- Twitter: @FaustLogic
Torque Owner Stefan Lundmark
The fxSunLight stuff looks alot better with your fix. Less flickering. Thanks