Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_engine.c
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| OVERLAY_Data *data = vedata; | OVERLAY_Data *data = vedata; | ||||
| OVERLAY_StorageList *stl = data->stl; | OVERLAY_StorageList *stl = data->stl; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const RegionView3D *rv3d = draw_ctx->rv3d; | const RegionView3D *rv3d = draw_ctx->rv3d; | ||||
| const View3D *v3d = draw_ctx->v3d; | const View3D *v3d = draw_ctx->v3d; | ||||
| const Scene *scene = draw_ctx->scene; | const Scene *scene = draw_ctx->scene; | ||||
| const ToolSettings *ts = scene->toolsettings; | const ToolSettings *ts = scene->toolsettings; | ||||
| const SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; | |||||
| BLI_assert(v3d || sima); | |||||
| OVERLAY_shader_library_ensure(); | OVERLAY_shader_library_ensure(); | ||||
| if (!stl->pd) { | if (!stl->pd) { | ||||
| /* Alloc transient pointers */ | /* Alloc transient pointers */ | ||||
| stl->pd = MEM_callocN(sizeof(*stl->pd), __func__); | stl->pd = MEM_callocN(sizeof(*stl->pd), __func__); | ||||
| } | } | ||||
| OVERLAY_PrivateData *pd = stl->pd; | OVERLAY_PrivateData *pd = stl->pd; | ||||
| pd->is_image_editor = sima != NULL; | pd->space_type = v3d != NULL ? SPACE_VIEW3D : draw_ctx->space_data->spacetype; | ||||
| if (pd->is_image_editor) { | if (pd->space_type == SPACE_IMAGE) { | ||||
| const SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; | |||||
| pd->hide_overlays = (sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS) == 0; | pd->hide_overlays = (sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS) == 0; | ||||
| pd->clipping_state = 0; | pd->clipping_state = 0; | ||||
| OVERLAY_grid_init(data); | OVERLAY_grid_init(data); | ||||
| OVERLAY_edit_uv_init(data); | OVERLAY_edit_uv_init(data); | ||||
| return; | return; | ||||
| } | } | ||||
| if (pd->space_type == SPACE_NODE) { | |||||
| pd->hide_overlays = true; | |||||
| pd->clipping_state = 0; | |||||
| return; | |||||
| } | |||||
| pd->hide_overlays = (v3d->flag2 & V3D_HIDE_OVERLAYS) != 0; | pd->hide_overlays = (v3d->flag2 & V3D_HIDE_OVERLAYS) != 0; | ||||
| pd->ctx_mode = CTX_data_mode_enum_ex( | pd->ctx_mode = CTX_data_mode_enum_ex( | ||||
| draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode); | draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode); | ||||
| if (!pd->hide_overlays) { | if (!pd->hide_overlays) { | ||||
| pd->overlay = v3d->overlay; | pd->overlay = v3d->overlay; | ||||
| pd->v3d_flag = v3d->flag; | pd->v3d_flag = v3d->flag; | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void OVERLAY_cache_init(void *vedata) | static void OVERLAY_cache_init(void *vedata) | ||||
| { | { | ||||
| OVERLAY_Data *data = vedata; | OVERLAY_Data *data = vedata; | ||||
| OVERLAY_StorageList *stl = data->stl; | OVERLAY_StorageList *stl = data->stl; | ||||
| OVERLAY_PrivateData *pd = stl->pd; | OVERLAY_PrivateData *pd = stl->pd; | ||||
| if (pd->is_image_editor) { | if (pd->space_type == SPACE_IMAGE) { | ||||
| OVERLAY_background_cache_init(vedata); | OVERLAY_background_cache_init(vedata); | ||||
| OVERLAY_grid_cache_init(vedata); | OVERLAY_grid_cache_init(vedata); | ||||
| OVERLAY_edit_uv_cache_init(vedata); | OVERLAY_edit_uv_cache_init(vedata); | ||||
| return; | return; | ||||
| } | } | ||||
| if (pd->space_type == SPACE_NODE) { | |||||
| OVERLAY_background_cache_init(vedata); | |||||
| return; | |||||
| } | |||||
| switch (pd->ctx_mode) { | switch (pd->ctx_mode) { | ||||
| case CTX_MODE_EDIT_MESH: | case CTX_MODE_EDIT_MESH: | ||||
| OVERLAY_edit_mesh_cache_init(vedata); | OVERLAY_edit_mesh_cache_init(vedata); | ||||
| /* `pd->edit_mesh.flag` is valid after calling `OVERLAY_edit_mesh_cache_init`. */ | /* `pd->edit_mesh.flag` is valid after calling `OVERLAY_edit_mesh_cache_init`. */ | ||||
| const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); | const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); | ||||
| if (draw_edit_weights) { | if (draw_edit_weights) { | ||||
| OVERLAY_paint_cache_init(vedata); | OVERLAY_paint_cache_init(vedata); | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | static bool overlay_should_fade_object(Object *ob, Object *active_object) | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void OVERLAY_cache_populate(void *vedata, Object *ob) | static void OVERLAY_cache_populate(void *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_Data *data = vedata; | OVERLAY_Data *data = vedata; | ||||
| OVERLAY_PrivateData *pd = data->stl->pd; | OVERLAY_PrivateData *pd = data->stl->pd; | ||||
| if (pd->is_image_editor) { | if (pd->space_type == SPACE_IMAGE) { | ||||
| if (ob->type == OB_MESH) { | if (ob->type == OB_MESH) { | ||||
| OVERLAY_edit_uv_cache_populate(vedata, ob); | OVERLAY_edit_uv_cache_populate(vedata, ob); | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const bool is_select = DRW_state_is_select(); | const bool is_select = DRW_state_is_select(); | ||||
| ▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | if (dupli) { | ||||
| dupli->base_flag = ob->base_flag; | dupli->base_flag = ob->base_flag; | ||||
| } | } | ||||
| } | } | ||||
| static void OVERLAY_cache_finish(void *vedata) | static void OVERLAY_cache_finish(void *vedata) | ||||
| { | { | ||||
| OVERLAY_Data *data = vedata; | OVERLAY_Data *data = vedata; | ||||
| OVERLAY_PrivateData *pd = data->stl->pd; | OVERLAY_PrivateData *pd = data->stl->pd; | ||||
| if (pd->is_image_editor) { | if (ELEM(pd->space_type, SPACE_IMAGE, SPACE_NODE)) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* TODO(fclem): Only do this when really needed. */ | /* TODO(fclem): Only do this when really needed. */ | ||||
| { | { | ||||
| /* HACK we allocate the in front depth here to avoid the overhead when if is not needed. */ | /* HACK we allocate the in front depth here to avoid the overhead when if is not needed. */ | ||||
| DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| Show All 13 Lines | |||||
| static void OVERLAY_draw_scene(void *vedata) | static void OVERLAY_draw_scene(void *vedata) | ||||
| { | { | ||||
| OVERLAY_Data *data = vedata; | OVERLAY_Data *data = vedata; | ||||
| OVERLAY_PrivateData *pd = data->stl->pd; | OVERLAY_PrivateData *pd = data->stl->pd; | ||||
| OVERLAY_FramebufferList *fbl = data->fbl; | OVERLAY_FramebufferList *fbl = data->fbl; | ||||
| DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | ||||
| /* Needs to be done first as it modifies the scene color and depth buffer. */ | /* Needs to be done first as it modifies the scene color and depth buffer. */ | ||||
| if (!pd->is_image_editor) { | if (pd->space_type == SPACE_VIEW3D) { | ||||
| OVERLAY_image_scene_background_draw(vedata); | OVERLAY_image_scene_background_draw(vedata); | ||||
| } | } | ||||
| if (DRW_state_is_fbo()) { | if (DRW_state_is_fbo()) { | ||||
| const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | |||||
| GPU_framebuffer_bind(dfbl->overlay_only_fb); | GPU_framebuffer_bind(dfbl->overlay_only_fb); | ||||
| /* Don't clear background for the node editor. The node editor draws the background and we | |||||
| * need to mask out the image from the already drawn overlay color buffer. */ | |||||
| if (pd->space_type != SPACE_NODE) { | |||||
| const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | |||||
| GPU_framebuffer_clear_color(dfbl->overlay_only_fb, clear_col); | GPU_framebuffer_clear_color(dfbl->overlay_only_fb, clear_col); | ||||
| } | } | ||||
| } | |||||
| if (pd->is_image_editor) { | if (pd->space_type == SPACE_IMAGE) { | ||||
| OVERLAY_background_draw(data); | OVERLAY_background_draw(data); | ||||
| OVERLAY_grid_draw(data); | OVERLAY_grid_draw(data); | ||||
| if (DRW_state_is_fbo()) { | if (DRW_state_is_fbo()) { | ||||
| GPU_framebuffer_bind(dfbl->overlay_fb); | GPU_framebuffer_bind(dfbl->overlay_fb); | ||||
| } | } | ||||
| OVERLAY_edit_uv_draw(data); | OVERLAY_edit_uv_draw(data); | ||||
| return; | return; | ||||
| } | } | ||||
| if (pd->space_type == SPACE_NODE) { | |||||
| OVERLAY_background_draw(data); | |||||
| return; | |||||
| } | |||||
| OVERLAY_image_background_draw(vedata); | OVERLAY_image_background_draw(vedata); | ||||
| OVERLAY_background_draw(vedata); | OVERLAY_background_draw(vedata); | ||||
| OVERLAY_antialiasing_start(vedata); | OVERLAY_antialiasing_start(vedata); | ||||
| DRW_view_set_active(NULL); | DRW_view_set_active(NULL); | ||||
| ▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines | |||||