[Bf-blender-cvs] [7d5df1c] hair_system: Disabled hair debugging code, due to excessive memory consumption and overhead.

Lukas Tönne noreply at git.blender.org
Fri Aug 22 15:53:31 CEST 2014


Commit: 7d5df1c5f248d7f9038bcf50dc751e46942252c9
Author: Lukas Tönne
Date:   Fri Aug 22 15:53:45 2014 +0200
Branches: hair_system
https://developer.blender.org/rB7d5df1c5f248d7f9038bcf50dc751e46942252c9

Disabled hair debugging code, due to excessive memory consumption and
overhead.

This can be implemented much nicer using a hash table and statically
typed solver function templates, but for now just disabled it.

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

M	source/blender/hair/HAIR_capi.cpp
M	source/blender/hair/intern/HAIR_debug.cpp
M	source/blender/hair/intern/HAIR_debug.h

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

diff --git a/source/blender/hair/HAIR_capi.cpp b/source/blender/hair/HAIR_capi.cpp
index 67795ec..87dc4e2 100644
--- a/source/blender/hair/HAIR_capi.cpp
+++ b/source/blender/hair/HAIR_capi.cpp
@@ -149,6 +149,7 @@ void HAIR_solver_step_debug(struct HAIR_Solver *csolver, float time, float times
 	
 	solver->step_threaded(time, timestep);
 	
+#ifdef HAIR_DEBUG
 	if (debug_data) {
 		int i, tot = Debug::elements.size();
 		for (i = 0; i < tot; ++i) {
@@ -158,58 +159,6 @@ void HAIR_solver_step_debug(struct HAIR_Solver *csolver, float time, float times
 			BKE_hair_debug_data_insert(debug_data, elem);
 		}
 	}
-	
-#if 0
-	if (points && totpoints) {
-		int tot = solver->data()->totpoints;
-		*totpoints = tot;
-		*points = (HAIR_SolverDebugPoint *)MEM_mallocN(sizeof(HAIR_SolverDebugPoint) * tot, "hair solver point debug data");
-	}
-	
-	if (contacts && totcontacts) {
-		*totcontacts = 0;
-		for (int d = 0; d < thread_data_list.size(); ++d) {
-			const DebugThreadData &data = thread_data_list[d];
-			*totcontacts += data.contacts.size();
-		}
-		*contacts = (HAIR_SolverDebugContact *)MEM_mallocN(sizeof(HAIR_SolverDebugContact) * (*totcontacts), "hair solver contact debug data");	
-	}
-	
-	HAIR_SolverDebugContact *pcontact = contacts ? *contacts : NULL;
-	for (int d = 0; d < thread_data_list.size(); ++d) {
-		const DebugThreadData &data = thread_data_list[d];
-		
-		if (points && totpoints) {
-			int tot = solver->data()->totpoints;
-			for (int i = 0; i < data.points.size(); ++i) {
-				const HAIR_SolverDebugPoint &dp = data.points[i];
-				if (dp.index < 0 || dp.index >= tot)
-					continue;
-				
-				HAIR_SolverDebugPoint &p = (*points)[dp.index];
-				p = dp;
-				
-				/* transform to object space for display */
-				mul_m4_v3(ob_imat, p.co);
-				mul_mat3_m4_v3(ob_imat, p.bend);
-				mul_mat3_m4_v3(ob_imat, p.rest_bend);
-				mul_mat3_m4_v3(ob_imat, p.frame[0]);
-				mul_mat3_m4_v3(ob_imat, p.frame[1]);
-				mul_mat3_m4_v3(ob_imat, p.frame[2]);
-			}
-		}
-		
-		if (contacts && totcontacts) {
-			for (int i = 0; i < data.contacts.size(); ++i) {
-				const HAIR_SolverDebugContact &dc = data.contacts[i];
-				HAIR_SolverDebugContact &c = *(pcontact++);
-				c = dc;
-				
-				mul_m4_v3(ob_imat, c.coA);
-				mul_m4_v3(ob_imat, c.coB);
-			}
-		}
-	}
 #endif
 	
 	Debug::end();
diff --git a/source/blender/hair/intern/HAIR_debug.cpp b/source/blender/hair/intern/HAIR_debug.cpp
index 01bf487..03f23df 100644
--- a/source/blender/hair/intern/HAIR_debug.cpp
+++ b/source/blender/hair/intern/HAIR_debug.cpp
@@ -30,13 +30,10 @@
 
 HAIR_NAMESPACE_BEGIN
 
-#ifdef HAIR_DEBUG
-
 bool Debug::active = false;
+#ifdef HAIR_DEBUG
 ThreadMutex Debug::mutex;
 Debug::Elements Debug::elements;
-
 #endif
 
-
 HAIR_NAMESPACE_END
diff --git a/source/blender/hair/intern/HAIR_debug.h b/source/blender/hair/intern/HAIR_debug.h
index b668ef9..da94036 100644
--- a/source/blender/hair/intern/HAIR_debug.h
+++ b/source/blender/hair/intern/HAIR_debug.h
@@ -41,7 +41,7 @@ extern "C" {
 HAIR_NAMESPACE_BEGIN
 
 #ifndef NDEBUG
-#define HAIR_DEBUG
+//#define HAIR_DEBUG
 #endif
 
 struct SolverData;
@@ -51,20 +51,25 @@ struct Debug {
 	
 	static void init()
 	{
+#ifdef HAIR_DEBUG
 		BLI_mutex_init(&mutex);
 		active = true;
+#endif
 	}
 	
 	static void end()
 	{
+#ifdef HAIR_DEBUG
 		elements.clear();
 		
 		BLI_mutex_end(&mutex);
 		active = false;
+#endif
 	}
 	
 	static void dot(const float3 &p, float r, float g, float b, int hash)
 	{
+#ifdef HAIR_DEBUG
 		HAIR_SolverDebugElement elem;
 		elem.type = HAIR_DEBUG_ELEM_DOT;
 		elem.hash = hash;
@@ -78,10 +83,18 @@ struct Debug {
 		BLI_mutex_lock(&mutex);
 		elements.push_back(elem);
 		BLI_mutex_unlock(&mutex);
+#else
+		(void)p;
+		(void)r;
+		(void)g;
+		(void)b;
+		(void)hash;
+#endif
 	}
 	
 	static void line(const float3 &v1, const float3 &v2, float r, float g, float b, int hash)
 	{
+#ifdef HAIR_DEBUG
 		HAIR_SolverDebugElement elem;
 		elem.type = HAIR_DEBUG_ELEM_LINE;
 		elem.hash = hash;
@@ -96,10 +109,19 @@ struct Debug {
 		BLI_mutex_lock(&mutex);
 		elements.push_back(elem);
 		BLI_mutex_unlock(&mutex);
+#else
+		(void)v1;
+		(void)v2;
+		(void)r;
+		(void)g;
+		(void)b;
+		(void)hash;
+#endif
 	}
 	
 	static void vector(const float3 &p, const float3 &d, float r, float g, float b, int hash)
 	{
+#ifdef HAIR_DEBUG
 		HAIR_SolverDebugElement elem;
 		elem.type = HAIR_DEBUG_ELEM_VECTOR;
 		elem.hash = hash;
@@ -114,11 +136,21 @@ struct Debug {
 		BLI_mutex_lock(&mutex);
 		elements.push_back(elem);
 		BLI_mutex_unlock(&mutex);
+#else
+		(void)p;
+		(void)d;
+		(void)r;
+		(void)g;
+		(void)b;
+		(void)hash;
+#endif
 	}
 	
 	static bool active;
+#ifdef HAIR_DEBUG
 	static ThreadMutex mutex;
 	static Elements elements;
+#endif
 };
 
 HAIR_NAMESPACE_END




More information about the Bf-blender-cvs mailing list