diff options
author | Hans Goudey <h.goudey@me.com> | 2022-10-14 23:05:35 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-10-14 23:05:35 +0300 |
commit | 6192f0c712f253a467ccdcea62e328c9e29fd7f3 (patch) | |
tree | c2d2030148e37fa07fd8630ccfbf04609ec7fd3d /source/blender/editors/object/object_modifier.cc | |
parent | 2ed302b5e13111b62b37cdd6a1d081e818f1574b (diff) | |
parent | 6c4b72b135749a3a9c405f410c6eec85fa0c1cc1 (diff) |
Merge branch 'master' into refactor-mesh-position-generic
Diffstat (limited to 'source/blender/editors/object/object_modifier.cc')
-rw-r--r-- | source/blender/editors/object/object_modifier.cc | 37 |
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 faad388edaa..bd4777b5272 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -21,6 +21,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_force_types.h" +#include "DNA_pointcloud_types.h" #include "DNA_scene_types.h" #include "DNA_space_types.h" @@ -789,7 +790,9 @@ static bool modifier_apply_obdata( if (ELEM(mti->type, eModifierTypeType_Constructive, eModifierTypeType_Nonconstructive)) { BKE_report( - reports, RPT_ERROR, "Transform curve to mesh in order to apply constructive modifiers"); + reports, + RPT_ERROR, + "Cannot apply constructive modifiers on curve. Convert curve to mesh in order to apply"); return false; } @@ -856,8 +859,38 @@ static bool modifier_apply_obdata( Main *bmain = DEG_get_bmain(depsgraph); BKE_object_material_from_eval_data(bmain, ob, &curves_eval.id); } + else if (ob->type == OB_POINTCLOUD) { + PointCloud &points = *static_cast<PointCloud *>(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<PointCloudComponent>().replace( + &points, GeometryOwnershipType::ReadOnly); + + ModifierEvalContext mectx = {depsgraph, ob, (ModifierApplyFlag)0}; + mti->modifyGeometrySet(md_eval, &mectx, &geometry_set); + if (!geometry_set.has_pointcloud()) { + BKE_report( + reports, RPT_ERROR, "Evaluated geometry from modifier does not contain a point cloud"); + return false; + } + PointCloud *pointcloud_eval = + geometry_set.get_component_for_write<PointCloudComponent>().release(); + + /* Anonymous attributes shouldn't be available on the applied geometry. */ + pointcloud_eval->attributes_for_write().remove_anonymous(); + + /* Copy the relevant information to the original. */ + Main *bmain = DEG_get_bmain(depsgraph); + BKE_object_material_from_eval_data(bmain, ob, &pointcloud_eval->id); + BKE_pointcloud_nomain_to_pointcloud(pointcloud_eval, &points, true); + } else { - /* TODO: implement for point clouds and volumes. */ + /* TODO: implement for volumes. */ BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type"); return false; } |