summaryrefslogtreecommitdiffstats
path: root/modules/bullet/godot_ray_world_algorithm.cpp
diff options
context:
space:
mode:
authorAndrea Catania <info@andreacatania.com>2018-02-19 20:59:57 +0100
committerAndrea Catania <info@andreacatania.com>2018-02-19 20:59:57 +0100
commitffc3ef86778f486823bedf66cc5a937fc09abe6a (patch)
tree15581f9cc2b0fedbacf20dbf989700682f6661c0 /modules/bullet/godot_ray_world_algorithm.cpp
parentcbdd410a6f476503ee4bc27ac2f475a73960236d (diff)
downloadredot-engine-ffc3ef86778f486823bedf66cc5a937fc09abe6a.tar.gz
Improved ray shape (2D and 3D) by addiing the possibility to act as regular shape
Diffstat (limited to 'modules/bullet/godot_ray_world_algorithm.cpp')
-rw-r--r--modules/bullet/godot_ray_world_algorithm.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/bullet/godot_ray_world_algorithm.cpp b/modules/bullet/godot_ray_world_algorithm.cpp
index 4a511b39a7..53d0ab7e3c 100644
--- a/modules/bullet/godot_ray_world_algorithm.cpp
+++ b/modules/bullet/godot_ray_world_algorithm.cpp
@@ -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);
+ }
}
}