Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/render/mesh.cpp')
-rw-r--r--intern/cycles/render/mesh.cpp58
1 files changed, 56 insertions, 2 deletions
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index ade575a52d6..3b85186948e 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -662,6 +662,61 @@ void Mesh::add_subd_face(int* corners, int num_corners, int shader_, bool smooth
subd_faces.push_back_reserved(face);
}
+static void get_uv_tiles_from_attribute(Attribute *attr, int num, vector<bool> &tiles)
+{
+ if(!attr) {
+ return;
+ }
+
+ const float3 *uv = attr->data_float3();
+ int size = tiles.size();
+ for(int i = 0; i < num; i++, uv++) {
+ float u = uv->x, v = uv->y;
+
+ if(u < 0.0f || v < 0.0f || u > 10.0f) continue;
+
+ int x = (int) u, y = (int) v;
+
+ /* Be conservative in corners - precisely touching the right-upper corner of a tile
+ * should not load its right-upper neighbor as well. */
+ if(x && (u == x)) x--;
+ if(y && (v == y)) y--;
+
+ int id = y*10 + x;
+ if(id >= size) {
+ tiles.resize(id+1);
+ size = id;
+ }
+ tiles[id] = true;
+ }
+}
+
+void Mesh::get_uv_tiles(ustring map, vector<bool> &tiles)
+{
+ if(map.empty()) {
+ get_uv_tiles_from_attribute(attributes.find(ATTR_STD_UV),
+ num_triangles()*3,
+ tiles);
+ get_uv_tiles_from_attribute(subd_attributes.find(ATTR_STD_UV),
+ subd_face_corners.size() + num_ngons,
+ tiles);
+ get_uv_tiles_from_attribute(curve_attributes.find(ATTR_STD_UV),
+ num_curves(),
+ tiles);
+ }
+ else {
+ get_uv_tiles_from_attribute(attributes.find(map),
+ num_triangles()*3,
+ tiles);
+ get_uv_tiles_from_attribute(subd_attributes.find(map),
+ subd_face_corners.size() + num_ngons,
+ tiles);
+ get_uv_tiles_from_attribute(curve_attributes.find(map),
+ num_curves(),
+ tiles);
+ }
+}
+
void Mesh::compute_bounds()
{
BoundBox bnds = BoundBox::empty;
@@ -1996,8 +2051,7 @@ void MeshManager::device_update_displacement_images(Device *device,
}
ImageSlotTextureNode *image_node = static_cast<ImageSlotTextureNode*>(node);
- int slot = image_node->slot;
- if(slot != -1) {
+ foreach(int slot, image_node->slots) {
bump_images.insert(slot);
}
}