Fix #121097: Cycles issue with sharp edges in mesh edit mode
The normal domain needs to be checked after converting the editmesh to mesh.
This commit is contained in:
@@ -64,6 +64,13 @@ BlenderAttributeType blender_attribute_name_split_type(ustring name, string *r_r
|
||||
void python_thread_state_save(void **python_thread_state);
|
||||
void python_thread_state_restore(void **python_thread_state);
|
||||
|
||||
static bool mesh_use_corner_normals(BL::Mesh &mesh, Mesh::SubdivisionType subdivision_type)
|
||||
{
|
||||
return mesh && (subdivision_type == Mesh::SUBDIVISION_NONE) &&
|
||||
(static_cast<const ::Mesh *>(mesh.ptr.data)->normals_domain(true) ==
|
||||
blender::bke::MeshNormalDomain::Corner);
|
||||
}
|
||||
|
||||
static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
|
||||
BObjectInfo &b_ob_info,
|
||||
BL::Depsgraph & /*depsgraph*/,
|
||||
@@ -88,27 +95,33 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
|
||||
|
||||
BL::Mesh mesh = (b_ob_info.object_data.is_a(&RNA_Mesh)) ? BL::Mesh(b_ob_info.object_data) :
|
||||
BL::Mesh(PointerRNA_NULL);
|
||||
const bool split_faces = (mesh) && (subdivision_type == Mesh::SUBDIVISION_NONE) &&
|
||||
(static_cast<const ::Mesh *>(mesh.ptr.data)->normals_domain(true) ==
|
||||
blender::bke::MeshNormalDomain::Corner);
|
||||
|
||||
bool use_corner_normals = false;
|
||||
|
||||
if (b_ob_info.is_real_object_data()) {
|
||||
if (mesh) {
|
||||
/* Make a copy to split faces if we use auto-smooth, otherwise not needed.
|
||||
* Also in edit mode do we need to make a copy, to ensure data layers like
|
||||
* UV are not empty. */
|
||||
if (mesh.is_editmode() || split_faces) {
|
||||
if (mesh.is_editmode()) {
|
||||
/* Flush editmesh to mesh, including all data layers. */
|
||||
BL::Depsgraph depsgraph(PointerRNA_NULL);
|
||||
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
|
||||
use_corner_normals = mesh_use_corner_normals(mesh, subdivision_type);
|
||||
}
|
||||
else if (mesh_use_corner_normals(mesh, subdivision_type)) {
|
||||
/* Make a copy to split faces. */
|
||||
BL::Depsgraph depsgraph(PointerRNA_NULL);
|
||||
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
|
||||
use_corner_normals = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BL::Depsgraph depsgraph(PointerRNA_NULL);
|
||||
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
|
||||
use_corner_normals = mesh_use_corner_normals(mesh, subdivision_type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* TODO: what to do about non-mesh geometry instances? */
|
||||
use_corner_normals = mesh_use_corner_normals(mesh, subdivision_type);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -121,7 +134,7 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
|
||||
#endif
|
||||
|
||||
if (mesh) {
|
||||
if (split_faces) {
|
||||
if (use_corner_normals) {
|
||||
mesh.split_faces();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user