Commit: b40533a111268599d2e8e9873843d579af673c71
Author: Lukas Tönne
Date:   Mon Aug 4 16:18:57 2014 +0200
Branches: hair_system
https://developer.blender.org/rBb40533a111268599d2e8e9873843d579af673c71

Transform contact points into object space for drawing and show both
points at the same time.

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

M       source/blender/blenkernel/intern/object.c
M       source/blender/editors/space_view3d/drawhair.c
M       source/blender/hair/HAIR_capi.cpp
M       source/blender/hair/HAIR_capi.h
M       source/blender/hair/intern/HAIR_debug.h
M       source/blender/hair/intern/HAIR_solver.cpp

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

diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index ded7a4b..da3ff6c 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3127,6 +3127,17 @@ void BKE_object_sim_tick(Scene *UNUSED(scene), Object 
*ob, float ctime, float ti
                        if (hmd->debug_contacts)
                                MEM_freeN(hmd->debug_contacts);
                        HAIR_solver_step_debug(hmd->solver, ctime, timestep, 
&hmd->debug_contacts, &hmd->debug_totcontacts);
+                       /* transform to object space */
+                       {
+                               float imat[4][4];
+                               int i;
+                               invert_m4_m4(imat, ob->obmat);
+                               for (i = 0; i < hmd->debug_totcontacts; ++i) {
+                                       HAIR_SolverContact *c = 
hmd->debug_contacts + i;
+                                       mul_m4_v3(imat, c->coA);
+                                       mul_m4_v3(imat, c->coB);
+                               }
+                       }
 #endif
                }
        }
diff --git a/source/blender/editors/space_view3d/drawhair.c 
b/source/blender/editors/space_view3d/drawhair.c
index 8d9855e..8f3b6e5 100644
--- a/source/blender/editors/space_view3d/drawhair.c
+++ b/source/blender/editors/space_view3d/drawhair.c
@@ -258,14 +258,25 @@ static void draw_hair_debug_contacts(HAIR_SolverContact 
*contacts, int totcontac
 #ifdef SHOW_CONTACTS
        int i;
        
-       glColor3f(1.0f, 0.1f, 0.0f);
+       glBegin(GL_LINES);
+       glColor3f(0.7f, 0.7f, 0.9f);
+       for (i = 0; i < totcontacts; ++i) {
+               HAIR_SolverContact *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_SolverContact *c = contacts + i;
                
-               glVertex3f(c->co[0], c->co[1], c->co[2]);
+               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);
diff --git a/source/blender/hair/HAIR_capi.cpp 
b/source/blender/hair/HAIR_capi.cpp
index c192184..f84d1ac 100644
--- a/source/blender/hair/HAIR_capi.cpp
+++ b/source/blender/hair/HAIR_capi.cpp
@@ -111,7 +111,8 @@ void HAIR_solver_step_debug(struct HAIR_Solver *csolver, 
float time, float times
        *contacts = (HAIR_SolverContact 
*)MEM_mallocN(sizeof(HAIR_SolverContact) * dbg_contacts.size(), "hair solver 
contact debug data");
        for (int i = 0; i < dbg_contacts.size(); ++i) {
                HAIR_SolverContact *c = (*contacts) + i;
-               copy_v3_v3(c->co, dbg_contacts[i].data());
+               copy_v3_v3(c->coA, dbg_contacts[i].coA.data());
+               copy_v3_v3(c->coB, dbg_contacts[i].coB.data());
        }
 }
 
diff --git a/source/blender/hair/HAIR_capi.h b/source/blender/hair/HAIR_capi.h
index 6a29e9d..faa20c3 100644
--- a/source/blender/hair/HAIR_capi.h
+++ b/source/blender/hair/HAIR_capi.h
@@ -45,7 +45,7 @@ void HAIR_solver_build_data(struct HAIR_Solver *solver, 
struct Scene *scene, str
 void HAIR_solver_update_externals(struct HAIR_Solver *solver, struct Scene 
*scene, struct Object *ob, struct DerivedMesh *dm, struct HairSystem *hsys, 
float time);
 
 typedef struct HAIR_SolverContact {
-       float co[3];
+       float coA[3], coB[3];
 } HAIR_SolverContact;
 
 void HAIR_solver_step(struct HAIR_Solver *solver, float time, float timestep);
diff --git a/source/blender/hair/intern/HAIR_debug.h 
b/source/blender/hair/intern/HAIR_debug.h
index 069c022..d363dde 100644
--- a/source/blender/hair/intern/HAIR_debug.h
+++ b/source/blender/hair/intern/HAIR_debug.h
@@ -38,14 +38,21 @@ HAIR_NAMESPACE_BEGIN
 #endif
 
 struct Debug {
-       typedef std::vector<float3> CollisionContacts;
+       struct Contact {
+               float3 coA, coB;
+       };
+       typedef std::vector<Contact> CollisionContacts;
        
 #ifdef HAIR_DEBUG
 
-       static void collision_contact(const float3 &co)
+       static void collision_contact(const float3 &coA, const float3 &coB)
        {
-               if (m_contacts)
-                       m_contacts->push_back(co);
+               if (m_contacts) {
+                       Contact c;
+                       c.coA = coA;
+                       c.coB = coB;
+                       m_contacts->push_back(c);
+               }
        }
        
        static void set_collision_contacts(CollisionContacts *contacts)
diff --git a/source/blender/hair/intern/HAIR_solver.cpp 
b/source/blender/hair/intern/HAIR_solver.cpp
index 4e07282..f176a6a 100644
--- a/source/blender/hair/intern/HAIR_solver.cpp
+++ b/source/blender/hair/intern/HAIR_solver.cpp
@@ -163,7 +163,7 @@ static void debug_point_contacts(btDynamicsWorld *dworld, 
Point *point)
                                        const btVector3 &ptB = 
pt.getPositionWorldOnB();
                                        const btVector3 &normalOnB = 
pt.m_normalWorldOnB;
                                        
-                                       
Debug::collision_contact(float3(ptB.x(), ptB.y(), ptB.z()));
+                                       
Debug::collision_contact(float3(ptA.x(), ptA.y(), ptA.z()), float3(ptB.x(), 
ptB.y(), ptB.z()));
                                }
                        }
                }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to