X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fmetascene.cc;h=09527e9db877c5e2d65edbcebd9fbc71210c075d;hp=c46742032d555b25f150da4eaec4d0aa77fadb6e;hb=5ce504b61cdb88166133d5977a2faad1664c850f;hpb=0d27f859021b4af5dbb5404ef5af012546abf335 diff --git a/src/metascene.cc b/src/metascene.cc index c467420..09527e9 100644 --- a/src/metascene.cc +++ b/src/metascene.cc @@ -223,25 +223,30 @@ int MetaScene::calc_mirror_planes() const Mesh *mesh = ((ObjMesh*)obj)->mesh; if(!mesh) continue; - // assume the object is actually flat, so grab the first triangle and make a plane - Triangle face = Triangle(0, (const Vec3*)mesh->get_attrib_data(MESH_ATTR_VERTEX), - mesh->get_index_data()); - face.calc_normal(); - FlatMirror *mir = new FlatMirror; - mir->plane.pt = face.v[0]; - mir->plane.normal = face.normal; mir->reflect = obj->mtl.reflect; + if(obj->mtl.flat_mirror == MTL_MIRROR_AUTO) { + // assume the object is actually flat, so grab the first triangle and make a plane + Triangle face = Triangle(0, (const Vec3*)mesh->get_attrib_data(MESH_ATTR_VERTEX), + mesh->get_index_data()); + face.calc_normal(); + + mir->plane.pt = face.v[0]; + mir->plane.normal = face.normal; + } else { + } + // check to see if we have found this mirror plane already bool found = false; FlatMirror *node = mirrors; while(node) { - if(fabs(dot(mir->plane.normal, node->plane.normal)) < 1e-4 && + if(1.0f - dot(mir->plane.normal, node->plane.normal) < 1e-4f && fabs(dot(mir->plane.normal, normalize(mir->plane.pt - node->plane.pt))) < 1e-4) { found = true; break; } + node = node->next; } if(!found) {