Stored undo step data for position changes in sculpt mode are now automatically compressed. Compression is run in background threads, reducing memory consumption during sculpting sessions while adding little performance overhead. For testing and benchmarks, memory usage is now available through `bpy.app.undo_memory_info()`. Undo memory usage is now tracked by the existing automated benchmark tests. Some changes to the web benchmark visualization present the data a bit better. ZSTD compression is run asynchronously in a backround task pool. Compression is only blocking if the data is requested immediately for undo/redo. Co-authored-by: Hans Goudey <hans@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/141310
117 lines
3.6 KiB
C++
117 lines
3.6 KiB
C++
/* SPDX-FileCopyrightText: 2008 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup editors
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
|
|
struct Depsgraph;
|
|
struct Main;
|
|
struct Mesh;
|
|
struct Object;
|
|
struct RegionView3D;
|
|
struct ReportList;
|
|
struct Scene;
|
|
struct UndoType;
|
|
struct UndoStep;
|
|
struct bContext;
|
|
struct wmKeyConfig;
|
|
struct wmOperator;
|
|
|
|
namespace blender::ed::sculpt_paint {
|
|
|
|
void object_sculpt_mode_enter(Main &bmain,
|
|
Depsgraph &depsgraph,
|
|
Scene &scene,
|
|
Object &ob,
|
|
bool force_dyntopo,
|
|
ReportList *reports);
|
|
void object_sculpt_mode_enter(bContext *C, Depsgraph &depsgraph, ReportList *reports);
|
|
void object_sculpt_mode_exit(Main &bmain, Depsgraph &depsgraph, Scene &scene, Object &ob);
|
|
void object_sculpt_mode_exit(bContext *C, Depsgraph &depsgraph);
|
|
|
|
/* `sculpt.cc` */
|
|
|
|
/**
|
|
* Checks if the currently active Sculpt Mode on the object is targeting a locked shape key,
|
|
* and produces an error message if so (unless \a reports is null).
|
|
* \return true if the shape key was locked.
|
|
*/
|
|
bool report_if_shape_key_is_locked(const Object &ob, ReportList *reports);
|
|
|
|
void operatortypes_sculpt();
|
|
|
|
void keymap_sculpt(wmKeyConfig *keyconf);
|
|
|
|
/* `sculpt_transform.cc` */
|
|
|
|
void update_modal_transform(bContext *C, Object &ob);
|
|
void cancel_modal_transform(bContext *C, Object &ob);
|
|
void init_transform(bContext *C, Object &ob, const float mval_fl[2], const char *undo_name);
|
|
void end_transform(bContext *C, Object &ob);
|
|
|
|
/* `sculpt_undo.cc` */
|
|
|
|
namespace undo {
|
|
|
|
void register_type(UndoType *ut);
|
|
|
|
/**
|
|
* Pushes an undo step using the operator name. This is necessary for
|
|
* redo panels to work; operators that do not support that may use
|
|
* #geometry_begin_ex instead if so desired.
|
|
*/
|
|
void geometry_begin(const Scene &scene, Object &ob, const wmOperator *op);
|
|
void geometry_begin_ex(const Scene &scene, Object &ob, const char *name);
|
|
void geometry_end(Object &ob);
|
|
|
|
/**
|
|
* Undo for changes happening on a base mesh for multires sculpting.
|
|
* if there is no multi-res sculpt active regular undo is used.
|
|
*/
|
|
void push_multires_mesh_begin(bContext *C, const char *str);
|
|
void push_multires_mesh_end(bContext *C, const char *str);
|
|
|
|
size_t step_memory_size_get(UndoStep *step);
|
|
|
|
} // namespace undo
|
|
|
|
namespace face_set {
|
|
|
|
int find_next_available_id(Object &object);
|
|
void initialize_none_to_id(Mesh *mesh, int new_id);
|
|
int active_update_and_get(bContext *C, Object &ob, const float mval_fl[2]);
|
|
|
|
} // namespace face_set
|
|
|
|
/**
|
|
* Fills the object's active color attribute layer with the fill color.
|
|
*
|
|
* \param only_selected: Limit the fill to selected faces or vertices.
|
|
*
|
|
* \return #true if successful.
|
|
*/
|
|
bool object_active_color_fill(Object &ob, const float fill_color[4], bool only_selected);
|
|
|
|
/**
|
|
* Fully replace the sculpt mesh with a mesh outside of #Main. This implements various checks to
|
|
* avoid pushing full geometry-type undo steps when possible, allowing for better performance.
|
|
*
|
|
* \warning To avoid false negatives when detecting mesh changes, it is critical that the caller
|
|
* adds an owner to the attribute data arrays before modifying the original object's mesh. This
|
|
* allows constant time checks for whether the mesh has changed.
|
|
*/
|
|
void store_mesh_from_eval(const wmOperator &op,
|
|
const Scene &scene,
|
|
const Depsgraph &depsgraph,
|
|
const RegionView3D *rv3d,
|
|
Object &object,
|
|
Mesh *new_mesh);
|
|
|
|
} // namespace blender::ed::sculpt_paint
|