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

@ -1,5 +1,5 @@
def can_build(env, platform):
return True
return not env["disable_physics_2d"]
def configure(env):

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_AREA_2D_H
#define GODOT_AREA_2D_H
#pragma once
#include "godot_collision_object_2d.h"
@ -187,5 +186,3 @@ void GodotArea2D::remove_area_from_query(GodotArea2D *p_area, uint32_t p_area_sh
_queue_monitor_update();
}
}
#endif // GODOT_AREA_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_AREA_PAIR_2D_H
#define GODOT_AREA_PAIR_2D_H
#pragma once
#include "godot_area_2d.h"
#include "godot_body_2d.h"
@ -74,5 +73,3 @@ public:
GodotArea2Pair2D(GodotArea2D *p_area_a, int p_shape_a, GodotArea2D *p_area_b, int p_shape_b);
~GodotArea2Pair2D();
};
#endif // GODOT_AREA_PAIR_2D_H

View file

@ -563,7 +563,7 @@ void GodotBody2D::integrate_forces(real_t p_step) {
linear_velocity = constant_linear_velocity + motion / p_step;
real_t rot = new_transform.get_rotation() - get_transform().get_rotation();
angular_velocity = constant_angular_velocity + remainder(rot, 2.0 * Math_PI) / p_step;
angular_velocity = constant_angular_velocity + remainder(rot, 2.0 * Math::PI) / p_step;
do_motion = true;
@ -626,7 +626,7 @@ void GodotBody2D::integrate_velocities(real_t p_step) {
if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
_set_transform(new_transform, false);
_set_inv_transform(new_transform.affine_inverse());
if (contacts.size() == 0 && linear_velocity == Vector2() && angular_velocity == 0) {
if (contacts.is_empty() && linear_velocity == Vector2() && angular_velocity == 0) {
set_active(false); //stopped moving, deactivate
}
return;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_BODY_2D_H
#define GODOT_BODY_2D_H
#pragma once
#include "godot_area_2d.h"
#include "godot_collision_object_2d.h"
@ -182,6 +181,7 @@ public:
}
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
ERR_FAIL_INDEX(p_size, MAX_CONTACTS_REPORTED_2D_MAX);
contacts.resize(p_size);
contact_count = 0;
if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && p_size) {
@ -385,5 +385,3 @@ void GodotBody2D::add_contact(const Vector2 &p_local_pos, const Vector2 &p_local
c[idx].collider_velocity_at_pos = p_collider_velocity_at_pos;
c[idx].impulse = p_impulse;
}
#endif // GODOT_BODY_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_BODY_DIRECT_STATE_2D_H
#define GODOT_BODY_DIRECT_STATE_2D_H
#pragma once
#include "servers/physics_server_2d.h"
@ -100,5 +99,3 @@ public:
virtual real_t get_step() const override;
};
#endif // GODOT_BODY_DIRECT_STATE_2D_H

View file

@ -36,7 +36,7 @@
#define ACCUMULATE_IMPULSES
#define MIN_VELOCITY 0.001
#define MAX_BIAS_ROTATION (Math_PI / 8)
#define MAX_BIAS_ROTATION (Math::PI / 8)
void GodotBodyPair2D::_add_contact(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_self) {
GodotBodyPair2D *self = static_cast<GodotBodyPair2D *>(p_self);
@ -244,7 +244,7 @@ real_t combine_bounce(GodotBody2D *A, GodotBody2D *B) {
}
real_t combine_friction(GodotBody2D *A, GodotBody2D *B) {
return ABS(MIN(A->get_friction(), B->get_friction()));
return Math::abs(MIN(A->get_friction(), B->get_friction()));
}
bool GodotBodyPair2D::setup(real_t p_step) {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_BODY_PAIR_2D_H
#define GODOT_BODY_PAIR_2D_H
#pragma once
#include "godot_body_2d.h"
#include "godot_constraint_2d.h"
@ -97,5 +96,3 @@ public:
GodotBodyPair2D(GodotBody2D *p_A, int p_shape_A, GodotBody2D *p_B, int p_shape_B);
~GodotBodyPair2D();
};
#endif // GODOT_BODY_PAIR_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_BROAD_PHASE_2D_H
#define GODOT_BROAD_PHASE_2D_H
#pragma once
#include "core/math/math_funcs.h"
#include "core/math/rect2.h"
@ -67,5 +66,3 @@ public:
virtual ~GodotBroadPhase2D();
};
#endif // GODOT_BROAD_PHASE_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_BROAD_PHASE_2D_BVH_H
#define GODOT_BROAD_PHASE_2D_BVH_H
#pragma once
#include "godot_broad_phase_2d.h"
@ -97,5 +96,3 @@ public:
static GodotBroadPhase2D *_create();
GodotBroadPhase2DBVH();
};
#endif // GODOT_BROAD_PHASE_2D_BVH_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_COLLISION_OBJECT_2D_H
#define GODOT_COLLISION_OBJECT_2D_H
#pragma once
#include "godot_broad_phase_2d.h"
#include "godot_shape_2d.h"
@ -194,5 +193,3 @@ public:
virtual ~GodotCollisionObject2D() {}
};
#endif // GODOT_COLLISION_OBJECT_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_COLLISION_SOLVER_2D_H
#define GODOT_COLLISION_SOLVER_2D_H
#pragma once
#include "godot_shape_2d.h"
@ -46,5 +45,3 @@ private:
public:
static bool solve(const GodotShape2D *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const GodotShape2D *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, Vector2 *r_sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0);
};
#endif // GODOT_COLLISION_SOLVER_2D_H

