Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
update some errors with new api.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ughuuu committed Feb 25, 2024
1 parent d561ab7 commit 10bfaea
Show file tree
Hide file tree
Showing 18 changed files with 500 additions and 542 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Binaries
*.os
*.os.tmp
*.o
*.dblite
Expand Down
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env.Append(
]
)

env.Prepend(CPPPATH=["box2d/extern/simde", "box2d/include", "box2d/src"])
env.Prepend(CPPPATH=["box2d/extern/simde", "box2d/include"])
# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
# tweak this if you want to use different folders, or more folders, to store your source code in.
Expand Down
10 changes: 0 additions & 10 deletions bin/addons/godot-box2d/godot-box2d.gd

This file was deleted.

1 change: 0 additions & 1 deletion bin/addons/godot-box2d/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
name="Godot Box2d"
description="A Box2D physics server for Godot Engine"
version="1.0"
script="godot-box2d.gd"
author="ughuuu"
8 changes: 4 additions & 4 deletions src/bodies/box2d_area_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void Box2DArea2D::set_space(Box2DSpace2D *p_space) {
_set_space(p_space);
}

void Box2DArea2D::on_body_enter(b2Fixture *p_collider_handle, Box2DBody2D *p_body, uint32_t p_body_shape, RID p_body_rid, ObjectID p_body_instance_id, b2Fixture *p_area_collider_handle, uint32_t p_area_shape) {
void Box2DArea2D::on_body_enter(b2ShapeId p_collider_handle, Box2DBody2D *p_body, uint32_t p_body_shape, RID p_body_rid, ObjectID p_body_instance_id, b2ShapeId p_area_collider_handle, uint32_t p_area_shape) {
ERR_FAIL_COND(!p_body); // Shouldn't happen after removal

// Add to keep track of currently detected bodies
Expand All @@ -56,7 +56,7 @@ void Box2DArea2D::on_body_enter(b2Fixture *p_collider_handle, Box2DBody2D *p_bod
}
}

void Box2DArea2D::on_body_exit(b2Fixture *p_collider_handle, Box2DBody2D *p_body, uint32_t p_body_shape, RID p_body_rid, ObjectID p_body_instance_id, b2Fixture *p_area_collider_handle, uint32_t p_area_shape, bool p_update_detection) {
void Box2DArea2D::on_body_exit(b2ShapeId p_collider_handle, Box2DBody2D *p_body, uint32_t p_body_shape, RID p_body_rid, ObjectID p_body_instance_id, b2ShapeId p_area_collider_handle, uint32_t p_area_shape, bool p_update_detection) {
if (p_update_detection) {
// Remove from currently detected bodies
auto foundIt = detected_bodies.find(p_body_rid);
Expand Down Expand Up @@ -93,7 +93,7 @@ void Box2DArea2D::on_body_exit(b2Fixture *p_collider_handle, Box2DBody2D *p_body
}
}

void Box2DArea2D::on_area_enter(b2Fixture *p_collider_handle, Box2DArea2D *p_other_area, uint32_t p_other_area_shape, RID p_other_area_rid, ObjectID p_other_area_instance_id, b2Fixture *p_area_collider_handle, uint32_t p_area_shape) {
void Box2DArea2D::on_area_enter(b2ShapeId p_collider_handle, Box2DArea2D *p_other_area, uint32_t p_other_area_shape, RID p_other_area_rid, ObjectID p_other_area_instance_id, b2ShapeId p_area_collider_handle, uint32_t p_area_shape) {
ERR_FAIL_COND(!p_other_area); // Shouldn't happen after removal

if (area_monitor_callback.is_null()) {
Expand All @@ -117,7 +117,7 @@ void Box2DArea2D::on_area_enter(b2Fixture *p_collider_handle, Box2DArea2D *p_oth
}
}

void Box2DArea2D::on_area_exit(b2Fixture *p_collider_handle, Box2DArea2D *p_other_area, uint32_t p_other_area_shape, RID p_other_area_rid, ObjectID p_other_area_instance_id, b2Fixture *p_area_collider_handle, uint32_t p_area_shape) {
void Box2DArea2D::on_area_exit(b2ShapeId p_collider_handle, Box2DArea2D *p_other_area, uint32_t p_other_area_shape, RID p_other_area_rid, ObjectID p_other_area_instance_id, b2ShapeId p_area_collider_handle, uint32_t p_area_shape) {
if (area_monitor_callback.is_null()) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/bodies/box2d_area_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class Box2DArea2D : public Box2DCollisionObject2D {
void _reset_space_override();

public:
void on_body_enter(b2Fixture *p_collider_handle, Box2DBody2D *p_body, uint32_t p_body_shape, RID p_body_rid, ObjectID p_body_instance_id, b2Fixture *p_area_collider_handle, uint32_t p_area_shape);
void on_body_exit(b2Fixture *p_collider_handle, Box2DBody2D *p_body, uint32_t p_body_shape, RID p_body_rid, ObjectID p_body_instance_id, b2Fixture *p_area_collider_handle, uint32_t p_area_shape, bool p_update_detection = true);
void on_body_enter(b2ShapeId p_collider_handle, Box2DBody2D *p_body, uint32_t p_body_shape, RID p_body_rid, ObjectID p_body_instance_id, b2ShapeId p_area_collider_handle, uint32_t p_area_shape);
void on_body_exit(b2ShapeId p_collider_handle, Box2DBody2D *p_body, uint32_t p_body_shape, RID p_body_rid, ObjectID p_body_instance_id, b2ShapeId p_area_collider_handle, uint32_t p_area_shape, bool p_update_detection = true);

void on_area_enter(b2Fixture *p_collider_handle, Box2DArea2D *p_other_area, uint32_t p_other_area_shape, RID p_other_area_rid, ObjectID p_other_area_instance_id, b2Fixture *p_area_collider_handle, uint32_t p_area_shape);
void on_area_exit(b2Fixture *p_collider_handle, Box2DArea2D *p_other_area, uint32_t p_other_area_shape, RID p_other_area_rid, ObjectID p_other_area_instance_id, b2Fixture *p_area_collider_handle, uint32_t p_area_shape);
void on_area_enter(b2ShapeId p_collider_handle, Box2DArea2D *p_other_area, uint32_t p_other_area_shape, RID p_other_area_rid, ObjectID p_other_area_instance_id, b2ShapeId p_area_collider_handle, uint32_t p_area_shape);
void on_area_exit(b2ShapeId p_collider_handle, Box2DArea2D *p_other_area, uint32_t p_other_area_shape, RID p_other_area_rid, ObjectID p_other_area_instance_id, b2ShapeId p_area_collider_handle, uint32_t p_area_shape);

void update_area_override();
bool has_any_space_override() const;
Expand Down
58 changes: 29 additions & 29 deletions src/bodies/box2d_body_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void Box2DBody2D::_apply_mass_properties(bool force_update) {

b2Vec2 com = { center_of_mass.x, center_of_mass.y };

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));

Expand Down Expand Up @@ -140,7 +140,7 @@ void Box2DBody2D::set_active(bool p_active) {
void Box2DBody2D::set_can_sleep(bool p_can_sleep) {
ERR_FAIL_COND(!get_space());

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

box2d::body_set_can_sleep(space_handle, body_handle, p_can_sleep);
Expand Down Expand Up @@ -204,7 +204,7 @@ void Box2DBody2D::set_param(PhysicsServer2D::BodyParameter p_param, const Varian
return;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
box2d::Material mat;
Expand Down Expand Up @@ -469,7 +469,7 @@ void Box2DBody2D::set_continuous_collision_detection_mode(PhysicsServer2D::CCDMo
ccd_mode = p_mode;

if (get_space()) {
b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

box2d::body_set_ccd_enabled(space_handle, body_handle, ccd_mode != PhysicsServer2D::CCD_MODE_DISABLED);
Expand All @@ -483,7 +483,7 @@ void Box2DBody2D::_init_material(box2d::Material &mat) const {

void Box2DBody2D::_init_collider(box2d::FixtureHandle collider_handle) const {
ERR_FAIL_COND(!get_space());
b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

// Send contact infos for dynamic bodies
Expand Down Expand Up @@ -574,7 +574,7 @@ void Box2DBody2D::set_space(Box2DSpace2D *p_space) {
apply_torque(torque_force);
torque_force = 0.0;
}
b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
box2d::Material mat;
mat.friction = friction;
mat.restitution = bounce;
Expand Down Expand Up @@ -651,7 +651,7 @@ void Box2DBody2D::apply_central_impulse(const Vector2 &p_impulse) {
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -671,7 +671,7 @@ void Box2DBody2D::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_posit
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -692,7 +692,7 @@ void Box2DBody2D::apply_torque_impulse(real_t p_torque) {
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -710,7 +710,7 @@ void Box2DBody2D::apply_central_force(const Vector2 &p_force) {
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
// Note: using last delta assuming constant physics time
real_t last_delta = get_space()->get_last_step();
Expand All @@ -732,7 +732,7 @@ void Box2DBody2D::apply_force(const Vector2 &p_force, const Vector2 &p_position)
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
// Note: using last delta assuming constant physics time
Expand All @@ -754,7 +754,7 @@ void Box2DBody2D::apply_torque(real_t p_torque) {
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -774,7 +774,7 @@ void Box2DBody2D::add_constant_central_force(const Vector2 &p_force) {
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -794,7 +794,7 @@ void Box2DBody2D::add_constant_force(const Vector2 &p_force, const Vector2 &p_po
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -815,7 +815,7 @@ void Box2DBody2D::add_constant_torque(real_t p_torque) {
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -833,7 +833,7 @@ void Box2DBody2D::set_constant_force(const Vector2 &p_force) {
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -847,7 +847,7 @@ Vector2 Box2DBody2D::get_constant_force() const {
return constant_force;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND_V(!box2d::is_handle_valid(space_handle), Vector2());

ERR_FAIL_COND_V(!box2d::is_handle_valid(body_handle), Vector2());
Expand All @@ -868,7 +868,7 @@ void Box2DBody2D::set_constant_torque(real_t p_torque) {
update_mass_properties(true);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -881,7 +881,7 @@ real_t Box2DBody2D::get_constant_torque() const {
return constant_torque;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND_V(!box2d::is_handle_valid(space_handle), 0.0);

ERR_FAIL_COND_V(!box2d::is_handle_valid(body_handle), 0.0);
Expand All @@ -899,7 +899,7 @@ void Box2DBody2D::wakeup() {
return;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -912,7 +912,7 @@ void Box2DBody2D::force_sleep() {
return;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
box2d::body_force_sleep(space_handle, body_handle);
Expand Down Expand Up @@ -963,7 +963,7 @@ void Box2DBody2D::set_linear_velocity(const Vector2 &p_linear_velocity) {
return;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

// TODO: apply delta
Expand All @@ -977,7 +977,7 @@ Vector2 Box2DBody2D::get_linear_velocity() const {
return linear_velocity;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND_V(!box2d::is_handle_valid(space_handle), Vector2());

ERR_FAIL_COND_V(!box2d::is_handle_valid(body_handle), Vector2());
Expand All @@ -999,7 +999,7 @@ void Box2DBody2D::set_angular_velocity(real_t p_angular_velocity) {
return;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

// TODO: apply delta
Expand All @@ -1012,7 +1012,7 @@ real_t Box2DBody2D::get_angular_velocity() const {
return angular_velocity;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND_V(!box2d::is_handle_valid(space_handle), 0.0f);

ERR_FAIL_COND_V(!box2d::is_handle_valid(body_handle), 0.0f);
Expand All @@ -1034,7 +1034,7 @@ void Box2DBody2D::_apply_linear_damping(real_t new_value, bool apply_default) {
total_linear_damping += (real_t)get_space()->get_default_area_param(PhysicsServer2D::AREA_PARAM_LINEAR_DAMP);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -1052,7 +1052,7 @@ void Box2DBody2D::_apply_angular_damping(real_t new_value, bool apply_default) {
total_angular_damping += (real_t)get_space()->get_default_area_param(PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP);
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand All @@ -1064,7 +1064,7 @@ void Box2DBody2D::_apply_gravity_scale(real_t new_value) {
return;
}

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand Down Expand Up @@ -1206,7 +1206,7 @@ void Box2DBody2D::update_gravity(real_t p_step) {

Vector2 gravity_impulse = total_gravity * mass * p_step;

b2World *space_handle = get_space()->get_handle();
b2WorldId space_handle = get_space()->get_handle();
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));

ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
Expand Down
Loading

0 comments on commit 10bfaea

Please sign in to comment.