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.cc42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index d4632e2..c687124 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -165,6 +165,12 @@ MapFile::MapFile()
MapFile::~MapFile()
{
clear_materials();
+
+ // delete bounds vertices
+ for (std::vector<math::Vector3f *>::iterator bvit = map_bounds_vertices.begin(); bvit != map_bounds_vertices.end(); ++bvit) {
+ delete (*bvit);
+ }
+ map_bounds_vertices.clear();
}
void MapFile::clear_materials()
@@ -397,7 +403,7 @@ bool MapFile::read_patchdef()
}
// ignore materials with the 'Ignore' flag set
- if (material->ignore_is_set()) {
+ if (material->has_flag_ignore()) {
return true;
}
@@ -527,7 +533,7 @@ bool MapFile::read_patchdef()
for (size_t i = 0; i < subdivide_u; i++) {
for (size_t j = 0; j < subdivide_v; j++) {
- if (material->flag_is_set(Material::FlagClip)) {
+ if (material->has_flag_clip()) {
// if the current material is clip, the patch needs to be converted to triangles
if (map_load_clip) {
@@ -754,7 +760,7 @@ void MapFile::make_brushface(Face *face)
using math::Vector3f;
// ignore materials with the 'Ignore' flag set
- if (face->material()->ignore_is_set()) {
+ if (face->material()->has_flag_ignore()) {
return;
}
@@ -954,12 +960,17 @@ void MapFile::make_brushface(Face *face)
primitives = (*mit).second;
}
- if (face->material()->origin_is_set()) {
+ if (face->material()->has_flag_origin()) {
// add vertices to the origin list
for (std::vector<Vector3f *>::iterator it = vl.begin(); it != vl.end(); ++it) {
class_origin_vertices.push_back(new math::Vector3f((*(*it) * SCALE)));
}
+ } else if (face->material()->has_flag_bounds()) {
+ // add vertices to the bounds list
+ for (std::vector<Vector3f *>::iterator it = vl.begin(); it != vl.end(); ++it) {
+ map_bounds_vertices.push_back(new math::Vector3f((*(*it) * SCALE)));
+ }
} else {
// add vertices to the bounding box
@@ -972,7 +983,7 @@ void MapFile::make_brushface(Face *face)
face_normal.normalize();
// clip faces have to be triangulated and can not be split into quads
- if (!face->material()->flag_is_set(Material::FlagClip)) {
+ if (!face->material()->has_flag_clip()) {
// split polygon into quads
while (vl.size() > 3) {
@@ -987,7 +998,7 @@ void MapFile::make_brushface(Face *face)
Quad *quad = new Quad(*(*vn2) * SCALE, *(*vn1) * SCALE, *(*vn) * SCALE, *(*v0) * SCALE, face_normal, face->detail());
primitives->add_quad(quad);
- if (face->material()->flag_is_set(Material::FlagTexture)) {
+ if (face->material()->has_flag_texture()) {
quad->t0().assign(map_texture_coords(face, *(*vn2)));
quad->t1().assign(map_texture_coords(face, *(*vn1)));
quad->t2().assign(map_texture_coords(face, *(*vn)));
@@ -1011,7 +1022,7 @@ void MapFile::make_brushface(Face *face)
Triangle * triangle = new Triangle(*(*vn1) * SCALE, *(*vn) * SCALE, *(*v0) * SCALE, face_normal, face->detail());
primitives->add_triangle(triangle);
- if (face->material()->flag_is_set(Material::FlagTexture)) {
+ if (face->material()->has_flag_texture()) {
triangle->t0().assign(map_texture_coords(face, *(*vn1)));
triangle->t1().assign(map_texture_coords(face, *(*vn)));
triangle->t2().assign(map_texture_coords(face, *(*v0)));
@@ -1245,7 +1256,7 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
// store triangles
if (primitives->triangles().size()) {
- if (primitives->material()->flag_is_set(Material::FlagClip)) {
+ if (primitives->material()->has_flag_clip()) {
if (map_load_clip) {
// clip materials are loaded into the CollisionMesh
@@ -2048,16 +2059,25 @@ Model * MapFile::load(std::string const &name)
delete tag_submodel;
}
- // center model around (0,0,0) and set the bounding box
+ // center model around (0,0,0) and set the bounding box
+ if (mapfile.map_bounds_vertices.size()) {
+
+ // bounds vertices override the calculated box
+ mapfile.map_box.assign(MAX_BOUNDS, -MAX_BOUNDS);
+ for (std::vector<math::Vector3f *>::iterator bvit = mapfile.map_bounds_vertices.begin(); bvit != mapfile.map_bounds_vertices.end(); ++bvit) {
+ mapfile.map_box.expand(*(*bvit));
+ }
+ }
+
math::Vector3f map_center = (mapfile.box().min() + mapfile.box().max()) * 0.5f;
model->model_box.assign(
mapfile.box().min() - map_center,
mapfile.box().max() - map_center
);
-
+
model->set_radius(model->box().max().length());
model->set_origin(map_center * -1.0f);
-
+
// translate transformed vertex groups
size_t frags = 0;
for (Model::Groups::iterator git = model->groups().begin(); git != model->groups().end(); ++git) {