Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/gpencil/gpencil_draw_utils.c
| Context not available. | |||||
| MEM_SAFE_FREE(uv); | MEM_SAFE_FREE(uv); | ||||
| } | } | ||||
| /* Check if stencil is required */ | |||||
| static bool gpencil_is_stencil_required(MaterialGPencilStyle *gp_style) | |||||
| { | |||||
| return (bool)(gp_style->stroke_style == GP_STYLE_STROKE_STYLE_SOLID); | |||||
| } | |||||
| /* draw stroke in drawing buffer */ | /* draw stroke in drawing buffer */ | ||||
| void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, | void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, | ||||
| void *vedata, | void *vedata, | ||||
| Context not available. | |||||
| false, | false, | ||||
| 1.0f, | 1.0f, | ||||
| (const int *)stl->storage->shade_render); | (const int *)stl->storage->shade_render); | ||||
| if (gpencil_is_stencil_required(gp_style)) { | |||||
| DRW_shgroup_stencil_mask(stl->g_data->shgrps_drawing_stroke, 0x01); | |||||
| } | |||||
| else { | |||||
| /* Disable stencil for this type */ | |||||
| DRW_shgroup_state_disable(stl->g_data->shgrps_drawing_stroke, | |||||
| DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| stl->g_data->shgrps_drawing_stroke = DRW_gpencil_shgroup_point_create( | stl->g_data->shgrps_drawing_stroke = DRW_gpencil_shgroup_point_create( | ||||
| Context not available. | |||||
| false, | false, | ||||
| 1.0f, | 1.0f, | ||||
| (const int *)stl->storage->shade_render); | (const int *)stl->storage->shade_render); | ||||
| /* Disable stencil for this type */ | |||||
| DRW_shgroup_state_disable(stl->g_data->shgrps_drawing_stroke, | |||||
| DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL); | |||||
| } | } | ||||
| /* use unit matrix because the buffer is in screen space and does not need conversion */ | /* use unit matrix because the buffer is in screen space and does not need conversion */ | ||||
| Context not available. | |||||
| } | } | ||||
| stl->g_data->shgrps_drawing_fill = DRW_shgroup_create(e_data->gpencil_drawing_fill_sh, | stl->g_data->shgrps_drawing_fill = DRW_shgroup_create(e_data->gpencil_drawing_fill_sh, | ||||
| psl->drawing_pass); | psl->drawing_pass); | ||||
| /* Disable stencil for this type */ | |||||
| DRW_shgroup_state_disable(stl->g_data->shgrps_drawing_stroke, | |||||
| DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL); | |||||
| stl->g_data->batch_buffer_fill = DRW_gpencil_get_buffer_fill_geom(gpd); | stl->g_data->batch_buffer_fill = DRW_gpencil_get_buffer_fill_geom(gpd); | ||||
| DRW_shgroup_call(stl->g_data->shgrps_drawing_fill, stl->g_data->batch_buffer_fill, NULL); | DRW_shgroup_call(stl->g_data->shgrps_drawing_fill, stl->g_data->batch_buffer_fill, NULL); | ||||
| Context not available. | |||||
| int start_edit = 0; | int start_edit = 0; | ||||
| int start_edlin = 0; | int start_edlin = 0; | ||||
| uint stencil_id = 1; | |||||
| for (int i = 0; i < cache->grp_used; i++) { | for (int i = 0; i < cache->grp_used; i++) { | ||||
| elm = &cache->grp_cache[i]; | elm = &cache->grp_cache[i]; | ||||
| array_elm = &cache_ob->shgrp_array[idx]; | array_elm = &cache_ob->shgrp_array[idx]; | ||||
| const float scale = cache_ob->scale; | const float scale = cache_ob->scale; | ||||
| /* Limit stencil id */ | |||||
| if (stencil_id > 255) { | |||||
| stencil_id = 1; | |||||
| } | |||||
| /* save last group when change */ | /* save last group when change */ | ||||
| if (gpl_prev == NULL) { | if (gpl_prev == NULL) { | ||||
| gpl_prev = elm->gpl; | gpl_prev = elm->gpl; | ||||
| Context not available. | |||||
| } | } | ||||
| stl->storage->shgroup_id++; | stl->storage->shgroup_id++; | ||||
| start_stroke = elm->vertex_idx; | start_stroke = elm->vertex_idx; | ||||
| /* set stencil mask id */ | |||||
| if (gpencil_is_stencil_required(gp_style)) { | |||||
| DRW_shgroup_stencil_mask(shgrp, stencil_id); | |||||
| stencil_id++; | |||||
| } | |||||
| else { | |||||
| /* Disable stencil for this type */ | |||||
| DRW_shgroup_state_disable(shgrp, DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL); | |||||
| /* set stencil mask id as not used */ | |||||
| DRW_shgroup_stencil_mask(shgrp, 0x0); | |||||
fclem: Not needed | |||||
antoniovAuthorUnsubmitted Done Inline ActionsI need this to check if stencil is used to limit the clean. antoniov: I need this to check if stencil is used to limit the clean. | |||||
| } | |||||
| break; | break; | ||||
| } | } | ||||
| case eGpencilBatchGroupType_Point: { | case eGpencilBatchGroupType_Point: { | ||||
| Context not available. | |||||
| } | } | ||||
| stl->storage->shgroup_id++; | stl->storage->shgroup_id++; | ||||
| start_point = elm->vertex_idx; | start_point = elm->vertex_idx; | ||||
| /* Disable stencil for this type */ | |||||
| DRW_shgroup_state_disable(shgrp, DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL); | |||||
| /* set stencil mask id as not used */ | |||||
| DRW_shgroup_stencil_mask(shgrp, 0x0); | |||||
fclemUnsubmitted Not Done Inline ActionsSame thing, DRW_shgroup_stencil_mask not needed. fclem: Same thing, DRW_shgroup_stencil_mask not needed. | |||||
| break; | break; | ||||
| } | } | ||||
| case eGpencilBatchGroupType_Fill: { | case eGpencilBatchGroupType_Fill: { | ||||
| Context not available. | |||||
| } | } | ||||
| stl->storage->shgroup_id++; | stl->storage->shgroup_id++; | ||||
| start_fill = elm->vertex_idx; | start_fill = elm->vertex_idx; | ||||
| /* Disable stencil for this type */ | |||||
| DRW_shgroup_state_disable(shgrp, DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL); | |||||
| /* set stencil mask id as not used */ | |||||
| DRW_shgroup_stencil_mask(shgrp, 0x0); | |||||
fclemUnsubmitted Not Done Inline Actionsand here fclem: and here | |||||
| break; | break; | ||||
| } | } | ||||
| case eGpencilBatchGroupType_Edit: { | case eGpencilBatchGroupType_Edit: { | ||||
| Context not available. | |||||
Not needed