[Bf-blender-cvs] [da381bb] gooseberry: Handle dupli cache on object copy and freeing.
Lukas Tönne
noreply at git.blender.org
Mon Mar 23 13:03:34 CET 2015
Commit: da381bb9487b3a075b18632be3b03073ba3cb101
Author: Lukas Tönne
Date: Sat Mar 14 15:04:47 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBda381bb9487b3a075b18632be3b03073ba3cb101
Handle dupli cache on object copy and freeing.
===================================================================
M source/blender/blenkernel/BKE_anim.h
M source/blender/blenkernel/intern/object.c
M source/blender/blenkernel/intern/object_dupli.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index 6d4eb1b..941a4df 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -80,6 +80,8 @@ int count_duplilist(struct Object *ob);
void BKE_object_dupli_cache_update(struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx);
void BKE_object_dupli_cache_clear(struct Object *ob);
+void BKE_object_dupli_cache_free(struct Object *ob);
+bool BKE_object_dupli_cache_contains(struct Object *ob, struct Object *other);
struct DupliObjectData *BKE_dupli_cache_add_mesh(struct DupliCache *dupcache, struct Object *ob, struct DerivedMesh *dm);
void BKE_dupli_cache_add_instance(struct DupliCache *dupcache, float obmat[4][4], struct DupliObjectData *data);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index dbc818c..67687d9 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -453,6 +453,8 @@ void BKE_object_free_ex(Object *ob, bool do_id_user)
free_path(ob->curve_cache->path);
MEM_freeN(ob->curve_cache);
}
+
+ BKE_object_dupli_cache_free(ob);
}
void BKE_object_free(Object *ob)
@@ -680,6 +682,10 @@ void BKE_object_unlink(Object *ob)
lod->source = NULL;
}
+ /* dupli cache is cleared entirely if the object in question is duplified to keep it simple */
+ if (BKE_object_dupli_cache_contains(obt, ob))
+ BKE_object_dupli_cache_clear(ob);
+
obt = obt->id.next;
}
@@ -1572,6 +1578,8 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
/* Copy runtime surve data. */
obn->curve_cache = NULL;
+ obn->dup_cache = NULL;
+
if (ob->id.lib) {
BKE_id_lib_local_paths(bmain, ob->id.lib, &obn->id);
}
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index bcdd3ab..5b83e35 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1425,6 +1425,26 @@ void BKE_object_dupli_cache_clear(Object *ob)
}
}
+void BKE_object_dupli_cache_free(Object *ob)
+{
+ if (ob->dup_cache) {
+ dupli_cache_free(ob->dup_cache);
+ ob->dup_cache = NULL;
+ }
+}
+
+bool BKE_object_dupli_cache_contains(Object *ob, Object *other)
+{
+ if (ob->dup_cache) {
+ DupliObject *dob;
+ for (dob = ob->dup_cache->duplilist.first; dob; dob = dob->next) {
+ if (dob->ob == other)
+ return true;
+ }
+ }
+ return false;
+}
+
DupliObjectData *BKE_dupli_cache_add_mesh(DupliCache *dupcache, Object *ob, DerivedMesh *dm)
{
DupliObjectData *data = dupli_cache_add_object_data(dupcache);
More information about the Bf-blender-cvs
mailing list