Commit: 01f509232bbc6fff39f0c1de45b79b9efa3fab47 Author: Hans Goudey Date: Tue Jan 10 13:05:56 2023 -0500 Branches: refactor-mesh-sharp-edge-generic https://developer.blender.org/rB01f509232bbc6fff39f0c1de45b79b9efa3fab47
Merge branch 'master' into refactor-mesh-sharp-edge-generic =================================================================== =================================================================== diff --cc source/blender/blenkernel/BKE_mesh.h index 998fca10f80,ffca4cff347..1cf86e87493 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@@ -596,10 -592,8 +592,10 @@@ void BKE_lnor_space_custom_normal_to_da * (splitting edges). * * \param loop_to_poly_map: Optional pre-created map from loops to their polygon. + * \param sharp_edges: Optional array of sharp edge tags, used to split the evaluated normals on + * each side of the edge. */ - void BKE_mesh_normals_loop_split(const struct MVert *mverts, + void BKE_mesh_normals_loop_split(const float (*vert_positions)[3], const float (*vert_normals)[3], int numVerts, const struct MEdge *medges, @@@ -617,10 -610,10 +613,10 @@@ MLoopNorSpaceArray *r_lnors_spacearr, short (*clnors_data)[2]); - void BKE_mesh_normals_loop_custom_set(const struct MVert *mverts, + void BKE_mesh_normals_loop_custom_set(const float (*vert_positions)[3], const float (*vert_normals)[3], int numVerts, - struct MEdge *medges, + const struct MEdge *medges, int numEdges, const struct MLoop *mloops, float (*r_custom_loop_normals)[3], @@@ -628,9 -621,8 +624,9 @@@ const struct MPoly *mpolys, const float (*poly_normals)[3], int numPolys, + bool *sharp_edges, short (*r_clnors_data)[2]); - void BKE_mesh_normals_loop_custom_from_verts_set(const struct MVert *mverts, + void BKE_mesh_normals_loop_custom_from_verts_set(const float (*vert_positions)[3], const float (*vert_normals)[3], float (*r_custom_vert_normals)[3], int numVerts, diff --cc source/blender/blenkernel/BKE_mesh_legacy_convert.h index 3fa45959d2c,3b1b94e516a..3a755599da0 --- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h +++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h @@@ -88,9 -95,13 +95,16 @@@ void BKE_mesh_legacy_convert_loose_edge void BKE_mesh_legacy_attribute_flags_to_strings(struct Mesh *mesh); void BKE_mesh_legacy_attribute_strings_to_flags(struct Mesh *mesh); +void BKE_mesh_sharp_edges_to_flags(struct Mesh *mesh); +void BKE_mesh_sharp_edges_from_flags(struct Mesh *mesh); + + struct MVert *BKE_mesh_legacy_convert_positions_to_verts( + Mesh *mesh, + blender::ResourceScope &temp_arrays_for_convert, + blender::Vector<CustomDataLayer, 16> &vert_layers_to_write); + + void BKE_mesh_legacy_convert_verts_to_positions(Mesh *mesh); + #endif /** diff --cc source/blender/blenkernel/intern/curve_to_mesh_convert.cc index 12da300598b,305a245a036..2a97e98a9fb --- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc +++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc @@@ -713,34 -688,26 +710,34 @@@ Mesh *curve_to_mesh_sweep(const CurvesG tangents.slice(info.main_points), normals.slice(info.main_points), radii.is_empty() ? radii : radii.slice(info.main_points), - verts.slice(info.vert_range)); + positions.slice(info.vert_range)); }); - if (profile.curve_type_counts()[CURVE_TYPE_BEZIER] > 0) { - const VArray<int8_t> curve_types = profile.curve_types(); - const VArraySpan<int8_t> handle_types_left{profile.handle_types_left()}; - const VArraySpan<int8_t> handle_types_right{profile.handle_types_right()}; + MutableAttributeAccessor mesh_attributes = mesh->attributes_for_write(); + SpanAttributeWriter<bool> sharp_edges; + write_sharp_bezier_edges(curves_info, offsets, mesh_attributes, sharp_edges); + if (fill_caps) { + if (!sharp_edges) { + sharp_edges = mesh_attributes.lookup_or_add_for_write_span<bool>("sharp_edge", + ATTR_DOMAIN_EDGE); + } foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) { - if (curve_types[info.i_profile] == CURVE_TYPE_BEZIER) { - const IndexRange points = profile.points_for_curve(info.i_profile); - mark_bezier_vector_edges_sharp(points.size(), - info.main_segment_num, - profile.bezier_evaluated_offsets_for_curve(info.i_profile), - handle_types_left.slice(points), - handle_types_right.slice(points), - edges.slice(info.edge_range)); + if (info.main_cyclic || !info.profile_cyclic) { + return; } + const int main_edges_start = info.edge_range.start(); + const int last_ring_index = info.main_points.size() - 1; + const int profile_edges_start = main_edges_start + + info.profile_points.size() * info.main_segment_num; + const int last_ring_edge_offset = profile_edges_start + + info.profile_segment_num * last_ring_index; + + sharp_edges.span.slice(profile_edges_start, info.profile_segment_num).fill(true); + sharp_edges.span.slice(last_ring_edge_offset, info.profile_segment_num).fill(true); }); } + sharp_edges.finish(); Set<AttributeIDRef> main_attributes_set; diff --cc source/blender/blenkernel/intern/data_transfer.cc index 7e56cd966f5,39837051c0a..430527e43d3 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@@ -345,12 -341,8 +345,12 @@@ static void data_transfer_dtdata_type_p ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, num_loops_dst)); } + bke::MutableAttributeAccessor attributes = me_dst->attributes_for_write(); + bke::SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_span<bool>( + "sharp_edge", ATTR_DOMAIN_EDGE); + /* Note loop_nors_dst contains our custom normals as transferred from source... */ - BKE_mesh_normals_loop_custom_set(verts_dst, + BKE_mesh_normals_loop_custom_set(positions_dst, BKE_mesh_vertex_normals_ensure(me_dst), num_verts_dst, edges_dst, diff --cc source/blender/blenkernel/intern/geometry_component_mesh.cc index 13f6c2f41d5,c91dc249249..7b694be324a --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@@ -1337,9 -1296,8 +1308,8 @@@ static ComponentAttributeProviders crea static CustomDataAttributeProvider face_custom_data(ATTR_DOMAIN_FACE, face_access); return ComponentAttributeProviders( - {&position, &id, &material_index, &shade_smooth, &normal, &crease}, + {&position, &id, &material_index, &shade_smooth, &sharp_edge, &normal, &crease}, - {&uvs, - &corner_custom_data, + {&corner_custom_data, &vertex_groups, &point_custom_data, &edge_custom_data, diff --cc source/blender/blenkernel/intern/mesh_normals.cc index 5c4d2a94c99,266ef0efa0b..cb5aeac364b --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@@ -1652,10 -1609,10 +1603,10 @@@ void BKE_mesh_normals_loop_split(const * r_custom_loop_normals is expected to have normalized normals, or zero ones, * in which case they will be replaced by default loop/vertex normal. */ - static void mesh_normals_loop_custom_set(const MVert *mverts, + static void mesh_normals_loop_custom_set(const float (*positions)[3], const float (*vert_normals)[3], const int numVerts, - MEdge *medges, + const MEdge *medges, const int numEdges, const MLoop *mloops, float (*r_custom_loop_normals)[3], @@@ -1895,10 -1849,10 +1846,10 @@@ BKE_lnor_spacearr_free(&lnors_spacearr); } - void BKE_mesh_normals_loop_custom_set(const MVert *mverts, + void BKE_mesh_normals_loop_custom_set(const float (*vert_positions)[3], const float (*vert_normals)[3], const int numVerts, - MEdge *medges, + const MEdge *medges, const int numEdges, const MLoop *mloops, float (*r_custom_loop_normals)[3], @@@ -1906,10 -1860,9 +1857,10 @@@ const MPoly *mpolys, const float (*poly_normals)[3], const int numPolys, + bool *sharp_edges, short (*r_clnors_data)[2]) { - mesh_normals_loop_custom_set(mverts, + mesh_normals_loop_custom_set(vert_positions, vert_normals, numVerts, medges, @@@ -1936,10 -1888,9 +1887,10 @@@ void BKE_mesh_normals_loop_custom_from_ const MPoly *mpolys, const float ( @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs