Fixed problem with disappearing DSOs that was caused by inadequate numerical
precision in calculations use to determine whether to cull an octree node.ver1_6_1
parent
5c5dc95ad3
commit
3234782d9f
|
@ -179,24 +179,25 @@ void DSODatabase::findVisibleDSOs(DSOHandler& dsoHandler,
|
|||
float limitingMag) const
|
||||
{
|
||||
// Compute the bounding planes of an infinite view frustum
|
||||
Planef frustumPlanes[5];
|
||||
Vec3f planeNormals[5];
|
||||
Planed frustumPlanes[5];
|
||||
Vec3d planeNormals[5];
|
||||
|
||||
Mat3f rot = obsOrient.toMatrix3();
|
||||
float h = (float) tan(fovY / 2);
|
||||
float w = h * aspectRatio;
|
||||
Quatd obsOrientd(obsOrient.w, obsOrient.x, obsOrient.y, obsOrient.z);
|
||||
Mat3d rot = obsOrientd.toMatrix3();
|
||||
double h = tan(fovY / 2);
|
||||
double w = h * aspectRatio;
|
||||
|
||||
planeNormals[0] = Vec3f(0, 1, -h);
|
||||
planeNormals[1] = Vec3f(0, -1, -h);
|
||||
planeNormals[2] = Vec3f(1, 0, -w);
|
||||
planeNormals[3] = Vec3f(-1, 0, -w);
|
||||
planeNormals[4] = Vec3f(0, 0, -1);
|
||||
planeNormals[0] = Vec3d( 0, 1, -h);
|
||||
planeNormals[1] = Vec3d( 0, -1, -h);
|
||||
planeNormals[2] = Vec3d( 1, 0, -w);
|
||||
planeNormals[3] = Vec3d(-1, 0, -w);
|
||||
planeNormals[4] = Vec3d( 0, 0, -1);
|
||||
|
||||
for (int i=0; i<5; ++i)
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
planeNormals[i].normalize(); //TODO: prenormalize ?
|
||||
planeNormals[i] = planeNormals[i] * rot;
|
||||
frustumPlanes[i] = Planef(planeNormals[i], Point3f((float) obsPos.x, (float) obsPos.y, (float) obsPos.z) );
|
||||
frustumPlanes[i] = Planed(planeNormals[i], obsPos);
|
||||
}
|
||||
|
||||
octreeRoot->processVisibleObjects(dsoHandler,
|
||||
|
|
|
@ -70,26 +70,24 @@ template<> DynamicDSOOctree::ExclusionFactorDecayFunction*
|
|||
template<>
|
||||
void DSOOctree::processVisibleObjects(DSOHandler& processor,
|
||||
const Point3d& obsPosition,
|
||||
const Planef* frustumPlanes,
|
||||
const Planed* frustumPlanes,
|
||||
float limitingFactor,
|
||||
double scale) const
|
||||
{
|
||||
// See if this node lies within the view frustum
|
||||
|
||||
// Test the cubic octree node against each one of the five
|
||||
// planes that define the infinite view frustum.
|
||||
for (int i=0; i<5; ++i)
|
||||
{
|
||||
const Planef* plane = frustumPlanes + i;
|
||||
double r = scale * (abs(plane->normal.x) +
|
||||
abs(plane->normal.y) +
|
||||
abs(plane->normal.z));
|
||||
// Test the cubic octree node against each one of the five
|
||||
// planes that define the infinite view frustum.
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
const Planed* plane = frustumPlanes + i;
|
||||
double r = scale * (abs(plane->normal.x) +
|
||||
abs(plane->normal.y) +
|
||||
abs(plane->normal.z));
|
||||
|
||||
Vec3d vecDbl((double) plane->normal.x, (double) plane->normal.y, (double) plane->normal.z);
|
||||
|
||||
if (vecDbl * Vec3d(cellCenterPos.x, cellCenterPos.y, cellCenterPos.z) - plane->d < -r)
|
||||
return;
|
||||
}
|
||||
if (plane->normal * Vec3d(cellCenterPos.x, cellCenterPos.y, cellCenterPos.z) - plane->d < -r)
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the distance to node; this is equal to the distance to
|
||||
// the cellCenterPos of the node minus the boundingRadius of the node, scale * SQRT3.
|
||||
|
|
|
@ -108,7 +108,7 @@ template <class OBJ, class PREC> class StaticOctree
|
|||
// (if one is required) is the responsibility of the callback method.
|
||||
void processVisibleObjects(OctreeProcessor<OBJ, PREC>& processor,
|
||||
const Point3<PREC>& obsPosition,
|
||||
const Plane<float>* frustumPlanes,
|
||||
const Plane<PREC>* frustumPlanes,
|
||||
float limitingFactor,
|
||||
PREC scale) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue