Shape Keys: support locking to protect from accidental editing. #104463
|
@ -88,9 +88,9 @@ struct KeyBlock *BKE_keyblock_add(struct Key *key, const char *name);
|
|||
*/
|
||||
struct KeyBlock *BKE_keyblock_add_ctime(struct Key *key, const char *name, bool do_force);
|
||||
/**
|
||||
* Get the appropriate #KeyBlock given an index.
|
||||
* Get the appropriate #KeyBlock given an index (0 refers to the basis key). Key may be null.
|
||||
|
||||
*/
|
||||
struct KeyBlock *BKE_keyblock_from_key(struct Key *key, int index);
|
||||
struct KeyBlock *BKE_keyblock_find_by_index(struct Key *key, int index);
|
||||
/**
|
||||
* Get the appropriate #KeyBlock given a name to search for.
|
||||
*/
|
||||
|
|
|
@ -357,9 +357,9 @@ static float (*get_orco_coords(Object *ob, BMEditMesh *em, int layer, int *free)
|
|||
if (!em) {
|
||||
ClothModifierData *clmd = (ClothModifierData *)BKE_modifiers_findby_type(
|
||||
ob, eModifierType_Cloth);
|
||||
if (clmd) {
|
||||
KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ob),
|
||||
clmd->sim_parms->shapekey_rest);
|
||||
if (clmd && clmd->sim_parms->shapekey_rest) {
|
||||
KeyBlock *kb = BKE_keyblock_find_by_index(BKE_key_from_object(ob),
|
||||
clmd->sim_parms->shapekey_rest);
|
||||
|
||||
if (kb && kb->data) {
|
||||
return (float(*)[3])kb->data;
|
||||
|
|
|
@ -443,7 +443,7 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int * /*r_array_ind
|
|||
else {
|
||||
/* Find the name of the ShapeKey (i.e. KeyBlock) to look for */
|
||||
Key *key = (Key *)id;
|
||||
KeyBlock *kb = BKE_keyblock_from_key(key, adrcode);
|
||||
KeyBlock *kb = BKE_keyblock_find_by_index(key, adrcode);
|
||||
|
||||
/* setting that we alter is the "value" (i.e. keyblock.curval) */
|
||||
if (kb) {
|
||||
|
|
|
@ -1897,12 +1897,7 @@ KeyBlock *BKE_keyblock_from_object(Object *ob)
|
|||
{
|
||||
Key *key = BKE_key_from_object(ob);
|
||||
|
||||
if (key) {
|
||||
KeyBlock *kb = static_cast<KeyBlock *>(BLI_findlink(&key->block, ob->shapenr - 1));
|
||||
return kb;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return BKE_keyblock_find_by_index(key, ob->shapenr - 1);
|
||||
}
|
||||
|
||||
KeyBlock *BKE_keyblock_from_object_reference(Object *ob)
|
||||
|
@ -1916,21 +1911,13 @@ KeyBlock *BKE_keyblock_from_object_reference(Object *ob)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
KeyBlock *BKE_keyblock_from_key(Key *key, int index)
|
||||
KeyBlock *BKE_keyblock_find_by_index(Key *key, int index)
|
||||
{
|
||||
if (key) {
|
||||
KeyBlock *kb = static_cast<KeyBlock *>(key->block.first);
|
||||
|
||||
for (int i = 1; i < key->totkey; i++) {
|
||||
kb = kb->next;
|
||||
|
||||
if (index == i) {
|
||||
return kb;
|
||||
}
|
||||
}
|
||||
if (!key) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return static_cast<KeyBlock *>(BLI_findlink(&key->block, index));
|
||||
}
|
||||
|
||||
KeyBlock *BKE_keyblock_find_name(Key *key, const char name[])
|
||||
|
|
|
@ -100,8 +100,8 @@ static void deform_verts(ModifierData *md,
|
|||
* Also hopefully new cloth system will arrive soon..
|
||||
*/
|
||||
if (mesh == nullptr && clmd->sim_parms->shapekey_rest) {
|
||||
KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ctx->object),
|
||||
clmd->sim_parms->shapekey_rest);
|
||||
KeyBlock *kb = BKE_keyblock_find_by_index(BKE_key_from_object(ctx->object),
|
||||
clmd->sim_parms->shapekey_rest);
|
||||
if (kb && kb->data != nullptr) {
|
||||
float(*layerorco)[3];
|
||||
if (!(layerorco = static_cast<float(*)[3]>(
|
||||
|
|
Loading…
Reference in New Issue
I don't understand the additional comment here. Does this mean that the index should be offset to account for the base key not counting? This should be documented better.
For whatever reason that function is designed to return null instead of the 0th (basis) key.