21 PassMain wireframe_ps_ = {
"Wireframe"};
28 } colored, non_colored;
31 bool show_wire_ =
false;
33 bool enabled_ =
false;
39 (
state.is_wireframe_mode || !
state.hide_overlays);
48 const float wire_threshold = wire_discard_threshold_get(
state.overlay.wireframe_threshold);
53 auto &pass = wireframe_ps_;
57 state.clipping_plane_count);
61 [&](
GPUShader *shader,
const char *name,
bool use_coloring,
float wire_threshold) {
62 auto &sub = pass.sub(name);
64 sub.specialize_constant(shader,
"use_custom_depth_bias", do_smooth_lines);
66 sub.shader_set(shader);
68 sub.bind_texture(
"depthTex", depth_tex);
69 sub.push_constant(
"wireOpacity",
state.overlay.wireframe_opacity);
70 sub.push_constant(
"isTransform", is_transform);
71 sub.push_constant(
"colorType",
state.v3d->shading.wire_color_type);
72 sub.push_constant(
"useColoring", use_coloring);
73 sub.push_constant(
"wireStepParam", wire_threshold);
74 sub.push_constant(
"isHair",
false);
78 auto coloring_pass = [&](ColoringPass &ps,
bool use_color) {
80 ps.mesh_ps_ = shader_pass(sh.
wireframe_mesh.get(),
"Mesh", use_color, wire_threshold);
81 ps.mesh_all_edges_ps_ = shader_pass(sh.
wireframe_mesh.get(),
"Wire", use_color, 1.0f);
82 ps.pointcloud_ps_ = shader_pass(sh.
wireframe_points.get(),
"PtCloud", use_color, 1.0f);
83 ps.curves_ps_ = shader_pass(sh.
wireframe_curve.get(),
"Curve", use_color, 1.0f);
86 coloring_pass(non_colored,
false);
87 coloring_pass(colored,
true);
95 const bool in_edit_paint_mode)
108 ColoringPass &coloring = in_edit_paint_mode ? non_colored : colored;
112 coloring.curves_ps_->
draw(
118 coloring.curves_ps_->
draw(
124 coloring.curves_ps_->
draw(
132 if (show_surface_wire) {
135 coloring.curves_ps_->
draw(
141 if (show_surface_wire) {
143 (all_edges ? coloring.mesh_all_edges_ps_ : coloring.mesh_ps_)
151 if ((mesh->edges_num == 0) && (mesh->verts_num > 0)) {
153 coloring.pointcloud_ps_->
draw(
157 coloring.mesh_all_edges_ps_->
draw(
163 if (show_surface_wire) {
165 coloring.pointcloud_ps_->
draw(
175 coloring.pointcloud_ps_->
draw(
179 coloring.mesh_ps_->
draw(
198 manager.
submit(wireframe_ps_, view);
202 float wire_discard_threshold_get(
float threshold)
206 threshold =
sqrt(
abs(threshold));
@ USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE
@ VOLUME_WIREFRAME_POINTS
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
struct GPUShader GPUShader
ResourceHandle unique_handle(const ObjectRef &ref)
void submit(PassSimple &pass, View &view)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
static bool mesh_has_edit_cage(const Object *ob)
ShaderPtr wireframe_points
ShaderPtr wireframe_curve
void begin_sync(Resources &res, const State &state)
void object_sync(Manager &manager, const ObjectRef &ob_ref, const State &state, Resources &res, const bool in_edit_paint_mode)
void draw(Framebuffer &framebuffer, Manager &manager, View &view)
blender::gpu::Batch * DRW_cache_curve_edge_wire_get(Object *ob)
blender::gpu::Batch * DRW_cache_surf_edge_wire_get(Object *ob)
blender::gpu::Batch * DRW_cache_mesh_all_verts_get(Object *ob)
blender::gpu::Batch * DRW_cache_text_edge_wire_get(Object *ob)
blender::gpu::Batch * DRW_cache_mesh_face_wireframe_get(Object *ob)
blender::gpu::Batch * DRW_cache_mesh_loose_edges_get(Object *ob)
@ DRW_STATE_DEPTH_LESS_EQUAL
@ DRW_STATE_FIRST_VERTEX_CONVENTION
blender::gpu::Batch * DRW_cache_volume_face_wireframe_get(Object *ob)
blender::gpu::Batch * DRW_cache_grease_pencil_face_wireframe_get(const Scene *scene, Object *ob)
blender::gpu::Batch * DRW_pointcloud_batch_cache_get_dots(Object *ob)
T interpolate(const T &a, const T &b, const FactorT &t)
GPUUniformBuf * globals_buf
void select_bind(PassSimple &pass)
const ID select_id(const ObjectRef &ob_ref, uint sub_object_id=0)