mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 18:11:13 +00:00
Improved ray shape (2D and 3D) by addiing the possibility to act as regular shape
This commit is contained in:
parent
cbdd410a6f
commit
ffc3ef8677
15 changed files with 117 additions and 20 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue