Fix cycles issue with wrong texture coordinates on a second render layer with
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 31 Jul 2012 15:05:16 +0000 (15:05 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 31 Jul 2012 15:05:16 +0000 (15:05 +0000)
a mask layer enabled.

intern/cycles/render/light.cpp
intern/cycles/render/object.cpp

index 6c03d0859a75caafd93f00f23e0e017979d8fd44..d00b242d153bf590b42e4edbcf3f0fba655e7e81 100644 (file)
@@ -194,10 +194,11 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
 
                /* sum area */
                if(have_emission) {
+                       bool transform_applied = mesh->transform_applied;
                        Transform tfm = object->tfm;
                        int object_id = j;
 
-                       if(mesh->transform_applied)
+                       if(transform_applied)
                                object_id = ~object_id;
 
                        for(size_t i = 0; i < mesh->triangles.size(); i++) {
@@ -211,9 +212,15 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                                        offset++;
 
                                        Mesh::Triangle t = mesh->triangles[i];
-                                       float3 p1 = transform_point(&tfm, mesh->verts[t.v[0]]);
-                                       float3 p2 = transform_point(&tfm, mesh->verts[t.v[1]]);
-                                       float3 p3 = transform_point(&tfm, mesh->verts[t.v[2]]);
+                                       float3 p1 = mesh->verts[t.v[0]];
+                                       float3 p2 = mesh->verts[t.v[1]];
+                                       float3 p3 = mesh->verts[t.v[2]];
+
+                                       if(!transform_applied) {
+                                               p1 = transform_point(&tfm, p1);
+                                               p2 = transform_point(&tfm, p2);
+                                               p3 = transform_point(&tfm, p3);
+                                       }
 
                                        totarea += triangle_area(p1, p2, p3);
                                }
index c4b25e633bf24eeb8da164af8520651674aeab92..0fe227fd1715d1a027e34233d614f714ab6b30aa 100644 (file)
@@ -111,8 +111,9 @@ void Object::apply_transform()
                mesh->compute_bounds();
                compute_bounds(false);
        }
-       
-       tfm = transform_identity();
+
+       /* tfm is not reset to identity, all code that uses it needs to check the
+          transform_applied boolean */
 }
 
 void Object::tag_update(Scene *scene)