diff options
-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; |