]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
jump ontop of Boars
authorPeter Schaefer <schaeferpm@gmail.com>
Fri, 24 Jun 2016 11:19:26 +0000 (13:19 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Fri, 24 Jun 2016 11:19:26 +0000 (13:19 +0200)
optimized lvl Collision

Weave/Scene/Boar.cpp
Weave/Scene/Level.cpp

index bce2cb277adb0b1557f3e3a04929592082c32edb..01e557a7d1cd3604f426a1f2c956c6a276359236 100644 (file)
@@ -43,11 +43,25 @@ void Boar::collides(SceneObject * _other, btPersistentManifold * _contactManifol
        int numContacts = _contactManifold->getNumContacts();
        //For each contact point in that manifold
        double pdist = (_contactManifold->getContactPoint(0).getDistance());
+       btVector3 ptN = (_contactManifold->getContactPoint(0).m_normalWorldOnB);;
        for (int j = 0; j < numContacts; j++) {
                //Get the contact information
                btManifoldPoint& pt = _contactManifold->getContactPoint(j);
-               btVector3 ptA = pt.getPositionWorldOnA();
-               pdist = min(((double)pt.getDistance()), pdist);
+
+               if (pdist >= pt.getDistance())
+               {
+                       pdist = pt.getDistance();
+                       ptN = pt.m_normalWorldOnB;
+               }
+
+
+       }
+
+       if (ptN.getY() >= .4f)
+       {
+               _other->ySpeed = 5;
+               //BOAR DIE!!!
+               return;
        }
 
        if (pdist >= .0f)
index e72d6134429d4f9e610381fce2f7a7a28f97a1d4..cf9b63dbfab7851db25f3275732897e9ddad60b1 100644 (file)
@@ -47,16 +47,12 @@ void Level::collides(SceneObject* _other, btPersistentManifold* _contactManifold
        {
                //Get the contact information
                btManifoldPoint& pt = _contactManifold->getContactPoint(j);
-               btVector3 ptA = pt.getPositionWorldOnA();
-               btVector3 ptB = pt.getPositionWorldOnB();
 
-               vec3 ptAg(ptA.getX(), ptA.getY(), ptA.getZ());
-               vec3 ptBg(ptB.getX(), ptB.getY(), ptB.getZ());
-               //normal = normalize(ptAg - ptBg);
                pdist = pt.getDistance();
 
                btVector3 ptN = pt.m_normalWorldOnB;
                normal = vec3(ptN.getX(), ptN.getY(), ptN.getZ());
+
                _other->yFloorDist = pdist * normal[1];