[Bf-blender-cvs] [81da7a9] hair_system: Removed deprecated old debug data types and per-thread debug data.
Lukas Tönne
noreply at git.blender.org
Fri Aug 22 12:17:53 CEST 2014
Commit: 81da7a91d4d5e2d0fa40b7427b05a0220d8a8b76
Author: Lukas Tönne
Date: Fri Aug 22 12:07:10 2014 +0200
Branches: hair_system
https://developer.blender.org/rB81da7a91d4d5e2d0fa40b7427b05a0220d8a8b76
Removed deprecated old debug data types and per-thread debug data.
The Debug class now uses a static mutex to prevent race conditions on
the debug elements. This is inefficient of course, but for the purpose
of debugging perfectly fine.
===================================================================
M source/blender/editors/space_view3d/drawhair.c
M source/blender/hair/HAIR_capi.cpp
M source/blender/hair/HAIR_debug_types.h
M source/blender/hair/intern/HAIR_debug.cpp
M source/blender/hair/intern/HAIR_debug.h
M source/blender/hair/intern/HAIR_solver.cpp
M source/blender/hair/intern/HAIR_solver.h
===================================================================
diff --git a/source/blender/editors/space_view3d/drawhair.c b/source/blender/editors/space_view3d/drawhair.c
index 1bec6fa..125c94b 100644
--- a/source/blender/editors/space_view3d/drawhair.c
+++ b/source/blender/editors/space_view3d/drawhair.c
@@ -464,73 +464,6 @@ bool draw_hair_system(Scene *UNUSED(scene), View3D *UNUSED(v3d), ARegion *ar, Ba
#define SHOW_CONTACTS
#define SHOW_BENDING
-static void draw_hair_debug_points(HairSystem *hsys, HAIR_SolverDebugPoint *dpoints, int dtotpoints)
-{
-#ifdef SHOW_POINTS
- int i, k, ktot = 0;
-
- glColor3f(0.8f, 1.0f, 1.0f);
- 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;
- float loc[3];
-
- glVertex3fv(point->co);
- add_v3_v3v3(loc, point->co, dpoint->bend);
- glVertex3fv(loc);
- }
- }
- }
-
- glEnd();
-#else
- (void)hsys;
- (void)dpoints;
- (void)dtotpoints;
-#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
@@ -579,135 +512,6 @@ static void draw_hair_debug_roots(HairSystem *hsys, struct DerivedMesh *dm)
#endif
}
-static void draw_hair_debug_frames(HairSystem *hsys, HAIR_SolverDebugPoint *dpoints, int dtotpoints)
-{
-#ifdef SHOW_FRAMES
- const float scale = 0.2f;
- int i, k, ktot;
-
- glColor3f(0.8f, 1.0f, 1.0f);
- glBegin(GL_LINES);
-
- ktot = 0;
- 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;
- float co[3], nor[3], tan[3], cotan[3];
-
- copy_v3_v3(co, dpoint->co);
- madd_v3_v3v3fl(nor, co, dpoint->frame[0], scale);
- madd_v3_v3v3fl(tan, co, dpoint->frame[1], scale);
- madd_v3_v3v3fl(cotan, co, dpoint->frame[2], scale);
-
- glColor3f(1.0f, 0.0f, 0.0f);
- glVertex3fv(co);
- glVertex3fv(nor);
- glColor3f(0.0f, 1.0f, 0.0f);
- glVertex3fv(co);
- glVertex3fv(tan);
- glColor3f(0.0f, 0.0f, 1.0f);
- glVertex3fv(co);
- glVertex3fv(cotan);
- }
- }
- }
-
- glEnd();
-#else
- (void)hsys;
- (void)dpoints;
- (void)dtotpoints;
-#endif
-}
-
-static void draw_hair_debug_bending(HairSystem *hsys, HAIR_SolverDebugPoint *dpoints, int dtotpoints)
-{
-#ifdef SHOW_BENDING
- int i, k, ktot;
-
- glBegin(GL_LINES);
-
- ktot = 0;
- 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;
- float co[3], bend[3];
-
- copy_v3_v3(co, dpoint->co);
-
- add_v3_v3v3(bend, co, dpoint->bend);
- glColor3f(0.15f, 0.55f, 0.55f);
- glVertex3fv(co);
- glVertex3fv(bend);
-
- add_v3_v3v3(bend, co, dpoint->rest_bend);
- glColor3f(0.4f, 0.25f, 0.55f);
- glVertex3fv(co);
- glVertex3fv(bend);
- }
- }
- }
-
- glEnd();
-#else
- (void)hsys;
- (void)dpoints;
- (void)dtotpoints;
-#endif
-}
-
-#if 0
-static void draw_hair_curve_debug_frames(HairSystem *hsys, HairCurve *hair)
-{
-#ifdef SHOW_FRAMES
- struct HAIR_FrameIterator *iter;
- float co[3], nor[3], tan[3], cotan[3];
- int k = 0;
- const float scale = 0.1f;
-
- glBegin(GL_LINES);
- iter = HAIR_frame_iter_new(hair, 1.0f / hair->totpoints, hsys->smooth);
-
- while (HAIR_frame_iter_valid(iter)) {
- HAIR_frame_iter_get(iter, nor, tan, cotan);
- copy_v3_v3(co, hair->points[k].co);
- mul_v3_fl(nor, scale);
- mul_v3_fl(tan, scale);
- mul_v3_fl(cotan, scale);
- add_v3_v3(nor, co);
- add_v3_v3(tan, co);
- add_v3_v3(cotan, co);
- ++k;
-
- glColor3f(1.0f, 0.0f, 0.0f);
- glVertex3fv(co);
- glVertex3fv(nor);
- glColor3f(0.0f, 1.0f, 0.0f);
- glVertex3fv(co);
- glVertex3fv(tan);
- glColor3f(0.0f, 0.0f, 1.0f);
- glVertex3fv(co);
- glVertex3fv(cotan);
-
- HAIR_frame_iter_next(iter);
- }
- HAIR_frame_iter_free(iter);
- glEnd();
-#else
- (void)hsys;
- (void)hair;
-#endif
-}
-#endif
-
static void draw_hair_curve_debug_smoothing(HairSystem *hsys, HairCurve *hair)
{
#ifdef SHOW_SMOOTHING
@@ -748,39 +552,6 @@ static void draw_hair_curve_debug_smoothing(HairSystem *hsys, HairCurve *hair)
#endif
}
-static void draw_hair_debug_contacts(HairSystem *UNUSED(hsys), HAIR_SolverDebugContact *contacts, int totcontacts)
-{
-#ifdef SHOW_CONTACTS
- int i;
-
- glBegin(GL_LINES);
- glColor3f(0.7f, 0.7f, 0.9f);
- for (i = 0; i < totcontacts; ++i) {
- HAIR_SolverDebugContact *c = contacts + i;
-
- glVertex3f(c->coA[0], c->coA[1], c->coA[2]);
- glVertex3f(c->coB[0], c->coB[1], c->coB[2]);
- }
- glEnd();
-
- glPointSize(3.0f);
- glBegin(GL_POINTS);
- for (i = 0; i < totcontacts; ++i) {
- HAIR_SolverDebugContact *c = contacts + i;
-
- glColor3f(1.0f, 0.1f, 0.0f);
- glVertex3f(c->coA[0], c->coA[1], c->coA[2]);
- glColor3f(0.0f, 1.0f, 0.7f);
- glVertex3f(c->coB[0], c->coB[1], c->coB[2]);
- }
- glEnd();
- glPointSize(1.0f);
-#else
- (void)contacts;
- (void)totcontacts;
-#endif
-}
-
static void draw_hair_debug_elements(HairSystem *UNUSED(hsys), HairDebugData *debug_data)
{
GHashIterator iter;
@@ -869,6 +640,7 @@ void draw_hair_debug_info(Scene *UNUSED(scene), View3D *UNUSED(v3d), ARegion *ar
for (hair = hsys->curves, i = 0; i < hsys->totcurves; ++hair, ++i)
draw_hair_curve_debug_smoothing(hsys, hair);
}
+
glPopMatrix();
if (hmd->debug_data) {
diff --git a/source/blender/hair/HAIR_capi.cpp b/source/blender/hair/HAIR_capi.cpp
index 8728a93..67795ec 100644
--- a/source/blender/hair/HAIR_capi.cpp
+++ b/source/blender/hair/HAIR_capi.cpp
@@ -147,8 +147,7 @@ void HAIR_solver_step_debug(struct HAIR_Solver *csolver, float time, float times
Debug::init();
- DebugThreadDataVector thread_data_list;
- solver->step_threaded(time, timestep, &thread_data_list);
+ solver->step_threaded(time, timestep);
if (debug_data) {
int i, tot = Debug::elements.size();
diff --git a/source/blender/hair/HAIR_debug_types.h b/source/blender/hair/HAIR_debug_types.h
index 1677c6c..e98fc2b 100644
--- a/source/blender/hair/HAIR_debug_types.h
+++ b/source/blender/hair/HAIR_debug_types.h
@@ -49,19 +49,6 @@ typedef enum eHAIR_SolverDebugElement_Type {
HAIR_DEBUG_ELEM_VECTOR,
} eHAIR_SolverDebugElement_Type;
-typedef struct HAIR_SolverDebugContact {
- float coA[3], coB[3];
-} HAIR_SolverDebugContact;
-
-typedef struct HAIR_SolverDebugPoint {
- int index;
- float co[3];
- float rest_bend[3];
- float bend[3];
- float force_bend[3];
- float frame[3][3];
-} HAIR_SolverDebugPoint;
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/hair/intern/HAIR_debug.cpp b/source/blender/hair/intern/HAIR_debug.cpp
index 11d6ec1..01bf487 100644
--- a/source/blender/hair/intern/HAIR_debug.cpp
+++ b/source/blender/hair/intern/HAIR_debug.cpp
@@ -32,6 +32,7 @@ HAIR_NAMESPACE_BEGIN
#ifdef HAIR_DEBUG
+bool Debug::active = false;
ThreadMutex Debug::mutex;
Debug::Elements Debug::elements;
diff --git a/source/blender/hair/intern/HAIR_debug.h b/source/blender/hair/intern/HAIR_debug.h
index 6157fcd..b5dda2d 100644
--- a/source/blender/hair/intern/HAIR_debug.h
+++ b/source/blender/hair/intern/HAIR_debug.h
@@ -46,21 +46,13 @@ HAIR_NAMESPACE_BEGIN
struct SolverData;
-struct DebugThreadData
-{
- typedef std::vector<HAIR_SolverDebugPoint> Points;
- typedef std::vector<HAIR_SolverDebugContact> CollisionContacts;
-
- CollisionContacts contacts;
- Points points;
-};
-
struct Debug {
typedef std::vector<HAIR_SolverDebugElement> Elements;
static void init()
{
BLI_mutex_init(&mutex);
+ active = true;
}
static void end()
@@ -68,6 +60,7 @@ struct Debug {
elements.clear();
BLI_mutex_end(&mutex);
+ active = false;
}
static void dot(const float3 &p, float r, float g, float b, int hash)
@@ -123,46 +116,7 @@ struct Debug {
BLI_mutex_unlock(&mutex);
}
- static void point(DebugThreadData *data, int index, const float3 &co,
- const float3 &rest_bend, const float3 &bend, const Frame &frame)
- {
-#ifdef HAIR_DEBUG
- if (data) {
- HAIR_SolverDebugPoint p;
- p.index = index;
- copy_v3_v3(p.co, co.data());
- copy_v3_v3(p.rest_bend, rest_bend.data());
- copy_v3_v3(p.bend, bend.data());
- copy_v3_v3(p.frame[0], frame.normal.data());
- copy_v3_v3(p.frame[1], frame.tangent.data());
- copy_v3_v3(p.frame[2], frame.cotangent.data());
- data->points.push_back(p);
- }
-#else
- (void)data;
- (void)index;
- (void)co;
- (void)bend;
- (void)frame;
-#endif
- }
-
- static void collision_contact(DebugThreadData *data, const float3 &coA, const float3 &coB)
- {
-#ifdef HAIR_DEBUG
- if (data) {
- HAIR_SolverDebugContact c;
- copy_v3_v3(c.coA, coA.data());
- copy_v3_v3(c.coB, coB.data());
- data->contacts.push_back(c);
- }
-#else
- (void)data;
- (void)coA;
- (void)coB;
-#endif
- }
-
+ static bool active;
static ThreadMutex mutex;
static Elements elements;
};
diff --git a/source/blender/hair/intern/HAIR_solver.cpp b/source/blender/hair/intern/HAIR_solver.cpp
index d25041e..cf3b6fc 100644
--- a/source/blender/hair/intern/HAIR_solver.cpp
+++ b/source/blender/hair/intern/HAI
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list