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-04-26 16:07:54 +0300
committerHans Goudey <h.goudey@me.com>2022-04-26 16:07:54 +0300
commit96bdd65e740e669eceb18258dbc4b27d268d10aa (patch)
tree35cd8211c3a836ef074e1f754fc590364f3f9bc4
parentdb45292d8e0c29f399cba191e33f8388d9254357 (diff)
Curves: Support applying geometry nodes modifier
This commit adds support for the curves object to the apply modifier operator. A warning is added when the evaluated result of the modifier doesn't contain any curves data. Differential Revision: https://developer.blender.org/D14730
-rw-r--r--source/blender/editors/object/object_modifier.cc37
1 files changed, 35 insertions, 2 deletions
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc
index 8dec2a5eb1c..f90a31a7cbe 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -38,6 +38,7 @@
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_curves.h"
+#include "BKE_curves.hh"
#include "BKE_displist.h"
#include "BKE_editmesh.h"
#include "BKE_effect.h"
@@ -701,7 +702,6 @@ static bool modifier_apply_shape(Main *bmain,
BKE_id_free(nullptr, mesh_applied);
}
else {
- /* TODO: implement for curves, point clouds and volumes. */
BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
return false;
}
@@ -804,8 +804,41 @@ static bool modifier_apply_obdata(
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
+ else if (ob->type == OB_CURVES) {
+ Curves &curves = *static_cast<Curves *>(ob->data);
+ if (mti->modifyGeometrySet == nullptr) {
+ BLI_assert_unreachable();
+ return false;
+ }
+
+ /* Create a temporary geometry set and component. */
+ GeometrySet geometry_set;
+ geometry_set.get_component_for_write<CurveComponent>().replace(
+ &curves, GeometryOwnershipType::Editable);
+
+ ModifierEvalContext mectx = {depsgraph, ob, (ModifierApplyFlag)0};
+ mti->modifyGeometrySet(md_eval, &mectx, &geometry_set);
+ if (!geometry_set.has_curves()) {
+ BKE_report(reports, RPT_ERROR, "Evaluated geometry from modifier does not contain curves");
+ return false;
+ }
+ CurveComponent &component = geometry_set.get_component_for_write<CurveComponent>();
+ Curves &curves_eval = *geometry_set.get_curves_for_write();
+
+ /* Anonymous attributes shouldn't be available on the applied geometry. */
+ component.attributes_remove_anonymous();
+
+ /* If the modifier's output is a different curves data-block, copy the relevant information to
+ * the original. */
+ if (&curves_eval != &curves) {
+ blender::bke::CurvesGeometry::wrap(curves.geometry) = std::move(
+ blender::bke::CurvesGeometry::wrap(curves_eval.geometry));
+ Main *bmain = DEG_get_bmain(depsgraph);
+ BKE_object_material_from_eval_data(bmain, ob, &curves_eval.id);
+ }
+ }
else {
- /* TODO: implement for curves, point clouds and volumes. */
+ /* TODO: implement for point clouds and volumes. */
BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
return false;
}