diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-19 04:18:25 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-19 04:18:25 +0400 |
commit | b748d4f0cf34e956bed1f411c45bb259f166883d (patch) | |
tree | aff5407e6a525333a59e5cb294bd5792e7cf71fd /source/blender/makesrna/intern/rna_object_api.c | |
parent | c69abe0965b8a2680070f8a5489161611acb243e (diff) |
debug function DM_debug_info / DM_debug_print, with access from python
through Object.dm_info('SOURCE/DEFORM/FINAL')
this is to help tracking down issues with modifiers where loosing data
layers between modifiers can cause bugs, also to helo with comparing
bmesh/trunk's modifier stack.
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 877da130357..53203717c85 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -63,6 +63,7 @@ #include "BKE_font.h" #include "BKE_mball.h" #include "BKE_modifier.h" +#include "BKE_cdderivedmesh.h" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" @@ -470,6 +471,44 @@ int rna_Object_is_modified(Object *ob, Scene *scene, int settings) return object_is_modified(scene, ob) & settings; } +#ifndef NDEBUG +void rna_Object_dm_info(struct Object *ob, int type, char *result) +{ + DerivedMesh *dm = NULL; + int dm_release = FALSE; + char *ret = NULL; + + result[0] = '\0'; + + switch(type) { + case 0: + if (ob->type == OB_MESH) { + dm = CDDM_from_mesh(ob->data, ob); + ret = DM_debug_info(dm); + dm_release = TRUE; + } + break; + case 1: + dm = ob->derivedDeform; + break; + case 2: + dm = ob->derivedFinal; + break; + } + + if (dm) { + ret = DM_debug_info(dm); + if (dm_release) { + dm->release(dm); + } + if (ret) { + strcpy(result, ret); + MEM_freeN(ret); + } + } +} +#endif /* NDEBUG */ + #else void RNA_api_object(StructRNA *srna) @@ -483,6 +522,15 @@ void RNA_api_object(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; +#ifndef NDEBUG + static EnumPropertyItem mesh_dm_info_items[] = { + {0, "SOURCE", 0, "Source", "Source mesh"}, + {1, "DEFORM", 0, "Deform", "Objects deform mesh"}, + {2, "FINAL", 0, "Final", "Objects final mesh"}, + {0, NULL, 0, NULL, NULL} + }; +#endif + /* mesh */ func= RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh"); RNA_def_function_ui_description(func, "Create a Mesh datablock with modifiers applied"); @@ -585,6 +633,20 @@ void RNA_api_object(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_boolean(func, "result", 0, "", "Object visibility"); RNA_def_function_return(func, parm); + + +#ifndef NDEBUG + /* mesh */ + func= RNA_def_function(srna, "dm_info", "rna_Object_dm_info"); + RNA_def_function_ui_description(func, "Returns a string for derived mesh data"); + + parm= RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* weak!, no way to return dynamic string type */ + parm= RNA_def_string(func, "result", "result", 1024, "result", ""); + RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */ + RNA_def_function_output(func, parm); +#endif /* NDEBUG */ } |