Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/modes/edit_mesh_mode.c
| Show First 20 Lines • Show All 343 Lines • ▼ Show 20 Lines | static void edit_mesh_create_overlay_passes(float face_alpha, | ||||
| /* Faces */ | /* Faces */ | ||||
| passes->faces = DRW_pass_create("Edit Mesh Faces", DRW_STATE_WRITE_COLOR | statemod); | passes->faces = DRW_pass_create("Edit Mesh Faces", DRW_STATE_WRITE_COLOR | statemod); | ||||
| grp = shgrps->faces = DRW_shgroup_create(face_sh, passes->faces); | grp = shgrps->faces = DRW_shgroup_create(face_sh, passes->faces); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_float_copy(grp, "faceAlphaMod", face_alpha); | DRW_shgroup_uniform_float_copy(grp, "faceAlphaMod", face_alpha); | ||||
| DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1); | DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face); | DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| /* Cage geom needs to be offsetted to avoid Z-fighting. */ | /* Cage geom needs to be offsetted to avoid Z-fighting. */ | ||||
| passes->faces_cage = DRW_pass_create("Edit Mesh Faces Cage", DRW_STATE_WRITE_COLOR | statemod); | passes->faces_cage = DRW_pass_create("Edit Mesh Faces Cage", DRW_STATE_WRITE_COLOR | statemod); | ||||
| grp = shgrps->faces_cage = DRW_shgroup_create(face_sh, passes->faces_cage); | grp = shgrps->faces_cage = DRW_shgroup_create(face_sh, passes->faces_cage); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_float_copy(grp, "faceAlphaMod", face_alpha); | DRW_shgroup_uniform_float_copy(grp, "faceAlphaMod", face_alpha); | ||||
| DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1); | DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face); | DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| /* Edges */ | /* Edges */ | ||||
| /* Change first vertex convention to match blender loop structure. */ | /* Change first vertex convention to match blender loop structure. */ | ||||
| passes->edges = DRW_pass_create( | passes->edges = DRW_pass_create( | ||||
| "Edit Mesh Edges", DRW_STATE_WRITE_COLOR | DRW_STATE_FIRST_VERTEX_CONVENTION | statemod); | "Edit Mesh Edges", DRW_STATE_WRITE_COLOR | DRW_STATE_FIRST_VERTEX_CONVENTION | statemod); | ||||
| grp = shgrps->edges = DRW_shgroup_create(edge_sh, passes->edges); | grp = shgrps->edges = DRW_shgroup_create(edge_sh, passes->edges); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1); | DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1); | ||||
| DRW_shgroup_uniform_vec2(grp, "viewportSizeInv", DRW_viewport_invert_size_get(), 1); | DRW_shgroup_uniform_vec2(grp, "viewportSizeInv", DRW_viewport_invert_size_get(), 1); | ||||
| DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1); | DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "selectEdges", do_edges || select_edge); | DRW_shgroup_uniform_bool_copy(grp, "selectEdges", do_edges || select_edge); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| /* Verts */ | /* Verts */ | ||||
| DRWState state = (DRW_STATE_WRITE_COLOR | statemod) & ~DRW_STATE_BLEND_ALPHA; | DRWState state = (DRW_STATE_WRITE_COLOR | statemod) & ~DRW_STATE_BLEND_ALPHA; | ||||
| passes->verts = DRW_pass_create("Edit Mesh Verts", state); | passes->verts = DRW_pass_create("Edit Mesh Verts", state); | ||||
| if (select_vert) { | if (select_vert) { | ||||
| grp = shgrps->verts = DRW_shgroup_create(vert_sh, passes->verts); | grp = shgrps->verts = DRW_shgroup_create(vert_sh, passes->verts); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1); | DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| } | } | ||||
| if (select_face) { | if (select_face) { | ||||
| grp = shgrps->facedots = DRW_shgroup_create(facedot_sh, passes->verts); | grp = shgrps->facedots = DRW_shgroup_create(facedot_sh, passes->verts); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_state_enable(grp, DRW_STATE_WRITE_DEPTH); | DRW_shgroup_state_enable(grp, DRW_STATE_WRITE_DEPTH); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void EDIT_MESH_cache_init(void *vedata) | static void EDIT_MESH_cache_init(void *vedata) | ||||
| { | { | ||||
| EDIT_MESH_PassList *psl = ((EDIT_MESH_Data *)vedata)->psl; | EDIT_MESH_PassList *psl = ((EDIT_MESH_Data *)vedata)->psl; | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | float face_mod = (do_occlude_wire || !g_data->do_faces) ? 0.0f : 1.0f; | ||||
| psl->weight_faces = DRW_pass_create( | psl->weight_faces = DRW_pass_create( | ||||
| "Weight Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL); | "Weight Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL); | ||||
| g_data->fweights_shgrp = DRW_shgroup_create(sh_data->weight_face, psl->weight_faces); | g_data->fweights_shgrp = DRW_shgroup_create(sh_data->weight_face, psl->weight_faces); | ||||
| DRW_shgroup_uniform_float_copy(g_data->fweights_shgrp, "opacity", 1.0); | DRW_shgroup_uniform_float_copy(g_data->fweights_shgrp, "opacity", 1.0); | ||||
| DRW_shgroup_uniform_texture(g_data->fweights_shgrp, "colorramp", G_draw.weight_ramp); | DRW_shgroup_uniform_texture(g_data->fweights_shgrp, "colorramp", G_draw.weight_ramp); | ||||
| DRW_shgroup_uniform_block(g_data->fweights_shgrp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(g_data->fweights_shgrp, "globalsBlock", G_draw.block_ubo); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(g_data->fweights_shgrp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(g_data->fweights_shgrp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| /* Complementary Depth Pass */ | /* Complementary Depth Pass */ | ||||
| psl->depth_hidden_wire = DRW_pass_create("Depth Pass Hidden Wire", | psl->depth_hidden_wire = DRW_pass_create("Depth Pass Hidden Wire", | ||||
| DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | | ||||
| DRW_STATE_CULL_BACK); | DRW_STATE_CULL_BACK); | ||||
| g_data->depth_shgrp_hidden_wire = DRW_shgroup_create(sh_data->depth, psl->depth_hidden_wire); | g_data->depth_shgrp_hidden_wire = DRW_shgroup_create(sh_data->depth, psl->depth_hidden_wire); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(g_data->depth_shgrp_hidden_wire, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(g_data->depth_shgrp_hidden_wire, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| psl->depth_hidden_wire_in_front = DRW_pass_create( | psl->depth_hidden_wire_in_front = DRW_pass_create( | ||||
| "Depth Pass Hidden Wire In Front", | "Depth Pass Hidden Wire In Front", | ||||
| DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK); | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK); | ||||
| g_data->depth_shgrp_hidden_wire_in_front = DRW_shgroup_create(sh_data->depth, | g_data->depth_shgrp_hidden_wire_in_front = DRW_shgroup_create(sh_data->depth, | ||||
| psl->depth_hidden_wire_in_front); | psl->depth_hidden_wire_in_front); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(g_data->depth_shgrp_hidden_wire_in_front, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(g_data->depth_shgrp_hidden_wire_in_front, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| /* Normals */ | /* Normals */ | ||||
| psl->normals = DRW_pass_create("Edit Mesh Normals Pass", | psl->normals = DRW_pass_create("Edit Mesh Normals Pass", | ||||
| DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | | DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | | ||||
| DRW_STATE_DEPTH_LESS_EQUAL); | DRW_STATE_DEPTH_LESS_EQUAL); | ||||
| g_data->fnormals_shgrp = DRW_shgroup_create(sh_data->normals_face, psl->normals); | g_data->fnormals_shgrp = DRW_shgroup_create(sh_data->normals_face, psl->normals); | ||||
| DRW_shgroup_uniform_float_copy(g_data->fnormals_shgrp, "normalSize", size_normal); | DRW_shgroup_uniform_float_copy(g_data->fnormals_shgrp, "normalSize", size_normal); | ||||
| DRW_shgroup_uniform_vec4(g_data->fnormals_shgrp, "color", G_draw.block.colorNormal, 1); | DRW_shgroup_uniform_vec4(g_data->fnormals_shgrp, "color", G_draw.block.colorNormal, 1); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(g_data->fnormals_shgrp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(g_data->fnormals_shgrp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| g_data->vnormals_shgrp = DRW_shgroup_create(sh_data->normals, psl->normals); | g_data->vnormals_shgrp = DRW_shgroup_create(sh_data->normals, psl->normals); | ||||
| DRW_shgroup_uniform_float_copy(g_data->vnormals_shgrp, "normalSize", size_normal); | DRW_shgroup_uniform_float_copy(g_data->vnormals_shgrp, "normalSize", size_normal); | ||||
| DRW_shgroup_uniform_vec4(g_data->vnormals_shgrp, "color", G_draw.block.colorVNormal, 1); | DRW_shgroup_uniform_vec4(g_data->vnormals_shgrp, "color", G_draw.block.colorVNormal, 1); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(g_data->vnormals_shgrp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(g_data->vnormals_shgrp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| g_data->lnormals_shgrp = DRW_shgroup_create(sh_data->normals_loop, psl->normals); | g_data->lnormals_shgrp = DRW_shgroup_create(sh_data->normals_loop, psl->normals); | ||||
| DRW_shgroup_uniform_float_copy(g_data->lnormals_shgrp, "normalSize", size_normal); | DRW_shgroup_uniform_float_copy(g_data->lnormals_shgrp, "normalSize", size_normal); | ||||
| DRW_shgroup_uniform_vec4(g_data->lnormals_shgrp, "color", G_draw.block.colorLNormal, 1); | DRW_shgroup_uniform_vec4(g_data->lnormals_shgrp, "color", G_draw.block.colorLNormal, 1); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(g_data->lnormals_shgrp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(g_data->lnormals_shgrp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| /* Mesh Analysis Pass */ | /* Mesh Analysis Pass */ | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA; | ||||
| psl->mesh_analysis_pass = DRW_pass_create("Mesh Analysis", state); | psl->mesh_analysis_pass = DRW_pass_create("Mesh Analysis", state); | ||||
| g_data->mesh_analysis_shgrp = DRW_shgroup_create(sh_data->mesh_analysis, | g_data->mesh_analysis_shgrp = DRW_shgroup_create(sh_data->mesh_analysis, | ||||
| psl->mesh_analysis_pass); | psl->mesh_analysis_pass); | ||||
| DRW_shgroup_uniform_texture(g_data->mesh_analysis_shgrp, "weightTex", G_draw.weight_ramp); | DRW_shgroup_uniform_texture(g_data->mesh_analysis_shgrp, "weightTex", G_draw.weight_ramp); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(g_data->mesh_analysis_shgrp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(g_data->mesh_analysis_shgrp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| } | } | ||||
| /* For in front option */ | /* For in front option */ | ||||
| edit_mesh_create_overlay_passes(face_mod, | edit_mesh_create_overlay_passes(face_mod, | ||||
| g_data->data_mask, | g_data->data_mask, | ||||
| g_data->do_edges, | g_data->do_edges, | ||||
| DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA, | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA, | ||||
| Show All 28 Lines | if (g_data->do_faces) { | ||||
| /* however we loose the front faces value (because we need the depth of occluded wires and | /* however we loose the front faces value (because we need the depth of occluded wires and | ||||
| * faces are alpha blended ) so we recover them in a new pass. */ | * faces are alpha blended ) so we recover them in a new pass. */ | ||||
| shgrp = g_data->facefill_occluded_shgrp = DRW_shgroup_create(sh_data->overlay_facefill, | shgrp = g_data->facefill_occluded_shgrp = DRW_shgroup_create(sh_data->overlay_facefill, | ||||
| psl->facefill_occlude); | psl->facefill_occlude); | ||||
| DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_ivec4(shgrp, "dataMask", g_data->data_mask, 1); | DRW_shgroup_uniform_ivec4(shgrp, "dataMask", g_data->data_mask, 1); | ||||
| DRW_shgroup_uniform_bool_copy(shgrp, "selectFaces", select_face); | DRW_shgroup_uniform_bool_copy(shgrp, "selectFaces", select_face); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| shgrp = g_data->facefill_occluded_cage_shgrp = DRW_shgroup_create( | shgrp = g_data->facefill_occluded_cage_shgrp = DRW_shgroup_create( | ||||
| sh_data->overlay_facefill, psl->facefill_occlude_cage); | sh_data->overlay_facefill, psl->facefill_occlude_cage); | ||||
| DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_ivec4(shgrp, "dataMask", g_data->data_mask, 1); | DRW_shgroup_uniform_ivec4(shgrp, "dataMask", g_data->data_mask, 1); | ||||
| DRW_shgroup_uniform_bool_copy(shgrp, "selectFaces", select_face); | DRW_shgroup_uniform_bool_copy(shgrp, "selectFaces", select_face); | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (DRW_state_is_clipping_enabled()) { | ||||
| DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES); | DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| g_data->facefill_occluded_shgrp = NULL; | g_data->facefill_occluded_shgrp = NULL; | ||||
| } | } | ||||
| /* we need a full screen pass to combine the result */ | /* we need a full screen pass to combine the result */ | ||||
| ▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines | |||||