[Bf-blender-cvs] [04cf08a] hair_system: More debugging options for hair display.

Lukas Tönne noreply at git.blender.org
Thu Aug 21 11:56:22 CEST 2014


Commit: 04cf08a00444b56739db8a390bfa4f2091797365
Author: Lukas Tönne
Date:   Thu Aug 21 11:29:29 2014 +0200
Branches: hair_system
https://developer.blender.org/rB04cf08a00444b56739db8a390bfa4f2091797365

More debugging options for hair display.

===================================================================

M	release/scripts/startup/bl_ui/properties_physics_hair.py
M	source/blender/editors/space_view3d/drawhair.c
M	source/blender/hair/HAIR_debug_types.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_physics_hair.py b/release/scripts/startup/bl_ui/properties_physics_hair.py
index 60ede18..8ed57a8 100644
--- a/release/scripts/startup/bl_ui/properties_physics_hair.py
+++ b/release/scripts/startup/bl_ui/properties_physics_hair.py
@@ -163,6 +163,11 @@ class PHYSICS_PT_hair_debug(PhysicButtonsPanel, Panel):
         col.prop(md, "show_debug_frames")
         col.prop(md, "show_debug_bending")
         col.prop(md, "show_debug_smoothing")
+        
+        box = col.box()
+        box.prop(md, "show_debug_forces")
+        sub = box.column(align=True)
+        sub.prop(md, "show_debug_force_bending", toggle=True)
 
 
 #class PHYSICS_PT_hair_cache(PhysicButtonsPanel, Panel):
diff --git a/source/blender/editors/space_view3d/drawhair.c b/source/blender/editors/space_view3d/drawhair.c
index ef23930..e757d42 100644
--- a/source/blender/editors/space_view3d/drawhair.c
+++ b/source/blender/editors/space_view3d/drawhair.c
@@ -495,6 +495,41 @@ static void draw_hair_debug_points(HairSystem *hsys, HAIR_SolverDebugPoint *dpoi
 #endif
 }
 
+static void draw_hair_debug_force_vector(const float co[3], const float f[3], float r, float g, float b)
+{
+	const float scale = 1.0f;
+	float p[3];
+	
+	madd_v3_v3v3fl(p, co, f, scale);
+	
+	glColor3f(r, g, b);
+	glVertex3fv(co);
+	glVertex3fv(p);
+}
+
+static void draw_hair_debug_forces(HairSystem *hsys, int debug_forces, HAIR_SolverDebugPoint *dpoints, int dtotpoints)
+{
+	int i, k, ktot = 0;
+	
+	glBegin(GL_LINES);
+	
+	for (i = 0; i < hsys->totcurves; ++i) {
+		HairCurve *hair = hsys->curves + i;
+		for (k = 0; k < hair->totpoints; ++k, ++ktot) {
+//			HairPoint *point = hair->points + k;
+			
+			if (ktot < dtotpoints) {
+				HAIR_SolverDebugPoint *dpoint = dpoints + ktot;
+				
+				if (debug_forces & MOD_HAIR_DEBUG_FORCE_BENDING)
+					draw_hair_debug_force_vector(dpoint->co, dpoint->force_bend, 1.0f, 1.0f, 0.0f);
+			}
+		}
+	}
+	
+	glEnd();
+}
+
 static void draw_hair_debug_size(HairSystem *hsys, float tmat[4][4])
 {
 #ifdef SHOW_SIZE
@@ -607,12 +642,12 @@ static void draw_hair_debug_bending(HairSystem *hsys, HAIR_SolverDebugPoint *dpo
 				copy_v3_v3(co, dpoint->co);
 				
 				add_v3_v3v3(bend, co, dpoint->bend);
-				glColor3f(0.4f, 0.25f, 0.55f);
+				glColor3f(0.15f, 0.55f, 0.55f);
 				glVertex3fv(co);
 				glVertex3fv(bend);
 				
 				add_v3_v3v3(bend, co, dpoint->rest_bend);
-				glColor3f(0.15f, 0.55f, 0.55f);
+				glColor3f(0.4f, 0.25f, 0.55f);
 				glVertex3fv(co);
 				glVertex3fv(bend);
 			}
@@ -777,5 +812,7 @@ void draw_hair_debug_info(Scene *UNUSED(scene), View3D *UNUSED(v3d), ARegion *ar
 //		draw_hair_debug_points(hsys, hmd->debug_data->points, hmd->debug_data->totpoints);
 		if (debug_flag & MOD_HAIR_DEBUG_CONTACTS)
 			draw_hair_debug_contacts(hsys, hmd->debug_data->contacts, hmd->debug_data->totcontacts);
+		if (debug_flag & MOD_HAIR_DEBUG_FORCES)
+			draw_hair_debug_forces(hsys, hmd->debug_flag_forces, hmd->debug_data->points, hmd->debug_data->totpoints);
 	}
 }
