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>2021-05-27 17:08:40 +0300
committerHans Goudey <h.goudey@me.com>2021-05-27 17:08:40 +0300
commitac833108dbbaa5f2a6d62effe962eb289cc92291 (patch)
tree21bc3ac8a666de9ee0e8f355b6337dda649867d2 /source/blender/blenkernel/intern/geometry_component_curve.cc
parent5621a8ed7fbcd9067c576d4066e83d9640a80c49 (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/intern/geometry_component_curve.cc')
-rw-r--r--source/blender/blenkernel/intern/geometry_component_curve.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc
index be3fdf26cb3..de8dc355557 100644
--- a/source/blender/blenkernel/intern/geometry_component_curve.cc
+++ b/source/blender/blenkernel/intern/geometry_component_curve.cc
@@ -14,9 +14,14 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "DNA_ID_enums.h"
+#include "DNA_curve_types.h"
+
#include "BKE_attribute_access.hh"
#include "BKE_attribute_math.hh"
+#include "BKE_curve.h"
#include "BKE_geometry_set.hh"
+#include "BKE_lib_id.h"
#include "BKE_spline.hh"
#include "attribute_access_intern.hh"
@@ -58,6 +63,11 @@ void CurveComponent::clear()
if (ownership_ == GeometryOwnershipType::Owned) {
delete curve_;
}
+ if (curve_for_render_ != nullptr) {
+ BKE_id_free(nullptr, curve_for_render_);
+ curve_for_render_ = nullptr;
+ }
+
curve_ = nullptr;
}
}
@@ -118,6 +128,29 @@ void CurveComponent::ensure_owns_direct_data()
}
}
+/**
+ * Create empty curve data used for rendering the spline's wire edges.
+ * \note See comment on #curve_for_render_ for further explanation.
+ */
+const Curve *CurveComponent::get_curve_for_render() const
+{
+ if (curve_ == nullptr) {
+ return nullptr;
+ }
+ if (curve_for_render_ != nullptr) {
+ return curve_for_render_;
+ }
+ std::lock_guard lock{curve_for_render_mutex_};
+ if (curve_for_render_ != nullptr) {
+ return curve_for_render_;
+ }
+
+ curve_for_render_ = (Curve *)BKE_id_new_nomain(ID_CU, nullptr);
+ curve_for_render_->curve_eval = curve_;
+
+ return curve_for_render_;
+}
+
/** \} */
/* -------------------------------------------------------------------- */