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:
authorLukas Tönne <lukas.toenne@gmail.com>2015-03-18 17:37:08 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-03-26 16:13:39 +0300
commitb4295d1c8fa0f05f6859ce9989273f5b811fa9a9 (patch)
tree2bf1430dcc48c3a124059f9990bf8b09428f3293 /source
parent850c47b5a87c26b04caf2116a07de8739309cbd5 (diff)
Calculate bounding boxes for cached DMs to avoid visual popping when
using the original Object's bb.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c17
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c21
-rw-r--r--source/blender/makesdna/DNA_object_types.h1
3 files changed, 34 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 5d26b876e31..9adb19047e7 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1466,10 +1466,27 @@ DupliObjectData *BKE_dupli_cache_find_data(DupliCache *dupcache, Object *ob)
return data;
}
+static void dupli_cache_calc_boundbox(DupliObjectData *data)
+{
+ float min[3], max[3];
+
+ if (data->cache_dm) {
+ INIT_MINMAX(min, max);
+ data->cache_dm->getMinMax(data->cache_dm, min, max);
+ }
+ else {
+ zero_v3(min);
+ zero_v3(max);
+ }
+
+ BKE_boundbox_init_from_minmax(&data->bb, min, max);
+}
+
DupliObjectData *BKE_dupli_cache_add_mesh(DupliCache *dupcache, Object *ob, DerivedMesh *dm)
{
DupliObjectData *data = dupli_cache_add_object_data(dupcache, ob);
data->cache_dm = dm;
+ dupli_cache_calc_boundbox(data);
/* we own this dm now and need to protect it until we free it ourselves */
dm->needsFree = false;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 20cf3c7c658..1002fb50934 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2058,10 +2058,13 @@ static void draw_dupli_objects_color(
if (dob) dob_next = dupli_step(dob->next);
for (; dob; dob_prev = dob, dob = dob_next, dob_next = dob_next ? dupli_step(dob_next->next) : NULL) {
- DerivedMesh *final_dm; /* for restoring after override */
+ /* for restoring after override */
+ DerivedMesh *store_final_dm;
+ BoundBox *store_bb;
tbase.object = dob->ob;
- final_dm = dob->ob->derivedFinal;
+ store_final_dm = dob->ob->derivedFinal;
+ store_bb = dob->ob->bb;
/* Make sure lod is updated from dupli's position */
@@ -2099,11 +2102,16 @@ static void draw_dupli_objects_color(
}
/* override final DM */
+ bb_tmp = NULL;
if (base->object->dup_cache) {
DupliObjectData *dob_data = BKE_dupli_cache_find_data(base->object->dup_cache, tbase.object);
- if (dob_data->cache_dm)
+ if (dob_data->cache_dm) {
tbase.object->derivedFinal = dob_data->cache_dm;
+ tbase.object->bb = bb_tmp = &dob_data->bb;
+ }
}
+ if (!bb_tmp)
+ bb_tmp = BKE_object_boundbox_get(dob->ob);
/* generate displist, test for new object */
if (dob_prev && dob_prev->ob != dob->ob) {
@@ -2113,7 +2121,7 @@ static void draw_dupli_objects_color(
use_displist = false;
}
- if ((bb_tmp = BKE_object_boundbox_get(dob->ob))) {
+ if (bb_tmp) {
bb = *bb_tmp; /* must make a copy */
testbb = true;
}
@@ -2174,7 +2182,10 @@ static void draw_dupli_objects_color(
tbase.object->dtx = dtx;
tbase.object->transflag = transflag;
tbase.object->currentlod = savedlod;
- tbase.object->derivedFinal = final_dm;
+
+ /* restore final DM */
+ tbase.object->derivedFinal = store_final_dm;
+ tbase.object->bb = store_bb;
}
if (apply_data) {
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 310ee7a110f..6fe40b407da 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -342,6 +342,7 @@ typedef struct DupliObjectData {
* others make this too difficult
*/
struct Object *ob;
+ struct BoundBox bb;
struct DerivedMesh *cache_dm;
} DupliObjectData;