34 PassMain wireframe_ps_ = {
"Wireframe"};
41 } colored, non_colored;
45 bool do_depth_copy_workaround_ =
false;
48 bool show_wire_ =
false;
58 show_wire_ =
state.is_wireframe_mode ||
state.show_wireframes();
60 const bool is_selection = res.is_selection();
63 const float wire_threshold = wire_discard_threshold_get(
state.overlay.wireframe_threshold);
67 depth_tex = &res.dummy_depth_tx;
71 do_depth_copy_workaround_ = !is_selection && (depth_tex == &tmp_depth_tx_);
74 auto &pass = wireframe_ps_;
80 state.clipping_plane_count);
81 res.select_bind(pass);
84 [&](
gpu::Shader *shader,
const char *
name,
bool use_coloring,
float wire_threshold) {
85 auto &sub = pass.sub(
name);
86 if (res.shaders->wireframe_mesh.get() == shader) {
87 sub.specialize_constant(shader,
"use_custom_depth_bias", do_smooth_lines);
89 sub.shader_set(shader);
90 sub.bind_texture(
"depth_tx", depth_tex);
91 sub.push_constant(
"wire_opacity",
state.overlay.wireframe_opacity);
92 sub.push_constant(
"is_transform", is_transform);
93 sub.push_constant(
"color_type",
state.v3d->shading.wire_color_type);
94 sub.push_constant(
"use_coloring", use_coloring);
95 sub.push_constant(
"wire_step_param", wire_threshold);
96 sub.push_constant(
"ndc_offset_factor", &
state.ndc_offset_factor);
97 sub.push_constant(
"is_hair",
false);
101 auto coloring_pass = [&](ColoringPass &ps,
bool use_color) {
103 ps.mesh_ps_ = shader_pass(sh.
wireframe_mesh.
get(),
"Mesh", use_color, wire_threshold);
104 ps.mesh_all_edges_ps_ = shader_pass(sh.
wireframe_mesh.
get(),
"Wire", use_color, 1.0f);
109 coloring_pass(non_colored,
false);
110 coloring_pass(colored,
true);
118 const bool in_edit_paint_mode,
119 const bool in_edit_mode)
133 ColoringPass &coloring = in_edit_paint_mode ? non_colored : colored;
137 coloring.curves_ps_->
draw(
143 coloring.curves_ps_->
draw(
149 coloring.curves_ps_->
draw(
157 if (show_surface_wire) {
160 coloring.curves_ps_->
draw(
167 const bool wireframe_no_overlay =
state.hide_overlays &&
state.is_wireframe_mode;
174 const bool edit_wires_overlap_all = mesh_edit_wires_overlap(ob_ref, in_edit_mode);
176 const bool bypass_mode_check = wireframe_no_overlay || !edit_wires_overlap_all;
178 if (show_surface_wire) {
183 coloring.mesh_all_edges_ps_->
draw(
batch.batch, handle);
186 else if (!in_edit_mode || bypass_mode_check) {
191 (all_edges ? coloring.mesh_all_edges_ps_ : coloring.mesh_ps_)
197 if (!in_edit_paint_mode || bypass_mode_check) {
202 coloring.pointcloud_ps_->
draw(
206 coloring.mesh_all_edges_ps_->
draw(
213 if (show_surface_wire) {
215 coloring.pointcloud_ps_->
draw(
221 if (show_surface_wire) {
223 if (geom ==
nullptr) {
229 coloring.pointcloud_ps_->
draw(
233 coloring.mesh_ps_->
draw(
252 manager.generate_commands(wireframe_ps_,
view);
257 if (!
enabled_ || !do_depth_copy_workaround_) {
263 tmp_depth_tx_.acquire(render_size, gpu::TextureFormat::SFLOAT_32_DEPTH_UINT_8, usage);
277 manager.submit_only(wireframe_ps_,
view);
279 tmp_depth_tx_.release();
283 float wire_discard_threshold_get(
float threshold)
287 threshold =
sqrt(
abs(threshold));
292 static bool mesh_edit_wires_overlap(
const ObjectRef &ob_ref,
const bool in_edit_mode)
300 if (!edit_mapping_valid) {
bool BKE_editmesh_eval_orig_map_available(const Mesh &mesh_eval, const Mesh *mesh_orig)
const Mesh * BKE_object_get_pre_modified_mesh(const Object *object)
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
@ USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE
@ VOLUME_WIREFRAME_POINTS
T & DRW_object_get_data_for_drawing(const Object &object)
void GPU_framebuffer_bind(blender::gpu::FrameBuffer *fb)
void GPU_texture_copy(blender::gpu::Texture *dst, blender::gpu::Texture *src)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
ResourceHandleRange unique_handle(const ObjectRef &ref)
int3 size(int miplvl=0) const
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIndexRange res_index={}, uint custom_id=0)
detail::PassBase< command::DrawMultiBuf > Sub
static bool mesh_has_edit_cage(const Object *ob)
StaticShader wireframe_points
StaticShader wireframe_curve
StaticShader wireframe_mesh
void begin_sync(Resources &res, const State &state) final
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
void pre_draw(Manager &manager, View &view) final
void object_sync_ex(Manager &manager, const ObjectRef &ob_ref, Resources &res, const State &state, const bool in_edit_paint_mode, const bool in_edit_mode)
void copy_depth(TextureRef &depth_tx)
blender::gpu::Shader * get()
#define DRW_CLIPPING_UBO_SLOT
#define OVERLAY_GLOBALS_SLOT
@ DRW_STATE_DEPTH_LESS_EQUAL
@ DRW_STATE_FIRST_VERTEX_CONVENTION
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
gpu::Batch * DRW_cache_text_edge_wire_get(Object *ob)
gpu::Batch * DRW_cache_mesh_all_verts_get(Object *ob)
gpu::Batch * DRW_cache_grease_pencil_face_wireframe_get(const Scene *scene, Object *ob)
detail::Pass< command::DrawMultiBuf > PassMain
gpu::Batch * DRW_cache_mesh_loose_edges_get(Object *ob)
gpu::Batch * DRW_cache_mesh_face_wireframe_get(Object *ob)
Vector< SculptBatch > sculpt_batches_get(const Object *ob, SculptBatchFeature features)
blender::gpu::Batch * DRW_pointcloud_batch_cache_get_dots(Object *ob)
gpu::Batch * DRW_cache_curve_edge_wire_get(Object *ob)
gpu::Batch * DRW_cache_surf_edge_wire_get(Object *ob)
gpu::Batch * DRW_cache_volume_face_wireframe_get(Object *ob)
T interpolate(const T &a, const T &b, const FactorT &t)
VecBase< int32_t, 2 > int2
virtual void draw(Framebuffer &, Manager &, View &)
const ID select_id(const ObjectRef &ob_ref, uint sub_object_id=0)