diff options
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/map.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/model/map.cc b/src/model/map.cc index 2930021..7495edb 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -268,7 +268,7 @@ void Map::make_brushface(Plane *face) // check if the face is x-axis oriented if ((fabsf(face->normal().x) >= fabsf(face->normal().y)) && (fabsf(face->normal().x) >= fabsf(face->normal().z))) { - if (face->normal().x >= 0) { + if (face->normal().x > MIN_DELTA) { vl.push_back(new math::Vector3f(0, -MAX_BOUNDS, -MAX_BOUNDS)); vl.push_back(new math::Vector3f(0, -MAX_BOUNDS, MAX_BOUNDS)); vl.push_back(new math::Vector3f(0, MAX_BOUNDS, MAX_BOUNDS)); @@ -291,7 +291,7 @@ void Map::make_brushface(Plane *face) // check if the face is y-axis oriented else if ((fabsf(face->normal().y) >= fabsf(face->normal().x)) && (fabsf(face->normal().y) >= fabsf(face->normal().z))) { - if (face->normal().y >= 0) { + if (face->normal().y > MIN_DELTA) { vl.push_back(new Vector3f(MAX_BOUNDS, 0, -MAX_BOUNDS)); vl.push_back(new Vector3f(MAX_BOUNDS, 0, MAX_BOUNDS)); vl.push_back(new Vector3f(-MAX_BOUNDS, 0, MAX_BOUNDS)); @@ -315,7 +315,7 @@ void Map::make_brushface(Plane *face) // face must be z-axis oriented else { - if (face->normal().z >= 0) { + if (face->normal().z > MIN_DELTA) { vl.push_back(new Vector3f(-MAX_BOUNDS, -MAX_BOUNDS, 0)); vl.push_back(new Vector3f(-MAX_BOUNDS, MAX_BOUNDS, 0)); vl.push_back(new Vector3f(MAX_BOUNDS, MAX_BOUNDS, 0)); @@ -339,6 +339,7 @@ void Map::make_brushface(Plane *face) // intersect the face with every plane for (std::vector<Plane *>::iterator pit = planes.begin(); pit != planes.end(); pit++) { + Plane *plane = (*pit); if (plane == face) { continue; @@ -380,7 +381,7 @@ void Map::make_brushface(Plane *face) } // check if prev - v intersects with plane - if ((prev.x*plane->normal().x + prev.y*plane->normal().y + prev.z*plane->normal().z + plane->d()) > -MIN_DELTA) { + if ((prev.x*plane->normal().x + prev.y*plane->normal().y + prev.z*plane->normal().z + plane->d()) > MIN_DELTA) { // calculate intersection float t1 = -plane->normal().x * prev.x - plane->normal().y * prev.y - plane->normal().z * prev.z -plane->d(); @@ -403,7 +404,7 @@ void Map::make_brushface(Plane *face) } // check if next - v intersects with plane - if ((next.x*plane->normal().x + next.y*plane->normal().y + next.z*plane->normal().z + plane->d()) > -MIN_DELTA) { + if ((next.x*plane->normal().x + next.y*plane->normal().y + next.z*plane->normal().z + plane->d()) > MIN_DELTA) { // calculate intersection float t1 = -plane->normal().x * v.x - plane->normal().y * v.y - plane->normal().z * v.z -plane->d(); @@ -523,6 +524,8 @@ void Map::make_brushface(Plane *face) } // split off quads + con_debug << " * face with " << vl.size() << " vertices" << std::endl; + while (vl.size() > 3) { std::vector<Vector3f *>::iterator v0 = vl.begin(); std::vector<Vector3f *>::reverse_iterator vn = vl.rbegin(); @@ -540,6 +543,7 @@ void Map::make_brushface(Plane *face) delete(*vn1); vl.pop_back(); vl.pop_back(); + con_debug << " culled quad, " << vl.size() << " vertices left" << std::endl; } // the remainder could be a triangle @@ -555,6 +559,7 @@ void Map::make_brushface(Plane *face) primitives->add_triangle(*(*vn1), *(*vn), *(*v0), n, color, face->detail()); delete(*vn); vl.pop_back(); + con_debug << " culled tris, " << vl.size() << " vertices left" << std::endl; } } else { con_debug << "Unresolved face!\n"; @@ -914,11 +919,11 @@ Model * Map::load(std::string const &name) } mapfile.close(); - /* - con_print << " " << mapfile.name() << " " << mapfile.map_materials.size() << " mat" << + + con_debug << " " << mapfile.name() << " " << mapfile.map_materials.size() << " mat " << mapfile.map_brushes << " brushes " << mapfile.map_faces << "/" << mapfile.map_faces_detail << " faces/detail " << std::endl; - */ + mapfile.load_fragments(model); con_debug << " " << mapfile.name() << " " << |