diff --git a/source/blender/hair/HAIR_debug_types.h b/source/blender/hair/HAIR_debug_types.h
index 514e74e..15031c1 100644
--- a/source/blender/hair/HAIR_debug_types.h
+++ b/source/blender/hair/HAIR_debug_types.h
@@ -44,6 +44,7 @@ typedef struct HAIR_SolverDebugPoint {
 	float co[3];
 	float rest_bend[3];
 	float bend[3];
+	float force_bend[3];
 	float frame[3][3];
 } HAIR_SolverDebugPoint;
 
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index f482acc..7e463fb 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1377,6 +1377,8 @@ typedef struct HairModifierData {
 	int flag;
 
 	int debug_flag;
+	int debug_flag_forces;
+	int pad;
 	struct HairDebugData *debug_data;
 } HairModifierData;
 
@@ -1385,13 +1387,18 @@ enum {
 };
 
 enum {
-	MOD_HAIR_DEBUG_SHOW         = (1 << 0),
-	MOD_HAIR_DEBUG_CONTACTS     = (1 << 1),
-	MOD_HAIR_DEBUG_SIZE         = (1 << 2),
-	MOD_HAIR_DEBUG_ROOTS        = (1 << 3),
-	MOD_HAIR_DEBUG_SMOOTHING    = (1 << 4),
-	MOD_HAIR_DEBUG_FRAMES       = (1 << 5),
-	MOD_HAIR_DEBUG_BENDING      = (1 << 6),
+	MOD_HAIR_DEBUG_SHOW             = (1 << 0),
+	MOD_HAIR_DEBUG_CONTACTS         = (1 << 1),
+	MOD_HAIR_DEBUG_SIZE             = (1 << 2),
+	MOD_HAIR_DEBUG_ROOTS            = (1 << 3),
+	MOD_HAIR_DEBUG_SMOOTHING        = (1 << 4),
+	MOD_HAIR_DEBUG_FRAMES           = (1 << 5),
+	MOD_HAIR_DEBUG_BENDING          = (1 << 6),
+	MOD_HAIR_DEBUG_FORCES           = (1 << 7),
+};
+
+enum {
+	MOD_HAIR_DEBUG_FORCE_BENDING    = (1 << 0),
 };
 
 
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index c45200b..7c27274 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -3695,6 +3695,7 @@ static void rna_def_modifier_hair(BlenderRNA *brna)
 	RNA_def_property_struct_type(prop, "HairSystem");
 	RNA_def_property_ui_text(prop, "Hair System", "");
 
+	/* debug flags */
 	prop = RNA_def_property(srna, "show_debug", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "debug_flag", MOD_HAIR_DEBUG_SHOW);
 	RNA_def_property_ui_text(prop, "Show Debug", "Show debugging data");
@@ -3729,6 +3730,17 @@ static void rna_def_modifier_hair(BlenderRNA *brna)
 	RNA_def_property_boolean_sdna(prop, NULL, "debug_flag", MOD_HAIR_DEBUG_BENDING);
 	RNA_def_property_ui_text(prop, "Show Bending", "");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "show_debug_forces", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "debug_flag", MOD_HAIR_DEBUG_FORCES);
+	RNA_def_property_ui_text(prop, "Show Forces", "");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	/* debug forces flags */
+	prop = RNA_def_property(srna, "show_debug_force_bending", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "debug_flag_forces", MOD_HAIR_DEBUG_FORCE_BENDING);
+	RNA_def_property_ui_text(prop, "Show Bending", "");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 void RNA_def_modifier(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list