BKE_key: add BKE_key_from_id helper functions
This commit is contained in:
@@ -65,6 +65,8 @@ float *BKE_key_evaluate_object_ex(
|
|||||||
float *BKE_key_evaluate_object(
|
float *BKE_key_evaluate_object(
|
||||||
struct Object *ob, int *r_totelem);
|
struct Object *ob, int *r_totelem);
|
||||||
|
|
||||||
|
struct Key **BKE_key_from_id_p(struct ID *id);
|
||||||
|
struct Key *BKE_key_from_id(struct ID *id);
|
||||||
struct Key **BKE_key_from_object_p(struct Object *ob);
|
struct Key **BKE_key_from_object_p(struct Object *ob);
|
||||||
struct Key *BKE_key_from_object(struct Object *ob);
|
struct Key *BKE_key_from_object(struct Object *ob);
|
||||||
struct KeyBlock *BKE_keyblock_from_object(struct Object *ob);
|
struct KeyBlock *BKE_keyblock_from_object(struct Object *ob);
|
||||||
|
@@ -1392,24 +1392,49 @@ float *BKE_key_evaluate_object(Object *ob, int *r_totelem)
|
|||||||
return BKE_key_evaluate_object_ex(ob, r_totelem, NULL, 0);
|
return BKE_key_evaluate_object_ex(ob, r_totelem, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Key **BKE_key_from_id_p(ID *id)
|
||||||
|
{
|
||||||
|
switch (GS(id->name)) {
|
||||||
|
case ID_ME:
|
||||||
|
{
|
||||||
|
Mesh *me = (Mesh *)id;
|
||||||
|
return &me->key;
|
||||||
|
}
|
||||||
|
case ID_CU:
|
||||||
|
{
|
||||||
|
Curve *cu = (Curve *)id;
|
||||||
|
if (cu->vfont == NULL) {
|
||||||
|
return &cu->key;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ID_LT:
|
||||||
|
{
|
||||||
|
Lattice *lt = (Lattice *)id;
|
||||||
|
return <->key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Key *BKE_key_from_id(ID *id)
|
||||||
|
{
|
||||||
|
Key **key_p;
|
||||||
|
key_p = BKE_key_from_id_p(id);
|
||||||
|
if (key_p) {
|
||||||
|
return *key_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Key **BKE_key_from_object_p(Object *ob)
|
Key **BKE_key_from_object_p(Object *ob)
|
||||||
{
|
{
|
||||||
if (ob == NULL)
|
if (ob == NULL || ob->data == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (ob->type == OB_MESH) {
|
return BKE_key_from_id_p(ob->data);
|
||||||
Mesh *me = ob->data;
|
|
||||||
return &me->key;
|
|
||||||
}
|
|
||||||
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
|
||||||
Curve *cu = ob->data;
|
|
||||||
return &cu->key;
|
|
||||||
}
|
|
||||||
else if (ob->type == OB_LATTICE) {
|
|
||||||
Lattice *lt = ob->data;
|
|
||||||
return <->key;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Key *BKE_key_from_object(Object *ob)
|
Key *BKE_key_from_object(Object *ob)
|
||||||
|
Reference in New Issue
Block a user