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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-01-19 16:11:40 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-01-19 17:51:20 +0300
commit0af11a1742030c1cf2e24304a94fbb96c5138571 (patch)
treea45621e6b404d4e2e221cab3a50fe33e8265d9f0 /source/blender/blenkernel/intern/mesh_evaluate.c
parent694806a9cfbfef8a8f4cfa0ab7d37a448d0f1bb3 (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_evaluate.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 915abdb6766..bdc8cd269b0 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -320,10 +320,28 @@ void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces,
* Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals').
* Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).
*/
-void BKE_mesh_normals_loop_split(MVert *mverts, const int UNUSED(numVerts), MEdge *medges, const int numEdges,
- MLoop *mloops, float (*r_loopnors)[3], const int numLoops,
- MPoly *mpolys, float (*polynors)[3], const int numPolys, float split_angle)
+void BKE_mesh_normals_loop_split(
+ MVert *mverts, const int UNUSED(numVerts), MEdge *medges, const int numEdges,
+ MLoop *mloops, float (*r_loopnors)[3], const int numLoops,
+ MPoly *mpolys, float (*polynors)[3], const int numPolys,
+ const bool use_split_normals, float split_angle)
{
+ if (!use_split_normals) {
+ /* In this case, we simply fill lnors with vnors, quite simple!
+ * Note this is done here to keep some logic and consistancy in this quite complex code,
+ * since we may want to use lnors even when mesh's 'autosmooth' is disabled (see e.g. mesh mapping code).
+ * As usual, we could handle that on case-by-case basis, but simpler to keep it well confined here.
+ */
+ int i;
+
+ for (i = 0; i < numLoops; i++) {
+ normal_short_to_float_v3(r_loopnors[i], mverts[mloops[i].v].no);
+ }
+ return;
+ }
+
+ {
+
#define INDEX_UNSET INT_MIN
#define INDEX_INVALID -1
/* See comment about edge_to_loops below. */
@@ -588,6 +606,8 @@ void BKE_mesh_normals_loop_split(MVert *mverts, const int UNUSED(numVerts), MEdg
#undef INDEX_UNSET
#undef INDEX_INVALID
#undef IS_EDGE_SHARP
+
+ }
}