From 7129e31075e021112ba6a859af29513e69671626 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 29 Jan 2011 13:04:59 +0000 Subject: code cleanups. --- src/model/mapfile.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/model') diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index f3f347f..7efd44b 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -398,7 +398,7 @@ bool MapFile::read_patchdef() // http://www.cc.gatech.edu/classes/AY2002/cs4451_spring/groups/group3/index.html#bpatches2 // // patchvertices[][] are the control points as read from the .map file - // mesh[][] is a subdivideXsubdivide quad mesh calculated for each set of 9 control points in the patch + // mesh[][] is a subdivide X subdivide quad mesh calculated for each set of 9 control points in the patch // binomial coefficient const float binom[3] = {1.0f, 2.0f, 1.0f}; @@ -520,7 +520,7 @@ bool MapFile::read_patchdef() mesh[i+1][j+1] * SCALE, mesh[i][j+1] * SCALE, mesh[i][j] * SCALE); - primitives->add_triangle(triangle); + map_collisiontriangles.add(*triangle); triangle = new Triangle( mesh[i+1][j+1] * SCALE, @@ -1201,7 +1201,7 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t 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); + Triangle *triangle = (*tris_it); //model->collisionmesh()->add_triangle(triangle->v0(), triangle->v1(), triangle->v2()); map_collisiontriangles.add(*triangle); } @@ -1918,17 +1918,18 @@ Model * MapFile::load(std::string const &name) if (mapfile.map_load_clip) { if (mapfile.map_collisiontriangles.size()) { - // create a collision mesh instance for the model - model->set_collisionmesh(new CollisionMesh(name)); + CollisionMesh *collisionmesh = new CollisionMesh(name); // add clip triangles to collision mesh for (TriangleList::iterator it = mapfile.map_collisiontriangles.begin(); it != mapfile.map_collisiontriangles.end(); it++) { Triangle *triangle = (*it); - model->collisionmesh()->add_triangle(triangle->v0() - map_center, triangle->v1() - map_center, triangle->v2() - map_center); + collisionmesh->add_triangle(triangle->v0() - map_center, triangle->v1() - map_center, triangle->v2() - map_center); } - // add the collision mesh to the registry - CollisionMesh::add(model->collisionmesh()); + // register the mesh + CollisionMesh::add(collisionmesh); + model->set_collisionmesh(collisionmesh); + con_debug << " " << mapfile.name() << " " << model->collisionmesh()->size() << " collision triangles" << std::endl; } } -- cgit v1.2.3