Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2021-06-23 19:42:20 +0300
committerPablo Dobarro <pablodp606@gmail.com>2021-06-23 19:42:40 +0300
commitef7fcaf8e6c684463ce143bf0ea43d23803919d2 (patch)
tree05356dd93bd111c81b5c2ef0a11d7e002ae1dec5 /source/blender/editors/object/object_remesh.c
parent6e4b9f5836cd9954c00b52e043e6a9af9fb4c112 (diff)
Voxel Remesher: Make smooth shading output automatic
Previously the smooth shading of the voxel remesher was controlled by a mesh property. With this change, the output will try to match the current shading of the object. This only takes into consideration the shading mode of the first polygon of the model, but it is probably what most users expect as it works as intended with the shade smooth/flat object mode options. Reviewed By: JulienKaspar, JacquesLucke Differential Revision: https://developer.blender.org/D11626
Diffstat (limited to 'source/blender/editors/object/object_remesh.c')
-rw-r--r--source/blender/editors/object/object_remesh.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c
index 1ff576504ce..c04c91d21b5 100644
--- a/source/blender/editors/object/object_remesh.c
+++ b/source/blender/editors/object/object_remesh.c
@@ -139,6 +139,13 @@ static int voxel_remesh_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ if (mesh->totpoly == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* Output mesh will be all smooth or all flat shading. */
+ const bool smooth_normals = mesh->mpoly[0].flag & ME_SMOOTH;
+
float isovalue = 0.0f;
if (mesh->flag & ME_REMESH_REPROJECT_VOLUME) {
isovalue = mesh->remesh_voxel_size * 0.3f;
@@ -185,7 +192,7 @@ static int voxel_remesh_exec(bContext *C, wmOperator *op)
BKE_mesh_nomain_to_mesh(new_mesh, mesh, ob, &CD_MASK_MESH, true);
- if (mesh->flag & ME_REMESH_SMOOTH_NORMALS) {
+ if (smooth_normals) {
BKE_mesh_smooth_flag_set(ob->data, true);
}