diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/draw/modes/edit_armature_mode.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/draw/modes/edit_armature_mode.c')
-rw-r--r-- | source/blender/draw/modes/edit_armature_mode.c | 273 |
1 files changed, 137 insertions, 136 deletions
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c index e2af2f10779..12bf4982ffb 100644 --- a/source/blender/draw/modes/edit_armature_mode.c +++ b/source/blender/draw/modes/edit_armature_mode.c @@ -33,169 +33,170 @@ /* *********** LISTS *********** */ typedef struct EDIT_ARMATURE_PassList { - struct DRWPass *bone_solid[2]; - struct DRWPass *bone_transp[2]; - struct DRWPass *bone_wire[2]; - struct DRWPass *bone_outline[2]; - struct DRWPass *bone_envelope[2]; - struct DRWPass *bone_axes; - struct DRWPass *relationship[2]; + struct DRWPass *bone_solid[2]; + struct DRWPass *bone_transp[2]; + struct DRWPass *bone_wire[2]; + struct DRWPass *bone_outline[2]; + struct DRWPass *bone_envelope[2]; + struct DRWPass *bone_axes; + struct DRWPass *relationship[2]; } EDIT_ARMATURE_PassList; typedef struct EDIT_ARMATURE_StorageList { - struct EDIT_ARMATURE_PrivateData *g_data; + struct EDIT_ARMATURE_PrivateData *g_data; } EDIT_ARMATURE_StorageList; typedef struct EDIT_ARMATURE_Data { - void *engine_type; - DRWViewportEmptyList *fbl; - DRWViewportEmptyList *txl; - EDIT_ARMATURE_PassList *psl; - EDIT_ARMATURE_StorageList *stl; + void *engine_type; + DRWViewportEmptyList *fbl; + DRWViewportEmptyList *txl; + EDIT_ARMATURE_PassList *psl; + EDIT_ARMATURE_StorageList *stl; } EDIT_ARMATURE_Data; /* *********** STATIC *********** */ typedef struct EDIT_ARMATURE_PrivateData { - bool transparent_bones; + bool transparent_bones; } EDIT_ARMATURE_PrivateData; /* Transient data */ /* *********** FUNCTIONS *********** */ static void EDIT_ARMATURE_cache_init(void *vedata) { - EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl; - EDIT_ARMATURE_StorageList *stl = ((EDIT_ARMATURE_Data *)vedata)->stl; - const DRWContextState *draw_ctx = DRW_context_state_get(); - - if (!stl->g_data) { - /* Alloc transient pointers */ - stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__); - } - stl->g_data->transparent_bones = (draw_ctx->v3d->shading.type == OB_WIRE); - - for (int i = 0; i < 2; ++i) { - /* Solid bones */ - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK; - psl->bone_solid[i] = DRW_pass_create("Bone Solid Pass", state | DRW_STATE_WRITE_DEPTH); - psl->bone_transp[i] = DRW_pass_create("Bone Transp Pass", state | DRW_STATE_BLEND); - - /* Bones Outline */ - state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; - psl->bone_outline[i] = DRW_pass_create("Bone Outline Pass", state); - - /* Wire bones */ - state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND; - psl->bone_wire[i] = DRW_pass_create("Bone Wire Pass", state); - - /* distance outline around envelope bones */ - state = DRW_STATE_ADDITIVE | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_FRONT; - psl->bone_envelope[i] = DRW_pass_create("Bone Envelope Outline Pass", state); - - state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | - DRW_STATE_BLEND | DRW_STATE_WIRE; - psl->relationship[i] = DRW_pass_create("Bone Relationship Pass", state); - } - - { - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WIRE_SMOOTH | DRW_STATE_BLEND; - psl->bone_axes = DRW_pass_create("Bone Axes Pass", state); - } + EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl; + EDIT_ARMATURE_StorageList *stl = ((EDIT_ARMATURE_Data *)vedata)->stl; + const DRWContextState *draw_ctx = DRW_context_state_get(); + + if (!stl->g_data) { + /* Alloc transient pointers */ + stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__); + } + stl->g_data->transparent_bones = (draw_ctx->v3d->shading.type == OB_WIRE); + + for (int i = 0; i < 2; ++i) { + /* Solid bones */ + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK; + psl->bone_solid[i] = DRW_pass_create("Bone Solid Pass", state | DRW_STATE_WRITE_DEPTH); + psl->bone_transp[i] = DRW_pass_create("Bone Transp Pass", state | DRW_STATE_BLEND); + + /* Bones Outline */ + state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; + psl->bone_outline[i] = DRW_pass_create("Bone Outline Pass", state); + + /* Wire bones */ + state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | + DRW_STATE_BLEND; + psl->bone_wire[i] = DRW_pass_create("Bone Wire Pass", state); + + /* distance outline around envelope bones */ + state = DRW_STATE_ADDITIVE | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | + DRW_STATE_CULL_FRONT; + psl->bone_envelope[i] = DRW_pass_create("Bone Envelope Outline Pass", state); + + state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | + DRW_STATE_BLEND | DRW_STATE_WIRE; + psl->relationship[i] = DRW_pass_create("Bone Relationship Pass", state); + } + + { + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WIRE_SMOOTH | DRW_STATE_BLEND; + psl->bone_axes = DRW_pass_create("Bone Axes Pass", state); + } } static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob) { - bArmature *arm = ob->data; - - if (ob->type == OB_ARMATURE) { - if (arm->edbo) { - EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl; - EDIT_ARMATURE_StorageList *stl = ((EDIT_ARMATURE_Data *)vedata)->stl; - const DRWContextState *draw_ctx = DRW_context_state_get(); - - int ghost = (ob->dtx & OB_DRAWXRAY) ? 1 : 0; - bool transp = (stl->g_data->transparent_bones || (ob->dt <= OB_WIRE)) || XRAY_FLAG_ENABLED(draw_ctx->v3d); - - DRWArmaturePasses passes = { - .bone_solid = (transp) ? psl->bone_transp[ghost] : psl->bone_solid[ghost], - .bone_outline = psl->bone_outline[ghost], - .bone_wire = psl->bone_wire[ghost], - .bone_envelope = psl->bone_envelope[ghost], - .bone_axes = psl->bone_axes, - .relationship_lines = psl->relationship[ghost], - }; - DRW_shgroup_armature_edit(ob, passes, transp); - } - } + bArmature *arm = ob->data; + + if (ob->type == OB_ARMATURE) { + if (arm->edbo) { + EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl; + EDIT_ARMATURE_StorageList *stl = ((EDIT_ARMATURE_Data *)vedata)->stl; + const DRWContextState *draw_ctx = DRW_context_state_get(); + + int ghost = (ob->dtx & OB_DRAWXRAY) ? 1 : 0; + bool transp = (stl->g_data->transparent_bones || (ob->dt <= OB_WIRE)) || + XRAY_FLAG_ENABLED(draw_ctx->v3d); + + DRWArmaturePasses passes = { + .bone_solid = (transp) ? psl->bone_transp[ghost] : psl->bone_solid[ghost], + .bone_outline = psl->bone_outline[ghost], + .bone_wire = psl->bone_wire[ghost], + .bone_envelope = psl->bone_envelope[ghost], + .bone_axes = psl->bone_axes, + .relationship_lines = psl->relationship[ghost], + }; + DRW_shgroup_armature_edit(ob, passes, transp); + } + } } static void EDIT_ARMATURE_draw_scene(void *vedata) { - EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl; - DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - - if (DRW_state_is_select()) { - DRW_draw_pass(psl->bone_outline[0]); - DRW_draw_pass(psl->bone_solid[0]); - DRW_draw_pass(psl->bone_wire[0]); - DRW_draw_pass(psl->bone_outline[1]); - DRW_draw_pass(psl->bone_solid[1]); - DRW_draw_pass(psl->bone_wire[1]); - return; - } - - DRW_draw_pass(psl->bone_envelope[0]); - - /* For performance reason, avoid blending on MS target. */ - DRW_draw_pass(psl->bone_transp[0]); - - MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl); - - DRW_draw_pass(psl->bone_solid[0]); - DRW_draw_pass(psl->bone_outline[0]); - DRW_draw_pass(psl->bone_wire[0]); - DRW_draw_pass(psl->relationship[0]); - - MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl); - - if (!DRW_pass_is_empty(psl->bone_envelope[1]) || - !DRW_pass_is_empty(psl->bone_solid[1]) || - !DRW_pass_is_empty(psl->bone_transp[1]) || - !DRW_pass_is_empty(psl->bone_outline[1]) || - !DRW_pass_is_empty(psl->bone_wire[1]) || - !DRW_pass_is_empty(psl->relationship[1])) - { - if (DRW_state_is_fbo()) { - GPU_framebuffer_bind(dfbl->default_fb); - GPU_framebuffer_clear_depth(dfbl->default_fb, 1.0f); - } - - DRW_draw_pass(psl->bone_envelope[1]); - DRW_draw_pass(psl->bone_solid[1]); - DRW_draw_pass(psl->bone_transp[1]); - DRW_draw_pass(psl->bone_outline[1]); - DRW_draw_pass(psl->bone_wire[1]); - DRW_draw_pass(psl->relationship[1]); - } - - /* Draw axes with linesmooth and outside of multisample buffer. */ - DRW_draw_pass(psl->bone_axes); + EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl; + DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); + DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + + if (DRW_state_is_select()) { + DRW_draw_pass(psl->bone_outline[0]); + DRW_draw_pass(psl->bone_solid[0]); + DRW_draw_pass(psl->bone_wire[0]); + DRW_draw_pass(psl->bone_outline[1]); + DRW_draw_pass(psl->bone_solid[1]); + DRW_draw_pass(psl->bone_wire[1]); + return; + } + + DRW_draw_pass(psl->bone_envelope[0]); + + /* For performance reason, avoid blending on MS target. */ + DRW_draw_pass(psl->bone_transp[0]); + + MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl); + + DRW_draw_pass(psl->bone_solid[0]); + DRW_draw_pass(psl->bone_outline[0]); + DRW_draw_pass(psl->bone_wire[0]); + DRW_draw_pass(psl->relationship[0]); + + MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl); + + if (!DRW_pass_is_empty(psl->bone_envelope[1]) || !DRW_pass_is_empty(psl->bone_solid[1]) || + !DRW_pass_is_empty(psl->bone_transp[1]) || !DRW_pass_is_empty(psl->bone_outline[1]) || + !DRW_pass_is_empty(psl->bone_wire[1]) || !DRW_pass_is_empty(psl->relationship[1])) { + if (DRW_state_is_fbo()) { + GPU_framebuffer_bind(dfbl->default_fb); + GPU_framebuffer_clear_depth(dfbl->default_fb, 1.0f); + } + + DRW_draw_pass(psl->bone_envelope[1]); + DRW_draw_pass(psl->bone_solid[1]); + DRW_draw_pass(psl->bone_transp[1]); + DRW_draw_pass(psl->bone_outline[1]); + DRW_draw_pass(psl->bone_wire[1]); + DRW_draw_pass(psl->relationship[1]); + } + + /* Draw axes with linesmooth and outside of multisample buffer. */ + DRW_draw_pass(psl->bone_axes); } -static const DrawEngineDataSize EDIT_ARMATURE_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_ARMATURE_Data); +static const DrawEngineDataSize EDIT_ARMATURE_data_size = DRW_VIEWPORT_DATA_SIZE( + EDIT_ARMATURE_Data); DrawEngineType draw_engine_edit_armature_type = { - NULL, NULL, - N_("EditArmatureMode"), - &EDIT_ARMATURE_data_size, - NULL, - NULL, - &EDIT_ARMATURE_cache_init, - &EDIT_ARMATURE_cache_populate, - NULL, - NULL, - &EDIT_ARMATURE_draw_scene, - NULL, - NULL, + NULL, + NULL, + N_("EditArmatureMode"), + &EDIT_ARMATURE_data_size, + NULL, + NULL, + &EDIT_ARMATURE_cache_init, + &EDIT_ARMATURE_cache_populate, + NULL, + NULL, + &EDIT_ARMATURE_draw_scene, + NULL, + NULL, }; |