Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2022-08-16 03:01:17 +0300
committerJoseph Eagar <joeedh@gmail.com>2022-08-16 03:01:17 +0300
commit7f3eb055dd0c708cb775332115be37dec0075e43 (patch)
treed488fee1138598198d386bd90181498d15e6beb4 /source/blender/draw/intern
parentc5feb4e6fe27f013cc17b841729fb6c5097b4848 (diff)
Sculpt: Improve sculpt debug draw
* Fixed crash in debug draw code. Apparently this is only used by PBVH draw? * Debug draw code can now be forcibly enabled in release mode (i.e. RelWithDebugInfo) by uncommenting a commented out #define. * Fixed colors in debug draw mode. * PBVH node boxes in debug mode now flash a different color when they are updated.
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r--source/blender/draw/intern/draw_debug.cc15
-rw-r--r--source/blender/draw/intern/draw_manager_data.c16
-rw-r--r--source/blender/draw/intern/shaders/draw_debug_draw_display_vert.glsl2
3 files changed, 23 insertions, 10 deletions
diff --git a/source/blender/draw/intern/draw_debug.cc b/source/blender/draw/intern/draw_debug.cc
index aaf18014143..b9d10302c1e 100644
--- a/source/blender/draw/intern/draw_debug.cc
+++ b/source/blender/draw/intern/draw_debug.cc
@@ -21,6 +21,13 @@
#include <iomanip>
+#ifdef DEBUG
+# define DRAW_DEBUG
+#else
+/* Uncomment to forcibly enable debug draw in release mode. */
+//#define DRAW_DEBUG
+#endif
+
namespace blender::draw {
/* -------------------------------------------------------------------- */
@@ -595,7 +602,7 @@ blender::draw::DebugDraw *DRW_debug_get()
void drw_debug_draw()
{
-#ifdef DEBUG
+#ifdef DRAW_DEBUG
if (!GPU_shader_storage_buffer_objects_support() || DST.debug == nullptr) {
return;
}
@@ -611,7 +618,7 @@ void drw_debug_init()
{
/* Module should not be used in release builds. */
/* TODO(@fclem): Hide the functions declarations without using `ifdefs` everywhere. */
-#ifdef DEBUG
+#ifdef DRAW_DEBUG
if (!GPU_shader_storage_buffer_objects_support()) {
return;
}
@@ -659,10 +666,12 @@ void DRW_debug_modelmat_reset()
void DRW_debug_modelmat(const float modelmat[4][4])
{
+#ifdef DRAW_DEBUG
if (!GPU_shader_storage_buffer_objects_support()) {
return;
}
reinterpret_cast<blender::draw::DebugDraw *>(DST.debug)->modelmat_set(modelmat);
+#endif
}
void DRW_debug_line_v3v3(const float v1[3], const float v2[3], const float color[4])
@@ -704,10 +713,12 @@ void DRW_debug_m4_as_bbox(const float m[4][4], bool invert, const float color[4]
void DRW_debug_bbox(const BoundBox *bbox, const float color[4])
{
+#ifdef DRAW_DEBUG
if (!GPU_shader_storage_buffer_objects_support()) {
return;
}
reinterpret_cast<blender::draw::DebugDraw *>(DST.debug)->draw_bbox(*bbox, color);
+#endif
}
void DRW_debug_sphere(const float center[3], float radius, const float color[4])
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 1a5d91444fe..abccbd66e80 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -1188,16 +1188,15 @@ static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers
DRW_shgroup_uniform_vec3(
shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->debug_node_nr++), 1);
}
+
/* DRW_shgroup_call_no_cull reuses matrices calculations for all the drawcalls of this
* object. */
DRW_shgroup_call_no_cull(shgrp, geom, scd->ob);
}
}
-static void sculpt_debug_cb(void *user_data,
- const float bmin[3],
- const float bmax[3],
- PBVHNodeFlags flag)
+static void sculpt_debug_cb(
+ PBVHNode *node, void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag)
{
int *debug_node_nr = (int *)user_data;
BoundBox bb;
@@ -1212,7 +1211,10 @@ static void sculpt_debug_cb(void *user_data,
}
#else /* Color coded leaf bounds. */
if (flag & PBVH_Leaf) {
- DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR((*debug_node_nr)++));
+ int color = (*debug_node_nr)++;
+ color += BKE_pbvh_debug_draw_gen_get(node);
+
+ DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR(color));
}
#endif
}
@@ -1305,8 +1307,8 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
DRW_debug_modelmat(scd->ob->obmat);
BKE_pbvh_draw_debug_cb(
pbvh,
- (void (*)(
- void *d, const float min[3], const float max[3], PBVHNodeFlags f))sculpt_debug_cb,
+ (void (*)(PBVHNode * n, void *d, const float min[3], const float max[3], PBVHNodeFlags f))
+ sculpt_debug_cb,
&debug_node_nr);
}
}
diff --git a/source/blender/draw/intern/shaders/draw_debug_draw_display_vert.glsl b/source/blender/draw/intern/shaders/draw_debug_draw_display_vert.glsl
index 92c546aa203..ab76df819d5 100644
--- a/source/blender/draw/intern/shaders/draw_debug_draw_display_vert.glsl
+++ b/source/blender/draw/intern/shaders/draw_debug_draw_display_vert.glsl
@@ -8,7 +8,7 @@ void main()
/* Skip the first vertex containing header data. */
DRWDebugVert vert = drw_debug_verts_buf[gl_VertexID + 1];
vec3 pos = uintBitsToFloat(uvec3(vert.pos0, vert.pos1, vert.pos2));
- vec4 col = vec4((uvec4(vert.color) >> uvec4(0, 8, 16, 24)) & 0xFFu);
+ vec4 col = vec4((uvec4(vert.color) >> uvec4(0, 8, 16, 24)) & 0xFFu) / 255.0;
interp.color = col;
gl_Position = persmat * vec4(pos, 1.0);