Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/mapfile.cc')
-rw-r--r--src/model/mapfile.cc80
1 files changed, 71 insertions, 9 deletions
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index c4f0b7b..54f6d78 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -142,13 +142,14 @@ inline bool spawnflag_isset(unsigned int spawnflags, unsigned int flag)
return ((spawnflags & flag) == flag);
}
-MapFile::MapFile() : map_center(0,0,0)
+MapFile::MapFile() : map_center(0.0f, 0.0f, 0.0f)
{
mapfile_name.clear();
map_brushes = 0;
map_faces = 0;
map_faces_detail = 0;
+ in_patchdef = false;
warning_q2brush = false;
}
@@ -205,6 +206,49 @@ bool MapFile::got_classend(const char * classnamelabel) const
return (last_read_was_classend && (classname_current.compare(classnamelabel) == 0));
}
+bool MapFile::read_patchdef()
+{
+ char data[1024];
+ memset(data, 0, sizeof(data));
+ size_t count = 0;
+
+ // first line: texture name
+ if (!mapfile_ifs.getline(data, 1023))
+ return false;
+ else
+ line_number++;
+
+ // second line: "( a b c d e )"
+ if (!mapfile_ifs.getline(data, 1023))
+ return false;
+ else
+ line_number++;
+
+ // third line: "("
+ if (!mapfile_ifs.getline(data, 1023))
+ return false;
+ else
+ line_number++;
+
+ while (mapfile_ifs.getline(data, 1023)) {
+ line_number++;
+
+ std::istringstream linestream(data);
+ std::string firstword;
+
+ if (linestream >> firstword) {
+ if (firstword.compare(")") == 0) {
+ //con_debug << " patchDef2 with " << count << " lines" << std::endl;
+ return true;
+ } else {
+ count ++;
+ }
+ }
+ }
+
+ return false;
+}
+
bool MapFile::getline()
{
using math::Vector3f;
@@ -236,9 +280,20 @@ bool MapFile::getline()
} else if (firstword == "{") {
parse_level++;
+
+ if ((parse_level == 3) && (in_patchdef)) {
+ if (!read_patchdef()) {
+ con_warn << name() << " error reading patchDef2 at line " << line_number << std::endl;
+ }
+ }
} else if (firstword == "}") {
- if ((parse_level == 2) && (planes.size())) {
+
+ if ((parse_level == 3) && (in_patchdef)) {
+ // end-of-patchdef
+ in_patchdef = false;
+
+ } else if ((parse_level == 2) && (planes.size())) {
// end-of-brush
// for every face
@@ -265,7 +320,7 @@ bool MapFile::getline()
} else if (parse_level == 1) {
- if (firstword == "\"classname\"") {
+ if (firstword.compare("\"classname\"") == 0) {
classname_current.clear();
if (linestream >> classname_current) {
@@ -295,7 +350,7 @@ bool MapFile::getline()
} else if (parse_level == 2) {
- if (firstword == "(") {
+ if (firstword.compare("(") == 0) {
// brush plane
Vector3f p1, p2, p3;
@@ -352,6 +407,9 @@ bool MapFile::getline()
planes.push_back(face);
value_current.clear();
+
+ } else if (firstword.compare("patchDef2") == 0) {
+ in_patchdef = true;
}
}
}
@@ -635,7 +693,7 @@ void MapFile::make_brushface(Face *face)
vl.pop_back();
}
} else {
- con_debug << "Unresolved face!\n";
+ con_warn << name() << " unresolved face at line " << line() << std::endl;
}
// clean up the vertex list
@@ -845,7 +903,7 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
if (primitives->quads().size()) {
Fragment *fragment = new Fragment(Fragment::Quads, primitives->material());
- // add structural triangles to the fragment
+ // add structural quads to the fragment
for (Primitives::Quads::iterator quad_it = primitives->quads().begin(); quad_it != primitives->quads().end(); quad_it++) {
Quad *quad = (*quad_it);
if (!quad->detail()) {
@@ -859,7 +917,7 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
}
}
- // add detail triangles to the fragment
+ // add detail quads to the fragment
for (Primitives::Quads::iterator quad_it = primitives->quads().begin(); quad_it != primitives->quads().end(); quad_it++) {
Quad *quad = (*quad_it);
if (quad->detail()) {
@@ -943,7 +1001,8 @@ Model * MapFile::load(std::string const &name)
// worldspawn attributes
if (mapfile.got_key("name")) {
- con_debug << " model name '" << name << "'" << std::endl;
+ //con_debug << " model name '" << name << "'" << std::endl;
+ continue;
} else if (mapfile.got_key_int("enginesound", u)) {
model->model_enginesound = u;
@@ -1403,7 +1462,10 @@ Model * MapFile::load(std::string const &name)
}
con_debug << " " << mapfile.name() << " " << mapfile.map_brushes << " brushes " <<
- mapfile.map_faces << "/" << mapfile.map_faces_detail << " faces/detail " << std::endl;
+ model->model_tris_count << "/" << model->model_tris_detail_count << " tris/detail " <<
+ model->model_quad_count << "/" << model->model_quad_detail_count << " quads/detail" <<
+ std::endl;
+
if (mapfile.warning_q2brush)
con_warn << " quake2 style brushes detected" << std::endl;