Cleanup: Fix/improve variable names and comments
This commit is contained in:
parent
276eebb274
commit
25aa943e8c
|
@ -110,7 +110,7 @@ void CurveEval::bounds_min_max(float3 &min, float3 &max, const bool use_evaluate
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the start indices for each of the curve spline's evaluated points, as if they were part
|
||||
* Return the start indices for each of the curve spline's control points, if they were part
|
||||
* of a flattened array. This can be used to facilitate parallelism by avoiding the need to
|
||||
* accumulate an offset while doing more complex calculations.
|
||||
*
|
||||
|
|
|
@ -190,7 +190,7 @@ static void accumulate_lengths(Span<float3> positions,
|
|||
* Return non-owning access to the cache of accumulated lengths along the spline. Each item is the
|
||||
* length of the subsequent segment, i.e. the first value is the length of the first segment rather
|
||||
* than 0. This calculation is rather trivial, and only depends on the evaluated positions.
|
||||
* However, the results are used often, so it makes sense to cache it.
|
||||
* However, the results are used often, and it is necessarily single threaded, so it is cached.
|
||||
*/
|
||||
Span<float> Spline::evaluated_lengths() const
|
||||
{
|
||||
|
|
|
@ -2039,14 +2039,14 @@ typedef enum GeometryNodeCurvePrimitiveBezierSegmentMode {
|
|||
} GeometryNodeCurvePrimitiveBezierSegmentMode;
|
||||
|
||||
typedef enum GeometryNodeCurveResampleMode {
|
||||
GEO_NODE_CURVE_SAMPLE_COUNT = 0,
|
||||
GEO_NODE_CURVE_SAMPLE_LENGTH = 1,
|
||||
GEO_NODE_CURVE_SAMPLE_EVALUATED = 2,
|
||||
GEO_NODE_CURVE_RESAMPLE_COUNT = 0,
|
||||
GEO_NODE_CURVE_RESAMPLE_LENGTH = 1,
|
||||
GEO_NODE_CURVE_RESAMPLE_EVALUATED = 2,
|
||||
} GeometryNodeCurveResampleMode;
|
||||
|
||||
typedef enum GeometryNodeCurveSampleMode {
|
||||
GEO_NODE_CURVE_INTERPOLATE_FACTOR = 0,
|
||||
GEO_NODE_CURVE_INTERPOLATE_LENGTH = 1,
|
||||
GEO_NODE_CURVE_SAMPLE_FACTOR = 0,
|
||||
GEO_NODE_CURVE_RESAMPLE_LENGTH = 1,
|
||||
} GeometryNodeCurveSampleMode;
|
||||
|
||||
typedef enum GeometryNodeAttributeTransferMapMode {
|
||||
|
|
|
@ -10116,18 +10116,18 @@ static void def_geo_curve_resample(StructRNA *srna)
|
|||
PropertyRNA *prop;
|
||||
|
||||
static EnumPropertyItem mode_items[] = {
|
||||
{GEO_NODE_CURVE_SAMPLE_EVALUATED,
|
||||
{GEO_NODE_CURVE_RESAMPLE_EVALUATED,
|
||||
"EVALUATED",
|
||||
0,
|
||||
"Evaluated",
|
||||
"Output the input spline's evaluated points, based on the resolution attribute for NURBS "
|
||||
"and Bezier splines. Poly splines are unchanged"},
|
||||
{GEO_NODE_CURVE_SAMPLE_COUNT,
|
||||
{GEO_NODE_CURVE_RESAMPLE_COUNT,
|
||||
"COUNT",
|
||||
0,
|
||||
"Count",
|
||||
"Sample the specified number of points along each spline"},
|
||||
{GEO_NODE_CURVE_SAMPLE_LENGTH,
|
||||
{GEO_NODE_CURVE_RESAMPLE_LENGTH,
|
||||
"LENGTH",
|
||||
0,
|
||||
"Length",
|
||||
|
@ -10161,18 +10161,18 @@ static void def_geo_curve_to_points(StructRNA *srna)
|
|||
PropertyRNA *prop;
|
||||
|
||||
static EnumPropertyItem mode_items[] = {
|
||||
{GEO_NODE_CURVE_SAMPLE_EVALUATED,
|
||||
{GEO_NODE_CURVE_RESAMPLE_EVALUATED,
|
||||
"EVALUATED",
|
||||
0,
|
||||
"Evaluated",
|
||||
"Create points from the curve's evaluated points, based on the resolution attribute for "
|
||||
"NURBS and Bezier splines"},
|
||||
{GEO_NODE_CURVE_SAMPLE_COUNT,
|
||||
{GEO_NODE_CURVE_RESAMPLE_COUNT,
|
||||
"COUNT",
|
||||
0,
|
||||
"Count",
|
||||
"Sample each spline by evenly distributing the specified number of points"},
|
||||
{GEO_NODE_CURVE_SAMPLE_LENGTH,
|
||||
{GEO_NODE_CURVE_RESAMPLE_LENGTH,
|
||||
"LENGTH",
|
||||
0,
|
||||
"Length",
|
||||
|
@ -10193,12 +10193,12 @@ static void def_geo_curve_trim(StructRNA *srna)
|
|||
PropertyRNA *prop;
|
||||
|
||||
static EnumPropertyItem mode_items[] = {
|
||||
{GEO_NODE_CURVE_INTERPOLATE_FACTOR,
|
||||
{GEO_NODE_CURVE_SAMPLE_FACTOR,
|
||||
"FACTOR",
|
||||
0,
|
||||
"Factor",
|
||||
"Find the endpoint positions using a factor of each spline's length"},
|
||||
{GEO_NODE_CURVE_INTERPOLATE_LENGTH,
|
||||
{GEO_NODE_CURVE_RESAMPLE_LENGTH,
|
||||
"LENGTH",
|
||||
0,
|
||||
"Length",
|
||||
|
|
|
@ -66,8 +66,8 @@ static void geo_node_attribute_capture_update(bNodeTree *UNUSED(ntree), bNode *n
|
|||
node->storage;
|
||||
const CustomDataType data_type = static_cast<CustomDataType>(storage.data_type);
|
||||
|
||||
bNodeSocket *socket_value_attribute_name = (bNodeSocket *)node->inputs.first;
|
||||
bNodeSocket *socket_value_vector = socket_value_attribute_name->next;
|
||||
bNodeSocket *socket_value_geometry = (bNodeSocket *)node->inputs.first;
|
||||
bNodeSocket *socket_value_vector = socket_value_geometry->next;
|
||||
bNodeSocket *socket_value_float = socket_value_vector->next;
|
||||
bNodeSocket *socket_value_color4f = socket_value_float->next;
|
||||
bNodeSocket *socket_value_boolean = socket_value_color4f->next;
|
||||
|
@ -79,8 +79,8 @@ static void geo_node_attribute_capture_update(bNodeTree *UNUSED(ntree), bNode *n
|
|||
nodeSetSocketAvailability(socket_value_boolean, data_type == CD_PROP_BOOL);
|
||||
nodeSetSocketAvailability(socket_value_int32, data_type == CD_PROP_INT32);
|
||||
|
||||
bNodeSocket *out_socket_value_attribute_name = (bNodeSocket *)node->outputs.first;
|
||||
bNodeSocket *out_socket_value_vector = out_socket_value_attribute_name->next;
|
||||
bNodeSocket *out_socket_value_geometry = (bNodeSocket *)node->outputs.first;
|
||||
bNodeSocket *out_socket_value_vector = out_socket_value_geometry->next;
|
||||
bNodeSocket *out_socket_value_float = out_socket_value_vector->next;
|
||||
bNodeSocket *out_socket_value_color4f = out_socket_value_float->next;
|
||||
bNodeSocket *out_socket_value_boolean = out_socket_value_color4f->next;
|
||||
|
|
|
@ -50,7 +50,7 @@ static void geo_node_curve_resample_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||
NodeGeometryCurveResample *data = (NodeGeometryCurveResample *)MEM_callocN(
|
||||
sizeof(NodeGeometryCurveResample), __func__);
|
||||
|
||||
data->mode = GEO_NODE_CURVE_SAMPLE_COUNT;
|
||||
data->mode = GEO_NODE_CURVE_RESAMPLE_COUNT;
|
||||
node->storage = data;
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ static void geo_node_curve_resample_update(bNodeTree *UNUSED(ntree), bNode *node
|
|||
bNodeSocket *count_socket = ((bNodeSocket *)node->inputs.first)->next;
|
||||
bNodeSocket *length_socket = count_socket->next;
|
||||
|
||||
nodeSetSocketAvailability(count_socket, mode == GEO_NODE_CURVE_SAMPLE_COUNT);
|
||||
nodeSetSocketAvailability(length_socket, mode == GEO_NODE_CURVE_SAMPLE_LENGTH);
|
||||
nodeSetSocketAvailability(count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT);
|
||||
nodeSetSocketAvailability(length_socket, mode == GEO_NODE_CURVE_RESAMPLE_LENGTH);
|
||||
}
|
||||
|
||||
struct SampleModeParam {
|
||||
|
@ -172,7 +172,7 @@ static std::unique_ptr<CurveEval> resample_curve(const CurveEval &input_curve,
|
|||
output_curve->resize(input_splines.size());
|
||||
MutableSpan<SplinePtr> output_splines = output_curve->splines();
|
||||
|
||||
if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_COUNT) {
|
||||
if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_COUNT) {
|
||||
threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
BLI_assert(mode_param.count);
|
||||
|
@ -180,7 +180,7 @@ static std::unique_ptr<CurveEval> resample_curve(const CurveEval &input_curve,
|
|||
}
|
||||
});
|
||||
}
|
||||
else if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_LENGTH) {
|
||||
else if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_LENGTH) {
|
||||
threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float length = input_splines[i]->length();
|
||||
|
@ -189,7 +189,7 @@ static std::unique_ptr<CurveEval> resample_curve(const CurveEval &input_curve,
|
|||
}
|
||||
});
|
||||
}
|
||||
else if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_EVALUATED) {
|
||||
else if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_EVALUATED) {
|
||||
threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
output_splines[i] = resample_spline_evaluated(*input_splines[i]);
|
||||
|
@ -218,7 +218,7 @@ static void geo_node_resample_exec(GeoNodeExecParams params)
|
|||
const GeometryNodeCurveResampleMode mode = (GeometryNodeCurveResampleMode)node_storage.mode;
|
||||
SampleModeParam mode_param;
|
||||
mode_param.mode = mode;
|
||||
if (mode == GEO_NODE_CURVE_SAMPLE_COUNT) {
|
||||
if (mode == GEO_NODE_CURVE_RESAMPLE_COUNT) {
|
||||
const int count = params.extract_input<int>("Count");
|
||||
if (count < 1) {
|
||||
params.set_output("Geometry", GeometrySet());
|
||||
|
@ -226,7 +226,7 @@ static void geo_node_resample_exec(GeoNodeExecParams params)
|
|||
}
|
||||
mode_param.count.emplace(count);
|
||||
}
|
||||
else if (mode == GEO_NODE_CURVE_SAMPLE_LENGTH) {
|
||||
else if (mode == GEO_NODE_CURVE_RESAMPLE_LENGTH) {
|
||||
/* Don't allow asymptotic count increase for low resolution values. */
|
||||
const float resolution = std::max(params.extract_input<float>("Length"), 0.0001f);
|
||||
mode_param.length.emplace(resolution);
|
||||
|
|
|
@ -46,7 +46,7 @@ static void geo_node_curve_to_points_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||
NodeGeometryCurveToPoints *data = (NodeGeometryCurveToPoints *)MEM_callocN(
|
||||
sizeof(NodeGeometryCurveToPoints), __func__);
|
||||
|
||||
data->mode = GEO_NODE_CURVE_SAMPLE_COUNT;
|
||||
data->mode = GEO_NODE_CURVE_RESAMPLE_COUNT;
|
||||
node->storage = data;
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,8 @@ static void geo_node_curve_to_points_update(bNodeTree *UNUSED(ntree), bNode *nod
|
|||
bNodeSocket *count_socket = ((bNodeSocket *)node->inputs.first)->next;
|
||||
bNodeSocket *length_socket = count_socket->next;
|
||||
|
||||
nodeSetSocketAvailability(count_socket, mode == GEO_NODE_CURVE_SAMPLE_COUNT);
|
||||
nodeSetSocketAvailability(length_socket, mode == GEO_NODE_CURVE_SAMPLE_LENGTH);
|
||||
nodeSetSocketAvailability(count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT);
|
||||
nodeSetSocketAvailability(length_socket, mode == GEO_NODE_CURVE_RESAMPLE_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ static Array<int> calculate_spline_point_offsets(GeoNodeExecParams ¶ms,
|
|||
{
|
||||
const int size = curve.splines().size();
|
||||
switch (mode) {
|
||||
case GEO_NODE_CURVE_SAMPLE_COUNT: {
|
||||
case GEO_NODE_CURVE_RESAMPLE_COUNT: {
|
||||
const int count = params.extract_input<int>("Count");
|
||||
if (count < 1) {
|
||||
return {0};
|
||||
|
@ -94,7 +94,7 @@ static Array<int> calculate_spline_point_offsets(GeoNodeExecParams ¶ms,
|
|||
}
|
||||
return offsets;
|
||||
}
|
||||
case GEO_NODE_CURVE_SAMPLE_LENGTH: {
|
||||
case GEO_NODE_CURVE_RESAMPLE_LENGTH: {
|
||||
/* Don't allow asymptotic count increase for low resolution values. */
|
||||
const float resolution = std::max(params.extract_input<float>("Length"), 0.0001f);
|
||||
Array<int> offsets(size + 1);
|
||||
|
@ -106,7 +106,7 @@ static Array<int> calculate_spline_point_offsets(GeoNodeExecParams ¶ms,
|
|||
offsets.last() = offset;
|
||||
return offsets;
|
||||
}
|
||||
case GEO_NODE_CURVE_SAMPLE_EVALUATED: {
|
||||
case GEO_NODE_CURVE_RESAMPLE_EVALUATED: {
|
||||
return curve.evaluated_point_offsets();
|
||||
}
|
||||
}
|
||||
|
@ -331,11 +331,11 @@ static void geo_node_curve_to_points_exec(GeoNodeExecParams params)
|
|||
CurveToPointsResults new_attributes = curve_to_points_create_result_attributes(point_component,
|
||||
curve);
|
||||
switch (mode) {
|
||||
case GEO_NODE_CURVE_SAMPLE_COUNT:
|
||||
case GEO_NODE_CURVE_SAMPLE_LENGTH:
|
||||
case GEO_NODE_CURVE_RESAMPLE_COUNT:
|
||||
case GEO_NODE_CURVE_RESAMPLE_LENGTH:
|
||||
copy_uniform_sample_point_attributes(splines, offsets, new_attributes);
|
||||
break;
|
||||
case GEO_NODE_CURVE_SAMPLE_EVALUATED:
|
||||
case GEO_NODE_CURVE_RESAMPLE_EVALUATED:
|
||||
copy_evaluated_point_attributes(splines, offsets, new_attributes);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ static void geo_node_curve_trim_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||
NodeGeometryCurveTrim *data = (NodeGeometryCurveTrim *)MEM_callocN(sizeof(NodeGeometryCurveTrim),
|
||||
__func__);
|
||||
|
||||
data->mode = GEO_NODE_CURVE_INTERPOLATE_FACTOR;
|
||||
data->mode = GEO_NODE_CURVE_SAMPLE_FACTOR;
|
||||
node->storage = data;
|
||||
}
|
||||
|
||||
|
@ -60,10 +60,10 @@ static void geo_node_curve_trim_update(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
bNodeSocket *start_len = end_fac->next;
|
||||
bNodeSocket *end_len = start_len->next;
|
||||
|
||||
nodeSetSocketAvailability(start_fac, mode == GEO_NODE_CURVE_INTERPOLATE_FACTOR);
|
||||
nodeSetSocketAvailability(end_fac, mode == GEO_NODE_CURVE_INTERPOLATE_FACTOR);
|
||||
nodeSetSocketAvailability(start_len, mode == GEO_NODE_CURVE_INTERPOLATE_LENGTH);
|
||||
nodeSetSocketAvailability(end_len, mode == GEO_NODE_CURVE_INTERPOLATE_LENGTH);
|
||||
nodeSetSocketAvailability(start_fac, mode == GEO_NODE_CURVE_SAMPLE_FACTOR);
|
||||
nodeSetSocketAvailability(end_fac, mode == GEO_NODE_CURVE_SAMPLE_FACTOR);
|
||||
nodeSetSocketAvailability(start_len, mode == GEO_NODE_CURVE_RESAMPLE_LENGTH);
|
||||
nodeSetSocketAvailability(end_len, mode == GEO_NODE_CURVE_RESAMPLE_LENGTH);
|
||||
}
|
||||
|
||||
struct TrimLocation {
|
||||
|
@ -336,12 +336,11 @@ static void geo_node_curve_trim_exec(GeoNodeExecParams params)
|
|||
CurveEval &curve = *curve_component.get_for_write();
|
||||
MutableSpan<SplinePtr> splines = curve.splines();
|
||||
|
||||
const float start = mode == GEO_NODE_CURVE_INTERPOLATE_FACTOR ?
|
||||
const float start = mode == GEO_NODE_CURVE_SAMPLE_FACTOR ?
|
||||
params.extract_input<float>("Start") :
|
||||
params.extract_input<float>("Start_001");
|
||||
const float end = mode == GEO_NODE_CURVE_INTERPOLATE_FACTOR ?
|
||||
params.extract_input<float>("End") :
|
||||
params.extract_input<float>("End_001");
|
||||
const float end = mode == GEO_NODE_CURVE_SAMPLE_FACTOR ? params.extract_input<float>("End") :
|
||||
params.extract_input<float>("End_001");
|
||||
|
||||
threading::parallel_for(splines.index_range(), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
|
@ -360,11 +359,11 @@ static void geo_node_curve_trim_exec(GeoNodeExecParams params)
|
|||
}
|
||||
|
||||
const Spline::LookupResult start_lookup =
|
||||
(mode == GEO_NODE_CURVE_INTERPOLATE_LENGTH) ?
|
||||
(mode == GEO_NODE_CURVE_RESAMPLE_LENGTH) ?
|
||||
spline.lookup_evaluated_length(std::clamp(start, 0.0f, spline.length())) :
|
||||
spline.lookup_evaluated_factor(std::clamp(start, 0.0f, 1.0f));
|
||||
const Spline::LookupResult end_lookup =
|
||||
(mode == GEO_NODE_CURVE_INTERPOLATE_LENGTH) ?
|
||||
(mode == GEO_NODE_CURVE_RESAMPLE_LENGTH) ?
|
||||
spline.lookup_evaluated_length(std::clamp(end, 0.0f, spline.length())) :
|
||||
spline.lookup_evaluated_factor(std::clamp(end, 0.0f, 1.0f));
|
||||
|
||||
|
|
Loading…
Reference in New Issue