diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/object/object_bake.c | 20 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc | 59 |
2 files changed, 69 insertions, 10 deletions
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 1483c24ac70..effbde41c38 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -220,22 +220,22 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0); Mesh *me = (Mesh *)ob->data; MultiresModifierData tmp_mmd = *mmd; - DerivedMesh *cddm = CDDM_from_mesh(me); - DM_set_only_copy(cddm, &CD_MASK_BAREMESH); + *lvl = mmd->lvl; if (mmd->lvl == 0) { - dm = CDDM_copy(cddm); - } - else { - tmp_mmd.lvl = mmd->lvl; - tmp_mmd.sculptlvl = mmd->lvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0); + DerivedMesh *cddm = CDDM_from_mesh(me); + DM_set_only_copy(cddm, &CD_MASK_BAREMESH); + return cddm; } - cddm->release(cddm); + DerivedMesh *cddm = CDDM_from_mesh(me); + DM_set_only_copy(cddm, &CD_MASK_BAREMESH); + tmp_mmd.lvl = mmd->lvl; + tmp_mmd.sculptlvl = mmd->lvl; + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0); - *lvl = mmd->lvl; + cddm->release(cddm); return dm; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 25c7840d633..3e2e07cb772 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -145,6 +145,34 @@ static void expand_mesh(Mesh &mesh, BKE_mesh_update_customdata_pointers(&mesh, false); } +static CustomData &get_customdata(Mesh &mesh, const AttributeDomain domain) +{ + switch (domain) { + case ATTR_DOMAIN_POINT: + return mesh.vdata; + case ATTR_DOMAIN_EDGE: + return mesh.edata; + case ATTR_DOMAIN_FACE: + return mesh.pdata; + case ATTR_DOMAIN_CORNER: + return mesh.ldata; + default: + BLI_assert_unreachable(); + return mesh.vdata; + } +} + +static MutableSpan<int> get_orig_index_layer(Mesh &mesh, const AttributeDomain domain) +{ + MeshComponent component; + component.replace(&mesh, GeometryOwnershipType::ReadOnly); + CustomData &custom_data = get_customdata(mesh, domain); + if (int *orig_indices = static_cast<int *>(CustomData_get_layer(&custom_data, CD_ORIGINDEX))) { + return {orig_indices, component.attribute_domain_size(domain)}; + } + return {}; +} + static MEdge new_edge(const int v1, const int v2) { MEdge edge; @@ -292,6 +320,9 @@ static void extrude_mesh_vertices(MeshComponent &component, }); }); + MutableSpan<int> vert_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_POINT); + vert_orig_indices.slice(new_vert_range).fill(ORIGINDEX_NONE); + if (attribute_outputs.top_id) { save_selection_as_attribute( component, attribute_outputs.top_id.get(), ATTR_DOMAIN_POINT, new_vert_range); @@ -615,6 +646,13 @@ static void extrude_mesh_edges(MeshComponent &component, }); } + MutableSpan<int> vert_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_POINT); + vert_orig_indices.slice(new_vert_range).fill(ORIGINDEX_NONE); + + MutableSpan<int> edge_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_EDGE); + edge_orig_indices.slice(connect_edge_range).fill(ORIGINDEX_NONE); + edge_orig_indices.slice(duplicate_edge_range).fill(ORIGINDEX_NONE); + if (attribute_outputs.top_id) { save_selection_as_attribute( component, attribute_outputs.top_id.get(), ATTR_DOMAIN_EDGE, duplicate_edge_range); @@ -983,6 +1021,17 @@ static void extrude_mesh_face_regions(MeshComponent &component, }); } + MutableSpan<int> vert_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_POINT); + vert_orig_indices.slice(new_vert_range).fill(ORIGINDEX_NONE); + + MutableSpan<int> edge_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_EDGE); + edge_orig_indices.slice(connect_edge_range).fill(ORIGINDEX_NONE); + edge_orig_indices.slice(new_inner_edge_range).fill(ORIGINDEX_NONE); + edge_orig_indices.slice(boundary_edge_range).fill(ORIGINDEX_NONE); + + MutableSpan<int> poly_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_FACE); + poly_orig_indices.slice(side_poly_range).fill(ORIGINDEX_NONE); + if (attribute_outputs.top_id) { save_selection_as_attribute( component, attribute_outputs.top_id.get(), ATTR_DOMAIN_FACE, poly_selection); @@ -1232,6 +1281,16 @@ static void extrude_individual_mesh_faces(MeshComponent &component, } }); + MutableSpan<int> vert_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_POINT); + vert_orig_indices.slice(new_vert_range).fill(ORIGINDEX_NONE); + + MutableSpan<int> edge_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_EDGE); + edge_orig_indices.slice(connect_edge_range).fill(ORIGINDEX_NONE); + edge_orig_indices.slice(duplicate_edge_range).fill(ORIGINDEX_NONE); + + MutableSpan<int> poly_orig_indices = get_orig_index_layer(mesh, ATTR_DOMAIN_FACE); + poly_orig_indices.slice(side_poly_range).fill(ORIGINDEX_NONE); + /* Finally update each extruded polygon's loops to point to the new edges and vertices. * This must be done last, because they were used to find original indices for attribute * interpolation before. Alternatively an original index array could be built for each domain. */ |