[Bf-blender-cvs] [e74cdb94c11] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic
Hans Goudey
noreply at git.blender.org
Mon Dec 12 06:51:02 CET 2022
Commit: e74cdb94c11703bfbf6d219ae9935a811268d878
Author: Hans Goudey
Date: Sun Dec 11 23:51:01 2022 -0600
Branches: refactor-mesh-position-generic
https://developer.blender.org/rBe74cdb94c11703bfbf6d219ae9935a811268d878
Merge branch 'master' into refactor-mesh-position-generic
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/mesh_normals.cc
index 1cc298039bf,5a15c54df9e..9bfe1f8d8c1
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@@ -948,19 -993,15 +945,15 @@@ static void split_loop_nor_single_do(Lo
MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
const Span<short2> clnors_data = common_data->clnors_data;
- const Span<MVert> verts = common_data->verts;
+ const Span<float3> positions = common_data->positions;
const Span<MEdge> edges = common_data->edges;
+ const Span<MLoop> loops = common_data->loops;
const Span<float3> polynors = common_data->polynors;
+ MutableSpan<float3> loop_normals = common_data->loopnors;
MLoopNorSpace *lnor_space = data->lnor_space;
- float3 *lnor = data->lnor;
- const MLoop *ml_curr = data->ml_curr;
- const MLoop *ml_prev = data->ml_prev;
const int ml_curr_index = data->ml_curr_index;
- #if 0 /* Not needed for 'single' loop. */
const int ml_prev_index = data->ml_prev_index;
- const int *e2l_prev = data->e2l_prev;
- #endif
const int mp_index = data->mp_index;
/* Simple case (both edges around that vertex are sharp in current polygon),
@@@ -980,21 -1021,21 +973,18 @@@
if (lnors_spacearr) {
float vec_curr[3], vec_prev[3];
- const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
- const float3 &mv_pivot = positions[mv_pivot_index];
- const MEdge *me_curr = &edges[ml_curr->e];
- const float3 &mv_2 = (me_curr->v1 == mv_pivot_index) ? positions[me_curr->v2] :
- positions[me_curr->v1];
- const MEdge *me_prev = &edges[ml_prev->e];
- const float3 &mv_3 = (me_prev->v1 == mv_pivot_index) ? positions[me_prev->v2] :
- positions[me_prev->v1];
+ const uint mv_pivot_index = loops[ml_curr_index].v; /* The vertex we are "fanning" around! */
- const MVert *mv_pivot = &verts[mv_pivot_index];
+ const MEdge *me_curr = &edges[loops[ml_curr_index].e];
- const MVert *mv_2 = (me_curr->v1 == mv_pivot_index) ? &verts[me_curr->v2] :
- &verts[me_curr->v1];
++ const int vert_2 = me_curr->v1 == mv_pivot_index ? me_curr->v2 : me_curr->v1;
+ const MEdge *me_prev = &edges[loops[ml_prev_index].e];
- const MVert *mv_3 = (me_prev->v1 == mv_pivot_index) ? &verts[me_prev->v2] :
- &verts[me_prev->v1];
++ const int vert_3 = me_prev->v1 == mv_pivot_index ? me_prev->v2 : me_prev->v1;
- sub_v3_v3v3(vec_curr, mv_2, mv_pivot);
- sub_v3_v3v3(vec_curr, mv_2->co, mv_pivot->co);
++ sub_v3_v3v3(vec_curr, positions[vert_2], positions[mv_pivot_index]);
normalize_v3(vec_curr);
- sub_v3_v3v3(vec_prev, mv_3, mv_pivot);
- sub_v3_v3v3(vec_prev, mv_3->co, mv_pivot->co);
++ sub_v3_v3v3(vec_prev, positions[vert_3], positions[mv_pivot_index]);
normalize_v3(vec_prev);
- BKE_lnor_space_define(lnor_space, *lnor, vec_curr, vec_prev, nullptr);
+ BKE_lnor_space_define(lnor_space, loop_normals[ml_curr_index], vec_curr, vec_prev, nullptr);
/* We know there is only one loop in this space, no need to create a link-list in this case. */
BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, ml_curr_index, nullptr, true);
@@@ -1037,11 -1076,11 +1025,10 @@@ static void split_loop_nor_fan_do(LoopS
* same as the vertex normal, but I do not see any easy way to detect that (would need to count
* number of sharp edges per vertex, I doubt the additional memory usage would be worth it,
* especially as it should not be a common case in real-life meshes anyway). */
- const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
- const float3 &mv_pivot = positions[mv_pivot_index];
+ const uint mv_pivot_index = loops[ml_curr_index].v; /* The vertex we are "fanning" around! */
- const MVert *mv_pivot = &verts[mv_pivot_index];
- /* `ml_curr` would be mlfan_prev if we needed that one. */
- const MEdge *me_org = &edges[ml_curr->e];
+ /* `ml_curr_index` would be mlfan_prev if we needed that one. */
+ const MEdge *me_org = &edges[loops[ml_curr_index].e];
float vec_curr[3], vec_prev[3], vec_org[3];
float lnor[3] = {0.0f, 0.0f, 0.0f};
@@@ -1071,10 -1108,9 +1056,10 @@@
/* Only need to compute previous edge's vector once, then we can just reuse old current one! */
{
- const MVert *mv_2 = (me_org->v1 == mv_pivot_index) ? &verts[me_org->v2] : &verts[me_org->v1];
+ const float3 &mv_2 = (me_org->v1 == mv_pivot_index) ? positions[me_org->v2] :
+ positions[me_org->v1];
- sub_v3_v3v3(vec_org, mv_2, mv_pivot);
- sub_v3_v3v3(vec_org, mv_2->co, mv_pivot->co);
++ sub_v3_v3v3(vec_org, mv_2, positions[mv_pivot_index]);
normalize_v3(vec_org);
copy_v3_v3(vec_prev, vec_org);
@@@ -1093,10 -1129,10 +1078,10 @@@
* given the fact that this code should not be called that much in real-life meshes.
*/
{
- const MVert *mv_2 = (me_curr->v1 == mv_pivot_index) ? &verts[me_curr->v2] :
- &verts[me_curr->v1];
+ const float3 &mv_2 = (me_curr->v1 == mv_pivot_index) ? positions[me_curr->v2] :
+ positions[me_curr->v1];
- sub_v3_v3v3(vec_curr, mv_2, mv_pivot);
- sub_v3_v3v3(vec_curr, mv_2->co, mv_pivot->co);
++ sub_v3_v3v3(vec_curr, mv_2, positions[mv_pivot_index]);
normalize_v3(vec_curr);
}
More information about the Bf-blender-cvs
mailing list