diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-09-19 20:04:12 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-09-19 20:04:12 +0400 |
commit | 23e2c97f63f18eadee34bf5ea9efc1b4aff2b5c2 (patch) | |
tree | ccc2448e4aaca9385e510f4c0038b7a16776de1b | |
parent | f2c820975699b9f07a516148df330e334dc3329c (diff) |
Fix T35993, issue with viewport when using instances.
Not really sure what the issue here was initially (might have been a
driver problem) but looks like the issue is solved if we skip generating
a display list for clipped objects; Driver does not like a generated
list that is not drawn.
Now we try to clip the object always, not only when using display lists.
This means that display lists will only get generated if object is
actually visible.
Also used glPush/glPop for instance matrices since glLoad can cause
recalculation of inverses in the driver.
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 110 |
1 files changed, 59 insertions, 51 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 004b3e1b7d3..90f6374199b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1981,8 +1981,10 @@ static void draw_dupli_objects_color( GLuint displist = 0; unsigned char color_rgb[3]; const short dflag_dupli = dflag | DRAW_CONSTCOLOR; - short transflag, use_displist = -1; /* -1 is initialize */ + short transflag; + bool use_displist = false; /* -1 is initialize */ char dt; + bool testbb = false; short dtx; DupliApplyData *apply_data; @@ -2037,71 +2039,77 @@ static void draw_dupli_objects_color( tbase.object->transflag |= OB_NEG_SCALE; else tbase.object->transflag &= ~OB_NEG_SCALE; - + /* should move outside the loop but possible color is set in draw_object still */ if ((dflag & DRAW_CONSTCOLOR) == 0) { glColor3ubv(color_rgb); } - + /* generate displist, test for new object */ if (dob_prev && dob_prev->ob != dob->ob) { if (use_displist == true) glDeleteLists(displist, 1); - - use_displist = -1; + + use_displist = false; + } + + if ((bb_tmp = BKE_object_boundbox_get(dob->ob))) { + bb = *bb_tmp; /* must make a copy */ + testbb = true; } - /* generate displist */ - if (use_displist == -1) { - - /* note, since this was added, its checked (dob->type == OB_DUPLIGROUP) - * however this is very slow, it was probably needed for the NLA - * offset feature (used in group-duplicate.blend but no longer works in 2.5) - * so for now it should be ok to - campbell */ - - if ( /* if this is the last no need to make a displist */ - (dob_next == NULL || dob_next->ob != dob->ob) || - /* lamp drawing messes with matrices, could be handled smarter... but this works */ - (dob->ob->type == OB_LAMP) || - (dob->type == OB_DUPLIGROUP && dob->animated) || - !(bb_tmp = BKE_object_boundbox_get(dob->ob)) || - draw_glsl_material(scene, dob->ob, v3d, dt) || - check_object_draw_texture(scene, v3d, dt) || - (base->object == OBACT && v3d->flag2 & V3D_SOLID_MATCAP)) - { - // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name + 2); - use_displist = false; - } - else { - // printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name + 2); - bb = *bb_tmp; /* must make a copy */ - - /* disable boundbox check for list creation */ - BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1); - /* need this for next part of code */ - unit_m4(dob->ob->obmat); /* obmat gets restored */ - - displist = glGenLists(1); - glNewList(displist, GL_COMPILE); - draw_object(scene, ar, v3d, &tbase, dflag_dupli); - glEndList(); - - use_displist = true; - BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0); + if (!testbb || ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) { + /* generate displist */ + if (use_displist == false) { + + /* note, since this was added, its checked (dob->type == OB_DUPLIGROUP) + * however this is very slow, it was probably needed for the NLA + * offset feature (used in group-duplicate.blend but no longer works in 2.5) + * so for now it should be ok to - campbell */ + + if ( /* if this is the last no need to make a displist */ + (dob_next == NULL || dob_next->ob != dob->ob) || + /* lamp drawing messes with matrices, could be handled smarter... but this works */ + (dob->ob->type == OB_LAMP) || + (dob->type == OB_DUPLIGROUP && dob->animated) || + !bb_tmp || + draw_glsl_material(scene, dob->ob, v3d, dt) || + check_object_draw_texture(scene, v3d, dt) || + (base->object == OBACT && v3d->flag2 & V3D_SOLID_MATCAP)) + { + // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name + 2); + use_displist = false; + } + else { + // printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name + 2); + + /* disable boundbox check for list creation */ + BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1); + /* need this for next part of code */ + unit_m4(dob->ob->obmat); /* obmat gets restored */ + + displist = glGenLists(1); + glNewList(displist, GL_COMPILE); + draw_object(scene, ar, v3d, &tbase, dflag_dupli); + glEndList(); + + use_displist = true; + BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0); + } } - } - if (use_displist) { - if (ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) { + + if (use_displist) { + glPushMatrix(); glMultMatrixf(dob->mat); glCallList(displist); - glLoadMatrixf(rv3d->viewmat); + glPopMatrix(); + } + else { + copy_m4_m4(dob->ob->obmat, dob->mat); + draw_object(scene, ar, v3d, &tbase, dflag_dupli); } } - else { - copy_m4_m4(dob->ob->obmat, dob->mat); - draw_object(scene, ar, v3d, &tbase, dflag_dupli); - } - + tbase.object->dt = dt; tbase.object->dtx = dtx; tbase.object->transflag = transflag; |