mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Shrinkwrap: use polygon normals for flat faces in Align To Normal.
Hit normal originates from tesselated triangles and isn't the actual normal used for shading of flat faces. Thus, it is better to use the actual polygon normals when available.
This commit is contained in:
parent
1ddfd8c9ec
commit
b4b224dc08
2 changed files with 7 additions and 1 deletions
|
|
@ -90,6 +90,7 @@ typedef struct ShrinkwrapTreeData {
|
|||
BVHTree *bvh;
|
||||
BVHTreeFromMesh treeData;
|
||||
|
||||
float (*pnors)[3];
|
||||
float (*clnors)[3];
|
||||
ShrinkwrapBoundaryData *boundary;
|
||||
} ShrinkwrapTreeData;
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ bool BKE_shrinkwrap_init_tree(ShrinkwrapTreeData *data, Mesh *mesh, int shrinkTy
|
|||
}
|
||||
|
||||
if (force_normals || BKE_shrinkwrap_needs_normals(shrinkType, shrinkMode)) {
|
||||
data->pnors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
|
||||
if ((mesh->flag & ME_AUTOSMOOTH) != 0) {
|
||||
data->clnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
|
||||
}
|
||||
|
|
@ -1164,7 +1165,11 @@ void BKE_shrinkwrap_compute_smooth_normal(
|
|||
normalize_v3(r_no);
|
||||
}
|
||||
}
|
||||
/* Use the looptri normal if flat. */
|
||||
/* Use the polygon normal if flat. */
|
||||
else if (tree->pnors != NULL) {
|
||||
copy_v3_v3(r_no, tree->pnors[tri->poly]);
|
||||
}
|
||||
/* Finally fallback to the looptri normal. */
|
||||
else {
|
||||
copy_v3_v3(r_no, hit_no);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue