Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_object.h1
-rw-r--r--source/blender/blenkernel/intern/object.c39
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c3
3 files changed, 43 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 46ec4697737..1c6f7221bec 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -69,6 +69,7 @@ void BKE_object_update_base_layer(struct Scene *scene, struct Object *ob);
void BKE_object_free(struct Object *ob);
void BKE_object_free_ex(struct Object *ob, bool do_id_user);
void BKE_object_free_derived_caches(struct Object *ob);
+void BKE_object_free_caches(struct Object *object);
void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *hmd);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8a6c6414266..d63e2516805 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -329,6 +329,45 @@ void BKE_object_free_derived_caches(Object *ob)
BKE_object_free_curve_cache(ob);
}
+void BKE_object_free_caches(Object *object)
+{
+ ModifierData *md;
+ short update_flag = 0;
+
+ /* Free particle system caches holding paths. */
+ if (object->particlesystem.first) {
+ ParticleSystem *psys;
+ for (psys = object->particlesystem.first;
+ psys != NULL;
+ psys = psys->next)
+ {
+ psys_free_path_cache(psys, psys->edit);
+ update_flag |= PSYS_RECALC;
+ }
+ }
+
+ /* Free memory used by cached derived meshes in the particle system modifiers. */
+ for (md = object->modifiers.first; md != NULL; md = md->next) {
+ if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
+ if (psmd->dm != NULL) {
+ psmd->dm->needsFree = 1;
+ psmd->dm->release(psmd->dm);
+ psmd->dm = NULL;
+ update_flag |= OB_RECALC_DATA;
+ }
+ }
+ }
+
+ /* Tag object for update, so once memory critical operation is over and
+ * scene update routines are back to it's business the object will be
+ * guaranteed to be in a known state.
+ */
+ if (update_flag != 0) {
+ DAG_id_tag_update(&object->id, update_flag);
+ }
+}
+
/* do not free object itself */
void BKE_object_free_ex(Object *ob, bool do_id_user)
{
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 814e6e8733b..2306682ca01 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -655,6 +655,9 @@ void RNA_api_object(StructRNA *srna)
RNA_def_function_ui_description(func, "Load the objects edit-mode data intp the object data");
parm = RNA_def_boolean(func, "result", 0, "", "Success");
RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "cache_release", "BKE_object_free_caches");
+ RNA_def_function_ui_description(func, "Release memory used by caches associated with this object. Intended to be used by render engines only");
}