1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Improved ray shape (2D and 3D) by addiing the possibility to act as regular shape

This commit is contained in:
Andrea Catania
2018-02-19 20:59:57 +01:00
parent cbdd410a6f
commit ffc3ef8677
15 changed files with 117 additions and 20 deletions

View File

@@ -100,14 +100,16 @@ void GodotRayWorldAlgorithm::processCollision(const btCollisionObjectWrapper *bo
if (btResult.hasHit()) {
btVector3 ray_normal(ray_transform.getOrigin() - to.getOrigin());
ray_normal.normalize();
btScalar depth(ray_shape->getScaledLength() * (btResult.m_closestHitFraction - 1));
if (depth >= -RAY_STABILITY_MARGIN)
depth = 0;
resultOut->addContactPoint(ray_normal, btResult.m_hitPointWorld, depth);
if (ray_shape->getSlipsOnSlope())
resultOut->addContactPoint(btResult.m_hitNormalWorld, btResult.m_hitPointWorld, depth);
else {
resultOut->addContactPoint((ray_transform.getOrigin() - to.getOrigin()).normalize(), btResult.m_hitPointWorld, depth);
}
}
}