Merge branch 'blender-v3.4-release'

This commit is contained in:
Hans Goudey 2022-11-08 13:39:45 -06:00
commit 96d8e5e66b
14 changed files with 108 additions and 12 deletions

View File

@ -306,6 +306,7 @@ class CurveLengthFieldInput final : public CurvesFieldInput {
IndexMask mask) const final;
uint64_t hash() const override;
bool is_equal_to(const fn::FieldNode &other) const override;
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry &curves) const final;
};
bool try_capture_field_on_geometry(GeometryComponent &component,

View File

@ -282,6 +282,12 @@ bool CurveLengthFieldInput::is_equal_to(const fn::FieldNode &other) const
return dynamic_cast<const CurveLengthFieldInput *>(&other) != nullptr;
}
std::optional<eAttrDomain> CurveLengthFieldInput::preferred_domain(
const bke::CurvesGeometry & /*curves*/) const
{
return ATTR_DOMAIN_CURVE;
}
/** \} */
} // namespace blender::bke

View File

@ -528,29 +528,33 @@ static void node_geo_exec(GeoNodeExecParams params)
mode == GEO_NODE_CURVE_SAMPLE_FACTOR ? "Factor" : "Length");
GField src_values_field = get_input_attribute_field(params, data_type);
auto sample_fn = std::make_unique<SampleCurveFunction>(
std::move(geometry_set), mode, std::move(src_values_field));
std::shared_ptr<FieldOperation> sample_op;
if (curves.curves_num() == 1) {
sample_op = FieldOperation::Create(std::move(sample_fn),
{fn::make_constant_field<int>(0), std::move(length_field)});
sample_op = FieldOperation::Create(
std::make_unique<SampleCurveFunction>(
std::move(geometry_set), mode, std::move(src_values_field)),
{fn::make_constant_field<int>(0), std::move(length_field)});
}
else {
Field<int> curve_index;
Field<float> length_in_curve;
if (storage.use_all_curves) {
auto index_fn = std::make_unique<SampleFloatSegmentsFunction>(
curve_accumulated_lengths(curves), mode);
auto index_op = FieldOperation::Create(std::move(index_fn), {std::move(length_field)});
curve_index = Field<int>(index_op, 0);
length_in_curve = Field<float>(index_op, 1);
Field<int> curve_index = Field<int>(index_op, 0);
Field<float> length_in_curve = Field<float>(index_op, 1);
sample_op = FieldOperation::Create(
std::make_unique<SampleCurveFunction>(
std::move(geometry_set), GEO_NODE_CURVE_SAMPLE_LENGTH, std::move(src_values_field)),
{std::move(curve_index), std::move(length_in_curve)});
}
else {
curve_index = params.extract_input<Field<int>>("Curve Index");
length_in_curve = std::move(length_field);
Field<int> curve_index = params.extract_input<Field<int>>("Curve Index");
Field<float> length_in_curve = std::move(length_field);
sample_op = FieldOperation::Create(
std::make_unique<SampleCurveFunction>(
std::move(geometry_set), mode, std::move(src_values_field)),
{std::move(curve_index), std::move(length_in_curve)});
}
sample_op = FieldOperation::Create(std::move(sample_fn), {curve_index, length_in_curve});
}
params.set_output("Position", Field<float3>(sample_op, 0));

View File

@ -48,6 +48,11 @@ class CurveOfPointInput final : public bke::CurvesFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/)const final
{
return ATTR_DOMAIN_POINT;
}
};
class PointIndexInCurveInput final : public bke::CurvesFieldInput {
@ -86,6 +91,11 @@ class PointIndexInCurveInput final : public bke::CurvesFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/)
{
return ATTR_DOMAIN_POINT;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -113,6 +113,11 @@ class PointsOfCurveInput final : public bke::CurvesFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/)const final
{
return ATTR_DOMAIN_CURVE;
}
};
class CurvePointCountInput final : public bke::CurvesFieldInput {
@ -146,6 +151,11 @@ class CurvePointCountInput final : public bke::CurvesFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/)const final
{
return ATTR_DOMAIN_CURVE;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -56,6 +56,11 @@ class SplineCountFieldInput final : public bke::CurvesFieldInput {
{
return dynamic_cast<const SplineCountFieldInput *>(&other) != nullptr;
}
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/) const final
{
return ATTR_DOMAIN_CURVE;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -110,6 +110,11 @@ class TangentFieldInput final : public bke::CurvesFieldInput {
{
return dynamic_cast<const TangentFieldInput *>(&other) != nullptr;
}
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/) const final
{
return ATTR_DOMAIN_POINT;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -117,6 +117,11 @@ class CornersOfFaceInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_FACE;
}
};
static int get_poly_totloop(const MPoly &poly)
@ -153,6 +158,11 @@ class CornersOfFaceCountInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_FACE;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -138,6 +138,11 @@ class CornersOfVertInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_POINT;
}
};
class CornersOfVertCountInput final : public bke::MeshFieldInput {
@ -174,6 +179,11 @@ class CornersOfVertCountInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_POINT;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -59,6 +59,11 @@ class CornerNextEdgeFieldInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_CORNER;
}
};
class CornerPreviousEdgeFieldInput final : public bke::MeshFieldInput {
@ -100,6 +105,11 @@ class CornerPreviousEdgeFieldInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_CORNER;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -138,6 +138,11 @@ class EdgesOfVertInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_POINT;
}
};
class EdgesOfVertCountInput final : public bke::MeshFieldInput {
@ -175,6 +180,11 @@ class EdgesOfVertCountInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_POINT;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -85,6 +85,11 @@ class CornerIndexInFaceInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const final
{
return ATTR_DOMAIN_CORNER;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -86,6 +86,11 @@ class OffsetCornerInFaceFieldInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/)const final
{
return ATTR_DOMAIN_CORNER;
}
};
static void node_geo_exec(GeoNodeExecParams params)

View File

@ -53,6 +53,11 @@ class CornerVertFieldInput final : public bke::MeshFieldInput {
}
return false;
}
std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const final
{
return ATTR_DOMAIN_CORNER;
}
};
static void node_geo_exec(GeoNodeExecParams params)