65 switch (obedit->
type) {
173 Object *ob,
KeyBlock *kb,
const bool use_topology,
int &totmirr,
int &totfail)
185 for (i1 = 0; i1 <
mesh->verts_num; i1++) {
188 fp1 = (
static_cast<float *
>(kb->
data)) + i1 * 3;
194 if (tag_elem[i1] == 0 && tag_elem[i2] == 0) {
195 fp1 = (
static_cast<float *
>(kb->
data)) + i1 * 3;
196 fp2 = (
static_cast<float *
>(kb->
data)) + i2 * 3;
207 tag_elem[i1] = tag_elem[i2] = 1;
217 const Lattice *lt = id_cast<const Lattice *>(ob->
data);
222 const int pntsu_half = (lt->
pntsu / 2) + (lt->
pntsu % 2);
233 for (u = 0; u < pntsu_half; u++) {
234 int u_inv = (lt->
pntsu - 1) - u;
238 fp1 = (
static_cast<float *
>(kb->
data)) + i1 * 3;
246 fp1 = (
static_cast<float *
>(kb->
data)) + i1 * 3;
247 fp2 = (
static_cast<float *
>(kb->
data)) + i2 * 3;
261 MEM_delete(tag_elem);
265 bContext *
C,
Object *ob,
int *r_totmirr,
int *r_totfail,
bool use_topology)
268 int totmirr = 0, totfail = 0;
270 *r_totmirr = *r_totfail = 0;
273 if (key ==
nullptr) {
281 *r_totmirr = totmirr;
282 *r_totfail = totfail;
364 return TIP_(
"Create a new shape key from the visual result of existing mix of keys");
373 ot->
name =
"Add Shape Key";
374 ot->
idname =
"OBJECT_OT_shape_key_add";
390 "Create a new shape key from the visual result of existing mix of keys");
406 for (
auto [
index, keyblock] : key->
block.enumerate()) {
417 to_duplicate.
append(&keyblock);
422 for (
KeyBlock *kb_src : to_duplicate) {
427 if (kb_new !=
nullptr) {
439 ot->
name =
"Duplicate Shape Key";
440 ot->
idname =
"OBJECT_OT_shape_key_copy";
441 ot->
description =
"Duplicate the active shape key";
459 bool changed =
false;
473 int num_selected_but_locked = 0;
485 num_selected_but_locked++;
496 if (cur_index == 0) {
501 if (num_selected_but_locked) {
504 "Could not delete %d locked shape key(s)",
505 num_selected_but_locked);
514 if (key && key->
totkey > 0) {
537 if (
STREQ(prop_id,
"apply_mix") && !do_all) {
549 return TIP_(
"Apply current visible shape to the object data, and delete all shape keys");
554 return TIP_(
"Remove all shape keys from the object");
563 ot->
name =
"Remove Shape Key";
564 ot->
idname =
"OBJECT_OT_shape_key_remove";
565 ot->
description =
"Remove selected shape keys from the object";
582 "Apply current mix of shape keys to the geometry before removing them");
596 if (!key || key->
block.is_empty()) {
613 ot->
name =
"Clear Shape Keys";
615 "Reset the weights of all shape keys to 0 or to the closest value respecting the limits";
616 ot->
idname =
"OBJECT_OT_shape_key_clear";
633 if (!key || key->
block.is_empty()) {
651 ot->
name =
"Re-Time Shape Keys";
652 ot->
description =
"Resets the timing for absolute shape keys";
653 ot->
idname =
"OBJECT_OT_shape_key_retime";
672 int totmirr = 0, totfail = 0;
693 if (do_use_topology) {
695 "Mirror the active shape key along the local X axis using topology based mirroring\n"
696 "(for when both sides of mesh have matching, unique topology)");
705 ot->
name =
"Mirror Shape Key";
706 ot->
idname =
"OBJECT_OT_shape_key_mirror";
707 ot->
description =
"Mirror the active shape key along the local X axis";
723 "Use topology based mirroring (for when both sides of mesh have matching, unique topology)");
745 const int totkey = key.
totkey;
747 bool changed =
false;
760 new_index = top_index;
778 int bottom_index = totkey - 1;
787 new_index = bottom_index;
819 {0,
nullptr, 0,
nullptr,
nullptr}};
822 ot->
name =
"Move Shape Key";
823 ot->
idname =
"OBJECT_OT_shape_key_move";
824 ot->
description =
"Move selected shape keys up/down in the list";
853 if (!keys || keys->
block.is_empty()) {
883 return TIP_(
"Lock all shape keys of the active object");
886 return TIP_(
"Unlock all shape keys of the active object");
898 {0,
nullptr, 0,
nullptr,
nullptr},
902 ot->
name =
"Change the Lock On Shape Keys";
903 ot->
idname =
"OBJECT_OT_shape_key_lock";
904 ot->
description =
"Change the lock state of all shape keys of active object";
916 shape_key_lock_actions,
919 "Lock action to execute on vertex groups");
946 const int from_index = -1;
947 const int to_index = 0;
976 id_cast<Curve *>(ob->
data),
995 ot->
name =
"Make Shape Key the Basis Key";
996 ot->
idname =
"OBJECT_OT_shape_key_make_basis";
998 "Make the active shape key the new basis key, effectively applying it to the mesh.\n"
999 "Note that this applies the shape key at its 100% value";
1033 for (const int i : range) {
1050 int locked_count = 0;
1052 for (
const auto [i, kb] : key->
block.enumerate()) {
1060 keys_to_process[i] =
true;
1063 if (locked_count != 0) {
1067 if (!keys_to_process.
as_span().contains(
true)) {
1074 positions.
cast<
float>().data(),
1081 translations[i] = positions[i] - basis_data[i];
1087 for (
const auto [i, kb] : key->
block.enumerate()) {
1088 if (keys_to_process[i]) {
1092 for (
KeyBlock *kb : processed_keys) {
1097 for (
const auto [i, kb] : key->
block.enumerate()) {
1098 if (&kb == basis_key) {
1101 if (!(*dependent)[i]) {
1120 ot->
name =
"Apply to Basis Key";
1121 ot->
idname =
"OBJECT_OT_shape_key_apply_to_basis";
1122 ot->
description =
"Apply deformations of selected shape keys to the basis key, removing them";
General operations, lookup, etc. for blender objects.
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Span< T > as_span() const
constexpr int64_t size() const
constexpr MutableSpan< NewT > cast() const
constexpr IndexRange index_range() const
constexpr void copy_from(Span< T > values) const
void add_new(const Key &key)
void append(const T &value)
void OBJECT_OT_shape_key_clear(wmOperatorType *ot)
static wmOperatorStatus shape_key_clear_exec(bContext *C, wmOperator *)
static bool shape_key_make_basis_poll(bContext *C)
static bool object_shape_key_mirror(bContext *C, Object *ob, int *r_totmirr, int *r_totfail, bool use_topology)
void OBJECT_OT_shape_key_move(wmOperatorType *ot)
static void add_arrays(const MutableSpan< float3 > a, const Span< float3 > b)
static void object_shape_key_add(bContext *C, Object *ob, const bool from_mix)
bool shape_key_report_if_locked(const Object *obedit, ReportList *reports)
static wmOperatorStatus shape_key_retime_exec(bContext *C, wmOperator *)
static wmOperatorStatus shape_key_apply_to_basis_exec(bContext *C, wmOperator *op)
bool shape_key_report_if_any_locked(Object *ob, ReportList *reports)
static std::string shape_key_mirror_get_description(bContext *, wmOperatorType *, PointerRNA *ptr)
static bool shape_key_exists_poll(bContext *C)
Object * context_object(const bContext *C)
static wmOperatorStatus shape_key_copy_exec(bContext *C, wmOperator *)
void OBJECT_OT_shape_key_copy(wmOperatorType *ot)
static bool shape_key_mode_exists_poll(bContext *C)
static std::string shape_key_add_get_description(bContext *, wmOperatorType *, PointerRNA *ptr)
static bool shape_key_move_poll(bContext *C)
static bool shape_key_mode_poll(bContext *C)
static wmOperatorStatus shape_key_remove_exec(bContext *C, wmOperator *op)
static wmOperatorStatus shape_key_add_exec(bContext *C, wmOperator *op)
void shape_key_mirror(Object *ob, KeyBlock *kb, bool use_topology, int &totmirr, int &totfail)
bool shape_key_report_if_active_locked(Object *ob, ReportList *reports)
static bool object_is_any_shape_key_locked(Object *ob)
static wmOperatorStatus shape_key_make_basis_exec(bContext *C, wmOperator *)
void OBJECT_OT_shape_key_lock(wmOperatorType *ot)
static wmOperatorStatus shape_key_lock_exec(bContext *C, wmOperator *op)
static bool shape_key_poll(bContext *C)
void OBJECT_OT_shape_key_make_basis(wmOperatorType *ot)
static bool shape_key_apply_to_basis_poll(bContext *C)
void OBJECT_OT_shape_key_retime(wmOperatorType *ot)
void OBJECT_OT_shape_key_add(wmOperatorType *ot)
static bool shape_key_remove_poll_property(const bContext *, wmOperator *op, const PropertyRNA *prop)
static std::string shape_key_remove_get_description(bContext *, wmOperatorType *, PointerRNA *ptr)
void OBJECT_OT_shape_key_apply_to_basis(wmOperatorType *ot)
void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
static wmOperatorStatus shape_key_move_exec(bContext *C, wmOperator *op)
bool shape_key_is_selected(const Object &object, const KeyBlock &kb, int keyblock_index)
static std::string shape_key_lock_get_description(bContext *, wmOperatorType *, PointerRNA *ptr)
void OBJECT_OT_shape_key_mirror(wmOperatorType *ot)
static wmOperatorStatus shape_key_mirror_exec(bContext *C, wmOperator *op)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
KeyBlock * BKE_keyblock_duplicate(Key *key, KeyBlock *kb_src)
int RNA_enum_get(PointerRNA *ptr, const char *name)
MINLINE void copy_v3_v3(float r[3], const float a[3])
KeyBlock * ED_lattice_get_edit_shape_key(const Lattice *latt)
bool BKE_keyblock_move(Object *ob, int org_index, int new_index)
ListBaseT< Nurb > * BKE_curve_nurbs_get(Curve *cu)
const char * RNA_property_identifier(const PropertyRNA *prop)
void BKE_keyblock_convert_to_mesh(const KeyBlock *kb, MutableSpan< float3 > vert_positions)
void ED_mesh_mirror_spatial_table_end(Object *ob)
KeyBlock * BKE_keyblock_from_object(Object *ob)
void BKE_keyblock_convert_to_curve(KeyBlock *kb, Curve *cu, ListBaseT< Nurb > *nurb)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
float * BKE_key_evaluate_object_ex(Object *ob, int *r_totelem, float *arr, size_t arr_size, std::optional< Span< bool > > keys_to_process, ID *obdata)
int mesh_get_x_mirror_vert(Object *ob, Mesh *mesh_eval, int index, bool use_topology)
MINLINE int max_ii(int a, int b)
ATTR_WARN_UNUSED_RESULT const BMVert * v
std::optional< Array< bool > > BKE_keyblock_get_dependent_keys(const Key *key, int index)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
KeyBlock * ED_curve_get_edit_shape_key(const Curve *cu)
void DEG_id_tag_update(ID *id, unsigned int flags)
BMesh const char void * data
int BKE_lattice_index_from_uvw(const Lattice *lt, int u, int v, int w)
bool BKE_object_shapekey_free(Main *bmain, Object *ob)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
KeyBlock * BKE_object_shapekey_insert(Main *bmain, Object *ob, const char *name, bool from_mix)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
bool BKE_object_shapekey_remove(Main *bmain, Object *ob, KeyBlock *kb)
void ED_mesh_report_mirror(ReportList &reports, int totmirr, int totfail)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Main * CTX_data_main(const bContext *C)
void ED_mesh_mirror_spatial_table_begin(Object *ob, Mesh *mesh_eval)
void DEG_relations_tag_update(Main *bmain)
VecBase< float, 3 > float3
Key * BKE_key_from_object(Object *ob)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void BKE_keyblock_convert_to_lattice(const KeyBlock *kb, Lattice *lt)
MINLINE int min_ii(int a, int b)
KeyBlock * ED_mesh_get_edit_shape_key(const Mesh *me)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE float clamp_f(float value, float min, float max)
ListBaseT< KeyBlock > block
struct EditLatt * editlatt
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll_property(const bContext *C, wmOperator *op, const PropertyRNA *prop) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
std::string(*) get_description(bContext *C, wmOperatorType *ot, PointerRNA *ptr)
struct ReportList * reports