Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/lattice.c
| Show First 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | Lattice *BKE_lattice_add(Main *bmain, const char *name) | ||||
| lt = BKE_libblock_alloc(bmain, ID_LT, name); | lt = BKE_libblock_alloc(bmain, ID_LT, name); | ||||
| BKE_lattice_init(lt); | BKE_lattice_init(lt); | ||||
| return lt; | return lt; | ||||
| } | } | ||||
| Lattice *BKE_lattice_copy(Main *bmain, const Lattice *lt) | /** | ||||
| * Only copy internal data of Lattice ID from source to already allocated/initialized destination. | |||||
| * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs. | |||||
| * | |||||
| * WARNING! This function will not handle ID user count! | |||||
| * | |||||
| * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). | |||||
| */ | |||||
| void BKE_lattice_copy_data(Main *bmain, Lattice *lt_dst, const Lattice *lt_src, const int flag) | |||||
| { | { | ||||
| Lattice *ltn; | lt_dst->def = MEM_dupallocN(lt_src->def); | ||||
| ltn = BKE_libblock_copy(bmain, <->id); | |||||
| ltn->def = MEM_dupallocN(lt->def); | |||||
| if (lt->key) { | if (lt_src->key) { | ||||
| ltn->key = BKE_key_copy(bmain, ltn->key); | BKE_id_copy_ex(bmain, <_src->key->id, (ID **)<_dst->key, flag, false); | ||||
| ltn->key->from = (ID *)ltn; | |||||
| } | } | ||||
| if (lt->dvert) { | if (lt_src->dvert) { | ||||
| int tot = lt->pntsu * lt->pntsv * lt->pntsw; | int tot = lt_src->pntsu * lt_src->pntsv * lt_src->pntsw; | ||||
| ltn->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); | lt_dst->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); | ||||
| BKE_defvert_array_copy(ltn->dvert, lt->dvert, tot); | BKE_defvert_array_copy(lt_dst->dvert, lt_src->dvert, tot); | ||||
| } | } | ||||
| ltn->editlatt = NULL; | lt_dst->editlatt = NULL; | ||||
| } | |||||
| BKE_id_copy_ensure_local(bmain, <->id, <n->id); | |||||
| return ltn; | Lattice *BKE_lattice_copy(Main *bmain, const Lattice *lt) | ||||
| { | |||||
| Lattice *lt_copy; | |||||
| BKE_id_copy_ex(bmain, <->id, (ID **)<_copy, 0, false); | |||||
| return lt_copy; | |||||
| } | } | ||||
| /** Free (or release) any data used by this lattice (does not free the lattice itself). */ | /** Free (or release) any data used by this lattice (does not free the lattice itself). */ | ||||
| void BKE_lattice_free(Lattice *lt) | void BKE_lattice_free(Lattice *lt) | ||||
| { | { | ||||
| BKE_animdata_free(<->id, false); | BKE_animdata_free(<->id, false); | ||||
| MEM_SAFE_FREE(lt->def); | MEM_SAFE_FREE(lt->def); | ||||
| if (lt->dvert) { | if (lt->dvert) { | ||||
| BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); | BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); | ||||
| lt->dvert = NULL; | lt->dvert = NULL; | ||||
| ▲ Show 20 Lines • Show All 921 Lines • Show Last 20 Lines | |||||