]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
Falling and walking against the lvl works
authorPeter Schaefer <schaeferpm@gmail.com>
Sun, 14 Jun 2015 08:41:32 +0000 (10:41 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Sun, 14 Jun 2015 08:41:32 +0000 (10:41 +0200)
still wrong CollideMeshes

Weave/Scene/Level.cpp
Weave/Scene/SceneObject.cpp

index 18566cc82be5c192685517a04704b725f47cfb21..03f67a2bbc1f76be2060e5ffe14f08f681be6d67 100644 (file)
@@ -22,19 +22,30 @@ void Level::collides(SceneObject* _other, btPersistentManifold* _contactManifold
 {
        int numContacts = _contactManifold->getNumContacts();
        //For each contact point in that manifold
-       //double pdist = _contactManifold->getContactPoint(0).getDistance();
-       for (int j = 0; j < numContacts; j++) {
+       float pdist = _contactManifold->getContactPoint(0).getDistance();
+       for (int j = 0; j < numContacts; j++) 
+       {
                //Get the contact information
                btManifoldPoint& pt = _contactManifold->getContactPoint(j);
-               btVector3 ptN = pt.m_normalWorldOnB;
-               _other->yFloorDist = (double)pt.getDistance() * abs(dot(vec3(0.f, 1.f, 0.f), vec3(ptN.getX(), ptN.getY(), ptN.getZ())));
-               //btVector3 ptA = pt.getPositionWorldOnA();
-               //pdist = min((double)pt.getDistance(), pdist);
+               btVector3 ptA = pt.getPositionWorldOnA();
+               btVector3 ptB = pt.getPositionWorldOnB();
+               vec3 ptAg(ptA.getX(), ptA.getY(), ptA.getZ());
+               vec3 ptBg(ptB.getX(), ptB.getY(), ptB.getZ());
+               vec3 normal = normalize(ptAg - ptBg);
+               pdist = pt.getDistance();
+
+               //btVector3 ptN = pt.m_normalWorldOnB;
+               //vec3 normal = vec3(ptN.getX(), ptN.getY(), ptN.getZ());
+               _other->yFloorDist = pdist * normal[1];
+
+               if (normal[1] <= .6f && pdist<0)
+                       _other->move(-pdist * vec3(normal[0], 0.f, normal[2]));
+
        }
 
        if (_other->yFloorDist <= 0 && _other->ySpeed<0)
                _other->ySpeed = 0;
 
-       Message::info((std::string)"Kollision! " + std::to_string(_other->yFloorDist) + " (LVL with " + (std::string)*_other->getModel() + ")");
+       //Message::info((std::string)"Kollision! " + std::to_string(_other->yFloorDist) + " (LVL with " + (std::string)*_other->getModel() + ")");
 
 }
\ No newline at end of file
index 96598379b7bb979106b681697a82145d52878c96..3ff94547dad551e9b13ffc974fab8e845be3df41 100644 (file)
@@ -179,8 +179,8 @@ void SceneObject::collides(SceneObject* _other, btPersistentManifold* _contactMa
                pdist = min((double)pt.getDistance(),pdist);
        }
        
-       if (!ignore && !_other->ignore && pdist <= 0)
-               Message::info((std::string)"Kollision! " + std::to_string(pdist) + " (" + (std::string)*model + " with " + (std::string)*_other->getModel() + ")");
+//     if (!ignore && !_other->ignore && pdist <= 0)
+//             Message::info((std::string)"Kollision! " + std::to_string(pdist) + " (" + (std::string)*model + " with " + (std::string)*_other->getModel() + ")");
 
 }