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) {