Edit Mode overlay: fast navigate
This commit is contained in:
parent
26fc6c71c4
commit
043c90fdcd
|
@ -27,6 +27,7 @@
|
|||
#include "DRW_render.h"
|
||||
|
||||
#include "GPU_shader.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
#include "draw_mode_pass.h"
|
||||
|
||||
|
@ -50,10 +51,15 @@ void EDIT_MESH_cache_init(void)
|
|||
{
|
||||
EDIT_MESH_PassList *psl = DRW_mode_pass_list_get();
|
||||
static struct GPUShader *depth_sh;
|
||||
static struct GPUShader *over_tri_sh, *over_vert_sh, *over_edge_sh;
|
||||
static struct GPUShader *over_tri_sh, *over_vert_sh, *over_edge_sh, *over_tri_fast_sh;
|
||||
|
||||
const struct bContext *C = DRW_get_context();
|
||||
struct RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
|
||||
if (!depth_sh)
|
||||
depth_sh = DRW_shader_create_3D_depth_only();
|
||||
if (!over_tri_fast_sh)
|
||||
over_tri_fast_sh = GPU_shader_get_builtin_shader(GPU_SHADER_EDGES_OVERLAY_EDIT_TRI_FAST);
|
||||
if (!over_tri_sh)
|
||||
over_tri_sh = GPU_shader_get_builtin_shader(GPU_SHADER_EDGES_OVERLAY_EDIT_TRI);
|
||||
if (!over_edge_sh)
|
||||
|
@ -65,7 +71,10 @@ void EDIT_MESH_cache_init(void)
|
|||
depth_shgrp_hidden_wire = DRW_shgroup_create(depth_sh, psl->depth_pass_hidden_wire);
|
||||
|
||||
psl->edit_face_overlay_pass = DRW_pass_create("Edit Mesh Face Overlay Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND);
|
||||
face_overlay_shgrp = DRW_shgroup_create(over_tri_sh, psl->edit_face_overlay_pass);
|
||||
if ((rv3d->rflag & RV3D_NAVIGATING) != 0)
|
||||
face_overlay_shgrp = DRW_shgroup_create(over_tri_fast_sh, psl->edit_face_overlay_pass);
|
||||
else
|
||||
face_overlay_shgrp = DRW_shgroup_create(over_tri_sh, psl->edit_face_overlay_pass);
|
||||
ledges_overlay_shgrp = DRW_shgroup_create(over_edge_sh, psl->edit_face_overlay_pass);
|
||||
lverts_overlay_shgrp = DRW_shgroup_create(over_vert_sh, psl->edit_face_overlay_pass);
|
||||
DRW_shgroup_uniform_vec2(face_overlay_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
|
||||
|
|
|
@ -819,8 +819,9 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even
|
|||
static void viewops_data_free(bContext *C, wmOperator *op)
|
||||
{
|
||||
ARegion *ar;
|
||||
#if 0
|
||||
Paint *p = BKE_paint_get_active_from_context(C);
|
||||
|
||||
#endif
|
||||
if (op->customdata) {
|
||||
ViewOpsData *vod = op->customdata;
|
||||
ar = vod->ar;
|
||||
|
@ -836,7 +837,9 @@ static void viewops_data_free(bContext *C, wmOperator *op)
|
|||
ar = CTX_wm_region(C);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (p && (p->flags & PAINT_FAST_NAVIGATE))
|
||||
#endif
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
/** \} */
|
||||
|
|
|
@ -101,6 +101,7 @@ typedef enum GPUBuiltinShader {
|
|||
GPU_SHADER_EDGES_FRONT_BACK_ORTHO,
|
||||
GPU_SHADER_EDGES_OVERLAY_SIMPLE,
|
||||
GPU_SHADER_EDGES_OVERLAY_EDIT_TRI,
|
||||
GPU_SHADER_EDGES_OVERLAY_EDIT_TRI_FAST,
|
||||
GPU_SHADER_EDGES_OVERLAY_EDIT_VERT,
|
||||
GPU_SHADER_EDGES_OVERLAY_EDIT_EDGE,
|
||||
GPU_SHADER_EDGES_OVERLAY,
|
||||
|
|
|
@ -675,6 +675,9 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
|||
[GPU_SHADER_EDGES_OVERLAY_EDIT_TRI] = { datatoc_gpu_shader_edit_overlay_vert_glsl,
|
||||
datatoc_gpu_shader_edit_overlay_frag_glsl,
|
||||
datatoc_gpu_shader_edit_overlay_geom_tri_glsl },
|
||||
[GPU_SHADER_EDGES_OVERLAY_EDIT_TRI_FAST] = { datatoc_gpu_shader_edit_overlay_vert_glsl,
|
||||
datatoc_gpu_shader_edit_overlay_frag_glsl,
|
||||
datatoc_gpu_shader_edit_overlay_geom_tri_glsl },
|
||||
[GPU_SHADER_EDGES_OVERLAY_EDIT_EDGE] = { datatoc_gpu_shader_edit_overlay_vert_glsl,
|
||||
datatoc_gpu_shader_edit_overlay_frag_glsl,
|
||||
datatoc_gpu_shader_edit_overlay_geom_edge_glsl },
|
||||
|
@ -775,6 +778,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
|||
/* just a few special cases */
|
||||
const char *defines = (shader == GPU_SHADER_SMOKE_COBA) ? "#define USE_COBA;\n" :
|
||||
(shader == GPU_SHADER_SIMPLE_LIGHTING) ? "#define USE_NORMALS;\n" :
|
||||
(shader == GPU_SHADER_EDGES_OVERLAY_EDIT_TRI) ? "#define EDGE_FIX;\n" :
|
||||
(shader == GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR) ? "#define USE_INSTANCE_COLOR;\n" : NULL;
|
||||
|
||||
const GPUShaderStages *stages = builtin_shader_stages + shader;
|
||||
|
|
|
@ -99,7 +99,7 @@ float getVertexSize(int v)
|
|||
|
||||
void colorDist(vec4 color, float width, inout float dist)
|
||||
{
|
||||
FragColor = mix(color, FragColor, smoothstep(0.0, transitionWidth, dist));
|
||||
FragColor = (dist - transitionWidth < 0) ? color : FragColor;
|
||||
dist += width;
|
||||
}
|
||||
|
||||
|
@ -191,4 +191,7 @@ void main()
|
|||
else
|
||||
colorDist(vec4(0.0, 0.0, 0.0, 1.0), vertexWidth, size);
|
||||
}
|
||||
|
||||
/* don't write depth if not opaque */
|
||||
if (FragColor.a == 0.0) discard;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
/* This shader follows the principles of
|
||||
* http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf */
|
||||
|
||||
//#define EDGE_FIX
|
||||
layout(triangles) in;
|
||||
|
||||
#ifdef EDGE_FIX
|
||||
|
|
Loading…
Reference in New Issue