Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_draw.c
| Show First 20 Lines • Show All 1,963 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| View3DAfter *v3da, *next; | View3DAfter *v3da, *next; | ||||
| glDepthMask(GL_FALSE); | glDepthMask(GL_FALSE); | ||||
| v3d->transp = true; | v3d->transp = true; | ||||
| for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | draw_object(scene, ar, v3d, v3da->base, v3da->dflag, NULL); | ||||
| BLI_remlink(&v3d->afterdraw_transp, v3da); | BLI_remlink(&v3d->afterdraw_transp, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| } | } | ||||
| v3d->transp = false; | v3d->transp = false; | ||||
| glDepthMask(GL_TRUE); | glDepthMask(GL_TRUE); | ||||
| } | } | ||||
| /* clears zbuffer and draws it over */ | /* clears zbuffer and draws it over */ | ||||
| static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, bool *clear) | static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, bool *clear) | ||||
| { | { | ||||
| View3DAfter *v3da, *next; | View3DAfter *v3da, *next; | ||||
| if (*clear && v3d->zbuf) { | if (*clear && v3d->zbuf) { | ||||
| glClear(GL_DEPTH_BUFFER_BIT); | glClear(GL_DEPTH_BUFFER_BIT); | ||||
| *clear = false; | *clear = false; | ||||
| } | } | ||||
| v3d->xray = true; | v3d->xray = true; | ||||
| for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | draw_object(scene, ar, v3d, v3da->base, v3da->dflag, NULL); | ||||
| BLI_remlink(&v3d->afterdraw_xray, v3da); | BLI_remlink(&v3d->afterdraw_xray, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| } | } | ||||
| v3d->xray = false; | v3d->xray = false; | ||||
| } | } | ||||
| /* clears zbuffer and draws it over */ | /* clears zbuffer and draws it over */ | ||||
| static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const bool clear) | static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const bool clear) | ||||
| { | { | ||||
| View3DAfter *v3da, *next; | View3DAfter *v3da, *next; | ||||
| if (clear && v3d->zbuf) | if (clear && v3d->zbuf) | ||||
| glClear(GL_DEPTH_BUFFER_BIT); | glClear(GL_DEPTH_BUFFER_BIT); | ||||
| v3d->xray = true; | v3d->xray = true; | ||||
| v3d->transp = true; | v3d->transp = true; | ||||
| glDepthMask(GL_FALSE); | glDepthMask(GL_FALSE); | ||||
| for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | draw_object(scene, ar, v3d, v3da->base, v3da->dflag, NULL); | ||||
| BLI_remlink(&v3d->afterdraw_xraytransp, v3da); | BLI_remlink(&v3d->afterdraw_xraytransp, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| } | } | ||||
| v3d->transp = false; | v3d->transp = false; | ||||
| v3d->xray = false; | v3d->xray = false; | ||||
| glDepthMask(GL_TRUE); | glDepthMask(GL_TRUE); | ||||
| ▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | if (!testbb || ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) { | ||||
| /* disable boundbox check for list creation */ | /* disable boundbox check for list creation */ | ||||
| BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1); | BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1); | ||||
| /* need this for next part of code */ | /* need this for next part of code */ | ||||
| unit_m4(dob->ob->obmat); /* obmat gets restored */ | unit_m4(dob->ob->obmat); /* obmat gets restored */ | ||||
| displist = glGenLists(1); | displist = glGenLists(1); | ||||
| glNewList(displist, GL_COMPILE); | glNewList(displist, GL_COMPILE); | ||||
| draw_object(scene, ar, v3d, &tbase, dflag_dupli); | draw_object(scene, ar, v3d, &tbase, dflag_dupli, dob); | ||||
psy-fi: This will fail. Display list will get called with the options used at compilation time so if… | |||||
| glEndList(); | glEndList(); | ||||
| use_displist = true; | use_displist = true; | ||||
| BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0); | BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0); | ||||
| } | } | ||||
| } | } | ||||
| if (use_displist) { | if (use_displist) { | ||||
| glPushMatrix(); | glPushMatrix(); | ||||
| glMultMatrixf(dob->mat); | glMultMatrixf(dob->mat); | ||||
| glCallList(displist); | glCallList(displist); | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_m4_m4(dob->ob->obmat, dob->mat); | copy_m4_m4(dob->ob->obmat, dob->mat); | ||||
| draw_object(scene, ar, v3d, &tbase, dflag_dupli); | draw_object(scene, ar, v3d, &tbase, dflag_dupli, dob); | ||||
psy-fiUnsubmitted Not Done Inline ActionsDue to GLSL (check above), lists are never used. This is the place where you can add the GPU_begin_dupliobject / GPU_end_dupliobject calls mentioned above. psy-fi: Due to GLSL (check above), lists are never used. This is the place where you can add the… | |||||
| } | } | ||||
| } | } | ||||
| tbase.object->dt = dt; | tbase.object->dt = dt; | ||||
| tbase.object->dtx = dtx; | tbase.object->dtx = dtx; | ||||
| tbase.object->transflag = transflag; | tbase.object->transflag = transflag; | ||||
| tbase.object->currentlod = savedlod; | tbase.object->currentlod = savedlod; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | // persp(PERSP_STORE); /* store correct view for persp(PERSP_VIEW) calls */ | ||||
| v3d->zbuf = true; | v3d->zbuf = true; | ||||
| glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | ||||
| /* draw set first */ | /* draw set first */ | ||||
| if (scene->set) { | if (scene->set) { | ||||
| Scene *sce_iter; | Scene *sce_iter; | ||||
| for (SETLOOPER(scene->set, sce_iter, base)) { | for (SETLOOPER(scene->set, sce_iter, base)) { | ||||
| if (v3d->lay & base->lay) { | if (v3d->lay & base->lay) { | ||||
| draw_object(scene, ar, v3d, base, 0); | draw_object(scene, ar, v3d, base, 0, NULL); | ||||
| if (base->object->transflag & OB_DUPLI) { | if (base->object->transflag & OB_DUPLI) { | ||||
| draw_dupli_objects_color(scene, ar, v3d, base, dflag_depth, TH_UNDEFINED); | draw_dupli_objects_color(scene, ar, v3d, base, dflag_depth, TH_UNDEFINED); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (base = scene->base.first; base; base = base->next) { | for (base = scene->base.first; base; base = base->next) { | ||||
| if (v3d->lay & base->lay) { | if (v3d->lay & base->lay) { | ||||
| /* dupli drawing */ | /* dupli drawing */ | ||||
| if (base->object->transflag & OB_DUPLI) { | if (base->object->transflag & OB_DUPLI) { | ||||
| draw_dupli_objects_color(scene, ar, v3d, base, dflag_depth, TH_UNDEFINED); | draw_dupli_objects_color(scene, ar, v3d, base, dflag_depth, TH_UNDEFINED); | ||||
| } | } | ||||
| draw_object(scene, ar, v3d, base, dflag_depth); | draw_object(scene, ar, v3d, base, dflag_depth, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* this isn't that nice, draw xray objects as if they are normal */ | /* this isn't that nice, draw xray objects as if they are normal */ | ||||
| if (v3d->afterdraw_transp.first || | if (v3d->afterdraw_transp.first || | ||||
| v3d->afterdraw_xray.first || | v3d->afterdraw_xray.first || | ||||
| v3d->afterdraw_xraytransp.first) | v3d->afterdraw_xraytransp.first) | ||||
| { | { | ||||
| View3DAfter *v3da, *next; | View3DAfter *v3da, *next; | ||||
| int mask_orig; | int mask_orig; | ||||
| v3d->xray = true; | v3d->xray = true; | ||||
| /* transp materials can change the depth mask, see #21388 */ | /* transp materials can change the depth mask, see #21388 */ | ||||
| glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); | glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); | ||||
| if (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) { | if (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) { | ||||
| glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */ | glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */ | ||||
| for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| draw_object(scene, ar, v3d, v3da->base, dflag_depth); | draw_object(scene, ar, v3d, v3da->base, dflag_depth, NULL); | ||||
| } | } | ||||
| glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */ | glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */ | ||||
| } | } | ||||
| /* draw 3 passes, transp/xray/xraytransp */ | /* draw 3 passes, transp/xray/xraytransp */ | ||||
| v3d->xray = false; | v3d->xray = false; | ||||
| v3d->transp = true; | v3d->transp = true; | ||||
| for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| draw_object(scene, ar, v3d, v3da->base, dflag_depth); | draw_object(scene, ar, v3d, v3da->base, dflag_depth, NULL); | ||||
| BLI_remlink(&v3d->afterdraw_transp, v3da); | BLI_remlink(&v3d->afterdraw_transp, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| } | } | ||||
| v3d->xray = true; | v3d->xray = true; | ||||
| v3d->transp = false; | v3d->transp = false; | ||||
| for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| draw_object(scene, ar, v3d, v3da->base, dflag_depth); | draw_object(scene, ar, v3d, v3da->base, dflag_depth, NULL); | ||||
| BLI_remlink(&v3d->afterdraw_xray, v3da); | BLI_remlink(&v3d->afterdraw_xray, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| } | } | ||||
| v3d->xray = true; | v3d->xray = true; | ||||
| v3d->transp = true; | v3d->transp = true; | ||||
| for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| draw_object(scene, ar, v3d, v3da->base, dflag_depth); | draw_object(scene, ar, v3d, v3da->base, dflag_depth, NULL); | ||||
| BLI_remlink(&v3d->afterdraw_xraytransp, v3da); | BLI_remlink(&v3d->afterdraw_xraytransp, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| } | } | ||||
| v3d->xray = false; | v3d->xray = false; | ||||
| v3d->transp = false; | v3d->transp = false; | ||||
| ▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | static void view3d_draw_objects( | ||||
| /* draw set first */ | /* draw set first */ | ||||
| if (scene->set) { | if (scene->set) { | ||||
| const short dflag = DRAW_CONSTCOLOR | DRAW_SCENESET; | const short dflag = DRAW_CONSTCOLOR | DRAW_SCENESET; | ||||
| Scene *sce_iter; | Scene *sce_iter; | ||||
| for (SETLOOPER(scene->set, sce_iter, base)) { | for (SETLOOPER(scene->set, sce_iter, base)) { | ||||
| if (v3d->lay & base->lay) { | if (v3d->lay & base->lay) { | ||||
| UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f); | UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f); | ||||
| draw_object(scene, ar, v3d, base, dflag); | draw_object(scene, ar, v3d, base, dflag, NULL); | ||||
| if (base->object->transflag & OB_DUPLI) { | if (base->object->transflag & OB_DUPLI) { | ||||
| draw_dupli_objects_color(scene, ar, v3d, base, dflag, TH_UNDEFINED); | draw_dupli_objects_color(scene, ar, v3d, base, dflag, TH_UNDEFINED); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Transp and X-ray afterdraw stuff for sets is done later */ | /* Transp and X-ray afterdraw stuff for sets is done later */ | ||||
| } | } | ||||
| if (draw_offscreen) { | if (draw_offscreen) { | ||||
| for (base = scene->base.first; base; base = base->next) { | for (base = scene->base.first; base; base = base->next) { | ||||
| if (v3d->lay & base->lay) { | if (v3d->lay & base->lay) { | ||||
| /* dupli drawing */ | /* dupli drawing */ | ||||
| if (base->object->transflag & OB_DUPLI) | if (base->object->transflag & OB_DUPLI) | ||||
| draw_dupli_objects(scene, ar, v3d, base); | draw_dupli_objects(scene, ar, v3d, base); | ||||
| draw_object(scene, ar, v3d, base, 0); | draw_object(scene, ar, v3d, base, 0, NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| unsigned int lay_used = 0; | unsigned int lay_used = 0; | ||||
| /* then draw not selected and the duplis, but skip editmode object */ | /* then draw not selected and the duplis, but skip editmode object */ | ||||
| for (base = scene->base.first; base; base = base->next) { | for (base = scene->base.first; base; base = base->next) { | ||||
| lay_used |= base->lay; | lay_used |= base->lay; | ||||
| if (v3d->lay & base->lay) { | if (v3d->lay & base->lay) { | ||||
| /* dupli drawing */ | /* dupli drawing */ | ||||
| if (base->object->transflag & OB_DUPLI) { | if (base->object->transflag & OB_DUPLI) { | ||||
| draw_dupli_objects(scene, ar, v3d, base); | draw_dupli_objects(scene, ar, v3d, base); | ||||
| } | } | ||||
| if ((base->flag & SELECT) == 0) { | if ((base->flag & SELECT) == 0) { | ||||
| if (base->object != scene->obedit) | if (base->object != scene->obedit) | ||||
| draw_object(scene, ar, v3d, base, 0); | draw_object(scene, ar, v3d, base, 0, NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* mask out localview */ | /* mask out localview */ | ||||
| v3d->lay_used = lay_used & ((1 << 20) - 1); | v3d->lay_used = lay_used & ((1 << 20) - 1); | ||||
| /* draw selected and editmode */ | /* draw selected and editmode */ | ||||
| for (base = scene->base.first; base; base = base->next) { | for (base = scene->base.first; base; base = base->next) { | ||||
| if (v3d->lay & base->lay) { | if (v3d->lay & base->lay) { | ||||
| if (base->object == scene->obedit || (base->flag & SELECT)) { | if (base->object == scene->obedit || (base->flag & SELECT)) { | ||||
| draw_object(scene, ar, v3d, base, 0); | draw_object(scene, ar, v3d, base, 0, NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* perspective floor goes last to use scene depth and avoid writing to depth buffer */ | /* perspective floor goes last to use scene depth and avoid writing to depth buffer */ | ||||
| if (draw_grids_after) { | if (draw_grids_after) { | ||||
| drawfloor(scene, v3d, grid_unit, false); | drawfloor(scene, v3d, grid_unit, false); | ||||
| ▲ Show 20 Lines • Show All 1,173 Lines • Show Last 20 Lines | |||||
This will fail. Display list will get called with the options used at compilation time so if particle attributes change, this won't be reflected on the instance. Also lists are not used for what you want (GLSL). Check code above to see why (use_displist disabled in that case)