Cleanup/sanitize usages of G.debug_value.
There was no documentation at all, some very bad practices (like using G.debug_value > 0 as some sort of global debug print switch), and even an overlapping use of '1' value... Also, python setter did not check for valid range (since this is a short, not an int).
This commit is contained in:
parent
feaf846f93
commit
8102200006
|
@ -73,7 +73,21 @@ typedef struct Global {
|
|||
/* to indicate render is busy, prevent renderwindow events etc */
|
||||
bool is_rendering;
|
||||
|
||||
/* debug value, can be set from the UI and python, used for testing nonstandard features */
|
||||
/* Debug value, can be set from the UI and python, used for testing nonstandard features.
|
||||
* DO NOT abuse it with generic checks like `if (G.debug_value > 0)`. Do not use it as bitflags.
|
||||
* Only precise specific values should be checked for, to avoid unpredictable side-effects.
|
||||
* Please document here the value(s) you are using (or a range of values reserved to some area).
|
||||
* * -16384 and below: Reserved for python (add-ons) usage.
|
||||
* * -1: Disable faster motion paths computation (since 08/2018).
|
||||
* * 1 - 30: EEVEE debug/stats values (01/2018).
|
||||
* * 101: Enable UI debug drawing of fullscreen area's corner widget (10/2014).
|
||||
* * 527: Old mysterious switch in behavior of MeshDeform modifier (before 04/2010).
|
||||
* * 777: Enable UI node panel's sockets polling (11/2011).
|
||||
* * 799: Enable some mysterious new depsgraph behavior (05/2015).
|
||||
* * 1112: Disable new Cloth internal springs hanlding (09/2014).
|
||||
* * 1234: Disable new dyntopo code fixing skinny faces generation (04/2015).
|
||||
* * 16384 and above: Reserved for python (add-ons) usage.
|
||||
*/
|
||||
short debug_value;
|
||||
|
||||
/* saved to the blend file as FileGlobal.globalf,
|
||||
|
|
|
@ -515,8 +515,9 @@ void cloth_free_modifier(ClothModifierData *clmd )
|
|||
void cloth_free_modifier_extern(ClothModifierData *clmd )
|
||||
{
|
||||
Cloth *cloth = NULL;
|
||||
if (G.debug_value > 0)
|
||||
if (G.debug & G_DEBUG_SIMDATA) {
|
||||
printf("cloth_free_modifier_extern\n");
|
||||
}
|
||||
|
||||
if ( !clmd )
|
||||
return;
|
||||
|
@ -524,8 +525,9 @@ void cloth_free_modifier_extern(ClothModifierData *clmd )
|
|||
cloth = clmd->clothObject;
|
||||
|
||||
if ( cloth ) {
|
||||
if (G.debug_value > 0)
|
||||
if (G.debug & G_DEBUG_SIMDATA) {
|
||||
printf("cloth_free_modifier_extern in\n");
|
||||
}
|
||||
|
||||
BPH_cloth_solver_free(clmd);
|
||||
|
||||
|
@ -728,8 +730,9 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, Mesh *mesh, fl
|
|||
// If we have a clothObject, free it.
|
||||
if ( clmd->clothObject != NULL ) {
|
||||
cloth_free_modifier ( clmd );
|
||||
if (G.debug_value > 0)
|
||||
if (G.debug & G_DEBUG_SIMDATA) {
|
||||
printf("cloth_free_modifier cloth_from_object\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate a new cloth object.
|
||||
|
|
|
@ -210,7 +210,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
|
|||
* The click_rect is the same as defined in fullscreen_click_rcti_init
|
||||
* Keep them both in sync */
|
||||
|
||||
if (G.debug_value == 1) {
|
||||
if (G.debug_value == 101) {
|
||||
rcti click_rect;
|
||||
float icon_size = UI_DPI_ICON_SIZE + 7 * UI_DPI_FAC;
|
||||
|
||||
|
|
|
@ -201,8 +201,9 @@ static void freeData(ModifierData *md)
|
|||
ClothModifierData *clmd = (ClothModifierData *) md;
|
||||
|
||||
if (clmd) {
|
||||
if (G.debug_value > 0)
|
||||
if (G.debug & G_DEBUG_SIMDATA) {
|
||||
printf("clothModifier_freeData\n");
|
||||
}
|
||||
|
||||
cloth_free_modifier_extern(clmd);
|
||||
|
||||
|
|
|
@ -141,8 +141,9 @@ static void deformVerts(
|
|||
|
||||
current_time = DEG_get_ctime(ctx->depsgraph);
|
||||
|
||||
if (G.debug_value > 0)
|
||||
if (G.debug & G_DEBUG_SIMDATA) {
|
||||
printf("current_time %f, collmd->time_xnew %f\n", current_time, collmd->time_xnew);
|
||||
}
|
||||
|
||||
mvert_num = mesh_src->totvert;
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ static PyObject *bpy_app_binary_path_python_get(PyObject *self, void *UNUSED(clo
|
|||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_app_debug_value_doc,
|
||||
"Int, number which can be set to non-zero values for testing purposes"
|
||||
"Short, number which can be set to non-zero values for testing purposes"
|
||||
);
|
||||
static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
||||
{
|
||||
|
@ -313,7 +313,13 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void
|
|||
return -1;
|
||||
}
|
||||
|
||||
G.debug_value = param;
|
||||
if (param < SHRT_MIN || param > SHRT_MAX) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"bpy.app.debug_value can only be set to short range [-32768, 32767]");
|
||||
return -1;
|
||||
}
|
||||
|
||||
G.debug_value = (short)param;
|
||||
|
||||
WM_main_add_notifier(NC_WINDOW, NULL);
|
||||
|
||||
|
|
Loading…
Reference in New Issue