Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
| Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | static void geo_node_curve_to_points_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| data->mode = GEO_NODE_CURVE_SAMPLE_COUNT; | data->mode = GEO_NODE_CURVE_SAMPLE_COUNT; | ||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| static void geo_node_curve_to_points_update(bNodeTree *UNUSED(ntree), bNode *node) | static void geo_node_curve_to_points_update(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeGeometryCurveToPoints &node_storage = *(NodeGeometryCurveToPoints *)node->storage; | NodeGeometryCurveToPoints &node_storage = *(NodeGeometryCurveToPoints *)node->storage; | ||||
| const GeometryNodeCurveResampleMode mode = (GeometryNodeCurveResampleMode)node_storage.mode; | const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)node_storage.mode; | ||||
| bNodeSocket *count_socket = ((bNodeSocket *)node->inputs.first)->next; | bNodeSocket *count_socket = ((bNodeSocket *)node->inputs.first)->next; | ||||
| bNodeSocket *length_socket = count_socket->next; | bNodeSocket *length_socket = count_socket->next; | ||||
| nodeSetSocketAvailability(count_socket, mode == GEO_NODE_CURVE_SAMPLE_COUNT); | nodeSetSocketAvailability(count_socket, mode == GEO_NODE_CURVE_SAMPLE_COUNT); | ||||
| nodeSetSocketAvailability(length_socket, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); | nodeSetSocketAvailability(length_socket, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); | ||||
| } | } | ||||
| /** | /** | ||||
| * Evaluate splines in parallel to speed up the rest of the node's execution. | * Evaluate splines in parallel to speed up the rest of the node's execution. | ||||
| */ | */ | ||||
| static void evaluate_splines(Span<SplinePtr> splines) | static void evaluate_splines(Span<SplinePtr> splines) | ||||
| { | { | ||||
| threading::parallel_for_each(splines, [](const SplinePtr &spline) { | threading::parallel_for_each(splines, [](const SplinePtr &spline) { | ||||
| /* These functions fill the corresponding caches on each spline. */ | /* These functions fill the corresponding caches on each spline. */ | ||||
| spline->evaluated_positions(); | spline->evaluated_positions(); | ||||
| spline->evaluated_tangents(); | spline->evaluated_tangents(); | ||||
| spline->evaluated_normals(); | spline->evaluated_normals(); | ||||
| spline->evaluated_lengths(); | spline->evaluated_lengths(); | ||||
| }); | }); | ||||
| } | } | ||||
| static Array<int> calculate_spline_point_offsets(GeoNodeExecParams ¶ms, | static Array<int> calculate_spline_point_offsets(GeoNodeExecParams ¶ms, | ||||
| const GeometryNodeCurveResampleMode mode, | const GeometryNodeCurveSampleMode mode, | ||||
| const CurveEval &curve, | const CurveEval &curve, | ||||
| const Span<SplinePtr> splines) | const Span<SplinePtr> splines) | ||||
| { | { | ||||
| const int size = curve.splines().size(); | const int size = curve.splines().size(); | ||||
| switch (mode) { | switch (mode) { | ||||
| case GEO_NODE_CURVE_SAMPLE_COUNT: { | case GEO_NODE_CURVE_SAMPLE_COUNT: { | ||||
| const int count = params.extract_input<int>("Count"); | const int count = params.extract_input<int>("Count"); | ||||
| if (count < 1) { | if (count < 1) { | ||||
| ▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | for (const int i : range) { | ||||
| float4x4::from_normalized_axis_data({0, 0, 0}, normals[i], tangents[i]).to_euler(); | float4x4::from_normalized_axis_data({0, 0, 0}, normals[i], tangents[i]).to_euler(); | ||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| static void geo_node_curve_to_points_exec(GeoNodeExecParams params) | static void geo_node_curve_to_points_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| NodeGeometryCurveToPoints &node_storage = *(NodeGeometryCurveToPoints *)params.node().storage; | NodeGeometryCurveToPoints &node_storage = *(NodeGeometryCurveToPoints *)params.node().storage; | ||||
| const GeometryNodeCurveResampleMode mode = (GeometryNodeCurveResampleMode)node_storage.mode; | const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)node_storage.mode; | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| geometry_set = bke::geometry_set_realize_instances(geometry_set); | geometry_set = bke::geometry_set_realize_instances(geometry_set); | ||||
| if (!geometry_set.has_curve()) { | if (!geometry_set.has_curve()) { | ||||
| params.set_output("Geometry", GeometrySet()); | params.set_output("Geometry", GeometrySet()); | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||