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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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