Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-02-28 18:46:34 +0300
committerHans Goudey <h.goudey@me.com>2022-02-28 18:46:34 +0300
commit9ec12c26f16ea3da1e6de95d5d5daf1057464830 (patch)
tree708e542d5d4de0efdda7b9a54def6b25b6b64039 /source/blender/blenkernel/BKE_geometry_set.hh
parent81bb86c7506c0ae5f07780a63f954a8416a0d4e6 (diff)
Geometry Nodes: Begin conversion to new curves
This commit changes `CurveComponent` to store the new curve type by adding conversions to and from `CurveEval` in most nodes. This will temporarily make performance of curves in geometry nodes much worse, but as functionality is implemented for the new type and it is used in more places, performance will become better than before. We still use `CurveEval` for drawing curves, because the new `Curves` data-block has no evaluated points yet. So the `Curve` ID is still generated for rendering in the same way as before. It's also still needed for drawing curve object edit mode overlays. The old curve component isn't removed yet, because it is still used to implement the conversions to and from `CurveEval`. A few more attributes are added to make this possible: - `nurbs_weight`: The weight for each control point on NURBS curves. - `nurbs_order`: The order of the NURBS curve - `knots_mode`: Necessary for conversion, not defined yet. - `handle_type_{left/right}`: An 8 bit integer attribute. Differential Revision: https://developer.blender.org/D14145
Diffstat (limited to 'source/blender/blenkernel/BKE_geometry_set.hh')
-rw-r--r--source/blender/blenkernel/BKE_geometry_set.hh73
1 files changed, 58 insertions, 15 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index d93b3ca95e7..f11bfb7692a 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -24,6 +24,7 @@
#include "FN_field.hh"
+struct Curves;
struct Collection;
struct Curve;
struct CurveEval;
@@ -415,7 +416,7 @@ struct GeometrySet {
* Create a new geometry set that only contains the given curve.
*/
static GeometrySet create_with_curve(
- CurveEval *curve, GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
+ Curves *curves, GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
/* Utility methods for access. */
/**
@@ -462,7 +463,7 @@ struct GeometrySet {
/**
* Returns a read-only curve or null.
*/
- const CurveEval *get_curve_for_read() const;
+ const Curves *get_curve_for_read() const;
/**
* Returns a mutable mesh or null. No ownership is transferred.
@@ -479,7 +480,7 @@ struct GeometrySet {
/**
* Returns a mutable curve or null. No ownership is transferred.
*/
- CurveEval *get_curve_for_write();
+ Curves *get_curve_for_write();
/* Utility methods for replacement. */
/**
@@ -499,7 +500,7 @@ struct GeometrySet {
/**
* Clear the existing curve and replace it with the given one.
*/
- void replace_curve(CurveEval *curve,
+ void replace_curve(Curves *curves,
GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
private:
@@ -632,17 +633,59 @@ class PointCloudComponent : public GeometryComponent {
};
/**
- * A geometry component that stores curve data, in other words, a group of splines.
- * Curves are stored differently than other geometry components, because the data structure used
- * here does not correspond exactly to the #Curve DNA data structure. A #CurveEval is stored here
- * instead, though the component does give access to a #Curve for interfacing with render engines
- * and other areas of Blender that expect to use a data-block with an #ID.
+ * Legacy runtime-only curves type.
+ * These curves are stored differently than other geometry components, because the data structure
+ * used here does not correspond exactly to the #Curve DNA data structure. A #CurveEval is stored
+ * here instead, though the component does give access to a #Curve for interfacing with render
+ * engines and other areas of Blender that expect to use a data-block with an #ID.
*/
-class CurveComponent : public GeometryComponent {
+class CurveComponentLegacy : public GeometryComponent {
private:
CurveEval *curve_ = nullptr;
GeometryOwnershipType ownership_ = GeometryOwnershipType::Owned;
+ public:
+ CurveComponentLegacy();
+ ~CurveComponentLegacy();
+ GeometryComponent *copy() const override;
+
+ void clear();
+ bool has_curve() const;
+ /**
+ * Clear the component and replace it with the new curve.
+ */
+ void replace(CurveEval *curve, GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
+ CurveEval *release();
+
+ const CurveEval *get_for_read() const;
+ CurveEval *get_for_write();
+
+ int attribute_domain_size(AttributeDomain domain) const final;
+
+ bool is_empty() const final;
+
+ bool owns_direct_data() const override;
+ void ensure_owns_direct_data() override;
+
+ static constexpr inline GeometryComponentType static_type = GEO_COMPONENT_TYPE_CURVE;
+
+ private:
+ const blender::bke::ComponentAttributeProviders *get_attribute_providers() const final;
+
+ blender::fn::GVArray attribute_try_adapt_domain_impl(const blender::fn::GVArray &varray,
+ AttributeDomain from_domain,
+ AttributeDomain to_domain) const final;
+};
+
+/**
+ * A geometry component that stores a group of curves, corresponding the the #Curves and
+ * #CurvesGeometry types.
+ */
+class CurveComponent : public GeometryComponent {
+ private:
+ Curves *curves_ = nullptr;
+ GeometryOwnershipType ownership_ = GeometryOwnershipType::Owned;
+
/**
* Curve data necessary to hold the draw cache for rendering, consistent over multiple redraws.
* This is necessary because Blender assumes that objects evaluate to an object data type, and
@@ -658,15 +701,15 @@ class CurveComponent : public GeometryComponent {
GeometryComponent *copy() const override;
void clear();
- bool has_curve() const;
+ bool has_curves() const;
/**
* Clear the component and replace it with the new curve.
*/
- void replace(CurveEval *curve, GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
- CurveEval *release();
+ void replace(Curves *curve, GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
+ Curves *release();
- const CurveEval *get_for_read() const;
- CurveEval *get_for_write();
+ const Curves *get_for_read() const;
+ Curves *get_for_write();
int attribute_domain_size(AttributeDomain domain) const final;