Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-01-27 12:36:26 +0000
committerStijn Buys <ingar@osirion.org>2011-01-27 12:36:26 +0000
commit2a87246be478e5ddd2bef4080f36382a889e02dd (patch)
treed203a9a49044f03764dc2661f688b1c6c836e56d /src/model
parent45b93da49b74acd7389e4faa1cfd5dba6cd75c95 (diff)
Moved material loading from render to core, make sure the dedicated server reads materials.ini,
removed unnecessary CollisionMesh::translate() method.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/collisionmesh.cc15
-rw-r--r--src/model/collisionmesh.h2
-rw-r--r--src/model/mapfile.cc90
3 files changed, 50 insertions, 57 deletions
diff --git a/src/model/collisionmesh.cc b/src/model/collisionmesh.cc
index b20074f..90aafc3 100644
--- a/src/model/collisionmesh.cc
+++ b/src/model/collisionmesh.cc
@@ -34,7 +34,8 @@ void CollisionMesh::clear()
con_debug << " clearing collision meshes" << std::endl;
for (Registry::iterator i = collisionmesh_registry.begin(); i != collisionmesh_registry.end(); ++i) {
- delete(*i).second;
+ delete (*i).second;
+ (*i).second = 0;
}
collisionmesh_registry.clear();
@@ -73,16 +74,4 @@ void CollisionMesh::add_triangle(const math::Vector3f & v0, const math::Vector3f
collisionmesh_size += 1;
}
-void CollisionMesh::translate(const math::Vector3f translation)
-{
- /*
- IndexedMeshArray & indexes = collisionmesh_triangles->getIndexedMeshArray();
- for (size_t i =0; i < indexes.size(); i++) {
- btIndexedMesh & mesh = indexes[i];
-
-
- }
- */
-}
-
} // namespace model
diff --git a/src/model/collisionmesh.h b/src/model/collisionmesh.h
index 7329a0e..9efd21a 100644
--- a/src/model/collisionmesh.h
+++ b/src/model/collisionmesh.h
@@ -58,8 +58,6 @@ public:
* @brief add a triangle to the collision mesh
*/
void add_triangle(const math::Vector3f & v0, const math::Vector3f & v1, const math::Vector3f & v2);
-
- void translate(const math::Vector3f translation);
/* ---- static ----------------------------------------------------- */
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index c5e2964..f3f347f 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -1158,9 +1158,6 @@ void MapFile::clear_bbox()
void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_type)
{
- if (!VertexArray::instance() || VertexArray::instance()->overflow())
- return;
-
if (!map_materials.size())
return;
@@ -1198,7 +1195,20 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
// store triangles
if (primitives->triangles().size()) {
- if (!(primitives->material()->flags() & Material::Clip)) {
+
+ if ((primitives->material()->flags() & Material::Clip) == Material::Clip) {
+
+ if (map_load_clip) {
+ // clip materials are loaded into the CollisionMesh
+ for (Primitives::Triangles::iterator tris_it = primitives->triangles().begin(); tris_it != primitives->triangles().end(); tris_it++) {
+ Triangle *triangle = (*tris_it);
+ //model->collisionmesh()->add_triangle(triangle->v0(), triangle->v1(), triangle->v2());
+ map_collisiontriangles.add(*triangle);
+ }
+ }
+
+ } else if (VertexArray::instance() && !VertexArray::instance()->overflow()) {
+
Fragment *fragment = new Fragment(Fragment::Triangles, primitives->material());
// add structural triangles to the fragment
@@ -1231,54 +1241,50 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
// add the fragment to the group
group->add_fragment(fragment);
-
- } else if (map_load_clip) {
- // clip materials are loaded into the CollisionMesh
- for (Primitives::Triangles::iterator tris_it = primitives->triangles().begin(); tris_it != primitives->triangles().end(); tris_it++) {
- Triangle *triangle = (*tris_it);
- //model->collisionmesh()->add_triangle(triangle->v0(), triangle->v1(), triangle->v2());
- map_collisiontriangles.add(*triangle);
- }
}
}
// store quads
if (primitives->quads().size()) {
- Fragment *fragment = new Fragment(Fragment::Quads, primitives->material());
-
- // 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()) {
- size_t count = 0;
- count += fragment->add_vertex(quad->v0() - translation, quad->n0(), quad->t0(), false);
- count += fragment->add_vertex(quad->v1() - translation, quad->n1(), quad->t1(), false);
- count += fragment->add_vertex(quad->v2() - translation, quad->n2(), quad->t2(), false);
- count += fragment->add_vertex(quad->v3() - translation, quad->n3(), quad->t3(), false);
- if (count == 4) {
- model->model_quad_count++;
+
+ if (VertexArray::instance() && !VertexArray::instance()->overflow()) {
+
+ Fragment *fragment = new Fragment(Fragment::Quads, primitives->material());
+
+ // 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()) {
+ size_t count = 0;
+ count += fragment->add_vertex(quad->v0() - translation, quad->n0(), quad->t0(), false);
+ count += fragment->add_vertex(quad->v1() - translation, quad->n1(), quad->t1(), false);
+ count += fragment->add_vertex(quad->v2() - translation, quad->n2(), quad->t2(), false);
+ count += fragment->add_vertex(quad->v3() - translation, quad->n3(), quad->t3(), false);
+ if (count == 4) {
+ model->model_quad_count++;
+ }
}
}
- }
- // 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()) {
- size_t count = 0;
- count += fragment->add_vertex(quad->v0() - translation, quad->n0(), quad->t0(), true);
- count += fragment->add_vertex(quad->v1() - translation, quad->n1(), quad->t1(), true);
- count += fragment->add_vertex(quad->v2() - translation, quad->n2(), quad->t2(), true);
- count += fragment->add_vertex(quad->v3() - translation, quad->n3(), quad->t3(), true);
- if (count == 4) {
- model->model_quad_count++;
- model->model_quad_detail_count++;
+ // 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()) {
+ size_t count = 0;
+ count += fragment->add_vertex(quad->v0() - translation, quad->n0(), quad->t0(), true);
+ count += fragment->add_vertex(quad->v1() - translation, quad->n1(), quad->t1(), true);
+ count += fragment->add_vertex(quad->v2() - translation, quad->n2(), quad->t2(), true);
+ count += fragment->add_vertex(quad->v3() - translation, quad->n3(), quad->t3(), true);
+ if (count == 4) {
+ model->model_quad_count++;
+ model->model_quad_detail_count++;
+ }
}
}
- }
- // add the fragment to the group
- group->add_fragment(fragment);
+ // add the fragment to the group
+ group->add_fragment(fragment);
+ }
}
}
@@ -1354,7 +1360,7 @@ Model * MapFile::load(std::string const &name)
model->set_collisionmesh(CollisionMesh::find(name));
if (CollisionMesh::initialized() && !model->collisionmesh()) {
- mapfile.map_load_clip = true;
+ mapfile.map_load_clip = true;
} else {
mapfile.map_load_clip = false;
}