Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_metaball.cc
- This file was moved from source/blender/draw/engines/overlay/overlay_metaball.c.
| Show All 9 Lines | |||||
| #include "DNA_meta_types.h" | #include "DNA_meta_types.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "ED_mball.h" | #include "ED_mball.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.hh" | ||||
| void OVERLAY_metaball_cache_init(OVERLAY_Data *vedata) | void OVERLAY_metaball_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); | OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); | ||||
| #define BUF_INSTANCE DRW_shgroup_call_buffer_instance | #define BUF_INSTANCE DRW_shgroup_call_buffer_instance | ||||
| for (int i = 0; i < 2; i++) { | for (int i = 0; i < 2; i++) { | ||||
| DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : 0; | DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : | ||||
| DRWState(0); | |||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; | ||||
| DRW_PASS_CREATE(psl->metaball_ps[i], state | pd->clipping_state | infront_state); | DRW_PASS_CREATE(psl->metaball_ps[i], state | pd->clipping_state | infront_state); | ||||
| /* Reuse armature shader as it's perfect to outline ellipsoids. */ | /* Reuse armature shader as it's perfect to outline ellipsoids. */ | ||||
| struct GPUVertFormat *format = formats->instance_bone; | struct GPUVertFormat *format = formats->instance_bone; | ||||
| struct GPUShader *sh = OVERLAY_shader_armature_sphere(true); | struct GPUShader *sh = OVERLAY_shader_armature_sphere(true); | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->metaball_ps[i]); | DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->metaball_ps[i]); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| Show All 13 Lines | static void metaball_instance_data_set( | ||||
| OVERLAY_bone_instance_data_set_color(data, color); | OVERLAY_bone_instance_data_set_color(data, color); | ||||
| } | } | ||||
| void OVERLAY_edit_metaball_cache_populate(OVERLAY_Data *vedata, Object *ob) | void OVERLAY_edit_metaball_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| const bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0; | const bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0; | ||||
| const bool is_select = DRW_state_is_select(); | const bool is_select = DRW_state_is_select(); | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| MetaBall *mb = ob->data; | MetaBall *mb = static_cast<MetaBall *>(ob->data); | ||||
| const float *color; | const float *color; | ||||
| const float *col_radius = G_draw.block.color_mball_radius; | const float *col_radius = G_draw.block.color_mball_radius; | ||||
| const float *col_radius_select = G_draw.block.color_mball_radius_select; | const float *col_radius_select = G_draw.block.color_mball_radius_select; | ||||
| const float *col_stiffness = G_draw.block.color_mball_stiffness; | const float *col_stiffness = G_draw.block.color_mball_stiffness; | ||||
| const float *col_stiffness_select = G_draw.block.color_mball_stiffness_select; | const float *col_stiffness_select = G_draw.block.color_mball_stiffness_select; | ||||
| int select_id = 0; | int select_id = 0; | ||||
| Show All 29 Lines | if (is_select) { | ||||
| DRW_select_load_id(-1); | DRW_select_load_id(-1); | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_metaball_cache_populate(OVERLAY_Data *vedata, Object *ob) | void OVERLAY_metaball_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| const bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0; | const bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| MetaBall *mb = ob->data; | MetaBall *mb = static_cast<MetaBall *>(ob->data); | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| float *color; | float *color; | ||||
| DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); | DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); | ||||
| LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) { | LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) { | ||||
| /* Draw radius only. */ | /* Draw radius only. */ | ||||
| BoneInstanceData instdata; | BoneInstanceData instdata; | ||||
| Show All 18 Lines | |||||