diff options
Diffstat (limited to 'source/blender/draw/engines/overlay')
5 files changed, 63 insertions, 22 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index 1da682ff01b..2345a110134 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -26,6 +26,7 @@ #include "DNA_armature_types.h" #include "DNA_constraint_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_view3d_types.h" @@ -39,6 +40,7 @@ #include "BKE_armature.h" #include "BKE_deform.h" #include "BKE_modifier.h" +#include "BKE_object.h" #include "DEG_depsgraph_query.h" @@ -52,6 +54,8 @@ #include "overlay_private.h" +#include "draw_cache_impl.h" + #define BONE_VAR(eBone, pchan, var) ((eBone) ? (eBone->var) : (pchan->var)) #define BONE_FLAG(eBone, pchan) ((eBone) ? (eBone->flag) : (pchan->bone->flag)) @@ -100,9 +104,6 @@ typedef struct ArmatureDrawContext { const ThemeWireColor *bcolor; /* pchan color */ } ArmatureDrawContext; -/** - * Return true if armature should be handled by the pose mode engine. - */ bool OVERLAY_armature_is_pose_mode(Object *ob, const DRWContextState *draw_ctx) { Object *active_ob = draw_ctx->obact; @@ -535,13 +536,22 @@ static void drw_shgroup_bone_custom_solid(ArmatureDrawContext *ctx, const float outline_color[4], Object *custom) { + /* The custom object is not an evaluated object, so its object->data field hasn't been replaced + * by #data_eval. This is bad since it gives preference to an object's evaluated mesh over any + * other data type, but supporting all evaluated geometry components would require a much larger + * refactor of this area. */ + Mesh *mesh = BKE_object_get_evaluated_mesh(custom); + if (mesh == NULL) { + return; + } + /* TODO(fclem): arg... less than ideal but we never iter on this object * to assure batch cache is valid. */ - drw_batch_cache_validate(custom); + DRW_mesh_batch_cache_validate(mesh); - struct GPUBatch *surf = DRW_cache_object_surface_get(custom); - struct GPUBatch *edges = DRW_cache_object_edge_detection_get(custom, NULL); - struct GPUBatch *ledges = DRW_cache_object_loose_edges_get(custom); + struct GPUBatch *surf = DRW_mesh_batch_cache_get_surface(mesh); + struct GPUBatch *edges = DRW_mesh_batch_cache_get_edge_detection(mesh, NULL); + struct GPUBatch *ledges = DRW_mesh_batch_cache_get_loose_edges(mesh); BoneInstanceData inst_data; DRWCallBuffer *buf; @@ -578,12 +588,16 @@ static void drw_shgroup_bone_custom_wire(ArmatureDrawContext *ctx, const float color[4], Object *custom) { + /* See comments in #drw_shgroup_bone_custom_solid. */ + Mesh *mesh = BKE_object_get_evaluated_mesh(custom); + if (mesh == NULL) { + return; + } /* TODO(fclem): arg... less than ideal but we never iter on this object * to assure batch cache is valid. */ - drw_batch_cache_validate(custom); - - struct GPUBatch *geom = DRW_cache_object_all_edges_get(custom); + DRW_mesh_batch_cache_validate(mesh); + struct GPUBatch *geom = DRW_mesh_batch_cache_get_all_edges(mesh); if (geom) { DRWCallBuffer *buf = custom_bone_instance_shgroup(ctx, ctx->custom_wire, geom); BoneInstanceData inst_data; @@ -1906,6 +1920,7 @@ static void draw_bone_name(ArmatureDrawContext *ctx, DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR, color); } + /** \} */ /* -------------------------------------------------------------------- */ @@ -2314,3 +2329,5 @@ void OVERLAY_pose_draw(OVERLAY_Data *vedata) DRW_draw_pass(psl->armature_ps[1]); } } + +/** \} */ diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 2bdceb5f3db..12db2bd02cf 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -703,6 +703,7 @@ DrawEngineType draw_engine_overlay_type = { &overlay_data_size, &OVERLAY_engine_init, &OVERLAY_engine_free, + NULL, /* instance_free */ &OVERLAY_cache_init, &OVERLAY_cache_populate, &OVERLAY_cache_finish, diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c index 2e9a9bc5c64..0608725d342 100644 --- a/source/blender/draw/engines/overlay/overlay_image.c +++ b/source/blender/draw/engines/overlay/overlay_image.c @@ -462,8 +462,6 @@ void OVERLAY_image_cache_finish(OVERLAY_Data *vedata) DRW_pass_sort_shgroup_z(psl->image_empties_back_ps); } -/* This function draws images that needs the view transform applied. - * It draws these images directly into the scene color buffer. */ void OVERLAY_image_scene_background_draw(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index def278f98df..8e7c3094062 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -510,6 +510,9 @@ void OVERLAY_xray_fade_draw(OVERLAY_Data *vedata); void OVERLAY_xray_depth_copy(OVERLAY_Data *vedata); void OVERLAY_xray_depth_infront_copy(OVERLAY_Data *vedata); +/** + * Return true if armature should be handled by the pose mode engine. + */ bool OVERLAY_armature_is_pose_mode(Object *ob, const struct DRWContextState *draw_ctx); void OVERLAY_armature_cache_init(OVERLAY_Data *vedata); void OVERLAY_armature_cache_populate(OVERLAY_Data *vedata, Object *ob); @@ -631,6 +634,10 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob); void OVERLAY_image_cache_finish(OVERLAY_Data *vedata); void OVERLAY_image_draw(OVERLAY_Data *vedata); void OVERLAY_image_background_draw(OVERLAY_Data *vedata); +/** + * This function draws images that needs the view transform applied. + * It draws these images directly into the scene color buffer. + */ void OVERLAY_image_scene_background_draw(OVERLAY_Data *vedata); void OVERLAY_image_in_front_draw(OVERLAY_Data *vedata); diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.c index fde376beeb2..449130c4c5b 100644 --- a/source/blender/draw/engines/overlay/overlay_wireframe.c +++ b/source/blender/draw/engines/overlay/overlay_wireframe.c @@ -237,7 +237,21 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, if (dupli && !init_dupli) { if (dupli->wire_shgrp && dupli->wire_geom) { if (dupli->base_flag == ob->base_flag) { - DRW_shgroup_call(dupli->wire_shgrp, dupli->wire_geom, ob); + /* Check for the special cases used below, assign specific theme colors to the shaders. */ + OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); + if (dupli->wire_shgrp == cb->extra_loose_points) { + float *color; + DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); + OVERLAY_extra_loose_points(cb, dupli->wire_geom, ob->obmat, color); + } + else if (dupli->wire_shgrp == cb->extra_wire) { + float *color; + DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); + OVERLAY_extra_wire(cb, dupli->wire_geom, ob->obmat, color); + } + else { + DRW_shgroup_call(dupli->wire_shgrp, dupli->wire_geom, ob); + } return; } } @@ -268,6 +282,9 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, } } + DRWShadingGroup *shgrp = NULL; + struct GPUBatch *geom = NULL; + /* Don't do that in edit Mesh mode, unless there is a modifier preview. */ if (use_wire && (!is_mesh || (!is_edit_mode || has_edit_mesh_cage))) { const bool is_sculpt_mode = ((ob->mode & OB_MODE_SCULPT) != 0) && (ob->sculpt != NULL); @@ -275,8 +292,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, !DRW_state_is_image_render(); const bool use_coloring = (use_wire && !is_edit_mode && !is_sculpt_mode && !has_edit_mesh_cage); - DRWShadingGroup *shgrp = NULL; - struct GPUBatch *geom = DRW_cache_object_face_wireframe_get(ob); + geom = DRW_cache_object_face_wireframe_get(ob); if (geom || use_sculpt_pbvh) { if (use_sculpt_pbvh) { @@ -300,11 +316,6 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, DRW_shgroup_call(shgrp, geom, ob); } } - - if (dupli) { - dupli->wire_shgrp = shgrp; - dupli->wire_geom = geom; - } } else if (is_mesh && (!is_edit_mode || has_edit_mesh_cage)) { OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); @@ -313,18 +324,25 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, /* Draw loose geometry. */ if (is_mesh_verts_only) { - struct GPUBatch *geom = DRW_cache_mesh_all_verts_get(ob); + geom = DRW_cache_mesh_all_verts_get(ob); if (geom) { OVERLAY_extra_loose_points(cb, geom, ob->obmat, color); + shgrp = cb->extra_loose_points; } } else { - struct GPUBatch *geom = DRW_cache_mesh_loose_edges_get(ob); + geom = DRW_cache_mesh_loose_edges_get(ob); if (geom) { OVERLAY_extra_wire(cb, geom, ob->obmat, color); + shgrp = cb->extra_wire; } } } + + if (dupli) { + dupli->wire_shgrp = shgrp; + dupli->wire_geom = geom; + } } void OVERLAY_wireframe_draw(OVERLAY_Data *data) |