diff --git a/src/celengine/dsodb.cpp b/src/celengine/dsodb.cpp index f34af24ab..e63dbf6b1 100644 --- a/src/celengine/dsodb.cpp +++ b/src/celengine/dsodb.cpp @@ -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, diff --git a/src/celengine/dsooctree.cpp b/src/celengine/dsooctree.cpp index 0eb8009e5..29e55c103 100644 --- a/src/celengine/dsooctree.cpp +++ b/src/celengine/dsooctree.cpp @@ -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. diff --git a/src/celengine/octree.h b/src/celengine/octree.h index e916fad53..4c89f4bd4 100644 --- a/src/celengine/octree.h +++ b/src/celengine/octree.h @@ -108,7 +108,7 @@ template class StaticOctree // (if one is required) is the responsibility of the callback method. void processVisibleObjects(OctreeProcessor& processor, const Point3& obsPosition, - const Plane* frustumPlanes, + const Plane* frustumPlanes, float limitingFactor, PREC scale) const;