From 14d36ba15e5f0b5524c9791a618a5e9c3e5d00b2 Mon Sep 17 00:00:00 2001 From: jitspoe Date: Fri, 16 Aug 2024 21:30:56 -0400 Subject: [PATCH] Enabled double precision for bullet physics engine and added a flag to get more correct raycast results. --- SConstruct | 2 ++ modules/bullet/space_bullet.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/SConstruct b/SConstruct index d0ffcde3e35b..e03bd1d501cc 100644 --- a/SConstruct +++ b/SConstruct @@ -382,6 +382,8 @@ if env_base["rids"] == "tracked_handles": env_base.Append(CPPDEFINES=["RID_HANDLE_ALLOCATION_TRACKING_ENABLED"]) print("WARNING: Building with RIDs as tracked handles.") +env_base.Append(CPPDEFINES=["BT_USE_DOUBLE_PRECISION"]) # Enable double precision in bullet physics engine + if selected_platform in platform_list: tmppath = "./platform/" + selected_platform sys.path.insert(0, tmppath) diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index f227e207c253..ac9c8d95d696 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V btResult.m_collisionFilterGroup = 0; btResult.m_collisionFilterMask = p_collision_mask; btResult.m_pickRay = p_pick_ray; + btResult.m_flags |= btTriangleRaycastCallback::kF_UseGjkConvexCastRaytest; space->dynamicsWorld->rayTest(btVec_from, btVec_to, btResult); if (btResult.hasHit()) {