Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc
| Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | static VArray<float3> construct_uv_gvarray(const Mesh &mesh, | ||||
| const bool fill_holes, | const bool fill_holes, | ||||
| const float margin, | const float margin, | ||||
| const GeometryNodeUVUnwrapMethod method, | const GeometryNodeUVUnwrapMethod method, | ||||
| const eAttrDomain domain) | const eAttrDomain domain) | ||||
| { | { | ||||
| const Span<float3> positions = mesh.vert_positions(); | const Span<float3> positions = mesh.vert_positions(); | ||||
| const Span<MEdge> edges = mesh.edges(); | const Span<MEdge> edges = mesh.edges(); | ||||
| const Span<MPoly> polys = mesh.polys(); | const Span<MPoly> polys = mesh.polys(); | ||||
| const Span<MLoop> loops = mesh.loops(); | const Span<int> corner_verts = mesh.corner_verts(); | ||||
| bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; | bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; | ||||
| FieldEvaluator face_evaluator{face_context, polys.size()}; | FieldEvaluator face_evaluator{face_context, polys.size()}; | ||||
| face_evaluator.add(selection_field); | face_evaluator.add(selection_field); | ||||
| face_evaluator.evaluate(); | face_evaluator.evaluate(); | ||||
| const IndexMask selection = face_evaluator.get_evaluated_as_mask(0); | const IndexMask selection = face_evaluator.get_evaluated_as_mask(0); | ||||
| if (selection.is_empty()) { | if (selection.is_empty()) { | ||||
| return {}; | return {}; | ||||
| } | } | ||||
| bke::MeshFieldContext edge_context{mesh, ATTR_DOMAIN_EDGE}; | bke::MeshFieldContext edge_context{mesh, ATTR_DOMAIN_EDGE}; | ||||
| FieldEvaluator edge_evaluator{edge_context, edges.size()}; | FieldEvaluator edge_evaluator{edge_context, edges.size()}; | ||||
| edge_evaluator.add(seam_field); | edge_evaluator.add(seam_field); | ||||
| edge_evaluator.evaluate(); | edge_evaluator.evaluate(); | ||||
| const IndexMask seam = edge_evaluator.get_evaluated_as_mask(0); | const IndexMask seam = edge_evaluator.get_evaluated_as_mask(0); | ||||
| Array<float3> uv(loops.size(), float3(0)); | Array<float3> uv(corner_verts.size(), float3(0)); | ||||
| ParamHandle *handle = GEO_uv_parametrizer_construct_begin(); | ParamHandle *handle = GEO_uv_parametrizer_construct_begin(); | ||||
| for (const int mp_index : selection) { | for (const int mp_index : selection) { | ||||
| const MPoly &mp = polys[mp_index]; | const MPoly &mp = polys[mp_index]; | ||||
| Array<ParamKey, 16> mp_vkeys(mp.totloop); | Array<ParamKey, 16> mp_vkeys(mp.totloop); | ||||
| Array<bool, 16> mp_pin(mp.totloop); | Array<bool, 16> mp_pin(mp.totloop); | ||||
| Array<bool, 16> mp_select(mp.totloop); | Array<bool, 16> mp_select(mp.totloop); | ||||
| Array<const float *, 16> mp_co(mp.totloop); | Array<const float *, 16> mp_co(mp.totloop); | ||||
| Array<float *, 16> mp_uv(mp.totloop); | Array<float *, 16> mp_uv(mp.totloop); | ||||
| for (const int i : IndexRange(mp.totloop)) { | for (const int i : IndexRange(mp.totloop)) { | ||||
| const MLoop &ml = loops[mp.loopstart + i]; | const int corner_i = corner_i; | ||||
| mp_vkeys[i] = ml.v; | const int vert_i = corner_verts[corner_i]; | ||||
| mp_co[i] = positions[ml.v]; | mp_vkeys[i] = vert_i; | ||||
| mp_uv[i] = uv[mp.loopstart + i]; | mp_co[i] = positions[vert_i]; | ||||
| mp_uv[i] = uv[corner_i]; | |||||
| mp_pin[i] = false; | mp_pin[i] = false; | ||||
| mp_select[i] = false; | mp_select[i] = false; | ||||
| } | } | ||||
| GEO_uv_parametrizer_face_add(handle, | GEO_uv_parametrizer_face_add(handle, | ||||
| mp_index, | mp_index, | ||||
| mp.totloop, | mp.totloop, | ||||
| mp_vkeys.data(), | mp_vkeys.data(), | ||||
| mp_co.data(), | mp_co.data(), | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||