diff options
author | Hans Goudey <h.goudey@me.com> | 2021-05-27 17:08:40 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-05-27 17:08:40 +0300 |
commit | ac833108dbbaa5f2a6d62effe962eb289cc92291 (patch) | |
tree | 21bc3ac8a666de9ee0e8f355b6337dda649867d2 /source/blender/blenkernel/BKE_geometry_set.hh | |
parent | 5621a8ed7fbcd9067c576d4066e83d9640a80c49 (diff) |
Geometry Nodes: Draw curve data in the viewport
This patch adds relatively small changes to the curve draw
cache implementation in order to draw the curve data in the
viewport. The dependency graph iterator is also modified
so that it iterates over the curve geometry component, which
is presented to users as `Curve` data with a pointer to the
`CurveEval`
The idea with the spline data type in geometry nodes is that
curve data itself is only the control points, and any evaluated
data with faces is a mesh. That is mostly expected elsewhere in
Blender anyway. This means it's only necessary to implement
wire edge drawing of `CurveEval` data.
Adding a `CurveEval` pointer to `Curve` is in line with changes
I'd like to make in the future like using `CurveEval` in more places
such as edit mode.
An alternate solution involves converting the curve wire data
to a mesh, however, that requires copying all of the data, and
since avoiding it is rather simple and is in-line with future plans
anyway, I think doing it this way is better.
Differential Revision: https://developer.blender.org/D11351
Diffstat (limited to 'source/blender/blenkernel/BKE_geometry_set.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.hh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 0ed6eea7954..9b50a9042eb 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -39,6 +39,7 @@ struct Mesh; struct Object; struct PointCloud; struct Volume; +struct Curve; class CurveEval; enum class GeometryOwnershipType { @@ -406,6 +407,15 @@ class CurveComponent : public GeometryComponent { CurveEval *curve_ = 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 + * we use #CurveEval rather than #Curve here. It also allows us to mostly reuse the same + * batch cache implementation. + */ + mutable Curve *curve_for_render_ = nullptr; + mutable std::mutex curve_for_render_mutex_; + public: CurveComponent(); ~CurveComponent(); @@ -430,6 +440,8 @@ class CurveComponent : public GeometryComponent { bool owns_direct_data() const override; void ensure_owns_direct_data() override; + const Curve *get_curve_for_render() const; + static constexpr inline GeometryComponentType static_type = GEO_COMPONENT_TYPE_CURVE; private: |