View file

@ -66,7 +66,7 @@ _FORCE_INLINE_ static void _generate_contacts_point_edge(const Vector2 *p_points
ERR_FAIL_COND(p_point_count_B != 2);
#endif
Vector2 closest_B = Geometry2D::get_closest_point_to_segment_uncapped(*p_points_A, p_points_B);
Vector2 closest_B = Geometry2D::get_closest_point_to_segment_uncapped(*p_points_A, p_points_B[0], p_points_B[1]);
p_collector->call(*p_points_A, closest_B);
}

View file

@ -28,11 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_COLLISION_SOLVER_2D_SAT_H
#define GODOT_COLLISION_SOLVER_2D_SAT_H
#pragma once
#include "godot_collision_solver_2d.h"
bool sat_2d_calculate_penetration(const GodotShape2D *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const GodotShape2D *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, GodotCollisionSolver2D::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector2 *sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0);
#endif // GODOT_COLLISION_SOLVER_2D_SAT_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_CONSTRAINT_2D_H
#define GODOT_CONSTRAINT_2D_H
#pragma once
#include "godot_body_2d.h"
@ -66,5 +65,3 @@ public:
virtual ~GodotConstraint2D() {}
};
#endif // GODOT_CONSTRAINT_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_JOINTS_2D_H
#define GODOT_JOINTS_2D_H
#pragma once
#include "godot_body_2d.h"
#include "godot_constraint_2d.h"
@ -188,5 +187,3 @@ public:
GodotDampedSpringJoint2D(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, GodotBody2D *p_body_a, GodotBody2D *p_body_b);
};
#endif // GODOT_JOINTS_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_PHYSICS_SERVER_2D_H
#define GODOT_PHYSICS_SERVER_2D_H
#pragma once
#include "godot_joints_2d.h"
#include "godot_shape_2d.h"
@ -303,5 +302,3 @@ public:
GodotPhysicsServer2D(bool p_using_threads = false);
~GodotPhysicsServer2D() {}
};
#endif // GODOT_PHYSICS_SERVER_2D_H

View file

@ -665,7 +665,7 @@ bool GodotConcavePolygonShape2D::contains_point(const Vector2 &p_point) const {
}
bool GodotConcavePolygonShape2D::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
if (segments.size() == 0 || points.size() == 0) {
if (segments.is_empty() || points.is_empty()) {
return false;
}
@ -919,7 +919,7 @@ void GodotConcavePolygonShape2D::cull(const Rect2 &p_local_aabb, QueryCallback p
stack[i]=0;
*/
if (segments.size() == 0 || points.size() == 0 || bvh.size() == 0) {
if (segments.is_empty() || points.is_empty() || bvh.is_empty()) {
return;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_SHAPE_2D_H
#define GODOT_SHAPE_2D_H
#pragma once
#include "servers/physics_server_2d.h"
@ -535,5 +534,3 @@ public:
};
#undef DEFAULT_PROJECT_RANGE_CAST
#endif // GODOT_SHAPE_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_SPACE_2D_H
#define GODOT_SPACE_2D_H
#pragma once
#include "godot_area_2d.h"
#include "godot_body_2d.h"
@ -206,5 +205,3 @@ public:
GodotSpace2D();
~GodotSpace2D();
};
#endif // GODOT_SPACE_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_STEP_2D_H
#define GODOT_STEP_2D_H
#pragma once
#include "godot_space_2d.h"
@ -56,5 +55,3 @@ public:
GodotStep2D();
~GodotStep2D();
};
#endif // GODOT_STEP_2D_H

View file

@ -28,12 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_PHYSICS_2D_REGISTER_TYPES_H
#define GODOT_PHYSICS_2D_REGISTER_TYPES_H
#pragma once
#include "modules/register_module_types.h"
void initialize_godot_physics_2d_module(ModuleInitializationLevel p_level);
void uninitialize_godot_physics_2d_module(ModuleInitializationLevel p_level);
#endif // GODOT_PHYSICS_2D_REGISTER_TYPES_H