[Bf-blender-cvs] [077a9c7] strand_nodes: Enable debug drawing of hair contacts.
Lukas Tönne
noreply at git.blender.org
Sun Aug 7 10:39:44 CEST 2016
Commit: 077a9c762103c37e12217718cfed29f0266eba30
Author: Lukas Tönne
Date: Fri Jul 29 12:36:20 2016 +0200
Branches: strand_nodes
https://developer.blender.org/rB077a9c762103c37e12217718cfed29f0266eba30
Enable debug drawing of hair contacts.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/BKE_collision.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
M source/blender/physics/intern/strands.cpp
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index ca70660..a5320ff 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2022,6 +2022,8 @@ class VIEW3D_PT_hairmode_debug(View3DPanel, Panel):
layout.active = settings.show_debug
+ layout.prop(settings, "show_debug_contacts", text="Contacts")
+
# Grease Pencil drawing tools
class VIEW3D_PT_tools_grease_pencil_draw(GreasePencilDrawingToolsPanel, Panel):
diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h
index 6fe4cd6..b3705a5 100644
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@ -182,8 +182,9 @@ CollisionContactPoint *BKE_collision_cache_add(struct CollisionContactCache *cac
int index_a, int index_b,
int part_id_a, int part_id_b);
+#define CollisionContactIterator BLI_mempool_iter
#define BKE_COLLISION_ITER_CONTACTS(point, iter, cache) \
- for (BLI_mempool_iternew(cache->points, iter); (point = BLI_mempool_iterstep(iter)); )
+ for (BLI_mempool_iternew(cache->points, iter); (point = (CollisionContactPoint *)BLI_mempool_iterstep(iter)); )
#endif
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 97b64e2..aaa2e4d 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1053,10 +1053,11 @@ typedef enum HairEditSelectMode {
/* HairEditSettings->flag */
typedef enum HairEditFlag {
- HAIR_EDIT_SHOW_BRUSH = (1 << 0),
- HAIR_EDIT_USE_DEFLECT = (1 << 8),
- HAIR_EDIT_DEFLECT_SCALP = (1 << 9),
- HAIR_EDIT_SHOW_DEBUG = (1 << 16),
+ HAIR_EDIT_SHOW_BRUSH = (1 << 0),
+ HAIR_EDIT_USE_DEFLECT = (1 << 8),
+ HAIR_EDIT_DEFLECT_SCALP = (1 << 9),
+ HAIR_EDIT_SHOW_DEBUG = (1 << 16),
+ HAIR_EDIT_SHOW_DEBUG_CONTACTS = (1 << 17),
} HairEditFlag;
typedef struct HairEditSettings {
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index e2cfd3a..01b7aa4 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -1140,6 +1140,11 @@ static void rna_def_hair_edit(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", HAIR_EDIT_SHOW_DEBUG);
RNA_def_property_ui_text(prop, "Show Debug", "Enable debugging visualization");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+ prop = RNA_def_property(srna, "show_debug_contacts", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", HAIR_EDIT_SHOW_DEBUG_CONTACTS);
+ RNA_def_property_ui_text(prop, "Show Debug Contacts", "Enable debugging deflection contacts");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
void RNA_def_sculpt_paint(BlenderRNA *brna)
diff --git a/source/blender/physics/intern/strands.cpp b/source/blender/physics/intern/strands.cpp
index 1d7c2eb..20042d8 100644
--- a/source/blender/physics/intern/strands.cpp
+++ b/source/blender/physics/intern/strands.cpp
@@ -432,6 +432,15 @@ void BPH_strands_solve_constraints(Scene *scene, Object *ob, BMEditStrands *edit
CollisionContactCache *contacts = BKE_collision_cache_create();
BKE_editstrands_get_collision_contacts(scene, ob, edit, contacts);
+ if (settings->flag & HAIR_EDIT_SHOW_DEBUG &&
+ settings->flag & HAIR_EDIT_SHOW_DEBUG_CONTACTS) {
+ CollisionContactIterator iter;
+ CollisionContactPoint *pt;
+ BKE_COLLISION_ITER_CONTACTS(pt, &iter, contacts) {
+ BKE_sim_debug_data_add_line(pt->point_world_a, pt->point_world_b, 0.95, 0.9, 0.1, "hair collision",
+ pt->index_a, pt->index_b, pt->part_id_a, pt->part_id_b);
+ }
+ }
BKE_collision_cache_free(contacts);
}
More information about the Bf-blender-cvs
mailing list