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:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2020-12-10 04:31:25 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2020-12-10 04:31:25 +0300
commit548e9624d0fe72f3a4a1f5d494f29b123f03bc20 (patch)
tree7bacd1dd2e98310267ac2d35710c37591a2533f6 /intern/cycles/render/mesh.cpp
parentb379f9348487ad4e13650f10820a987deef76fe6 (diff)
Fix T82852: Cycles crashes when editing a mesh with adaptive subdivision
The issue is caused by stale data on the Mesh Node which is not cleared during synchronizing since the socket API refactor so that we can detect changes. However, synchronization only updates the sockets of the Mesh, so other properties were left with outdated values. This caused an underflow when computing attribute size for undisplaced coordinates as it was using the current number of vertices minus the previous count of subdivision vertices, which at this point should be 0. Added a simple method to clear non socket data. Also modified Mesh.add_undisplaced to always use an ATTR_PRIM_GEOMETRY as the data is not subdivided yet and it avoids any further issues regarding computing attribute sizes.
Diffstat (limited to 'intern/cycles/render/mesh.cpp')
-rw-r--r--intern/cycles/render/mesh.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 11c8e240afd..43e664a686f 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -277,6 +277,20 @@ void Mesh::reserve_subd_creases(size_t num_creases)
subd_creases_weight.reserve(num_creases);
}
+void Mesh::clear_non_sockets()
+{
+ Geometry::clear(true);
+
+ num_subd_verts = 0;
+ num_subd_faces = 0;
+
+ vert_to_stitching_key_map.clear();
+ vert_stitching_map.clear();
+
+ delete patch_table;
+ patch_table = NULL;
+}
+
void Mesh::clear(bool preserve_shaders, bool preserve_voxel_data)
{
Geometry::clear(preserve_shaders);
@@ -297,22 +311,15 @@ void Mesh::clear(bool preserve_shaders, bool preserve_voxel_data)
subd_ptex_offset.clear();
subd_face_corners.clear();
- num_subd_verts = 0;
- num_subd_faces = 0;
-
subd_creases_edge.clear();
subd_creases_weight.clear();
subd_attributes.clear();
attributes.clear(preserve_voxel_data);
- vert_to_stitching_key_map.clear();
- vert_stitching_map.clear();
-
subdivision_type = SubdivisionType::SUBDIVISION_NONE;
- delete patch_table;
- patch_table = NULL;
+ clear_non_sockets();
}
void Mesh::clear(bool preserve_shaders)
@@ -662,7 +669,7 @@ void Mesh::add_undisplaced()
float3 *data = attr->data_float3();
/* copy verts */
- size_t size = attr->buffer_size(this, attrs.prim);
+ size_t size = attr->buffer_size(this, ATTR_PRIM_GEOMETRY);
/* Center points for ngons aren't stored in Mesh::verts but are included in size since they will
* be calculated later, we subtract them from size here so we don't have an overflow while