feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -132,19 +132,14 @@ thirdparty_sources = [
|
|||
"Jolt/Skeleton/Skeleton.cpp",
|
||||
"Jolt/Skeleton/SkeletonMapper.cpp",
|
||||
"Jolt/Skeleton/SkeletonPose.cpp",
|
||||
"Jolt/TriangleGrouper/TriangleGrouperClosestCentroid.cpp",
|
||||
"Jolt/TriangleGrouper/TriangleGrouperMorton.cpp",
|
||||
"Jolt/TriangleSplitter/TriangleSplitter.cpp",
|
||||
"Jolt/TriangleSplitter/TriangleSplitterBinning.cpp",
|
||||
"Jolt/TriangleSplitter/TriangleSplitterFixedLeafSize.cpp",
|
||||
"Jolt/TriangleSplitter/TriangleSplitterLongestAxis.cpp",
|
||||
"Jolt/TriangleSplitter/TriangleSplitterMean.cpp",
|
||||
"Jolt/TriangleSplitter/TriangleSplitterMorton.cpp",
|
||||
]
|
||||
|
||||
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
|
||||
|
||||
env_jolt.Prepend(CPPPATH=[thirdparty_dir])
|
||||
env_jolt.Prepend(CPPEXTPATH=[thirdparty_dir])
|
||||
|
||||
if env.dev_build:
|
||||
env_jolt.Append(CPPDEFINES=["JPH_ENABLE_ASSERTS"])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
def can_build(env, platform):
|
||||
return not env["disable_3d"] and not env["arch"] == "ppc32"
|
||||
return not env["disable_physics_3d"] and not env["arch"] == "ppc32"
|
||||
|
||||
|
||||
def configure(env):
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CONE_TWIST_JOINT_3D_H
|
||||
#define JOLT_CONE_TWIST_JOINT_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "../jolt_physics_server_3d.h"
|
||||
#include "jolt_joint_3d.h"
|
||||
|
|
@ -93,5 +92,3 @@ public:
|
|||
|
||||
virtual void rebuild() override;
|
||||
};
|
||||
|
||||
#endif // JOLT_CONE_TWIST_JOINT_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_GENERIC_6DOF_JOINT_3D_H
|
||||
#define JOLT_GENERIC_6DOF_JOINT_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "../jolt_physics_server_3d.h"
|
||||
#include "jolt_joint_3d.h"
|
||||
|
|
@ -123,5 +122,3 @@ public:
|
|||
|
||||
virtual void rebuild() override;
|
||||
};
|
||||
|
||||
#endif // JOLT_GENERIC_6DOF_JOINT_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_HINGE_JOINT_3D_H
|
||||
#define JOLT_HINGE_JOINT_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "../jolt_physics_server_3d.h"
|
||||
#include "jolt_joint_3d.h"
|
||||
|
|
@ -96,5 +95,3 @@ public:
|
|||
|
||||
virtual void rebuild() override;
|
||||
};
|
||||
|
||||
#endif // JOLT_HINGE_JOINT_3D_H
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ JoltJoint3D::JoltJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, J
|
|||
body_b->add_joint(this);
|
||||
}
|
||||
|
||||
if (body_b == nullptr && JoltProjectSettings::use_joint_world_node_a()) {
|
||||
if (body_b == nullptr && JoltProjectSettings::joint_world_node == JOLT_JOINT_WORLD_NODE_A) {
|
||||
// The joint scene nodes will, when omitting one of the two body nodes, always pass in a
|
||||
// null `body_b` to indicate it being the "world node", regardless of which body node you
|
||||
// leave blank. So we need to correct for that if we wish to use the arguably more intuitive
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_JOINT_3D_H
|
||||
#define JOLT_JOINT_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/physics_server_3d.h"
|
||||
|
||||
|
|
@ -103,5 +102,3 @@ public:
|
|||
|
||||
virtual void rebuild() {}
|
||||
};
|
||||
|
||||
#endif // JOLT_JOINT_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_PIN_JOINT_3D_H
|
||||
#define JOLT_PIN_JOINT_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_joint_3d.h"
|
||||
|
||||
|
|
@ -60,5 +59,3 @@ public:
|
|||
|
||||
virtual void rebuild() override;
|
||||
};
|
||||
|
||||
#endif // JOLT_PIN_JOINT_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_SLIDER_JOINT_3D_H
|
||||
#define JOLT_SLIDER_JOINT_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "../jolt_physics_server_3d.h"
|
||||
#include "jolt_joint_3d.h"
|
||||
|
|
@ -92,5 +91,3 @@ public:
|
|||
|
||||
virtual void rebuild() override;
|
||||
};
|
||||
|
||||
#endif // JOLT_SLIDER_JOINT_3D_H
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_GLOBALS_H
|
||||
#define JOLT_GLOBALS_H
|
||||
#pragma once
|
||||
|
||||
void jolt_initialize();
|
||||
void jolt_deinitialize();
|
||||
|
||||
#endif // JOLT_GLOBALS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_PHYSICS_SERVER_3D_H
|
||||
#define JOLT_PHYSICS_SERVER_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/rid_owner.h"
|
||||
#include "servers/physics_server_3d.h"
|
||||
|
|
@ -499,5 +498,3 @@ VARIANT_ENUM_CAST(JoltPhysicsServer3D::ConeTwistJointParamJolt)
|
|||
VARIANT_ENUM_CAST(JoltPhysicsServer3D::ConeTwistJointFlagJolt)
|
||||
VARIANT_ENUM_CAST(JoltPhysicsServer3D::G6DOFJointAxisParamJolt)
|
||||
VARIANT_ENUM_CAST(JoltPhysicsServer3D::G6DOFJointAxisFlagJolt)
|
||||
|
||||
#endif // JOLT_PHYSICS_SERVER_3D_H
|
||||
|
|
|
|||
|
|
@ -32,15 +32,6 @@
|
|||
|
||||
#include "core/config/project_settings.h"
|
||||
|
||||
namespace {
|
||||
|
||||
enum JoltJointWorldNode : int {
|
||||
JOLT_JOINT_WORLD_NODE_A,
|
||||
JOLT_JOINT_WORLD_NODE_B,
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void JoltProjectSettings::register_settings() {
|
||||
GLOBAL_DEF(PropertyInfo(Variant::INT, "physics/jolt_physics_3d/simulation/velocity_steps", PROPERTY_HINT_RANGE, U"2,16,or_greater"), 10);
|
||||
GLOBAL_DEF(PropertyInfo(Variant::INT, "physics/jolt_physics_3d/simulation/position_steps", PROPERTY_HINT_RANGE, U"1,16,or_greater"), 2);
|
||||
|
|
@ -80,149 +71,53 @@ void JoltProjectSettings::register_settings() {
|
|||
GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "physics/jolt_physics_3d/limits/max_bodies", PROPERTY_HINT_RANGE, U"1,10240,or_greater"), 10240);
|
||||
GLOBAL_DEF(PropertyInfo(Variant::INT, "physics/jolt_physics_3d/limits/max_body_pairs", PROPERTY_HINT_RANGE, U"8,65536,or_greater"), 65536);
|
||||
GLOBAL_DEF(PropertyInfo(Variant::INT, "physics/jolt_physics_3d/limits/max_contact_constraints", PROPERTY_HINT_RANGE, U"8,20480,or_greater"), 20480);
|
||||
|
||||
read_settings();
|
||||
|
||||
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp_static(JoltProjectSettings::read_settings));
|
||||
}
|
||||
|
||||
int JoltProjectSettings::get_simulation_velocity_steps() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/velocity_steps");
|
||||
}
|
||||
void JoltProjectSettings::read_settings() {
|
||||
simulation_velocity_steps = GLOBAL_GET("physics/jolt_physics_3d/simulation/velocity_steps");
|
||||
simulation_position_steps = GLOBAL_GET("physics/jolt_physics_3d/simulation/position_steps");
|
||||
use_enhanced_internal_edge_removal_for_bodies = GLOBAL_GET("physics/jolt_physics_3d/simulation/use_enhanced_internal_edge_removal");
|
||||
areas_detect_static_bodies = GLOBAL_GET("physics/jolt_physics_3d/simulation/areas_detect_static_bodies");
|
||||
generate_all_kinematic_contacts = GLOBAL_GET("physics/jolt_physics_3d/simulation/generate_all_kinematic_contacts");
|
||||
penetration_slop = GLOBAL_GET("physics/jolt_physics_3d/simulation/penetration_slop");
|
||||
speculative_contact_distance = GLOBAL_GET("physics/jolt_physics_3d/simulation/speculative_contact_distance");
|
||||
baumgarte_stabilization_factor = GLOBAL_GET("physics/jolt_physics_3d/simulation/baumgarte_stabilization_factor");
|
||||
soft_body_point_radius = GLOBAL_GET("physics/jolt_physics_3d/simulation/soft_body_point_radius");
|
||||
bounce_velocity_threshold = GLOBAL_GET("physics/jolt_physics_3d/simulation/bounce_velocity_threshold");
|
||||
sleep_allowed = GLOBAL_GET("physics/jolt_physics_3d/simulation/allow_sleep");
|
||||
sleep_velocity_threshold = GLOBAL_GET("physics/jolt_physics_3d/simulation/sleep_velocity_threshold");
|
||||
sleep_time_threshold = GLOBAL_GET("physics/jolt_physics_3d/simulation/sleep_time_threshold");
|
||||
ccd_movement_threshold = GLOBAL_GET("physics/jolt_physics_3d/simulation/continuous_cd_movement_threshold");
|
||||
ccd_max_penetration = GLOBAL_GET("physics/jolt_physics_3d/simulation/continuous_cd_max_penetration");
|
||||
body_pair_contact_cache_enabled = GLOBAL_GET("physics/jolt_physics_3d/simulation/body_pair_contact_cache_enabled");
|
||||
float body_pair_cache_distance = GLOBAL_GET("physics/jolt_physics_3d/simulation/body_pair_contact_cache_distance_threshold");
|
||||
body_pair_cache_distance_sq = body_pair_cache_distance * body_pair_cache_distance;
|
||||
float body_pair_cache_angle = GLOBAL_GET("physics/jolt_physics_3d/simulation/body_pair_contact_cache_angle_threshold");
|
||||
body_pair_cache_angle_cos_div2 = Math::cos(body_pair_cache_angle / 2.0f);
|
||||
|
||||
int JoltProjectSettings::get_simulation_position_steps() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/position_steps");
|
||||
}
|
||||
use_enhanced_internal_edge_removal_for_queries = GLOBAL_GET("physics/jolt_physics_3d/queries/use_enhanced_internal_edge_removal");
|
||||
enable_ray_cast_face_index = GLOBAL_GET("physics/jolt_physics_3d/queries/enable_ray_cast_face_index");
|
||||
|
||||
bool JoltProjectSettings::use_enhanced_internal_edge_removal_for_bodies() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/use_enhanced_internal_edge_removal");
|
||||
}
|
||||
use_enhanced_internal_edge_removal_for_motion_queries = GLOBAL_GET("physics/jolt_physics_3d/motion_queries/use_enhanced_internal_edge_removal");
|
||||
motion_query_recovery_iterations = GLOBAL_GET("physics/jolt_physics_3d/motion_queries/recovery_iterations");
|
||||
motion_query_recovery_amount = GLOBAL_GET("physics/jolt_physics_3d/motion_queries/recovery_amount");
|
||||
|
||||
bool JoltProjectSettings::areas_detect_static_bodies() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/areas_detect_static_bodies");
|
||||
}
|
||||
collision_margin_fraction = GLOBAL_GET("physics/jolt_physics_3d/collisions/collision_margin_fraction");
|
||||
float active_edge_threshold = GLOBAL_GET("physics/jolt_physics_3d/collisions/active_edge_threshold");
|
||||
active_edge_threshold_cos = Math::cos(active_edge_threshold);
|
||||
|
||||
bool JoltProjectSettings::should_generate_all_kinematic_contacts() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/generate_all_kinematic_contacts");
|
||||
}
|
||||
joint_world_node = (JoltJointWorldNode)(int)GLOBAL_GET("physics/jolt_physics_3d/joints/world_node");
|
||||
|
||||
float JoltProjectSettings::get_penetration_slop() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/penetration_slop");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_speculative_contact_distance() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/speculative_contact_distance");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_baumgarte_stabilization_factor() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/baumgarte_stabilization_factor");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_soft_body_point_radius() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/soft_body_point_radius");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_bounce_velocity_threshold() {
|
||||
static const float value = GLOBAL_GET("physics/jolt_physics_3d/simulation/bounce_velocity_threshold");
|
||||
return value;
|
||||
}
|
||||
|
||||
bool JoltProjectSettings::is_sleep_allowed() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/allow_sleep");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_sleep_velocity_threshold() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/sleep_velocity_threshold");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_sleep_time_threshold() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/sleep_time_threshold");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_ccd_movement_threshold() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/continuous_cd_movement_threshold");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_ccd_max_penetration() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/continuous_cd_max_penetration");
|
||||
}
|
||||
|
||||
bool JoltProjectSettings::is_body_pair_contact_cache_enabled() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/simulation/body_pair_contact_cache_enabled");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_body_pair_cache_distance_sq() {
|
||||
const float value = GLOBAL_GET("physics/jolt_physics_3d/simulation/body_pair_contact_cache_distance_threshold");
|
||||
return value * value;
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_body_pair_cache_angle_cos_div2() {
|
||||
return Math::cos((float)GLOBAL_GET("physics/jolt_physics_3d/simulation/body_pair_contact_cache_angle_threshold") / 2.0f);
|
||||
}
|
||||
|
||||
bool JoltProjectSettings::use_enhanced_internal_edge_removal_for_queries() {
|
||||
static const bool value = GLOBAL_GET("physics/jolt_physics_3d/queries/use_enhanced_internal_edge_removal");
|
||||
return value;
|
||||
}
|
||||
|
||||
bool JoltProjectSettings::enable_ray_cast_face_index() {
|
||||
static const bool value = GLOBAL_GET("physics/jolt_physics_3d/queries/enable_ray_cast_face_index");
|
||||
return value;
|
||||
}
|
||||
|
||||
bool JoltProjectSettings::use_enhanced_internal_edge_removal_for_motion_queries() {
|
||||
static const bool value = GLOBAL_GET("physics/jolt_physics_3d/motion_queries/use_enhanced_internal_edge_removal");
|
||||
return value;
|
||||
}
|
||||
|
||||
int JoltProjectSettings::get_motion_query_recovery_iterations() {
|
||||
static const int value = GLOBAL_GET("physics/jolt_physics_3d/motion_queries/recovery_iterations");
|
||||
return value;
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_motion_query_recovery_amount() {
|
||||
static const float value = GLOBAL_GET("physics/jolt_physics_3d/motion_queries/recovery_amount");
|
||||
return value;
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_collision_margin_fraction() {
|
||||
static const float value = GLOBAL_GET("physics/jolt_physics_3d/collisions/collision_margin_fraction");
|
||||
return value;
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_active_edge_threshold() {
|
||||
static const float value = Math::cos((float)GLOBAL_GET("physics/jolt_physics_3d/collisions/active_edge_threshold"));
|
||||
return value;
|
||||
}
|
||||
|
||||
bool JoltProjectSettings::use_joint_world_node_a() {
|
||||
return (int)GLOBAL_GET("physics/jolt_physics_3d/joints/world_node") == JOLT_JOINT_WORLD_NODE_A;
|
||||
}
|
||||
|
||||
int JoltProjectSettings::get_temp_memory_mib() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/limits/temporary_memory_buffer_size");
|
||||
}
|
||||
|
||||
int64_t JoltProjectSettings::get_temp_memory_b() {
|
||||
return get_temp_memory_mib() * 1024 * 1024;
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_world_boundary_shape_size() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/limits/world_boundary_shape_size");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_max_linear_velocity() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/limits/max_linear_velocity");
|
||||
}
|
||||
|
||||
float JoltProjectSettings::get_max_angular_velocity() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/limits/max_angular_velocity");
|
||||
}
|
||||
|
||||
int JoltProjectSettings::get_max_bodies() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/limits/max_bodies");
|
||||
}
|
||||
|
||||
int JoltProjectSettings::get_max_pairs() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/limits/max_body_pairs");
|
||||
}
|
||||
|
||||
int JoltProjectSettings::get_max_contact_constraints() {
|
||||
return GLOBAL_GET("physics/jolt_physics_3d/limits/max_contact_constraints");
|
||||
temp_memory_mib = GLOBAL_GET("physics/jolt_physics_3d/limits/temporary_memory_buffer_size");
|
||||
temp_memory_b = temp_memory_mib * 1024 * 1024;
|
||||
world_boundary_shape_size = GLOBAL_GET("physics/jolt_physics_3d/limits/world_boundary_shape_size");
|
||||
max_linear_velocity = GLOBAL_GET("physics/jolt_physics_3d/limits/max_linear_velocity");
|
||||
max_angular_velocity = GLOBAL_GET("physics/jolt_physics_3d/limits/max_angular_velocity");
|
||||
max_bodies = GLOBAL_GET("physics/jolt_physics_3d/limits/max_bodies");
|
||||
max_body_pairs = GLOBAL_GET("physics/jolt_physics_3d/limits/max_body_pairs");
|
||||
max_contact_constraints = GLOBAL_GET("physics/jolt_physics_3d/limits/max_contact_constraints");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,54 +28,57 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_PROJECT_SETTINGS_H
|
||||
#define JOLT_PROJECT_SETTINGS_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class JoltProjectSettings {
|
||||
public:
|
||||
static void register_settings();
|
||||
|
||||
static int get_simulation_velocity_steps();
|
||||
static int get_simulation_position_steps();
|
||||
static bool use_enhanced_internal_edge_removal_for_bodies();
|
||||
static bool areas_detect_static_bodies();
|
||||
static bool should_generate_all_kinematic_contacts();
|
||||
static float get_penetration_slop();
|
||||
static float get_speculative_contact_distance();
|
||||
static float get_baumgarte_stabilization_factor();
|
||||
static float get_soft_body_point_radius();
|
||||
static float get_bounce_velocity_threshold();
|
||||
static bool is_sleep_allowed();
|
||||
static float get_sleep_velocity_threshold();
|
||||
static float get_sleep_time_threshold();
|
||||
static float get_ccd_movement_threshold();
|
||||
static float get_ccd_max_penetration();
|
||||
static bool is_body_pair_contact_cache_enabled();
|
||||
static float get_body_pair_cache_distance_sq();
|
||||
static float get_body_pair_cache_angle_cos_div2();
|
||||
|
||||
static bool use_enhanced_internal_edge_removal_for_queries();
|
||||
static bool enable_ray_cast_face_index();
|
||||
|
||||
static bool use_enhanced_internal_edge_removal_for_motion_queries();
|
||||
static int get_motion_query_recovery_iterations();
|
||||
static float get_motion_query_recovery_amount();
|
||||
|
||||
static float get_collision_margin_fraction();
|
||||
static float get_active_edge_threshold();
|
||||
|
||||
static bool use_joint_world_node_a();
|
||||
|
||||
static int get_temp_memory_mib();
|
||||
static int64_t get_temp_memory_b();
|
||||
static float get_world_boundary_shape_size();
|
||||
static float get_max_linear_velocity();
|
||||
static float get_max_angular_velocity();
|
||||
static int get_max_bodies();
|
||||
static int get_max_pairs();
|
||||
static int get_max_contact_constraints();
|
||||
enum JoltJointWorldNode : int {
|
||||
JOLT_JOINT_WORLD_NODE_A,
|
||||
JOLT_JOINT_WORLD_NODE_B,
|
||||
};
|
||||
|
||||
#endif // JOLT_PROJECT_SETTINGS_H
|
||||
class JoltProjectSettings {
|
||||
public:
|
||||
inline static int simulation_velocity_steps;
|
||||
inline static int simulation_position_steps;
|
||||
inline static bool use_enhanced_internal_edge_removal_for_bodies;
|
||||
inline static bool areas_detect_static_bodies;
|
||||
inline static bool generate_all_kinematic_contacts;
|
||||
inline static float penetration_slop;
|
||||
inline static float speculative_contact_distance;
|
||||
inline static float baumgarte_stabilization_factor;
|
||||
inline static float soft_body_point_radius;
|
||||
inline static float bounce_velocity_threshold;
|
||||
inline static bool sleep_allowed;
|
||||
inline static float sleep_velocity_threshold;
|
||||
inline static float sleep_time_threshold;
|
||||
inline static float ccd_movement_threshold;
|
||||
inline static float ccd_max_penetration;
|
||||
inline static bool body_pair_contact_cache_enabled;
|
||||
inline static float body_pair_cache_distance_sq;
|
||||
inline static float body_pair_cache_angle_cos_div2;
|
||||
|
||||
inline static bool use_enhanced_internal_edge_removal_for_queries;
|
||||
inline static bool enable_ray_cast_face_index;
|
||||
|
||||
inline static bool use_enhanced_internal_edge_removal_for_motion_queries;
|
||||
inline static int motion_query_recovery_iterations;
|
||||
inline static float motion_query_recovery_amount;
|
||||
|
||||
inline static float collision_margin_fraction;
|
||||
inline static float active_edge_threshold_cos;
|
||||
|
||||
inline static JoltJointWorldNode joint_world_node;
|
||||
|
||||
inline static int temp_memory_mib;
|
||||
inline static int64_t temp_memory_b;
|
||||
inline static float world_boundary_shape_size;
|
||||
inline static float max_linear_velocity;
|
||||
inline static float max_angular_velocity;
|
||||
inline static int max_bodies;
|
||||
inline static int max_body_pairs;
|
||||
inline static int max_contact_constraints;
|
||||
|
||||
static void register_settings();
|
||||
static void read_settings();
|
||||
};
|
||||
|
|
|
|||
70
engine/modules/jolt_physics/misc/jolt_math_funcs.cpp
Normal file
70
engine/modules/jolt_physics/misc/jolt_math_funcs.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/**************************************************************************/
|
||||
/* jolt_math_funcs.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
/*
|
||||
Adapted to Godot from the Jolt Physics library.
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2021 Jorrit Rouwe
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "jolt_math_funcs.h"
|
||||
|
||||
void JoltMath::decompose(Basis &p_basis, Vector3 &r_scale) {
|
||||
Vector3 x = p_basis.get_column(Vector3::AXIS_X);
|
||||
Vector3 y = p_basis.get_column(Vector3::AXIS_Y);
|
||||
Vector3 z = p_basis.get_column(Vector3::AXIS_Z);
|
||||
|
||||
const real_t x_dot_x = x.dot(x);
|
||||
y -= x * (y.dot(x) / x_dot_x);
|
||||
z -= x * (z.dot(x) / x_dot_x);
|
||||
const real_t y_dot_y = y.dot(y);
|
||||
z -= y * (z.dot(y) / y_dot_y);
|
||||
const real_t z_dot_z = z.dot(z);
|
||||
|
||||
const real_t det = x.cross(y).dot(z);
|
||||
|
||||
r_scale = SIGN(det) * Vector3(Math::sqrt(x_dot_x), Math::sqrt(y_dot_y), Math::sqrt(z_dot_z));
|
||||
|
||||
p_basis.set_column(Vector3::AXIS_X, x / r_scale.x);
|
||||
p_basis.set_column(Vector3::AXIS_Y, y / r_scale.y);
|
||||
p_basis.set_column(Vector3::AXIS_Z, z / r_scale.z);
|
||||
}
|
||||
56
engine/modules/jolt_physics/misc/jolt_math_funcs.h
Normal file
56
engine/modules/jolt_physics/misc/jolt_math_funcs.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/**************************************************************************/
|
||||
/* jolt_math_funcs.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/math/transform_3d.h"
|
||||
|
||||
class JoltMath {
|
||||
public:
|
||||
// Note that `p_basis` is mutated to be right-handed orthonormal.
|
||||
static void decompose(Basis &p_basis, Vector3 &r_scale);
|
||||
|
||||
// Note that `p_transform` is mutated to be right-handed orthonormal.
|
||||
static _FORCE_INLINE_ void decompose(Transform3D &p_transform, Vector3 &r_scale) {
|
||||
decompose(p_transform.basis, r_scale);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ void decomposed(const Basis &p_basis, Basis &r_new_basis, Vector3 &r_scale) {
|
||||
Basis new_basis = p_basis;
|
||||
decompose(new_basis, r_scale);
|
||||
r_new_basis = new_basis;
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ void decomposed(const Transform3D &p_transform, Transform3D &r_new_transform, Vector3 &r_scale) {
|
||||
Transform3D new_transform;
|
||||
decompose(new_transform, r_scale);
|
||||
r_new_transform = new_transform;
|
||||
}
|
||||
};
|
||||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_STREAM_WRAPPERS_H
|
||||
#define JOLT_STREAM_WRAPPERS_H
|
||||
#pragma once
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
|
|
@ -77,5 +76,3 @@ public:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // JOLT_STREAM_WRAPPERS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_TYPE_CONVERSIONS_H
|
||||
#define JOLT_TYPE_CONVERSIONS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/math/aabb.h"
|
||||
#include "core/math/color.h"
|
||||
|
|
@ -143,5 +142,3 @@ _FORCE_INLINE_ JPH::RMat44 to_jolt_r(const Transform3D &p_transform) {
|
|||
JPH::Vec4(b[0][2], b[1][2], b[2][2], 0.0f),
|
||||
JPH::RVec3(o.x, o.y, o.z));
|
||||
}
|
||||
|
||||
#endif // JOLT_TYPE_CONVERSIONS_H
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "jolt_area_3d.h"
|
||||
|
||||
#include "../jolt_project_settings.h"
|
||||
#include "../misc/jolt_math_funcs.h"
|
||||
#include "../misc/jolt_type_conversions.h"
|
||||
#include "../shapes/jolt_shape_3d.h"
|
||||
#include "../spaces/jolt_broad_phase_layer.h"
|
||||
|
|
@ -76,7 +77,7 @@ void JoltArea3D::_add_to_space() {
|
|||
jolt_settings->mMassPropertiesOverride.mMass = 1.0f;
|
||||
jolt_settings->mMassPropertiesOverride.mInertia = JPH::Mat44::sIdentity();
|
||||
|
||||
if (JoltProjectSettings::areas_detect_static_bodies()) {
|
||||
if (JoltProjectSettings::areas_detect_static_bodies) {
|
||||
jolt_settings->mCollideKinematicVsNonDynamic = true;
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +371,8 @@ void JoltArea3D::set_default_area(bool p_value) {
|
|||
void JoltArea3D::set_transform(Transform3D p_transform) {
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(p_transform, vformat("An invalid transform was passed to area '%s'.", to_string()));
|
||||
|
||||
const Vector3 new_scale = p_transform.basis.get_scale();
|
||||
Vector3 new_scale;
|
||||
JoltMath::decompose(p_transform, new_scale);
|
||||
|
||||
// Ideally we would do an exact comparison here, but due to floating-point precision this would be invalidated very often.
|
||||
if (!scale.is_equal_approx(new_scale)) {
|
||||
|
|
@ -378,8 +380,6 @@ void JoltArea3D::set_transform(Transform3D p_transform) {
|
|||
_shapes_changed();
|
||||
}
|
||||
|
||||
p_transform.basis.orthonormalize();
|
||||
|
||||
if (!in_space()) {
|
||||
jolt_settings->mPosition = to_jolt_r(p_transform.origin);
|
||||
jolt_settings->mRotation = to_jolt(p_transform.basis);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_AREA_3D_H
|
||||
#define JOLT_AREA_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shaped_object_3d.h"
|
||||
|
||||
|
|
@ -228,5 +227,3 @@ public:
|
|||
virtual bool has_custom_center_of_mass() const override { return false; }
|
||||
virtual Vector3 get_center_of_mass_custom() const override { return Vector3(); }
|
||||
};
|
||||
|
||||
#endif // JOLT_AREA_3D_H
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "../joints/jolt_joint_3d.h"
|
||||
#include "../jolt_project_settings.h"
|
||||
#include "../misc/jolt_math_funcs.h"
|
||||
#include "../misc/jolt_type_conversions.h"
|
||||
#include "../shapes/jolt_shape_3d.h"
|
||||
#include "../spaces/jolt_broad_phase_layer.h"
|
||||
|
|
@ -131,10 +132,10 @@ void JoltBody3D::_add_to_space() {
|
|||
jolt_settings->mAllowSleeping = is_sleep_actually_allowed();
|
||||
jolt_settings->mLinearDamping = 0.0f;
|
||||
jolt_settings->mAngularDamping = 0.0f;
|
||||
jolt_settings->mMaxLinearVelocity = JoltProjectSettings::get_max_linear_velocity();
|
||||
jolt_settings->mMaxAngularVelocity = JoltProjectSettings::get_max_angular_velocity();
|
||||
jolt_settings->mMaxLinearVelocity = JoltProjectSettings::max_linear_velocity;
|
||||
jolt_settings->mMaxAngularVelocity = JoltProjectSettings::max_angular_velocity;
|
||||
|
||||
if (JoltProjectSettings::use_enhanced_internal_edge_removal_for_bodies()) {
|
||||
if (JoltProjectSettings::use_enhanced_internal_edge_removal_for_bodies) {
|
||||
jolt_settings->mEnhancedInternalEdgeRemoval = true;
|
||||
}
|
||||
|
||||
|
|
@ -543,7 +544,8 @@ JoltBody3D::~JoltBody3D() {
|
|||
void JoltBody3D::set_transform(Transform3D p_transform) {
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(p_transform, vformat("An invalid transform was passed to physics body '%s'.", to_string()));
|
||||
|
||||
const Vector3 new_scale = p_transform.basis.get_scale();
|
||||
Vector3 new_scale;
|
||||
JoltMath::decompose(p_transform, new_scale);
|
||||
|
||||
// Ideally we would do an exact comparison here, but due to floating-point precision this would be invalidated very often.
|
||||
if (!scale.is_equal_approx(new_scale)) {
|
||||
|
|
@ -551,8 +553,6 @@ void JoltBody3D::set_transform(Transform3D p_transform) {
|
|||
_shapes_changed();
|
||||
}
|
||||
|
||||
p_transform.basis.orthonormalize();
|
||||
|
||||
if (!in_space()) {
|
||||
jolt_settings->mPosition = to_jolt_r(p_transform.origin);
|
||||
jolt_settings->mRotation = to_jolt(p_transform.basis);
|
||||
|
|
@ -881,7 +881,7 @@ void JoltBody3D::set_center_of_mass_custom(const Vector3 &p_center_of_mass) {
|
|||
}
|
||||
|
||||
void JoltBody3D::set_max_contacts_reported(int p_count) {
|
||||
ERR_FAIL_COND(p_count < 0);
|
||||
ERR_FAIL_INDEX(p_count, MAX_CONTACTS_REPORTED_3D_MAX);
|
||||
|
||||
if (unlikely((int)contacts.size() == p_count)) {
|
||||
return;
|
||||
|
|
@ -906,7 +906,7 @@ void JoltBody3D::set_max_contacts_reported(int p_count) {
|
|||
}
|
||||
|
||||
bool JoltBody3D::reports_all_kinematic_contacts() const {
|
||||
return reports_contacts() && JoltProjectSettings::should_generate_all_kinematic_contacts();
|
||||
return reports_contacts() && JoltProjectSettings::generate_all_kinematic_contacts;
|
||||
}
|
||||
|
||||
void JoltBody3D::add_contact(const JoltBody3D *p_collider, float p_depth, int p_shape_index, int p_collider_shape_index, const Vector3 &p_normal, const Vector3 &p_position, const Vector3 &p_collider_position, const Vector3 &p_velocity, const Vector3 &p_collider_velocity, const Vector3 &p_impulse) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_BODY_3D_H
|
||||
#define JOLT_BODY_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_physics_direct_body_state_3d.h"
|
||||
#include "jolt_shaped_object_3d.h"
|
||||
|
|
@ -305,5 +304,3 @@ public:
|
|||
virtual bool can_interact_with(const JoltSoftBody3D &p_other) const override;
|
||||
virtual bool can_interact_with(const JoltArea3D &p_other) const override;
|
||||
};
|
||||
|
||||
#endif // JOLT_BODY_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_GROUP_FILTER_H
|
||||
#define JOLT_GROUP_FILTER_H
|
||||
#pragma once
|
||||
|
||||
#include "Jolt/Jolt.h"
|
||||
|
||||
|
|
@ -47,5 +46,3 @@ public:
|
|||
static void encode_object(const JoltObject3D *p_object, JPH::CollisionGroup::GroupID &r_group_id, JPH::CollisionGroup::SubGroupID &r_sub_group_id);
|
||||
static const JoltObject3D *decode_object(JPH::CollisionGroup::GroupID p_group_id, JPH::CollisionGroup::SubGroupID p_sub_group_id);
|
||||
};
|
||||
|
||||
#endif // JOLT_GROUP_FILTER_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_OBJECT_3D_H
|
||||
#define JOLT_OBJECT_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "../shapes/jolt_shape_instance_3d.h"
|
||||
|
||||
|
|
@ -152,5 +151,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_OBJECT_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_PHYSICS_DIRECT_BODY_STATE_3D_H
|
||||
#define JOLT_PHYSICS_DIRECT_BODY_STATE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/physics_server_3d.h"
|
||||
|
||||
|
|
@ -112,5 +111,3 @@ public:
|
|||
|
||||
virtual PhysicsDirectSpaceState3D *get_space_state() override;
|
||||
};
|
||||
|
||||
#endif // JOLT_PHYSICS_DIRECT_BODY_STATE_3D_H
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "jolt_shaped_object_3d.h"
|
||||
|
||||
#include "../misc/jolt_math_funcs.h"
|
||||
#include "../misc/jolt_type_conversions.h"
|
||||
#include "../shapes/jolt_custom_double_sided_shape.h"
|
||||
#include "../shapes/jolt_shape_3d.h"
|
||||
|
|
@ -347,7 +348,10 @@ void JoltShapedObject3D::commit_shapes(bool p_optimize_compound) {
|
|||
void JoltShapedObject3D::add_shape(JoltShape3D *p_shape, Transform3D p_transform, bool p_disabled) {
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(p_transform, vformat("An invalid transform was passed when adding shape at index %d to physics body '%s'.", shapes.size(), to_string()));
|
||||
|
||||
shapes.push_back(JoltShapeInstance3D(this, p_shape, p_transform.orthonormalized(), p_transform.basis.get_scale(), p_disabled));
|
||||
Vector3 shape_scale;
|
||||
JoltMath::decompose(p_transform, shape_scale);
|
||||
|
||||
shapes.push_back(JoltShapeInstance3D(this, p_shape, p_transform, shape_scale, p_disabled));
|
||||
|
||||
_shapes_changed();
|
||||
}
|
||||
|
|
@ -430,8 +434,8 @@ void JoltShapedObject3D::set_shape_transform(int p_index, Transform3D p_transfor
|
|||
ERR_FAIL_INDEX(p_index, (int)shapes.size());
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(p_transform, "Failed to correctly set transform for shape at index %d in body '%s'.");
|
||||
|
||||
Vector3 new_scale = p_transform.basis.get_scale();
|
||||
p_transform.basis.orthonormalize();
|
||||
Vector3 new_scale;
|
||||
JoltMath::decompose(p_transform, new_scale);
|
||||
|
||||
JoltShapeInstance3D &shape = shapes[p_index];
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_SHAPED_OBJECT_3D_H
|
||||
#define JOLT_SHAPED_OBJECT_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_object_3d.h"
|
||||
|
||||
|
|
@ -129,5 +128,3 @@ public:
|
|||
bool is_shape_disabled(int p_index) const;
|
||||
void set_shape_disabled(int p_index, bool p_disabled);
|
||||
};
|
||||
|
||||
#endif // JOLT_SHAPED_OBJECT_3D_H
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ void JoltSoftBody3D::_add_to_space() {
|
|||
jolt_settings->mUserData = reinterpret_cast<JPH::uint64>(this);
|
||||
jolt_settings->mObjectLayer = _get_object_layer();
|
||||
jolt_settings->mCollisionGroup = JPH::CollisionGroup(nullptr, group_id, sub_group_id);
|
||||
jolt_settings->mMaxLinearVelocity = JoltProjectSettings::get_max_linear_velocity();
|
||||
jolt_settings->mMaxLinearVelocity = JoltProjectSettings::max_linear_velocity;
|
||||
|
||||
const JPH::BodyID new_jolt_id = space->add_soft_body(*this, *jolt_settings);
|
||||
if (new_jolt_id.IsInvalid()) {
|
||||
|
|
@ -148,7 +148,7 @@ bool JoltSoftBody3D::_ref_shared_data() {
|
|||
LocalVector<int> &mesh_to_physics = iter_shared_data->value.mesh_to_physics;
|
||||
|
||||
JPH::SoftBodySharedSettings &settings = *iter_shared_data->value.settings;
|
||||
settings.mVertexRadius = JoltProjectSettings::get_soft_body_point_radius();
|
||||
settings.mVertexRadius = JoltProjectSettings::soft_body_point_radius;
|
||||
|
||||
JPH::Array<JPH::SoftBodySharedSettings::Vertex> &physics_vertices = settings.mVertices;
|
||||
JPH::Array<JPH::SoftBodySharedSettings::Face> &physics_faces = settings.mFaces;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_SOFT_BODY_3D_H
|
||||
#define JOLT_SOFT_BODY_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_object_3d.h"
|
||||
|
||||
|
|
@ -168,5 +167,3 @@ public:
|
|||
|
||||
bool is_vertex_pinned(int p_index) const;
|
||||
};
|
||||
|
||||
#endif // JOLT_SOFT_BODY_3D_H
|
||||
|
|
|
|||
|
|
@ -49,31 +49,19 @@ PhysicsServer3D *create_jolt_physics_server() {
|
|||
}
|
||||
|
||||
void initialize_jolt_physics_module(ModuleInitializationLevel p_level) {
|
||||
switch (p_level) {
|
||||
case MODULE_INITIALIZATION_LEVEL_CORE: {
|
||||
} break;
|
||||
case MODULE_INITIALIZATION_LEVEL_SERVERS: {
|
||||
jolt_initialize();
|
||||
PhysicsServer3DManager::get_singleton()->register_server("Jolt Physics", callable_mp_static(&create_jolt_physics_server));
|
||||
JoltProjectSettings::register_settings();
|
||||
} break;
|
||||
case MODULE_INITIALIZATION_LEVEL_SCENE: {
|
||||
} break;
|
||||
case MODULE_INITIALIZATION_LEVEL_EDITOR: {
|
||||
} break;
|
||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SERVERS) {
|
||||
return;
|
||||
}
|
||||
|
||||
jolt_initialize();
|
||||
PhysicsServer3DManager::get_singleton()->register_server("Jolt Physics", callable_mp_static(&create_jolt_physics_server));
|
||||
JoltProjectSettings::register_settings();
|
||||
}
|
||||
|
||||
void uninitialize_jolt_physics_module(ModuleInitializationLevel p_level) {
|
||||
switch (p_level) {
|
||||
case MODULE_INITIALIZATION_LEVEL_CORE: {
|
||||
} break;
|
||||
case MODULE_INITIALIZATION_LEVEL_SERVERS: {
|
||||
jolt_deinitialize();
|
||||
} break;
|
||||
case MODULE_INITIALIZATION_LEVEL_SCENE: {
|
||||
} break;
|
||||
case MODULE_INITIALIZATION_LEVEL_EDITOR: {
|
||||
} break;
|
||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SERVERS) {
|
||||
return;
|
||||
}
|
||||
|
||||
jolt_deinitialize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_PHYSICS_REGISTER_TYPES_H
|
||||
#define JOLT_PHYSICS_REGISTER_TYPES_H
|
||||
#pragma once
|
||||
|
||||
#include "modules/register_module_types.h"
|
||||
|
||||
void initialize_jolt_physics_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_jolt_physics_module(ModuleInitializationLevel p_level);
|
||||
|
||||
#endif // JOLT_PHYSICS_REGISTER_TYPES_H
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
JPH::ShapeRefC JoltBoxShape3D::_build() const {
|
||||
const float min_half_extent = (float)half_extents[half_extents.min_axis_index()];
|
||||
const float actual_margin = MIN(margin, min_half_extent * JoltProjectSettings::get_collision_margin_fraction());
|
||||
const float actual_margin = MIN(margin, min_half_extent * JoltProjectSettings::collision_margin_fraction);
|
||||
|
||||
const JPH::BoxShapeSettings shape_settings(to_jolt(half_extents), actual_margin);
|
||||
const JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_BOX_SHAPE_3D_H
|
||||
#define JOLT_BOX_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -53,5 +52,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_BOX_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CAPSULE_SHAPE_3D_H
|
||||
#define JOLT_CAPSULE_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -53,5 +52,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_CAPSULE_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ JPH::ShapeRefC JoltConcavePolygonShape3D::_build() const {
|
|||
}
|
||||
|
||||
JPH::MeshShapeSettings shape_settings(jolt_faces);
|
||||
shape_settings.mActiveEdgeCosThresholdAngle = JoltProjectSettings::get_active_edge_threshold();
|
||||
shape_settings.mPerTriangleUserData = JoltProjectSettings::enable_ray_cast_face_index();
|
||||
shape_settings.mActiveEdgeCosThresholdAngle = JoltProjectSettings::active_edge_threshold_cos;
|
||||
shape_settings.mPerTriangleUserData = JoltProjectSettings::enable_ray_cast_face_index;
|
||||
|
||||
const JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
|
||||
ERR_FAIL_COND_V_MSG(shape_result.HasError(), nullptr, vformat("Failed to build Jolt Physics concave polygon shape with %s. It returned the following error: '%s'. This shape belongs to %s.", to_string(), to_godot(shape_result.GetError()), _owners_to_string()));
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CONCAVE_POLYGON_SHAPE_3D_H
|
||||
#define JOLT_CONCAVE_POLYGON_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -56,5 +55,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_CONCAVE_POLYGON_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ JPH::ShapeRefC JoltConvexPolygonShape3D::_build() const {
|
|||
}
|
||||
|
||||
const float min_half_extent = _calculate_aabb().get_shortest_axis_size() * 0.5f;
|
||||
const float actual_margin = MIN(margin, min_half_extent * JoltProjectSettings::get_collision_margin_fraction());
|
||||
const float actual_margin = MIN(margin, min_half_extent * JoltProjectSettings::collision_margin_fraction);
|
||||
|
||||
const JPH::ConvexHullShapeSettings shape_settings(jolt_vertices, actual_margin);
|
||||
const JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CONVEX_POLYGON_SHAPE_3D_H
|
||||
#define JOLT_CONVEX_POLYGON_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -56,5 +55,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_CONVEX_POLYGON_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CUSTOM_DECORATED_SHAPE_H
|
||||
#define JOLT_CUSTOM_DECORATED_SHAPE_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_custom_shape_type.h"
|
||||
|
||||
|
|
@ -91,5 +90,3 @@ public:
|
|||
|
||||
virtual float GetVolume() const override { return mInnerShape->GetVolume(); }
|
||||
};
|
||||
|
||||
#endif // JOLT_CUSTOM_DECORATED_SHAPE_H
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@ void collide_double_sided_vs_shape(const JPH::Shape *p_shape1, const JPH::Shape
|
|||
const JoltCustomDoubleSidedShape *shape1 = static_cast<const JoltCustomDoubleSidedShape *>(p_shape1);
|
||||
|
||||
JPH::CollideShapeSettings new_collide_shape_settings = p_collide_shape_settings;
|
||||
new_collide_shape_settings.mBackFaceMode = JPH::EBackFaceMode::CollideWithBackFaces;
|
||||
if (shape1->should_collide_with_back_faces()) {
|
||||
new_collide_shape_settings.mBackFaceMode = JPH::EBackFaceMode::CollideWithBackFaces;
|
||||
}
|
||||
|
||||
JPH::CollisionDispatch::sCollideShapeVsShape(shape1->GetInnerShape(), p_shape2, p_scale1, p_scale2, p_center_of_mass_transform1, p_center_of_mass_transform2, p_sub_shape_id_creator1, p_sub_shape_id_creator2, new_collide_shape_settings, p_collector, p_shape_filter);
|
||||
}
|
||||
|
|
@ -60,7 +62,9 @@ void collide_shape_vs_double_sided(const JPH::Shape *p_shape1, const JPH::Shape
|
|||
const JoltCustomDoubleSidedShape *shape2 = static_cast<const JoltCustomDoubleSidedShape *>(p_shape2);
|
||||
|
||||
JPH::CollideShapeSettings new_collide_shape_settings = p_collide_shape_settings;
|
||||
new_collide_shape_settings.mBackFaceMode = JPH::EBackFaceMode::CollideWithBackFaces;
|
||||
if (shape2->should_collide_with_back_faces()) {
|
||||
new_collide_shape_settings.mBackFaceMode = JPH::EBackFaceMode::CollideWithBackFaces;
|
||||
}
|
||||
|
||||
JPH::CollisionDispatch::sCollideShapeVsShape(p_shape1, shape2->GetInnerShape(), p_scale1, p_scale2, p_center_of_mass_transform1, p_center_of_mass_transform2, p_sub_shape_id_creator1, p_sub_shape_id_creator2, new_collide_shape_settings, p_collector, p_shape_filter);
|
||||
}
|
||||
|
|
@ -71,7 +75,9 @@ void cast_shape_vs_double_sided(const JPH::ShapeCast &p_shape_cast, const JPH::S
|
|||
const JoltCustomDoubleSidedShape *shape = static_cast<const JoltCustomDoubleSidedShape *>(p_shape);
|
||||
|
||||
JPH::ShapeCastSettings new_shape_cast_settings = p_shape_cast_settings;
|
||||
new_shape_cast_settings.mBackFaceModeTriangles = JPH::EBackFaceMode::CollideWithBackFaces;
|
||||
if (shape->should_collide_with_back_faces()) {
|
||||
new_shape_cast_settings.mBackFaceModeTriangles = JPH::EBackFaceMode::CollideWithBackFaces;
|
||||
}
|
||||
|
||||
JPH::CollisionDispatch::sCastShapeVsShapeLocalSpace(p_shape_cast, new_shape_cast_settings, shape->GetInnerShape(), p_scale, p_shape_filter, p_center_of_mass_transform2, p_sub_shape_id_creator1, p_sub_shape_id_creator2, p_collector);
|
||||
}
|
||||
|
|
@ -104,8 +110,7 @@ void JoltCustomDoubleSidedShape::register_type() {
|
|||
|
||||
void JoltCustomDoubleSidedShape::CastRay(const JPH::RayCast &p_ray, const JPH::RayCastSettings &p_ray_cast_settings, const JPH::SubShapeIDCreator &p_sub_shape_id_creator, JPH::CastRayCollector &p_collector, const JPH::ShapeFilter &p_shape_filter) const {
|
||||
JPH::RayCastSettings new_ray_cast_settings = p_ray_cast_settings;
|
||||
|
||||
if (!back_face_collision) {
|
||||
if (!should_collide_with_back_faces()) {
|
||||
new_ray_cast_settings.SetBackFaceMode(JPH::EBackFaceMode::IgnoreBackFaces);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CUSTOM_DOUBLE_SIDED_SHAPE_H
|
||||
#define JOLT_CUSTOM_DOUBLE_SIDED_SHAPE_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_custom_decorated_shape.h"
|
||||
#include "jolt_custom_shape_type.h"
|
||||
|
|
@ -69,6 +68,6 @@ public:
|
|||
JoltCustomDecoratedShape(JoltCustomShapeSubType::DOUBLE_SIDED, p_inner_shape), back_face_collision(p_back_face_collision) {}
|
||||
|
||||
virtual void CastRay(const JPH::RayCast &p_ray, const JPH::RayCastSettings &p_ray_cast_settings, const JPH::SubShapeIDCreator &p_sub_shape_id_creator, JPH::CastRayCollector &p_collector, const JPH::ShapeFilter &p_shape_filter = JPH::ShapeFilter()) const override;
|
||||
};
|
||||
|
||||
#endif // JOLT_CUSTOM_DOUBLE_SIDED_SHAPE_H
|
||||
bool should_collide_with_back_faces() const { return back_face_collision; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CUSTOM_MOTION_SHAPE_H
|
||||
#define JOLT_CUSTOM_MOTION_SHAPE_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_custom_shape_type.h"
|
||||
|
||||
|
|
@ -113,5 +112,3 @@ public:
|
|||
|
||||
void set_motion(JPH::Vec3Arg p_motion) { motion = p_motion; }
|
||||
};
|
||||
|
||||
#endif // JOLT_CUSTOM_MOTION_SHAPE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CUSTOM_RAY_SHAPE_H
|
||||
#define JOLT_CUSTOM_RAY_SHAPE_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_custom_shape_type.h"
|
||||
|
||||
|
|
@ -103,5 +102,3 @@ public:
|
|||
|
||||
virtual const JPH::ConvexShape::Support *GetSupportFunction(JPH::ConvexShape::ESupportMode p_mode, JPH::ConvexShape::SupportBuffer &p_buffer, JPH::Vec3Arg p_scale) const override;
|
||||
};
|
||||
|
||||
#endif // JOLT_CUSTOM_RAY_SHAPE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CUSTOM_SHAPE_TYPE_H
|
||||
#define JOLT_CUSTOM_SHAPE_TYPE_H
|
||||
#pragma once
|
||||
|
||||
#include "Jolt/Jolt.h"
|
||||
|
||||
|
|
@ -43,5 +42,3 @@ constexpr JPH::EShapeSubType RAY = JPH::EShapeSubType::UserConvex1;
|
|||
constexpr JPH::EShapeSubType MOTION = JPH::EShapeSubType::UserConvex2;
|
||||
|
||||
} // namespace JoltCustomShapeSubType
|
||||
|
||||
#endif // JOLT_CUSTOM_SHAPE_TYPE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CUSTOM_USER_DATA_SHAPE_H
|
||||
#define JOLT_CUSTOM_USER_DATA_SHAPE_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_custom_decorated_shape.h"
|
||||
#include "jolt_custom_shape_type.h"
|
||||
|
|
@ -57,5 +56,3 @@ public:
|
|||
|
||||
virtual JPH::uint64 GetSubShapeUserData(const JPH::SubShapeID &p_sub_shape_id) const override { return GetUserData(); }
|
||||
};
|
||||
|
||||
#endif // JOLT_CUSTOM_USER_DATA_SHAPE_H
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
JPH::ShapeRefC JoltCylinderShape3D::_build() const {
|
||||
const float half_height = height / 2.0f;
|
||||
const float min_half_extent = MIN(half_height, radius);
|
||||
const float actual_margin = MIN(margin, min_half_extent * JoltProjectSettings::get_collision_margin_fraction());
|
||||
const float actual_margin = MIN(margin, min_half_extent * JoltProjectSettings::collision_margin_fraction);
|
||||
|
||||
const JPH::CylinderShapeSettings shape_settings(half_height, radius, actual_margin);
|
||||
const JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CYLINDER_SHAPE_3D_H
|
||||
#define JOLT_CYLINDER_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -54,5 +53,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_CYLINDER_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -103,10 +103,10 @@ JPH::ShapeRefC JoltHeightMapShape3D::_build_height_field() const {
|
|||
}
|
||||
}
|
||||
|
||||
JPH::HeightFieldShapeSettings shape_settings(heights_rev.ptr(), JPH::Vec3(offset_x, 0, offset_y), JPH::Vec3::sReplicate(1.0f), (JPH::uint32)width);
|
||||
JPH::HeightFieldShapeSettings shape_settings(heights_rev.ptr(), JPH::Vec3(offset_x, 0, offset_y), JPH::Vec3::sOne(), (JPH::uint32)width);
|
||||
|
||||
shape_settings.mBitsPerSample = shape_settings.CalculateBitsPerSampleForError(0.0f);
|
||||
shape_settings.mActiveEdgeCosThresholdAngle = JoltProjectSettings::get_active_edge_threshold();
|
||||
shape_settings.mActiveEdgeCosThresholdAngle = JoltProjectSettings::active_edge_threshold_cos;
|
||||
|
||||
const JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
|
||||
ERR_FAIL_COND_V_MSG(shape_result.HasError(), nullptr, vformat("Failed to build Jolt Physics height map shape with %s. It returned the following error: '%s'. This shape belongs to %s.", to_string(), to_godot(shape_result.GetError()), _owners_to_string()));
|
||||
|
|
@ -160,7 +160,7 @@ JPH::ShapeRefC JoltHeightMapShape3D::_build_mesh() const {
|
|||
}
|
||||
|
||||
JPH::MeshShapeSettings shape_settings(std::move(vertices), std::move(indices));
|
||||
shape_settings.mActiveEdgeCosThresholdAngle = JoltProjectSettings::get_active_edge_threshold();
|
||||
shape_settings.mActiveEdgeCosThresholdAngle = JoltProjectSettings::active_edge_threshold_cos;
|
||||
|
||||
const JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
|
||||
ERR_FAIL_COND_V_MSG(shape_result.HasError(), nullptr, vformat("Failed to build Jolt Physics height map shape (as polygon) with %s. It returned the following error: '%s'. This shape belongs to %s.", to_string(), to_godot(shape_result.GetError()), _owners_to_string()));
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_HEIGHT_MAP_SHAPE_3D_H
|
||||
#define JOLT_HEIGHT_MAP_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -65,5 +64,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_HEIGHT_MAP_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_SEPARATION_RAY_SHAPE_3D_H
|
||||
#define JOLT_SEPARATION_RAY_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -53,5 +52,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_SEPARATION_RAY_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_SHAPE_3D_H
|
||||
#define JOLT_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/physics_server_3d.h"
|
||||
|
||||
|
|
@ -132,5 +131,3 @@ public:
|
|||
(m_scale) = valid_scale; \
|
||||
} else \
|
||||
((void)0)
|
||||
|
||||
#endif // JOLT_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_SHAPE_INSTANCE_3D_H
|
||||
#define JOLT_SHAPE_INSTANCE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "core/math/transform_3d.h"
|
||||
|
||||
|
|
@ -99,5 +98,3 @@ public:
|
|||
|
||||
bool try_build();
|
||||
};
|
||||
|
||||
#endif // JOLT_SHAPE_INSTANCE_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_SPHERE_SHAPE_3D_H
|
||||
#define JOLT_SPHERE_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -52,5 +51,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_SPHERE_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ JPH::ShapeRefC JoltWorldBoundaryShape3D::_build() const {
|
|||
const Plane normalized_plane = plane.normalized();
|
||||
ERR_FAIL_COND_V_MSG(normalized_plane == Plane(), nullptr, vformat("Failed to build Jolt Physics world boundary shape with %s. The plane's normal must not be zero. This shape belongs to %s.", to_string(), _owners_to_string()));
|
||||
|
||||
const float half_size = JoltProjectSettings::get_world_boundary_shape_size() / 2.0f;
|
||||
const float half_size = JoltProjectSettings::world_boundary_shape_size / 2.0f;
|
||||
const JPH::PlaneShapeSettings shape_settings(to_jolt(normalized_plane), nullptr, half_size);
|
||||
const JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
|
||||
ERR_FAIL_COND_V_MSG(shape_result.HasError(), nullptr, vformat("Failed to build Jolt Physics world boundary shape with %s. It returned the following error: '%s'. This shape belongs to %s.", to_string(), to_godot(shape_result.GetError()), _owners_to_string()));
|
||||
|
|
@ -65,7 +65,7 @@ void JoltWorldBoundaryShape3D::set_data(const Variant &p_data) {
|
|||
}
|
||||
|
||||
AABB JoltWorldBoundaryShape3D::get_aabb() const {
|
||||
const float size = JoltProjectSettings::get_world_boundary_shape_size();
|
||||
const float size = JoltProjectSettings::world_boundary_shape_size;
|
||||
const float half_size = size / 2.0f;
|
||||
return AABB(Vector3(-half_size, -half_size, -half_size), Vector3(size, half_size, size));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_WORLD_BOUNDARY_SHAPE_3D_H
|
||||
#define JOLT_WORLD_BOUNDARY_SHAPE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_shape_3d.h"
|
||||
|
||||
|
|
@ -52,5 +51,3 @@ public:
|
|||
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
#endif // JOLT_WORLD_BOUNDARY_SHAPE_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_BODY_ACCESSOR_3D_H
|
||||
#define JOLT_BODY_ACCESSOR_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "../objects/jolt_object_3d.h"
|
||||
|
||||
|
|
@ -210,5 +209,3 @@ typedef JoltAccessibleBody3D<JoltScopedBodyWriter3D, JPH::Body> JoltWritableBody
|
|||
|
||||
typedef JoltAccessibleBodies3D<JoltScopedBodyReader3D, const JPH::Body> JoltReadableBodies3D;
|
||||
typedef JoltAccessibleBodies3D<JoltScopedBodyWriter3D, JPH::Body> JoltWritableBodies3D;
|
||||
|
||||
#endif // JOLT_BODY_ACCESSOR_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_BROAD_PHASE_LAYER_H
|
||||
#define JOLT_BROAD_PHASE_LAYER_H
|
||||
#pragma once
|
||||
|
||||
#include "Jolt/Jolt.h"
|
||||
|
||||
|
|
@ -48,5 +47,3 @@ constexpr JPH::BroadPhaseLayer AREA_UNDETECTABLE(4);
|
|||
constexpr uint32_t COUNT = 5;
|
||||
|
||||
} // namespace JoltBroadPhaseLayer
|
||||
|
||||
#endif // JOLT_BROAD_PHASE_LAYER_H
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ bool JoltContactListener3D::_try_add_contacts(const JPH::Body &p_jolt_body1, con
|
|||
manifold.depth = p_manifold.mPenetrationDepth;
|
||||
|
||||
JPH::CollisionEstimationResult collision;
|
||||
JPH::EstimateCollisionResponse(p_jolt_body1, p_jolt_body2, p_manifold, collision, p_settings.mCombinedFriction, p_settings.mCombinedRestitution, JoltProjectSettings::get_bounce_velocity_threshold(), 5);
|
||||
JPH::EstimateCollisionResponse(p_jolt_body1, p_jolt_body2, p_manifold, collision, p_settings.mCombinedFriction, p_settings.mCombinedRestitution, JoltProjectSettings::bounce_velocity_threshold, 5);
|
||||
|
||||
for (JPH::uint i = 0; i < contact_count; ++i) {
|
||||
const JPH::RVec3 relative_point1 = JPH::RVec3(p_manifold.mRelativeContactPointsOn1[i]);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_CONTACT_LISTENER_3D_H
|
||||
#define JOLT_CONTACT_LISTENER_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
|
|
@ -44,7 +43,6 @@
|
|||
#include "Jolt/Physics/Collision/ContactListener.h"
|
||||
#include "Jolt/Physics/SoftBody/SoftBodyContactListener.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <new>
|
||||
|
||||
class JoltShapedObject3D;
|
||||
|
|
@ -138,5 +136,3 @@ public:
|
|||
void set_max_debug_contacts(int p_count) { debug_contacts.resize(p_count); }
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // JOLT_CONTACT_LISTENER_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_JOB_SYSTEM_H
|
||||
#define JOLT_JOB_SYSTEM_H
|
||||
#pragma once
|
||||
|
||||
#include "core/os/spin_lock.h"
|
||||
#include "core/templates/hash_map.h"
|
||||
|
|
@ -39,7 +38,6 @@
|
|||
#include "Jolt/Core/FixedSizeFreeList.h"
|
||||
#include "Jolt/Core/JobSystemWithBarrier.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <atomic>
|
||||
|
||||
class JoltJobSystem final : public JPH::JobSystemWithBarrier {
|
||||
|
|
@ -103,5 +101,3 @@ public:
|
|||
void flush_timings();
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // JOLT_JOB_SYSTEM_H
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public:
|
|||
allow_collision(AREA_UNDETECTABLE, BODY_DYNAMIC);
|
||||
allow_collision(AREA_UNDETECTABLE, AREA_DETECTABLE);
|
||||
|
||||
if (JoltProjectSettings::areas_detect_static_bodies()) {
|
||||
if (JoltProjectSettings::areas_detect_static_bodies) {
|
||||
allow_collision(BODY_STATIC, AREA_DETECTABLE);
|
||||
allow_collision(BODY_STATIC, AREA_UNDETECTABLE);
|
||||
allow_collision(BODY_STATIC_BIG, AREA_DETECTABLE);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_LAYERS_H
|
||||
#define JOLT_LAYERS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
|
|
@ -39,8 +38,6 @@
|
|||
#include "Jolt/Physics/Collision/BroadPhase/BroadPhaseLayer.h"
|
||||
#include "Jolt/Physics/Collision/ObjectLayer.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class JoltLayers final
|
||||
: public JPH::BroadPhaseLayerInterface,
|
||||
public JPH::ObjectLayerPairFilter,
|
||||
|
|
@ -68,5 +65,3 @@ public:
|
|||
JPH::ObjectLayer to_object_layer(JPH::BroadPhaseLayer p_broad_phase_layer, uint32_t p_collision_layer, uint32_t p_collision_mask);
|
||||
void from_object_layer(JPH::ObjectLayer p_encoded_layer, JPH::BroadPhaseLayer &r_broad_phase_layer, uint32_t &r_collision_layer, uint32_t &r_collision_mask) const;
|
||||
};
|
||||
|
||||
#endif // JOLT_LAYERS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_MOTION_FILTER_3D_H
|
||||
#define JOLT_MOTION_FILTER_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "core/object/object_id.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
|
|
@ -68,5 +67,3 @@ public:
|
|||
virtual bool ShouldCollide(const JPH::Shape *p_jolt_shape, const JPH::SubShapeID &p_jolt_shape_id) const override;
|
||||
virtual bool ShouldCollide(const JPH::Shape *p_jolt_shape_self, const JPH::SubShapeID &p_jolt_shape_id_self, const JPH::Shape *p_jolt_shape_other, const JPH::SubShapeID &p_jolt_shape_id_other) const override;
|
||||
};
|
||||
|
||||
#endif // JOLT_MOTION_FILTER_3D_H
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "../jolt_physics_server_3d.h"
|
||||
#include "../jolt_project_settings.h"
|
||||
#include "../misc/jolt_math_funcs.h"
|
||||
#include "../misc/jolt_type_conversions.h"
|
||||
#include "../objects/jolt_area_3d.h"
|
||||
#include "../objects/jolt_body_3d.h"
|
||||
|
|
@ -110,7 +111,7 @@ bool JoltPhysicsDirectSpaceState3D::_cast_motion_impl(const JPH::Shape &p_jolt_s
|
|||
};
|
||||
|
||||
// Figure out the number of steps we need in our binary search in order to achieve millimeter precision, within reason.
|
||||
const int step_count = CLAMP(int(logf(1000.0f * motion_length) / (float)Math_LN2), 4, 16);
|
||||
const int step_count = CLAMP(int(logf(1000.0f * motion_length) / (float)Math::LN2), 4, 16);
|
||||
|
||||
bool collided = false;
|
||||
|
||||
|
|
@ -171,9 +172,6 @@ bool JoltPhysicsDirectSpaceState3D::_cast_motion_impl(const JPH::Shape &p_jolt_s
|
|||
}
|
||||
|
||||
bool JoltPhysicsDirectSpaceState3D::_body_motion_recover(const JoltBody3D &p_body, const Transform3D &p_transform, float p_margin, const HashSet<RID> &p_excluded_bodies, const HashSet<ObjectID> &p_excluded_objects, Vector3 &r_recovery) const {
|
||||
const int recovery_iterations = JoltProjectSettings::get_motion_query_recovery_iterations();
|
||||
const float recovery_amount = JoltProjectSettings::get_motion_query_recovery_amount();
|
||||
|
||||
const JPH::Shape *jolt_shape = p_body.get_jolt_shape();
|
||||
|
||||
const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
||||
|
|
@ -189,10 +187,10 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_recover(const JoltBody3D &p_bod
|
|||
|
||||
bool recovered = false;
|
||||
|
||||
for (int i = 0; i < recovery_iterations; ++i) {
|
||||
for (int i = 0; i < JoltProjectSettings::motion_query_recovery_iterations; ++i) {
|
||||
collector.reset();
|
||||
|
||||
_collide_shape_kinematics(jolt_shape, JPH::Vec3::sReplicate(1.0f), to_jolt_r(transform_com), settings, to_jolt_r(base_offset), collector, motion_filter, motion_filter, motion_filter, motion_filter);
|
||||
_collide_shape_kinematics(jolt_shape, JPH::Vec3::sOne(), to_jolt_r(transform_com), settings, to_jolt_r(base_offset), collector, motion_filter, motion_filter, motion_filter, motion_filter);
|
||||
|
||||
if (!collector.had_hit()) {
|
||||
break;
|
||||
|
|
@ -240,7 +238,7 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_recover(const JoltBody3D &p_bod
|
|||
const JoltBody3D *other_body = other_jolt_body.as_body();
|
||||
ERR_CONTINUE(other_body == nullptr);
|
||||
|
||||
const float recovery_distance = penetration_depth * recovery_amount;
|
||||
const float recovery_distance = penetration_depth * JoltProjectSettings::motion_query_recovery_amount;
|
||||
const float other_priority = other_body->get_collision_priority();
|
||||
const float other_priority_normalized = other_priority / average_priority;
|
||||
const float scaled_recovery_distance = recovery_distance * other_priority_normalized;
|
||||
|
|
@ -288,15 +286,14 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_cast(const JoltBody3D &p_body,
|
|||
const Transform3D transform_com_local = transform_local.translated_local(com_scaled);
|
||||
Transform3D transform_com = body_transform * transform_com_local;
|
||||
|
||||
Vector3 scale = transform_com.basis.get_scale();
|
||||
Vector3 scale;
|
||||
JoltMath::decompose(transform_com, scale);
|
||||
JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "body_test_motion was passed an invalid transform along with body '%s'. This results in invalid scaling for shape at index %d.");
|
||||
|
||||
transform_com.basis.orthonormalize();
|
||||
|
||||
real_t shape_safe_fraction = 1.0;
|
||||
real_t shape_unsafe_fraction = 1.0;
|
||||
|
||||
collided |= _cast_motion_impl(*jolt_shape, transform_com, scale, p_motion, JoltProjectSettings::use_enhanced_internal_edge_removal_for_motion_queries(), false, settings, motion_filter, motion_filter, motion_filter, motion_filter, shape_safe_fraction, shape_unsafe_fraction);
|
||||
collided |= _cast_motion_impl(*jolt_shape, transform_com, scale, p_motion, JoltProjectSettings::use_enhanced_internal_edge_removal_for_motion_queries, false, settings, motion_filter, motion_filter, motion_filter, motion_filter, shape_safe_fraction, shape_unsafe_fraction);
|
||||
|
||||
r_safe_fraction = MIN(r_safe_fraction, shape_safe_fraction);
|
||||
r_unsafe_fraction = MIN(r_unsafe_fraction, shape_unsafe_fraction);
|
||||
|
|
@ -323,7 +320,7 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_collide(const JoltBody3D &p_bod
|
|||
|
||||
const JoltMotionFilter3D motion_filter(p_body, p_excluded_bodies, p_excluded_objects);
|
||||
JoltQueryCollectorClosestMulti<JPH::CollideShapeCollector, 32> collector(p_max_collisions);
|
||||
_collide_shape_kinematics(jolt_shape, JPH::Vec3::sReplicate(1.0f), to_jolt_r(transform_com), settings, to_jolt_r(base_offset), collector, motion_filter, motion_filter, motion_filter, motion_filter);
|
||||
_collide_shape_kinematics(jolt_shape, JPH::Vec3::sOne(), to_jolt_r(transform_com), settings, to_jolt_r(base_offset), collector, motion_filter, motion_filter, motion_filter, motion_filter);
|
||||
|
||||
if (!collector.had_hit() || p_result == nullptr) {
|
||||
return collector.had_hit();
|
||||
|
|
@ -400,7 +397,7 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_collide(const JoltBody3D &p_bod
|
|||
}
|
||||
|
||||
int JoltPhysicsDirectSpaceState3D::_try_get_face_index(const JPH::Body &p_body, const JPH::SubShapeID &p_sub_shape_id) {
|
||||
if (!JoltProjectSettings::enable_ray_cast_face_index()) {
|
||||
if (!JoltProjectSettings::enable_ray_cast_face_index) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +418,7 @@ void JoltPhysicsDirectSpaceState3D::_generate_manifold(const JPH::CollideShapeRe
|
|||
const JPH::PhysicsSettings &physics_settings = physics_system.GetPhysicsSettings();
|
||||
const JPH::Vec3 penetration_axis = p_hit.mPenetrationAxis.Normalized();
|
||||
|
||||
JPH::ManifoldBetweenTwoFaces(p_hit.mContactPointOn1, p_hit.mContactPointOn2, penetration_axis, physics_settings.mManifoldToleranceSq, p_hit.mShape1Face, p_hit.mShape2Face, r_contact_points1, r_contact_points2 JPH_IF_DEBUG_RENDERER(, p_center_of_mass));
|
||||
JPH::ManifoldBetweenTwoFaces(p_hit.mContactPointOn1, p_hit.mContactPointOn2, penetration_axis, physics_settings.mManifoldTolerance, p_hit.mShape1Face, p_hit.mShape2Face, r_contact_points1, r_contact_points2 JPH_IF_DEBUG_RENDERER(, p_center_of_mass));
|
||||
|
||||
if (r_contact_points1.size() > 4) {
|
||||
JPH::PruneContactPoints(penetration_axis, r_contact_points1, r_contact_points2 JPH_IF_DEBUG_RENDERER(, p_center_of_mass));
|
||||
|
|
@ -439,7 +436,7 @@ void JoltPhysicsDirectSpaceState3D::_collide_shape_queries(
|
|||
const JPH::ObjectLayerFilter &p_object_layer_filter,
|
||||
const JPH::BodyFilter &p_body_filter,
|
||||
const JPH::ShapeFilter &p_shape_filter) const {
|
||||
if (JoltProjectSettings::use_enhanced_internal_edge_removal_for_queries()) {
|
||||
if (JoltProjectSettings::use_enhanced_internal_edge_removal_for_queries) {
|
||||
space->get_narrow_phase_query().CollideShapeWithInternalEdgeRemoval(p_shape, p_scale, p_transform_com, p_settings, p_base_offset, p_collector, p_broad_phase_layer_filter, p_object_layer_filter, p_body_filter, p_shape_filter);
|
||||
} else {
|
||||
space->get_narrow_phase_query().CollideShape(p_shape, p_scale, p_transform_com, p_settings, p_base_offset, p_collector, p_broad_phase_layer_filter, p_object_layer_filter, p_body_filter, p_shape_filter);
|
||||
|
|
@ -457,7 +454,7 @@ void JoltPhysicsDirectSpaceState3D::_collide_shape_kinematics(
|
|||
const JPH::ObjectLayerFilter &p_object_layer_filter,
|
||||
const JPH::BodyFilter &p_body_filter,
|
||||
const JPH::ShapeFilter &p_shape_filter) const {
|
||||
if (JoltProjectSettings::use_enhanced_internal_edge_removal_for_motion_queries()) {
|
||||
if (JoltProjectSettings::use_enhanced_internal_edge_removal_for_motion_queries) {
|
||||
space->get_narrow_phase_query().CollideShapeWithInternalEdgeRemoval(p_shape, p_scale, p_transform_com, p_settings, p_base_offset, p_collector, p_broad_phase_layer_filter, p_object_layer_filter, p_body_filter, p_shape_filter);
|
||||
} else {
|
||||
space->get_narrow_phase_query().CollideShape(p_shape, p_scale, p_transform_com, p_settings, p_base_offset, p_collector, p_broad_phase_layer_filter, p_object_layer_filter, p_body_filter, p_shape_filter);
|
||||
|
|
@ -590,11 +587,10 @@ int JoltPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_para
|
|||
Transform3D transform = p_parameters.transform;
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(transform, "intersect_shape was passed an invalid transform.");
|
||||
|
||||
Vector3 scale = transform.basis.get_scale();
|
||||
Vector3 scale;
|
||||
JoltMath::decompose(transform, scale);
|
||||
JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "intersect_shape was passed an invalid transform.");
|
||||
|
||||
transform.basis.orthonormalize();
|
||||
|
||||
const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
||||
const Transform3D transform_com = transform.translated_local(com_scaled);
|
||||
|
||||
|
|
@ -647,11 +643,10 @@ bool JoltPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_paramet
|
|||
Transform3D transform = p_parameters.transform;
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(transform, "cast_motion (maybe from ShapeCast3D?) was passed an invalid transform.");
|
||||
|
||||
Vector3 scale = transform.basis.get_scale();
|
||||
Vector3 scale;
|
||||
JoltMath::decompose(transform, scale);
|
||||
JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "cast_motion (maybe from ShapeCast3D?) was passed an invalid transform.");
|
||||
|
||||
transform.basis.orthonormalize();
|
||||
|
||||
const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
||||
Transform3D transform_com = transform.translated_local(com_scaled);
|
||||
|
||||
|
|
@ -659,7 +654,7 @@ bool JoltPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_paramet
|
|||
settings.mMaxSeparationDistance = (float)p_parameters.margin;
|
||||
|
||||
const JoltQueryFilter3D query_filter(*this, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, p_parameters.exclude);
|
||||
_cast_motion_impl(*jolt_shape, transform_com, scale, p_parameters.motion, JoltProjectSettings::use_enhanced_internal_edge_removal_for_queries(), true, settings, query_filter, query_filter, query_filter, JPH::ShapeFilter(), r_closest_safe, r_closest_unsafe);
|
||||
_cast_motion_impl(*jolt_shape, transform_com, scale, p_parameters.motion, JoltProjectSettings::use_enhanced_internal_edge_removal_for_queries, true, settings, query_filter, query_filter, query_filter, JPH::ShapeFilter(), r_closest_safe, r_closest_unsafe);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -684,11 +679,10 @@ bool JoltPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_param
|
|||
Transform3D transform = p_parameters.transform;
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(transform, "collide_shape was passed an invalid transform.");
|
||||
|
||||
Vector3 scale = transform.basis.get_scale();
|
||||
Vector3 scale;
|
||||
JoltMath::decompose(transform, scale);
|
||||
JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "collide_shape was passed an invalid transform.");
|
||||
|
||||
transform.basis.orthonormalize();
|
||||
|
||||
const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
||||
const Transform3D transform_com = transform.translated_local(com_scaled);
|
||||
|
||||
|
|
@ -754,11 +748,10 @@ bool JoltPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameter
|
|||
Transform3D transform = p_parameters.transform;
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(transform, "get_rest_info (maybe from ShapeCast3D?) was passed an invalid transform.");
|
||||
|
||||
Vector3 scale = transform.basis.get_scale();
|
||||
Vector3 scale;
|
||||
JoltMath::decompose(transform, scale);
|
||||
JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "get_rest_info (maybe from ShapeCast3D?) was passed an invalid transform.");
|
||||
|
||||
transform.basis.orthonormalize();
|
||||
|
||||
const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
||||
const Transform3D transform_com = transform.translated_local(com_scaled);
|
||||
|
||||
|
|
@ -794,7 +787,6 @@ bool JoltPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameter
|
|||
r_info->normal = to_godot(-hit.mPenetrationAxis.Normalized());
|
||||
r_info->rid = object->get_rid();
|
||||
r_info->collider_id = object->get_instance_id();
|
||||
r_info->shape = 0;
|
||||
r_info->linear_velocity = object->get_velocity_at_position(hit_point);
|
||||
|
||||
return true;
|
||||
|
|
@ -890,8 +882,8 @@ bool JoltPhysicsDirectSpaceState3D::body_test_motion(const JoltBody3D &p_body, c
|
|||
Transform3D transform = p_parameters.from;
|
||||
JOLT_ENSURE_SCALE_NOT_ZERO(transform, vformat("body_test_motion (maybe from move_and_slide?) was passed an invalid transform along with body '%s'.", p_body.to_string()));
|
||||
|
||||
Vector3 scale = transform.basis.get_scale();
|
||||
transform.basis.orthonormalize();
|
||||
Vector3 scale;
|
||||
JoltMath::decompose(transform, scale);
|
||||
|
||||
space->try_optimize();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_PHYSICS_DIRECT_SPACE_STATE_3D_H
|
||||
#define JOLT_PHYSICS_DIRECT_SPACE_STATE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/physics_server_3d.h"
|
||||
|
||||
|
|
@ -83,5 +82,3 @@ public:
|
|||
|
||||
JoltSpace3D &get_space() const { return *space; }
|
||||
};
|
||||
|
||||
#endif // JOLT_PHYSICS_DIRECT_SPACE_STATE_3D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_QUERY_COLLECTORS_H
|
||||
#define JOLT_QUERY_COLLECTORS_H
|
||||
#pragma once
|
||||
|
||||
#include "../jolt_project_settings.h"
|
||||
#include "jolt_space_3d.h"
|
||||
|
|
@ -244,5 +243,3 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // JOLT_QUERY_COLLECTORS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_QUERY_FILTER_3D_H
|
||||
#define JOLT_QUERY_FILTER_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "core/templates/rid.h"
|
||||
|
|
@ -63,5 +62,3 @@ public:
|
|||
virtual bool ShouldCollide(const JPH::BodyID &p_body_id) const override;
|
||||
virtual bool ShouldCollideLocked(const JPH::Body &p_body) const override;
|
||||
};
|
||||
|
||||
#endif // JOLT_QUERY_FILTER_3D_H
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ constexpr double DEFAULT_CONTACT_MAX_SEPARATION = 0.05;
|
|||
constexpr double DEFAULT_CONTACT_MAX_ALLOWED_PENETRATION = 0.01;
|
||||
constexpr double DEFAULT_CONTACT_DEFAULT_BIAS = 0.8;
|
||||
constexpr double DEFAULT_SLEEP_THRESHOLD_LINEAR = 0.1;
|
||||
constexpr double DEFAULT_SLEEP_THRESHOLD_ANGULAR = 8.0 * Math_PI / 180;
|
||||
constexpr double DEFAULT_SLEEP_THRESHOLD_ANGULAR = 8.0 * Math::PI / 180;
|
||||
constexpr double DEFAULT_SOLVER_ITERATIONS = 8;
|
||||
|
||||
} // namespace
|
||||
|
|
@ -98,23 +98,23 @@ JoltSpace3D::JoltSpace3D(JPH::JobSystem *p_job_system) :
|
|||
layers(new JoltLayers()),
|
||||
contact_listener(new JoltContactListener3D(this)),
|
||||
physics_system(new JPH::PhysicsSystem()) {
|
||||
physics_system->Init((JPH::uint)JoltProjectSettings::get_max_bodies(), 0, (JPH::uint)JoltProjectSettings::get_max_pairs(), (JPH::uint)JoltProjectSettings::get_max_contact_constraints(), *layers, *layers, *layers);
|
||||
physics_system->Init((JPH::uint)JoltProjectSettings::max_bodies, 0, (JPH::uint)JoltProjectSettings::max_body_pairs, (JPH::uint)JoltProjectSettings::max_contact_constraints, *layers, *layers, *layers);
|
||||
|
||||
JPH::PhysicsSettings settings;
|
||||
settings.mBaumgarte = JoltProjectSettings::get_baumgarte_stabilization_factor();
|
||||
settings.mSpeculativeContactDistance = JoltProjectSettings::get_speculative_contact_distance();
|
||||
settings.mPenetrationSlop = JoltProjectSettings::get_penetration_slop();
|
||||
settings.mLinearCastThreshold = JoltProjectSettings::get_ccd_movement_threshold();
|
||||
settings.mLinearCastMaxPenetration = JoltProjectSettings::get_ccd_max_penetration();
|
||||
settings.mBodyPairCacheMaxDeltaPositionSq = JoltProjectSettings::get_body_pair_cache_distance_sq();
|
||||
settings.mBodyPairCacheCosMaxDeltaRotationDiv2 = JoltProjectSettings::get_body_pair_cache_angle_cos_div2();
|
||||
settings.mNumVelocitySteps = (JPH::uint)JoltProjectSettings::get_simulation_velocity_steps();
|
||||
settings.mNumPositionSteps = (JPH::uint)JoltProjectSettings::get_simulation_position_steps();
|
||||
settings.mMinVelocityForRestitution = JoltProjectSettings::get_bounce_velocity_threshold();
|
||||
settings.mTimeBeforeSleep = JoltProjectSettings::get_sleep_time_threshold();
|
||||
settings.mPointVelocitySleepThreshold = JoltProjectSettings::get_sleep_velocity_threshold();
|
||||
settings.mUseBodyPairContactCache = JoltProjectSettings::is_body_pair_contact_cache_enabled();
|
||||
settings.mAllowSleeping = JoltProjectSettings::is_sleep_allowed();
|
||||
settings.mBaumgarte = JoltProjectSettings::baumgarte_stabilization_factor;
|
||||
settings.mSpeculativeContactDistance = JoltProjectSettings::speculative_contact_distance;
|
||||
settings.mPenetrationSlop = JoltProjectSettings::penetration_slop;
|
||||
settings.mLinearCastThreshold = JoltProjectSettings::ccd_movement_threshold;
|
||||
settings.mLinearCastMaxPenetration = JoltProjectSettings::ccd_max_penetration;
|
||||
settings.mBodyPairCacheMaxDeltaPositionSq = JoltProjectSettings::body_pair_cache_distance_sq;
|
||||
settings.mBodyPairCacheCosMaxDeltaRotationDiv2 = JoltProjectSettings::body_pair_cache_angle_cos_div2;
|
||||
settings.mNumVelocitySteps = (JPH::uint)JoltProjectSettings::simulation_velocity_steps;
|
||||
settings.mNumPositionSteps = (JPH::uint)JoltProjectSettings::simulation_position_steps;
|
||||
settings.mMinVelocityForRestitution = JoltProjectSettings::bounce_velocity_threshold;
|
||||
settings.mTimeBeforeSleep = JoltProjectSettings::sleep_time_threshold;
|
||||
settings.mPointVelocitySleepThreshold = JoltProjectSettings::sleep_velocity_threshold;
|
||||
settings.mUseBodyPairContactCache = JoltProjectSettings::body_pair_contact_cache_enabled;
|
||||
settings.mAllowSleeping = JoltProjectSettings::sleep_allowed;
|
||||
|
||||
physics_system->SetPhysicsSettings(settings);
|
||||
physics_system->SetGravity(JPH::Vec3::sZero());
|
||||
|
|
@ -122,7 +122,7 @@ JoltSpace3D::JoltSpace3D(JPH::JobSystem *p_job_system) :
|
|||
physics_system->SetSoftBodyContactListener(contact_listener);
|
||||
|
||||
physics_system->SetCombineFriction([](const JPH::Body &p_body1, const JPH::SubShapeID &p_sub_shape_id1, const JPH::Body &p_body2, const JPH::SubShapeID &p_sub_shape_id2) {
|
||||
return ABS(MIN(p_body1.GetFriction(), p_body2.GetFriction()));
|
||||
return Math::abs(MIN(p_body1.GetFriction(), p_body2.GetFriction()));
|
||||
});
|
||||
|
||||
physics_system->SetCombineRestitution([](const JPH::Body &p_body1, const JPH::SubShapeID &p_sub_shape_id1, const JPH::Body &p_body2, const JPH::SubShapeID &p_sub_shape_id2) {
|
||||
|
|
@ -169,21 +169,21 @@ void JoltSpace3D::step(float p_step) {
|
|||
WARN_PRINT_ONCE(vformat("Jolt Physics manifold cache exceeded capacity and contacts were ignored. "
|
||||
"Consider increasing maximum number of contact constraints in project settings. "
|
||||
"Maximum number of contact constraints is currently set to %d.",
|
||||
JoltProjectSettings::get_max_contact_constraints()));
|
||||
JoltProjectSettings::max_contact_constraints));
|
||||
}
|
||||
|
||||
if ((update_error & JPH::EPhysicsUpdateError::BodyPairCacheFull) != JPH::EPhysicsUpdateError::None) {
|
||||
WARN_PRINT_ONCE(vformat("Jolt Physics body pair cache exceeded capacity and contacts were ignored. "
|
||||
"Consider increasing maximum number of body pairs in project settings. "
|
||||
"Maximum number of body pairs is currently set to %d.",
|
||||
JoltProjectSettings::get_max_pairs()));
|
||||
JoltProjectSettings::max_body_pairs));
|
||||
}
|
||||
|
||||
if ((update_error & JPH::EPhysicsUpdateError::ContactConstraintsFull) != JPH::EPhysicsUpdateError::None) {
|
||||
WARN_PRINT_ONCE(vformat("Jolt Physics contact constraint buffer exceeded capacity and contacts were ignored. "
|
||||
"Consider increasing maximum number of contact constraints in project settings. "
|
||||
"Maximum number of contact constraints is currently set to %d.",
|
||||
JoltProjectSettings::get_max_contact_constraints()));
|
||||
JoltProjectSettings::max_contact_constraints));
|
||||
}
|
||||
|
||||
_post_step(p_step);
|
||||
|
|
@ -227,7 +227,7 @@ double JoltSpace3D::get_param(PhysicsServer3D::SpaceParameter p_param) const {
|
|||
return DEFAULT_SLEEP_THRESHOLD_ANGULAR;
|
||||
}
|
||||
case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: {
|
||||
return JoltProjectSettings::get_sleep_time_threshold();
|
||||
return JoltProjectSettings::sleep_time_threshold;
|
||||
}
|
||||
case PhysicsServer3D::SPACE_PARAM_SOLVER_ITERATIONS: {
|
||||
return DEFAULT_SOLVER_ITERATIONS;
|
||||
|
|
@ -353,7 +353,7 @@ JPH::BodyID JoltSpace3D::add_rigid_body(const JoltObject3D &p_object, const JPH:
|
|||
ERR_PRINT_ONCE(vformat("Failed to create underlying Jolt Physics body for '%s'. "
|
||||
"Consider increasing maximum number of bodies in project settings. "
|
||||
"Maximum number of bodies is currently set to %d.",
|
||||
p_object.to_string(), JoltProjectSettings::get_max_bodies()));
|
||||
p_object.to_string(), JoltProjectSettings::max_bodies));
|
||||
|
||||
return JPH::BodyID();
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ JPH::BodyID JoltSpace3D::add_soft_body(const JoltObject3D &p_object, const JPH::
|
|||
ERR_PRINT_ONCE(vformat("Failed to create underlying Jolt Physics body for '%s'. "
|
||||
"Consider increasing maximum number of bodies in project settings. "
|
||||
"Maximum number of bodies is currently set to %d.",
|
||||
p_object.to_string(), JoltProjectSettings::get_max_bodies()));
|
||||
p_object.to_string(), JoltProjectSettings::max_bodies));
|
||||
|
||||
return JPH::BodyID();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_SPACE_3D_H
|
||||
#define JOLT_SPACE_3D_H
|
||||
#pragma once
|
||||
|
||||
#include "jolt_body_accessor_3d.h"
|
||||
|
||||
|
|
@ -45,8 +44,6 @@
|
|||
#include "Jolt/Physics/Constraints/Constraint.h"
|
||||
#include "Jolt/Physics/PhysicsSystem.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class JoltArea3D;
|
||||
class JoltBody3D;
|
||||
class JoltContactListener3D;
|
||||
|
|
@ -162,5 +159,3 @@ public:
|
|||
void set_max_debug_contacts(int p_count);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // JOLT_SPACE_3D_H
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ constexpr TValue align_up(TValue p_value, TAlignment p_alignment) {
|
|||
} //namespace
|
||||
|
||||
JoltTempAllocator::JoltTempAllocator() :
|
||||
capacity((uint64_t)JoltProjectSettings::get_temp_memory_b()),
|
||||
capacity((uint64_t)JoltProjectSettings::temp_memory_b),
|
||||
base(static_cast<uint8_t *>(JPH::Allocate((size_t)capacity))) {
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ void *JoltTempAllocator::Allocate(uint32_t p_size) {
|
|||
WARN_PRINT_ONCE(vformat("Jolt Physics temporary memory allocator exceeded capacity of %d MiB. "
|
||||
"Falling back to slower general-purpose allocator. "
|
||||
"Consider increasing maximum temporary memory in project settings.",
|
||||
JoltProjectSettings::get_temp_memory_mib()));
|
||||
JoltProjectSettings::temp_memory_mib));
|
||||
|
||||
ptr = JPH::Allocate(p_size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef JOLT_TEMP_ALLOCATOR_H
|
||||
#define JOLT_TEMP_ALLOCATOR_H
|
||||
#pragma once
|
||||
|
||||
#include "Jolt/Jolt.h"
|
||||
|
||||
|
|
@ -49,5 +48,3 @@ public:
|
|||
virtual void *Allocate(JPH::uint p_size) override;
|
||||
virtual void Free(void *p_ptr, JPH::uint p_size) override;
|
||||
};
|
||||
|
||||
#endif // JOLT_TEMP_ALLOCATOR_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue