Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/mesh.cpp
| Show First 20 Lines • Show All 628 Lines • ▼ Show 20 Lines | if(subd_faces.size()) { | ||||
| SubdFace& s = subd_faces[subd_faces.size()-1]; | SubdFace& s = subd_faces[subd_faces.size()-1]; | ||||
| ptex_offset = s.ptex_offset + s.num_ptex_faces(); | ptex_offset = s.ptex_offset + s.num_ptex_faces(); | ||||
| } | } | ||||
| SubdFace face = {start_corner, num_corners, shader_, smooth_, ptex_offset}; | SubdFace face = {start_corner, num_corners, shader_, smooth_, ptex_offset}; | ||||
| subd_faces.push_back_reserved(face); | subd_faces.push_back_reserved(face); | ||||
| } | } | ||||
| static void get_uv_tiles_from_attribute(Attribute *attr, int num, vector<int> &tiles, int columns) | |||||
| { | |||||
| 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; | |||||
| int x = clamp((int) u, 0, columns-1); | |||||
| int y = max((int) v, 0); | |||||
| /* 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*columns + x; | |||||
| if(id >= size) { | |||||
| tiles.resize(id+1); | |||||
| size = id; | |||||
| } | |||||
| if(tiles[id] == 0) { | |||||
| VLOG(2) << "Allocating UDIM ID " << id << " for UV " << uv->x << " " << uv->y; | |||||
| } | |||||
| tiles[id] = 1; | |||||
| } | |||||
| } | |||||
| void Mesh::get_uv_tiles(ustring map, vector<int> &tiles, int columns) | |||||
| { | |||||
| if(map.empty()) { | |||||
| get_uv_tiles_from_attribute(attributes.find(ATTR_STD_UV), | |||||
| num_triangles()*3, | |||||
| tiles, | |||||
| columns); | |||||
| get_uv_tiles_from_attribute(subd_attributes.find(ATTR_STD_UV), | |||||
| subd_face_corners.size() + num_ngons, | |||||
| tiles, | |||||
| columns); | |||||
| get_uv_tiles_from_attribute(curve_attributes.find(ATTR_STD_UV), | |||||
| num_curves(), | |||||
| tiles, | |||||
| columns); | |||||
| } | |||||
| else { | |||||
| get_uv_tiles_from_attribute(attributes.find(map), | |||||
| num_triangles()*3, | |||||
| tiles, | |||||
| columns); | |||||
| get_uv_tiles_from_attribute(subd_attributes.find(map), | |||||
| subd_face_corners.size() + num_ngons, | |||||
| tiles, | |||||
| columns); | |||||
| get_uv_tiles_from_attribute(curve_attributes.find(map), | |||||
| num_curves(), | |||||
| tiles, | |||||
| columns); | |||||
| } | |||||
| } | |||||
| void Mesh::compute_bounds() | void Mesh::compute_bounds() | ||||
| { | { | ||||
| BoundBox bnds = BoundBox::empty; | BoundBox bnds = BoundBox::empty; | ||||
| size_t verts_size = verts.size(); | size_t verts_size = verts.size(); | ||||
| size_t curve_keys_size = curve_keys.size(); | size_t curve_keys_size = curve_keys.size(); | ||||
| if(verts_size + curve_keys_size > 0) { | if(verts_size + curve_keys_size > 0) { | ||||
| for(size_t i = 0; i < verts_size; i++) | for(size_t i = 0; i < verts_size; i++) | ||||
| ▲ Show 20 Lines • Show All 1,596 Lines • Show Last 20 Lines | |||||