Fixed SplitBox/MergeBox boundaries.

This commit is contained in:
Georges Dupéron 2012-10-27 16:34:16 +02:00
parent 40299aa45b
commit d15ef280f6
3 changed files with 14 additions and 13 deletions

View File

@ -140,8 +140,9 @@ void Chose::addBBPoints(const Quad q, float height) {
}
void Chose::updateAABB() {
float splitFactor = Dimensions::splitFactor * LODFactor();
float mergeFactor = Dimensions::mergeFactor * LODFactor();
float thisSplitFactor = Dimensions::splitFactor * LODFactor();
// TODO : adapt mergeFactor to Camera::moveSensitivity
float thisMergeFactor = thisSplitFactor * std::max(1.01f, Dimensions::mergeFactor);
float nonFacingFactor = 2.f/3.f;
lod.firstBBPoint = true;
getBoundingBoxPoints();
@ -152,13 +153,13 @@ void Chose::updateAABB() {
for (int i = 0; i < 3; i++)
areaFacing[i] = size[(i+1)%3]*size[(i+1)%3];
for (int i = 0; i < 3; i++) {
float pseudoLength = std::max(1.f, std::sqrt(areaFacing[i] + areaFacing[(i+1)%3] * nonFacingFactor + areaFacing[(i+1)%3] * nonFacingFactor));
float splitIncrement = std::min(Dimensions::backFrustum, splitFactor * pseudoLength);
float mergeIncrement = std::min(Dimensions::backFrustum * mergeFactor/splitFactor, mergeFactor * pseudoLength);
lod.splitBox[2*i] = lod.aabb[2*i] - splitIncrement;
lod.splitBox[2*i+1] = lod.aabb[2*i+1] + splitIncrement;
lod.mergeBox[2*i] = lod.aabb[2*i] - mergeIncrement;
lod.mergeBox[2*i+1] = lod.aabb[2*i+1] + splitIncrement;
float pseudoLength = std::max(size[i]/2.f, std::sqrt(areaFacing[i] + areaFacing[(i+1)%3] * nonFacingFactor + areaFacing[(i+1)%3] * nonFacingFactor));
float splitDistance = thisSplitFactor * pseudoLength;
float mergeDistance = thisMergeFactor * pseudoLength;
lod.splitBox[2*i] = center[i] - splitDistance;
lod.splitBox[2*i+1] = center[i] + splitDistance;
lod.mergeBox[2*i] = center[i] - mergeDistance;
lod.mergeBox[2*i+1] = center[i] + mergeDistance;
}
}

View File

@ -2,7 +2,7 @@
const unsigned int Couleurs::fog = mix(cielHaut, cielBas, 0.5);
const float Dimensions::splitFactor = 4.f;
const float Dimensions::mergeFactor = 4.5f;
const float Dimensions::splitFactor = 1.f;
const float Dimensions::mergeFactor = 1.25f;
const float Dimensions::frontFrustum = 1.f;
const float Dimensions::backFrustum = 4000 * 100; // 4km

View File

@ -165,8 +165,8 @@ void View::renderScene(int lastTime, int currentTime) {
float fps = (int)(1000/(currentTime-lastTime));
char text[100]; // Text
snprintf(&(text[0]), 100, "FPS: %4.2f", fps);
std::cout << "\r" << fps << " ";
std::cout.flush();
std::cerr << "\r" << fps << " ";
std::cerr.flush();
/*
glLoadIdentity ();
glDisable(GL_LIGHTING);