diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-19 16:11:40 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-19 17:51:20 +0300 |
commit | 0af11a1742030c1cf2e24304a94fbb96c5138571 (patch) | |
tree | a45621e6b404d4e2e221cab3a50fe33e8265d9f0 /source/blender/blenkernel/intern/mesh_remap.c | |
parent | 694806a9cfbfef8a8f4cfa0ab7d37a448d0f1bb3 (diff) |
Make use/computation of lnors consistant.
Issue was, when requesting (building) lnors for a mesh that has
autosmooth disabled, one would expect to simply get vnors as lnors.
Until now, it wasn't the case, which was bad e.g. for normal projections
of loops in recent remap code (projecting along split loop normals
when you would expect projection along vertex normals...).
Also, removed the 'angle' parameter from RNA's `mesh.calc_normals_split`.
This should *always* use mesh settings (both autosmooth and smoothresh),
otherwise once again we'd get inconsistencies in some cases.
Will update fbx and obj addons too.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_remap.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_remap.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c index 1deb7cfdd7f..3a51af7b54c 100644 --- a/source/blender/blenkernel/intern/mesh_remap.c +++ b/source/blender/blenkernel/intern/mesh_remap.c @@ -933,8 +933,9 @@ void BKE_mesh_remap_calc_loops_from_dm( const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, MVert *verts_dst, const int numverts_dst, MEdge *edges_dst, const int numedges_dst, MLoop *loops_dst, const int numloops_dst, MPoly *polys_dst, const int numpolys_dst, - CustomData *ldata_dst, CustomData *pdata_dst, const float split_angle_dst, const bool dirty_nors_dst, - DerivedMesh *dm_src, + CustomData *ldata_dst, CustomData *pdata_dst, + const bool use_split_nors_dst, const float split_angle_dst, const bool dirty_nors_dst, + DerivedMesh *dm_src, const bool use_split_nors_src, const float split_angle_src, MeshRemapIslandsCalc gen_islands_src, const float islands_precision_src, MeshPairRemap *r_map) { const float full_weight = 1.0f; @@ -1048,19 +1049,20 @@ void BKE_mesh_remap_calc_loops_from_dm( if (need_lnors_dst) { /* Cache poly nors into a temp CDLayer. */ loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL); - if (!loop_nors_dst) { - loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, numloops_dst); - CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); - } - if (dirty_nors_dst) { + if (dirty_nors_dst || !loop_nors_dst) { + if (!loop_nors_dst) { + loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, numloops_dst); + CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); + } BKE_mesh_normals_loop_split(verts_dst, numverts_dst, edges_dst, numedges_dst, loops_dst, loop_nors_dst, numloops_dst, - polys_dst, poly_nors_dst, numpolys_dst, split_angle_dst); + polys_dst, poly_nors_dst, numpolys_dst, + use_split_nors_dst, split_angle_dst); } } if (need_pnors_src || need_lnors_src) { /* Simpler for now, calcNormals never stores pnors :( */ - dm_src->calcLoopNormals(dm_src, /* TODO */ (float)M_PI); + dm_src->calcLoopNormals(dm_src, use_split_nors_src, split_angle_src); if (need_pnors_src) { poly_nors_src = dm_src->getPolyDataArray(dm_src, CD_NORMAL); |