{
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
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() + ")");
}