Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_draw_legacy.c
| Context not available. | |||||
| return mask; | return mask; | ||||
| } | } | ||||
| /** | |||||
| * Draw grease pencil object strokes | |||||
| */ | |||||
| static void draw_gpencil_object_strokes(const bContext *C, Scene *scene, const struct Depsgraph *depsgraph, View3D *v3d, ARegion *ar, Base *base) | |||||
| { | |||||
| const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0; | |||||
| Object *ob = base->object; | |||||
| if (ob != CTX_data_edit_object(C)) { | |||||
| if (ob->restrictflag & OB_RESTRICT_VIEW) | |||||
| return; | |||||
| if (render_override) { | |||||
| if (ob->restrictflag & OB_RESTRICT_RENDER) | |||||
| return; | |||||
| if (ob->transflag & (OB_DUPLI & ~OB_DUPLIFRAMES)) | |||||
| return; | |||||
| } | |||||
| } | |||||
| wmWindowManager *wm = (C != NULL) ? CTX_wm_manager(C) : NULL; | |||||
| if (v3d->zbuf) glDisable(GL_DEPTH_TEST); | |||||
| ED_gpencil_draw_view3d_object(wm, scene, depsgraph, ob, v3d, ar, true); | |||||
| if (v3d->zbuf) glEnable(GL_DEPTH_TEST); | |||||
| } | |||||
| /* helper function to sort gpencil objects using qsort */ | |||||
| static int compare_gpencil_zdepth(const void *a1, const void *a2) | |||||
| { | |||||
| const tGPencilSort *ps1 = a1, *ps2 = a2; | |||||
| if (ps1->zdepth > ps2->zdepth) return 1; | |||||
| else if (ps1->zdepth < ps2->zdepth) return -1; | |||||
| return 0; | |||||
| } | |||||
| /* draw objects in cache from back to from */ | |||||
| static void gpencil_draw_objects(const bContext *C, Scene *scene, const struct Depsgraph *depsgraph, View3D *v3d, ARegion *ar, tGPencilSort *cache, int gp_cache_used) | |||||
| { | |||||
| if (gp_cache_used > 0) { | |||||
| /* sort by zdepth */ | |||||
| qsort(cache, gp_cache_used, sizeof(tGPencilSort), compare_gpencil_zdepth); | |||||
| /* inverse loop to draw from back to front */ | |||||
| for (int i = gp_cache_used; i > 0; --i) { | |||||
| Base *base = cache[i - 1].base; | |||||
| draw_gpencil_object_strokes(C, scene, depsgraph,v3d, ar, base); | |||||
| } | |||||
| } | |||||
| /* free memory */ | |||||
| if (cache) { | |||||
| MEM_freeN(cache); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Shared by #ED_view3d_draw_offscreen and #view3d_main_region_draw_objects | * Shared by #ED_view3d_draw_offscreen and #view3d_main_region_draw_objects | ||||
| * | * | ||||
| Context not available. | |||||
| bool do_composite_xray = false; | bool do_composite_xray = false; | ||||
| bool xrayclear = true; | bool xrayclear = true; | ||||
| int gp_cache_used = 0; | |||||
| int gp_cache_size = 0; | |||||
| tGPencilSort *gp_cache = NULL; | |||||
| if (!draw_offscreen) { | if (!draw_offscreen) { | ||||
| ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); | ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0); | draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0); | ||||
| /* draw grease pencil */ | |||||
| if (base->object->type == OB_GPENCIL) { | |||||
| /* allocate memory for saving gp objects */ | |||||
| gp_cache = ED_gpencil_allocate_cache(gp_cache, &gp_cache_size, gp_cache_used); | |||||
| /* add for drawing later */ | |||||
| ED_gpencil_add_to_cache(gp_cache, rv3d, base, &gp_cache_used); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| /* draw pending gpencil strokes */ | |||||
| gpencil_draw_objects(C, scene, depsgraph, v3d, ar, gp_cache, gp_cache_used); | |||||
| } | } | ||||
| else { | else { | ||||
| unsigned int lay_used = 0; | unsigned int lay_used = 0; | ||||
| Context not available. | |||||
| draw_dupli_objects(eval_ctx, scene, view_layer, ar, v3d, base); | draw_dupli_objects(eval_ctx, scene, view_layer, ar, v3d, base); | ||||
| } | } | ||||
| if ((base->flag & BASE_SELECTED) == 0) { | if ((base->flag & BASE_SELECTED) == 0) { | ||||
| if (base->object != obedit) | if (base->object != obedit) { | ||||
| draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0); | draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0); | ||||
| /* draw grease pencil */ | |||||
| if (base->object->type == OB_GPENCIL) { | |||||
| /* allocate memory for saving gp objects */ | |||||
| gp_cache = ED_gpencil_allocate_cache(gp_cache, &gp_cache_size, gp_cache_used); | |||||
| /* add for drawing later */ | |||||
| ED_gpencil_add_to_cache(gp_cache, rv3d, base, &gp_cache_used); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| if ((base->flag & BASE_VISIBLED) != 0) { | if ((base->flag & BASE_VISIBLED) != 0) { | ||||
| if (base->object == obedit || (base->flag & BASE_SELECTED)) { | if (base->object == obedit || (base->flag & BASE_SELECTED)) { | ||||
| draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0); | draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0); | ||||
| /* draw grease pencil */ | |||||
| if (base->object->type == OB_GPENCIL) { | |||||
| /* allocate memory for saving gp objects */ | |||||
| gp_cache = ED_gpencil_allocate_cache(gp_cache, &gp_cache_size, gp_cache_used); | |||||
| /* add for drawing later */ | |||||
| ED_gpencil_add_to_cache(gp_cache, rv3d, base, &gp_cache_used); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* draw pending gpencil strokes */ | |||||
| gpencil_draw_objects(C, scene, depsgraph, v3d, ar, gp_cache, gp_cache_used); | |||||
| } | } | ||||
| /* 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 */ | ||||
| Context not available. | |||||
| if (v3d->flag2 & V3D_SHOW_GPENCIL) { | if (v3d->flag2 & V3D_SHOW_GPENCIL) { | ||||
| /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ | /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ | ||||
| ED_gpencil_draw_view3d(wm, scene, view_layer, depsgraph, v3d, ar, false); | ED_gpencil_draw_view3d(wm, scene, view_layer, depsgraph, v3d, ar, false); | ||||
| Object *obact = CTX_data_active_object(C); | |||||
| if (obact && obact->type == OB_GPENCIL) { | |||||
| ED_gpencil_draw_view3d_object(wm, scene, depsgraph, obact, v3d, ar, false); | |||||
| } | |||||
| } | } | ||||
| if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | ||||
| Context not available. | |||||