Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/curve.c
| Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | Curve *BKE_curve_add(Main *bmain, const char *name, int type) | ||||
| cu = BKE_libblock_alloc(bmain, ID_CU, name); | cu = BKE_libblock_alloc(bmain, ID_CU, name); | ||||
| cu->type = type; | cu->type = type; | ||||
| BKE_curve_init(cu); | BKE_curve_init(cu); | ||||
| return cu; | return cu; | ||||
| } | } | ||||
| Curve *BKE_curve_copy(Main *bmain, const Curve *cu) | /** | ||||
| * Only copy internal data of Curve 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_curve_copy_data(Main *bmain, Curve *cu_dst, const Curve *cu_src, const int flag) | |||||
| { | { | ||||
| Curve *cun; | BLI_listbase_clear(&cu_dst->nurb); | ||||
| int a; | BKE_nurbList_duplicate(&(cu_dst->nurb), &(cu_src->nurb)); | ||||
| cun = BKE_libblock_copy(bmain, &cu->id); | cu_dst->mat = MEM_dupallocN(cu_src->mat); | ||||
| BLI_listbase_clear(&cun->nurb); | cu_dst->str = MEM_dupallocN(cu_src->str); | ||||
| BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb)); | cu_dst->strinfo = MEM_dupallocN(cu_src->strinfo); | ||||
| cu_dst->tb = MEM_dupallocN(cu_src->tb); | |||||
| cu_dst->bb = MEM_dupallocN(cu_src->bb); | |||||
| cun->mat = MEM_dupallocN(cu->mat); | if (cu_src->key) { | ||||
| for (a = 0; a < cun->totcol; a++) { | BKE_id_copy_ex(bmain, &cu_src->key->id, (ID **)&cu_dst->key, flag, false); | ||||
| id_us_plus((ID *)cun->mat[a]); | |||||
| } | } | ||||
| cun->str = MEM_dupallocN(cu->str); | cu_dst->editnurb = NULL; | ||||
| cun->strinfo = MEM_dupallocN(cu->strinfo); | cu_dst->editfont = NULL; | ||||
| cun->tb = MEM_dupallocN(cu->tb); | |||||
| cun->bb = MEM_dupallocN(cu->bb); | |||||
| if (cu->key) { | |||||
| cun->key = BKE_key_copy(bmain, cu->key); | |||||
| cun->key->from = (ID *)cun; | |||||
| } | } | ||||
| cun->editnurb = NULL; | Curve *BKE_curve_copy(Main *bmain, const Curve *cu) | ||||
| cun->editfont = NULL; | { | ||||
| Curve *cu_copy; | |||||
| id_us_plus((ID *)cun->vfont); | BKE_id_copy_ex(bmain, &cu->id, (ID **)&cu_copy, 0, false); | ||||
| id_us_plus((ID *)cun->vfontb); | return cu_copy; | ||||
| id_us_plus((ID *)cun->vfonti); | |||||
| id_us_plus((ID *)cun->vfontbi); | |||||
| BKE_id_copy_ensure_local(bmain, &cu->id, &cun->id); | |||||
| return cun; | |||||
| } | } | ||||
| void BKE_curve_make_local(Main *bmain, Curve *cu, const bool lib_local) | void BKE_curve_make_local(Main *bmain, Curve *cu, const bool lib_local) | ||||
| { | { | ||||
| BKE_id_make_local_generic(bmain, &cu->id, true, lib_local); | BKE_id_make_local_generic(bmain, &cu->id, true, lib_local); | ||||
| } | } | ||||
| /* Get list of nurbs from editnurbs structure */ | /* Get list of nurbs from editnurbs structure */ | ||||
| ▲ Show 20 Lines • Show All 4,455 Lines • Show Last 20 Lines | |||||