Differential D15982 Diff 59259 source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static void deform_curves(const CurvesGeometry &curves, | ||||
| Array<ReverseUVSampler::Result> surface_samples_new(curves_num); | Array<ReverseUVSampler::Result> surface_samples_new(curves_num); | ||||
| threading::parallel_invoke( | threading::parallel_invoke( | ||||
| 1024 < curves_num, | 1024 < curves_num, | ||||
| [&]() { reverse_uv_sampler_old.sample_many(curve_attachment_uvs, surface_samples_old); }, | [&]() { reverse_uv_sampler_old.sample_many(curve_attachment_uvs, surface_samples_old); }, | ||||
| [&]() { reverse_uv_sampler_new.sample_many(curve_attachment_uvs, surface_samples_new); }); | [&]() { reverse_uv_sampler_new.sample_many(curve_attachment_uvs, surface_samples_new); }); | ||||
| const float4x4 curves_to_surface = surface_to_curves.inverted(); | const float4x4 curves_to_surface = surface_to_curves.inverted(); | ||||
| const Span<MVert> surface_verts_old = surface_mesh_old.verts(); | const Span<float3> surface_positions_old = surface_mesh_old.vert_positions(); | ||||
| const Span<MLoop> surface_loops_old = surface_mesh_old.loops(); | const Span<MLoop> surface_loops_old = surface_mesh_old.loops(); | ||||
| const Span<MLoopTri> surface_looptris_old = surface_mesh_old.looptris(); | const Span<MLoopTri> surface_looptris_old = surface_mesh_old.looptris(); | ||||
| const Span<MVert> surface_verts_new = surface_mesh_new.verts(); | const Span<float3> surface_positions_new = surface_mesh_new.vert_positions(); | ||||
| const Span<MLoop> surface_loops_new = surface_mesh_new.loops(); | const Span<MLoop> surface_loops_new = surface_mesh_new.loops(); | ||||
| const Span<MLoopTri> surface_looptris_new = surface_mesh_new.looptris(); | const Span<MLoopTri> surface_looptris_new = surface_mesh_new.looptris(); | ||||
| threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange range) { | threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange range) { | ||||
| for (const int curve_i : range) { | for (const int curve_i : range) { | ||||
| const ReverseUVSampler::Result &surface_sample_old = surface_samples_old[curve_i]; | const ReverseUVSampler::Result &surface_sample_old = surface_samples_old[curve_i]; | ||||
| if (surface_sample_old.type != ReverseUVSampler::ResultType::Ok) { | if (surface_sample_old.type != ReverseUVSampler::ResultType::Ok) { | ||||
| r_invalid_uv_count++; | r_invalid_uv_count++; | ||||
| Show All 33 Lines | for (const int curve_i : range) { | ||||
| mix3(bary_weights_old, normal_0_old, normal_1_old, normal_2_old)); | mix3(bary_weights_old, normal_0_old, normal_1_old, normal_2_old)); | ||||
| const float3 &normal_0_new = corner_normals_new[corner_0_new]; | const float3 &normal_0_new = corner_normals_new[corner_0_new]; | ||||
| const float3 &normal_1_new = corner_normals_new[corner_1_new]; | const float3 &normal_1_new = corner_normals_new[corner_1_new]; | ||||
| const float3 &normal_2_new = corner_normals_new[corner_2_new]; | const float3 &normal_2_new = corner_normals_new[corner_2_new]; | ||||
| const float3 normal_new = math::normalize( | const float3 normal_new = math::normalize( | ||||
| mix3(bary_weights_new, normal_0_new, normal_1_new, normal_2_new)); | mix3(bary_weights_new, normal_0_new, normal_1_new, normal_2_new)); | ||||
| const float3 &pos_0_old = surface_verts_old[vert_0_old].co; | const float3 &pos_0_old = surface_positions_old[vert_0_old]; | ||||
| const float3 &pos_1_old = surface_verts_old[vert_1_old].co; | const float3 &pos_1_old = surface_positions_old[vert_1_old]; | ||||
| const float3 &pos_2_old = surface_verts_old[vert_2_old].co; | const float3 &pos_2_old = surface_positions_old[vert_2_old]; | ||||
| const float3 pos_old = mix3(bary_weights_old, pos_0_old, pos_1_old, pos_2_old); | const float3 pos_old = mix3(bary_weights_old, pos_0_old, pos_1_old, pos_2_old); | ||||
| const float3 &pos_0_new = surface_verts_new[vert_0_new].co; | const float3 &pos_0_new = surface_positions_new[vert_0_new]; | ||||
| const float3 &pos_1_new = surface_verts_new[vert_1_new].co; | const float3 &pos_1_new = surface_positions_new[vert_1_new]; | ||||
| const float3 &pos_2_new = surface_verts_new[vert_2_new].co; | const float3 &pos_2_new = surface_positions_new[vert_2_new]; | ||||
| const float3 pos_new = mix3(bary_weights_new, pos_0_new, pos_1_new, pos_2_new); | const float3 pos_new = mix3(bary_weights_new, pos_0_new, pos_1_new, pos_2_new); | ||||
| /* The translation is just the difference between the old and new position on the surface. */ | /* The translation is just the difference between the old and new position on the surface. */ | ||||
| const float3 translation = pos_new - pos_old; | const float3 translation = pos_new - pos_old; | ||||
| const float3 &rest_pos_0 = rest_positions[vert_0_new]; | const float3 &rest_pos_0 = rest_positions[vert_0_new]; | ||||
| const float3 &rest_pos_1 = rest_positions[vert_1_new]; | const float3 &rest_pos_1 = rest_positions[vert_1_new]; | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||