Frustrum Culling Near clip
by Alex Huck · in Torque Game Engine Advanced · 12/14/2008 (4:31 am) · 1 replies
Hi, I'm trying to implement culling of objects which are nearby the player (Similar to the fxFoliageReplicator's innerRadius) for use with GroundCover. I'm having difficulty though.
So far I've tried going in util/FrustrumCuller.cpp and editing the FrustrumCuller::testBoxVisibility(); method
Towards the end of that function (About line 154) there's a section dealing with the Far plane:
So using that as the basis I made a new variable, mNearDistance and copied pasted the above and made it do the opposite:
This plan didn't work and now the plants simply flicker occasionally at certain positions but for the most part don't show up at all.
Admittedly I have no idea what the value of squareDistance was so I made it Con:Prinrf it's value so I can check the console to see what's going on still can't quite make out a pattern though
Can anyone shed some light on how to implement NearDistance culling, or explain what squareDistance "does" in plain english?
is what it "does" but it's hardly plain english to me ;)
So far I've tried going in util/FrustrumCuller.cpp and editing the FrustrumCuller::testBoxVisibility(); method
Towards the end of that function (About line 154) there's a section dealing with the Far plane:
F32 squareDistance = getBoxDistance(bounds);
if(squareDistance >= mFarDistance)
return -1;So using that as the basis I made a new variable, mNearDistance and copied pasted the above and made it do the opposite:
F32 squareDistance = getBoxDistance(bounds);
if(squareDistance >= mFarDistance)
return -1;
if(squareDistance [b]<[/b]= m[b]Near[/b]Distance) // <- Note the <= as opposed to >=
return -1;This plan didn't work and now the plants simply flicker occasionally at certain positions but for the most part don't show up at all.
Admittedly I have no idea what the value of squareDistance was so I made it Con:Prinrf it's value so I can check the console to see what's going on still can't quite make out a pattern though
Can anyone shed some light on how to implement NearDistance culling, or explain what squareDistance "does" in plain english?
const F32 FrustrumCuller::getBoxDistance(const Box3F &box) const
{
Point3F vec;
const Point3F &minPoint = box.minExtents;
const Point3F &maxPoint = box.maxExtents;
if(mCamPos.z < minPoint.z)
vec.z = minPoint.z - mCamPos.z;
else if(mCamPos.z > maxPoint.z)
vec.z = mCamPos.z - maxPoint.z;
else
vec.z = 0;
if(mCamPos.x < minPoint.x)
vec.x = minPoint.x - mCamPos.x;
else if(mCamPos.x > maxPoint.x)
vec.x = mCamPos.x - maxPoint.x;
else
vec.x = 0;
if(mCamPos.y < minPoint.y)
vec.y = minPoint.y - mCamPos.y;
else if(mCamPos.y > maxPoint.y)
vec.y = mCamPos.y - maxPoint.y;
else
vec.y = 0;
return vec.len();
}is what it "does" but it's hardly plain english to me ;)
About the author
Torque Owner Stefan Lundmark