diff options
Diffstat (limited to 'source/blender/blenkernel/intern/mball.c')
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 89c6a7d00b9..c09cd1aabdc 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -66,32 +66,29 @@ /* Functions */ -/** - * Free (or release) any data used by this mball (does not free the mball itself). - * - * \param mb The mball to free. - * \param do_id_user When \a true, ID datablocks used (referenced) by this mball are 'released' - * (their user count is decreased). - */ -void BKE_mball_free(MetaBall *mb, const bool do_id_user) +void BKE_mball_unlink(MetaBall *mb) { - if (do_id_user) { - int a; + int a; - for (a = 0; a < mb->totcol; a++) { - if (mb->mat[a]) { - id_us_min(&mb->mat[a]->id); - mb->mat[a] = NULL; - } - } + for (a = 0; a < mb->totcol; a++) { + if (mb->mat[a]) mb->mat[a]->id.us--; + mb->mat[a] = NULL; } - - BKE_animdata_free((ID *)mb); +} - MEM_SAFE_FREE(mb->mat); +/* do not free mball itself */ +void BKE_mball_free(MetaBall *mb) +{ + BKE_mball_unlink(mb); + + if (mb->adt) { + BKE_animdata_free((ID *)mb); + mb->adt = NULL; + } + if (mb->mat) MEM_freeN(mb->mat); BLI_freelistN(&mb->elems); - BKE_displist_free(&mb->disp); + if (mb->disp.first) BKE_displist_free(&mb->disp); } MetaBall *BKE_mball_add(Main *bmain, const char *name) |