67 for (const int i : range) {
68 Object *ob = objects[i];
69 StepObject &object = us->objects[i];
70 const PointCloud &pointcloud = *static_cast<const PointCloud *>(ob->data);
71 object.obedit_ref.ptr = ob;
72 object.attribute_storage.wrap() = pointcloud.attribute_storage.wrap();
73 object.bounds_cache = pointcloud.runtime->bounds_cache;
74 object.bounds_with_radius_cache = pointcloud.runtime->bounds_with_radius_cache;
75 object.totpoint = pointcloud.totpoint;
79 bmain->is_memfile_undo_flush_needed =
true;
95 &us->
objects.first().obedit_ref.ptr,
97 sizeof(
decltype(us->
objects)::value_type));
104 const bool positions_changed = [&]() {
106 const bke::Attribute *attr_b =
object.attribute_storage.wrap().lookup(
"position");
107 if (!attr_b && !attr_a) {
110 if (!attr_a || !attr_b) {
113 return std::get<bke::Attribute::ArrayData>(attr_a->
data()).
data !=
114 std::get<bke::Attribute::ArrayData>(attr_b->
data()).data;
117 pointcloud.attribute_storage.wrap() =
object.attribute_storage.wrap();
120 pointcloud.runtime->bounds_cache =
object.bounds_cache;
121 pointcloud.runtime->bounds_with_radius_cache =
object.bounds_with_radius_cache;
122 if (positions_changed) {
129 scene, view_layer, us->
objects.first().obedit_ref.ptr, us_p->
name, &
LOG);
150 foreach_ID_ref_fn(user_data, ((
UndoRefID *)&
object.obedit_ref));
160 ut->
name =
"Edit Point Cloud";
Scene * CTX_data_scene(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
General operations, lookup, etc. for blender objects.
bool BKE_object_is_in_editmode(const Object *ob)
General operations for point clouds.
@ UNDOTYPE_FLAG_NEED_CONTEXT_FOR_ENCODE
void(*)(void *user_data, UndoRefID *id_ref) UndoTypeForEachIDRefFn
void DEG_id_tag_update(ID *id, unsigned int flags)
void ED_undo_object_set_active_or_warn(Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
void ED_undo_object_editmode_restore_helper(Scene *scene, ViewLayer *view_layer, Object **object_array, uint object_array_len, uint object_array_stride)
blender::Vector< Object * > ED_undo_editmode_objects_from_view_layer(const Scene *scene, ViewLayer *view_layer)
void ED_undo_object_editmode_validate_scene_from_windows(wmWindowManager *wm, const Scene *scene_ref, Scene **scene_p, ViewLayer **view_layer_p)
const DataVariant & data() const
static void foreach_ID_ref(UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
static void step_free(UndoStep *us_p)
static bool step_encode(bContext *C, Main *bmain, UndoStep *us_p)
static void step_decode(bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir, bool)
bool editable_pointcloud_in_edit_mode_poll(bContext *C)
void undosys_type_register(UndoType *ut)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
bool is_memfile_undo_flush_needed
void(* step_foreach_ID_ref)(UndoStep *us, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
void(* step_free)(UndoStep *us)
bool(* poll)(struct bContext *C)
void(* step_decode)(bContext *C, Main *bmain, UndoStep *us, eUndoStepDir dir, bool is_final)
bool(* step_encode)(bContext *C, Main *bmain, UndoStep *us)
Array< StepObject > objects
UndoRefID_Scene scene_ref
bke::AttributeStorage attribute_storage
SharedCache< Bounds< float3 > > bounds_with_radius_cache
SharedCache< Bounds< float3 > > bounds_cache
UndoRefID_Object obedit_ref
void WM_event_add_notifier(const bContext *C, uint type, void *reference)