diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-03-19 12:32:16 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-03-19 12:33:51 +0300 |
commit | b49dbb635af74db5359cfc6c14a00ef397725968 (patch) | |
tree | 5a3dca9f5fb359ca0c79742ab799f8b1d745b7b5 /source/blender/blenkernel/intern | |
parent | 53674fb255d92da4b18fa844130a58ea9b57ff9d (diff) |
Subdiv: Make Blender crease to OSD sharpness reusable
Makes it so conversion is centralized in a single place.
We might consider removing any conversion, passing value as-is which
will be easier for I/O scripts to match crease. The downside of that
would be loose of control range in certain qualities and values of
crease.
There shouldn't be any functional changes in this commit.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_converter_mesh.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_inline.h | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c index a078648e68b..41fc28c5d52 100644 --- a/source/blender/blenkernel/intern/subdiv_converter_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c @@ -168,8 +168,7 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter, int manif } const int edge_index = storage->manifold_edge_index_reverse[manifold_edge_index]; const MEdge *medge = storage->mesh->medge; - const float edge_crease = (float)medge[edge_index].crease / 255.0f; - return edge_crease * edge_crease * 10.0f; + return BKE_subdiv_edge_crease_to_sharpness_char(medge[edge_index].crease); } static bool is_infinite_sharp_vertex(const OpenSubdiv_Converter *converter, diff --git a/source/blender/blenkernel/intern/subdiv_inline.h b/source/blender/blenkernel/intern/subdiv_inline.h index f00c5cf7ff7..a51a33feb3d 100644 --- a/source/blender/blenkernel/intern/subdiv_inline.h +++ b/source/blender/blenkernel/intern/subdiv_inline.h @@ -104,4 +104,15 @@ BLI_INLINE void BKE_subdiv_rotate_grid_to_quad( } } +BLI_INLINE float BKE_subdiv_edge_crease_to_sharpness_f(float edge_crease) +{ + return edge_crease * edge_crease * 10.0f; +} + +BLI_INLINE float BKE_subdiv_edge_crease_to_sharpness_char(char edge_crease) +{ + const float edge_crease_f = edge_crease / 255.0f; + return BKE_subdiv_edge_crease_to_sharpness_f(edge_crease_f); +} + #endif /* __SUBDIV_INLINE_H__ */ |