Debug: add 888 and 889 debug values for redraw and PBVH node visualizatons

More convenient to use the debug menu than having to modify code every time.
This commit is contained in:
2019-09-28 01:29:59 +02:00
parent 1c1a3198af
commit a2457dd7bb
2 changed files with 38 additions and 42 deletions

View File

@@ -807,8 +807,7 @@ void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup,
drw_command_draw(shgroup, batch, handle);
}
// #define SCULPT_DEBUG_BUFFERS
#define SCULPT_DEBUG_BUFFERS (G.debug_value == 889)
typedef struct DRWSculptCallbackData {
Object *ob;
DRWShadingGroup **shading_groups;
@@ -816,13 +815,11 @@ typedef struct DRWSculptCallbackData {
bool use_mats;
bool use_mask;
bool fast_mode; /* Set by draw manager. Do not init. */
#ifdef SCULPT_DEBUG_BUFFERS
int node_nr;
#endif
int debug_node_nr;
} DRWSculptCallbackData;
#ifdef SCULPT_DEBUG_BUFFERS
# define SCULPT_DEBUG_COLOR(id) (sculpt_debug_colors[id % 9])
#define SCULPT_DEBUG_COLOR(id) (sculpt_debug_colors[id % 9])
static float sculpt_debug_colors[9][4] = {
{1.0f, 0.2f, 0.2f, 1.0f},
{0.2f, 1.0f, 0.2f, 1.0f},
@@ -834,7 +831,6 @@ static float sculpt_debug_colors[9][4] = {
{0.2f, 1.0f, 0.7f, 1.0f},
{0.7f, 0.2f, 1.0f, 1.0f},
};
#endif
static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers)
{
@@ -852,41 +848,40 @@ static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers
DRWShadingGroup *shgrp = scd->shading_groups[index];
if (geom != NULL && shgrp != NULL) {
#ifdef SCULPT_DEBUG_BUFFERS
/* Color each buffers in different colors. Only work in solid/Xray mode. */
shgrp = DRW_shgroup_create_sub(shgrp);
DRW_shgroup_uniform_vec3(shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->node_nr++), 1);
#endif
if (SCULPT_DEBUG_BUFFERS) {
/* Color each buffers in different colors. Only work in solid/Xray mode. */
shgrp = DRW_shgroup_create_sub(shgrp);
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);
}
}
#ifdef SCULPT_DEBUG_BUFFERS
static void sculpt_debug_cb(void *user_data,
const float bmin[3],
const float bmax[3],
PBVHNodeFlags flag)
{
int *node_nr = (int *)user_data;
int *debug_node_nr = (int *)user_data;
BoundBox bb;
BKE_boundbox_init_from_minmax(&bb, bmin, bmax);
# if 0 /* Nodes hierarchy. */
#if 0 /* Nodes hierarchy. */
if (flag & PBVH_Leaf) {
DRW_debug_bbox(&bb, (float[4]){0.0f, 1.0f, 0.0f, 1.0f});
}
else {
DRW_debug_bbox(&bb, (float[4]){0.5f, 0.5f, 0.5f, 0.6f});
}
# else /* Color coded leaf bounds. */
#else /* Color coded leaf bounds. */
if (flag & PBVH_Leaf) {
DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR((*node_nr)++));
DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR((*debug_node_nr)++));
}
# endif
}
#endif
}
static void drw_sculpt_get_frustum_planes(Object *ob, float planes[6][4])
{
@@ -931,14 +926,15 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol)
BKE_pbvh_draw_cb(pbvh, &frustum, (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, scd);
#ifdef SCULPT_DEBUG_BUFFERS
int node_nr = 0;
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,
&node_nr);
#endif
if (SCULPT_DEBUG_BUFFERS) {
int debug_node_nr = 0;
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,
&debug_node_nr);
}
}
void DRW_shgroup_call_sculpt(

View File

@@ -542,20 +542,20 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
region_draw_azones(sa, ar);
/* for debugging unneeded area redraws and partial redraw */
#if 0
GPU_blend(true);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(drand48(), drand48(), drand48(), 0.1f);
immRectf(pos,
ar->drawrct.xmin - ar->winrct.xmin,
ar->drawrct.ymin - ar->winrct.ymin,
ar->drawrct.xmax - ar->winrct.xmin,
ar->drawrct.ymax - ar->winrct.ymin);
immUnbindProgram();
GPU_blend(false);
#endif
if (G.debug_value == 888) {
GPU_blend(true);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(drand48(), drand48(), drand48(), 0.1f);
immRectf(pos,
ar->drawrct.xmin - ar->winrct.xmin,
ar->drawrct.ymin - ar->winrct.ymin,
ar->drawrct.xmax - ar->winrct.xmin,
ar->drawrct.ymax - ar->winrct.ymin);
immUnbindProgram();
GPU_blend(false);
}
memset(&ar->drawrct, 0, sizeof(ar->drawrct));