Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_draw.c
| Context not available. | |||||
| /* ********* end custom clipping *********** */ | /* ********* end custom clipping *********** */ | ||||
| void ED_view3d_color_overlay(View3D *v3d) | |||||
| { | |||||
| if (V3D_IS_WIRECOLOR(v3d)) { | |||||
| cpack(0xffffff); | |||||
| } | |||||
| else { | |||||
| UI_ThemeColor(TH_VIEW_OVERLAY); | |||||
| } | |||||
| } | |||||
| static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, double dx) | static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, double dx) | ||||
| { | { | ||||
| Context not available. | |||||
| circ((float)co[0], (float)co[1], f10); | circ((float)co[0], (float)co[1], f10); | ||||
| setlinestyle(0); | setlinestyle(0); | ||||
| UI_ThemeColor(TH_VIEW_OVERLAY); | ED_view3d_color_overlay(v3d); | ||||
| sdrawline(co[0] - f20, co[1], co[0] - f5, co[1]); | sdrawline(co[0] - f20, co[1], co[0] - f5, co[1]); | ||||
| sdrawline(co[0] + f5, co[1], co[0] + f20, co[1]); | sdrawline(co[0] + f5, co[1], co[0] + f20, co[1]); | ||||
| sdrawline(co[0], co[1] - f20, co[0], co[1] - f5); | sdrawline(co[0], co[1] - f20, co[0], co[1] - f5); | ||||
| Context not available. | |||||
| glRectf(x1i - 1, y1i - 1, x2i + 1, y2i + 1); | glRectf(x1i - 1, y1i - 1, x2i + 1, y2i + 1); | ||||
| } | } | ||||
| UI_ThemeColor(TH_VIEW_OVERLAY); | ED_view3d_color_overlay(v3d); | ||||
| glRectf(x1i, y1i, x2i, y2i); | glRectf(x1i, y1i, x2i, y2i); | ||||
| /* border */ | /* border */ | ||||
| Context not available. | |||||
| /* disables write in zbuffer and draws it over */ | /* disables write in zbuffer and draws it over */ | ||||
| static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d) | static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d) | ||||
| { | { | ||||
| const bool is_wire_color = V3D_IS_WIRECOLOR(v3d); | |||||
| View3DAfter *v3da, *next; | View3DAfter *v3da, *next; | ||||
| glDepthMask(0); | glDepthMask(0); | ||||
| Context not available. | |||||
| for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| if (is_wire_color) { | |||||
| setlinestyle(v3da->base->flag & SELECT ? 0 : 1); | |||||
| } | |||||
| draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | ||||
| BLI_remlink(&v3d->afterdraw_transp, v3da); | BLI_remlink(&v3d->afterdraw_transp, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| Context not available. | |||||
| v3d->transp = false; | v3d->transp = false; | ||||
| glDepthMask(1); | glDepthMask(1); | ||||
| if (is_wire_color) { | |||||
| setlinestyle(0); | |||||
| } | |||||
| } | } | ||||
| /* clears zbuffer and draws it over */ | /* clears zbuffer and draws it over */ | ||||
| static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear) | static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear) | ||||
| { | { | ||||
| const bool is_wire_color = V3D_IS_WIRECOLOR(v3d); | |||||
| View3DAfter *v3da, *next; | View3DAfter *v3da, *next; | ||||
| if (clear && v3d->zbuf) | if (clear && v3d->zbuf) | ||||
| Context not available. | |||||
| 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; | ||||
| if (is_wire_color) { | |||||
| setlinestyle(v3da->base->flag & SELECT ? 0 : 1); | |||||
| } | |||||
| draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | ||||
| BLI_remlink(&v3d->afterdraw_xray, v3da); | BLI_remlink(&v3d->afterdraw_xray, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| } | } | ||||
| v3d->xray = false; | v3d->xray = false; | ||||
| if (is_wire_color) { | |||||
| setlinestyle(0); | |||||
| } | |||||
| } | } | ||||
| /* clears zbuffer and draws it over */ | /* clears zbuffer and draws it over */ | ||||
| static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int clear) | static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int clear) | ||||
| { | { | ||||
| const bool is_wire_color = V3D_IS_WIRECOLOR(v3d); | |||||
| View3DAfter *v3da, *next; | View3DAfter *v3da, *next; | ||||
| if (clear && v3d->zbuf) | if (clear && v3d->zbuf) | ||||
| Context not available. | |||||
| for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { | for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { | ||||
| next = v3da->next; | next = v3da->next; | ||||
| if (is_wire_color) { | |||||
| setlinestyle(v3da->base->flag & SELECT ? 0 : 1); | |||||
| } | |||||
| draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | draw_object(scene, ar, v3d, v3da->base, v3da->dflag); | ||||
| BLI_remlink(&v3d->afterdraw_xraytransp, v3da); | BLI_remlink(&v3d->afterdraw_xraytransp, v3da); | ||||
| MEM_freeN(v3da); | MEM_freeN(v3da); | ||||
| Context not available. | |||||
| v3d->transp = false; | v3d->transp = false; | ||||
| v3d->xray = false; | v3d->xray = false; | ||||
| if (is_wire_color) { | |||||
| setlinestyle(0); | |||||
| } | |||||
| } | } | ||||
| /* *********************** */ | /* *********************** */ | ||||
| Context not available. | |||||
| static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int color) | static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int color) | ||||
| { | { | ||||
| const bool is_wire_color = V3D_IS_WIRECOLOR(v3d); | |||||
| const char dflag = DRAW_CONSTCOLOR | (is_wire_color ? DRAW_CONSTSTIPPLE : 0); | |||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| ListBase *lb; | ListBase *lb; | ||||
| LodLevel *savedlod; | LodLevel *savedlod; | ||||
| Context not available. | |||||
| dob = dupli_step(lb->first); | dob = dupli_step(lb->first); | ||||
| if (dob) dob_next = dupli_step(dob->next); | if (dob) dob_next = dupli_step(dob->next); | ||||
| if (is_wire_color && !(base->flag & SELECT)) | |||||
| setlinestyle(1); | |||||
| for (; dob; dob_prev = dob, dob = dob_next, dob_next = dob_next ? dupli_step(dob_next->next) : NULL) { | for (; dob; dob_prev = dob, dob = dob_next, dob_next = dob_next ? dupli_step(dob_next->next) : NULL) { | ||||
| tbase.object = dob->ob; | tbase.object = dob->ob; | ||||
| Context not available. | |||||
| else | else | ||||
| tbase.object->transflag &= ~OB_NEG_SCALE; | tbase.object->transflag &= ~OB_NEG_SCALE; | ||||
| UI_ThemeColorBlend(color, TH_BACK, 0.5); | if (is_wire_color) { | ||||
| glColor3fv(base->object->col); | |||||
| } | |||||
| else { | |||||
| UI_ThemeColorBlend(color, TH_BACK, 0.5); | |||||
| } | |||||
| /* generate displist, test for new object */ | /* generate displist, test for new object */ | ||||
| if (dob_prev && dob_prev->ob != dob->ob) { | if (dob_prev && dob_prev->ob != dob->ob) { | ||||
| Context not available. | |||||
| displist = glGenLists(1); | displist = glGenLists(1); | ||||
| glNewList(displist, GL_COMPILE); | glNewList(displist, GL_COMPILE); | ||||
| draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR); | draw_object(scene, ar, v3d, &tbase, dflag); | ||||
| glEndList(); | glEndList(); | ||||
| use_displist = true; | use_displist = true; | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR); | draw_object(scene, ar, v3d, &tbase, dflag); | ||||
| } | } | ||||
| tbase.object->dt = dt; | tbase.object->dt = dt; | ||||
| Context not available. | |||||
| copy_m4_m4(tbase.object->obmat, savedobmat); | copy_m4_m4(tbase.object->obmat, savedobmat); | ||||
| } | } | ||||
| if (is_wire_color && !(base->flag & SELECT)) | |||||
| setlinestyle(0); | |||||
| /* Transp afterdraw disabled, afterdraw only stores base pointers, and duplis can be same obj */ | /* Transp afterdraw disabled, afterdraw only stores base pointers, and duplis can be same obj */ | ||||
| free_object_duplilist(lb); | free_object_duplilist(lb); | ||||
| Context not available. | |||||
| void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, | void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, | ||||
| float viewmat[4][4], float winmat[4][4], bool do_bgpic, bool do_sky) | float viewmat[4][4], float winmat[4][4], bool do_bgpic, bool do_sky) | ||||
| { | { | ||||
| const bool is_wire_color = V3D_IS_WIRECOLOR(v3d); | |||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| Base *base; | Base *base; | ||||
| int bwinx, bwiny; | int bwinx, bwiny; | ||||
| Context not available. | |||||
| /* draw set first */ | /* draw set first */ | ||||
| if (scene->set) { | if (scene->set) { | ||||
| const char dflag = (DRAW_CONSTCOLOR | DRAW_SCENESET) | (is_wire_color ? DRAW_CONSTSTIPPLE : 0); | |||||
| 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); | if (is_wire_color) { | ||||
| draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET); | glColor3fv(base->object->col); | ||||
| } | |||||
| else { | |||||
| UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f); | |||||
| } | |||||
| draw_object(scene, ar, v3d, base, dflag); | |||||
| if (base->object->transflag & OB_DUPLI) | if (base->object->transflag & OB_DUPLI) | ||||
| draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE); | draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE); | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) { | if (V3D_IS_WIRECOLOR(v3d)) { | ||||
| glClearColor(0.0, 0.0, 0.0, 0.0); | |||||
| glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |||||
| } | |||||
| else if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) { | |||||
| glMatrixMode(GL_PROJECTION); | glMatrixMode(GL_PROJECTION); | ||||
| glPushMatrix(); | glPushMatrix(); | ||||
| glLoadIdentity(); | glLoadIdentity(); | ||||
| Context not available. | |||||
| RegionView3D *rv3d = CTX_wm_region_view3d(C); | RegionView3D *rv3d = CTX_wm_region_view3d(C); | ||||
| Base *base; | Base *base; | ||||
| unsigned int lay_used; | unsigned int lay_used; | ||||
| const bool is_wire_color = V3D_IS_WIRECOLOR(v3d); | |||||
| /* shadow buffers, before we setup matrices */ | /* shadow buffers, before we setup matrices */ | ||||
| if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) | if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) | ||||
| Context not available. | |||||
| lay_used = 0; | 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 */ | ||||
| if (is_wire_color) | |||||
| setlinestyle(1); | |||||
| for (base = scene->base.first; base; base = base->next) { | for (base = scene->base.first; base; base = base->next) { | ||||
| lay_used |= base->lay & ((1 << 20) - 1); | lay_used |= base->lay & ((1 << 20) - 1); | ||||
| Context not available. | |||||
| v3d->lay_used = lay_used; | v3d->lay_used = lay_used; | ||||
| } | } | ||||
| if (is_wire_color) | |||||
| setlinestyle(0); | |||||
| /* 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, (base->flag & SELECT)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||