summaryrefslogtreecommitdiff
path: root/modules/bullet/godot_ray_world_algorithm.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-02-19 22:15:49 +0100
committerGitHub <noreply@github.com>2018-02-19 22:15:49 +0100
commitb2aeb02e7d43d98973334e39db5c39626ba9f775 (patch)
treed0d97ce31a873972558a01d7e12d3157f7162869 /modules/bullet/godot_ray_world_algorithm.cpp
parent6ee4298ee3192e2c82e7b26b078f32302764ace5 (diff)
parentffc3ef86778f486823bedf66cc5a937fc09abe6a (diff)
Merge pull request #16530 from AndreaCatania/rays
Improved ray shape (2D and 3D) by addiing the possibility to act as r…
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);
+ }
}
}