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
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-09-28 02:29:59 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-09-28 02:35:53 +0300
commita2457dd7bba136dcfd4065f770b75ec5ce28004b (patch)
treec66bb1bf9e7ba85a6e69af17958df61ff8f90f5d /source
parent1c1a3198af9dad58ff0a09e0828f64df5d9a4646 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/intern/draw_manager_data.c52
-rw-r--r--source/blender/editors/screen/area.c28
2 files changed, 38 insertions, 42 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 7887f6874b3..78353a58e33 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -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(
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 32b5c6ba6d4..6be571f692d 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -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));