diff options
-rw-r--r-- | intern/opensubdiv/internal/opensubdiv_converter_factory.cc | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc index d5902918663..ab93b5ce952 100644 --- a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc +++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc @@ -173,18 +173,27 @@ inline bool TopologyRefinerFactory<TopologyRefinerData>::assignComponentTags( setBaseVertexSharpness(refiner, vertex_index, Crease::SHARPNESS_INFINITE); continue; } + + // Get sharpness provided by the converter. + float sharpness = 0.0f; if (converter->getVertexSharpness != NULL) { - float sharpness = converter->getVertexSharpness(converter, vertex_index); - if (vertex_edges.size() == 2) { - const int edge0 = vertex_edges[0], edge1 = vertex_edges[1]; - const float sharpness0 = refiner._levels[0]->getEdgeSharpness(edge0); - const float sharpness1 = refiner._levels[0]->getEdgeSharpness(edge1); - // TODO(sergey): Find a better mixing between edge and vertex sharpness. - sharpness += min(sharpness0, sharpness1); - sharpness = min(sharpness, 10.0f); - } - setBaseVertexSharpness(refiner, vertex_index, sharpness); + sharpness = converter->getVertexSharpness(converter, vertex_index); } + + // If it's vertex where 2 non-manifold edges meet adjust vertex sharpness to + // the edges. + // This way having a plane with all 4 edges set to be sharp produces sharp + // corners in the subdivided result. + if (vertex_edges.size() == 2) { + const int edge0 = vertex_edges[0], edge1 = vertex_edges[1]; + const float sharpness0 = refiner._levels[0]->getEdgeSharpness(edge0); + const float sharpness1 = refiner._levels[0]->getEdgeSharpness(edge1); + // TODO(sergey): Find a better mixing between edge and vertex sharpness. + sharpness += min(sharpness0, sharpness1); + sharpness = min(sharpness, 10.0f); + } + + setBaseVertexSharpness(refiner, vertex_index, sharpness); } return true; } |