diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-23 17:02:05 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-23 17:02:28 +0300 |
commit | a8a454287a27d408668f8adc6fe1b3aa988de1ac (patch) | |
tree | a0c55182e620598bb92542562d2fc134091a2c08 /source/blender/blenkernel/intern/subdiv_converter_mesh.c | |
parent | b197cd5821f1dfaa5168d31984dd8014f5252456 (diff) |
Mesh: Move edge crease out of MEdge
This is very similar to D14077. There are two differences though.
First is that vertex creases are already stored in a separate layer,
and second is that we can now completely remove use of `Mesh.cd_flag`,
since that information is now inherent to whether the layers exist.
There are two functional differences here:
* Operators are used to add and remove layers instead of a property.
* The "crease" attribute can be created and removed by geometry nodes.
The second change should make various geometry nodes slightly faster,
since the "crease" attribute was always processed before. Creases are
now interpolated generically in the CustomData API too, which should
help maintain the values across edits better.
Meshes get an `edge_creases` RNA property like the existing vertex
property, to provide more efficient access to the data in Cycles.
One test failure is expected, where different rounding between float
the old char storage means that 5 additional points are scattered in
a geometry nodes test.
Differential Revision: https://developer.blender.org/D15927
Diffstat (limited to 'source/blender/blenkernel/intern/subdiv_converter_mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_converter_mesh.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c index b13aec37c78..369e7f7060a 100644 --- a/source/blender/blenkernel/intern/subdiv_converter_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c @@ -41,6 +41,8 @@ typedef struct ConverterStorage { /* CustomData layer for vertex sharpnesses. */ const float *cd_vertex_crease; + /* CustomData layer for edge sharpness. */ + const float *cd_edge_crease; /* Indexed by loop index, value denotes index of face-varying vertex * which corresponds to the UV coordinate. */ @@ -157,12 +159,11 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter, int manif return 10.0f; } #endif - if (!storage->settings.use_creases) { + if (!storage->settings.use_creases || storage->cd_edge_crease == NULL) { return 0.0f; } const int edge_index = storage->manifold_edge_index_reverse[manifold_edge_index]; - const MEdge *medge = storage->edges; - return BKE_subdiv_crease_to_sharpness_char(medge[edge_index].crease); + return BKE_subdiv_crease_to_sharpness_f(storage->cd_edge_crease[edge_index]); } static bool is_infinite_sharp_vertex(const OpenSubdiv_Converter *converter, @@ -398,6 +399,7 @@ static void init_user_data(OpenSubdiv_Converter *converter, user_data->polys = BKE_mesh_polys(mesh); user_data->loops = BKE_mesh_loops(mesh); user_data->cd_vertex_crease = CustomData_get_layer(&mesh->vdata, CD_CREASE); + user_data->cd_edge_crease = CustomData_get_layer(&mesh->edata, CD_CREASE); user_data->loop_uv_indices = NULL; initialize_manifold_indices(user_data); converter->user_data = user_data; |