feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -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);

View file

@ -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

View file

@ -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) {

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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];

View file

@ -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

View file

@ -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;

View file

@ -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