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

Commit 10bfaea

Browse files
committed
update some errors with new api.
1 parent d561ab7 commit 10bfaea

18 files changed

+500
-542
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Binaries
2-
*.os
32
*.os.tmp
43
*.o
54
*.dblite

SConstruct

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env.Append(
1212
]
1313
)
1414

15-
env.Prepend(CPPPATH=["box2d/extern/simde", "box2d/include", "box2d/src"])
15+
env.Prepend(CPPPATH=["box2d/extern/simde", "box2d/include"])
1616
# For the reference:
1717
# - CCFLAGS are compilation flags shared between C and C++
1818
# tweak this if you want to use different folders, or more folders, to store your source code in.

bin/addons/godot-box2d/godot-box2d.gd

-10
This file was deleted.

bin/addons/godot-box2d/plugin.cfg

-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
name="Godot Box2d"
44
description="A Box2D physics server for Godot Engine"
55
version="1.0"
6-
script="godot-box2d.gd"
76
author="ughuuu"

src/bodies/box2d_area_2d.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void Box2DArea2D::set_space(Box2DSpace2D *p_space) {
3131
_set_space(p_space);
3232
}
3333

34-
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) {
34+
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) {
3535
ERR_FAIL_COND(!p_body); // Shouldn't happen after removal
3636

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

59-
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) {
59+
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) {
6060
if (p_update_detection) {
6161
// Remove from currently detected bodies
6262
auto foundIt = detected_bodies.find(p_body_rid);
@@ -93,7 +93,7 @@ void Box2DArea2D::on_body_exit(b2Fixture *p_collider_handle, Box2DBody2D *p_body
9393
}
9494
}
9595

96-
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) {
96+
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) {
9797
ERR_FAIL_COND(!p_other_area); // Shouldn't happen after removal
9898

9999
if (area_monitor_callback.is_null()) {
@@ -117,7 +117,7 @@ void Box2DArea2D::on_area_enter(b2Fixture *p_collider_handle, Box2DArea2D *p_oth
117117
}
118118
}
119119

120-
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) {
120+
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) {
121121
if (area_monitor_callback.is_null()) {
122122
return;
123123
}

src/bodies/box2d_area_2d.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ class Box2DArea2D : public Box2DCollisionObject2D {
5555
void _reset_space_override();
5656

5757
public:
58-
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);
59-
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);
58+
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);
59+
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);
6060

61-
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);
62-
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);
61+
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);
62+
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);
6363

6464
void update_area_override();
6565
bool has_any_space_override() const;

src/bodies/box2d_body_2d.cpp

+29-29
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void Box2DBody2D::_apply_mass_properties(bool force_update) {
2929

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

32-
b2World *space_handle = get_space()->get_handle();
32+
b2WorldId space_handle = get_space()->get_handle();
3333
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
3434
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
3535

@@ -140,7 +140,7 @@ void Box2DBody2D::set_active(bool p_active) {
140140
void Box2DBody2D::set_can_sleep(bool p_can_sleep) {
141141
ERR_FAIL_COND(!get_space());
142142

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

146146
box2d::body_set_can_sleep(space_handle, body_handle, p_can_sleep);
@@ -204,7 +204,7 @@ void Box2DBody2D::set_param(PhysicsServer2D::BodyParameter p_param, const Varian
204204
return;
205205
}
206206

207-
b2World *space_handle = get_space()->get_handle();
207+
b2WorldId space_handle = get_space()->get_handle();
208208
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
209209
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
210210
box2d::Material mat;
@@ -469,7 +469,7 @@ void Box2DBody2D::set_continuous_collision_detection_mode(PhysicsServer2D::CCDMo
469469
ccd_mode = p_mode;
470470

471471
if (get_space()) {
472-
b2World *space_handle = get_space()->get_handle();
472+
b2WorldId space_handle = get_space()->get_handle();
473473
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
474474

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

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

489489
// Send contact infos for dynamic bodies
@@ -574,7 +574,7 @@ void Box2DBody2D::set_space(Box2DSpace2D *p_space) {
574574
apply_torque(torque_force);
575575
torque_force = 0.0;
576576
}
577-
b2World *space_handle = get_space()->get_handle();
577+
b2WorldId space_handle = get_space()->get_handle();
578578
box2d::Material mat;
579579
mat.friction = friction;
580580
mat.restitution = bounce;
@@ -651,7 +651,7 @@ void Box2DBody2D::apply_central_impulse(const Vector2 &p_impulse) {
651651
update_mass_properties(true);
652652
}
653653

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

839839
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
@@ -847,7 +847,7 @@ Vector2 Box2DBody2D::get_constant_force() const {
847847
return constant_force;
848848
}
849849

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

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

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

874874
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
@@ -881,7 +881,7 @@ real_t Box2DBody2D::get_constant_torque() const {
881881
return constant_torque;
882882
}
883883

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

887887
ERR_FAIL_COND_V(!box2d::is_handle_valid(body_handle), 0.0);
@@ -899,7 +899,7 @@ void Box2DBody2D::wakeup() {
899899
return;
900900
}
901901

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

905905
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
@@ -912,7 +912,7 @@ void Box2DBody2D::force_sleep() {
912912
return;
913913
}
914914

915-
b2World *space_handle = get_space()->get_handle();
915+
b2WorldId space_handle = get_space()->get_handle();
916916
ERR_FAIL_COND(!box2d::is_handle_valid(space_handle));
917917
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
918918
box2d::body_force_sleep(space_handle, body_handle);
@@ -963,7 +963,7 @@ void Box2DBody2D::set_linear_velocity(const Vector2 &p_linear_velocity) {
963963
return;
964964
}
965965

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

969969
// TODO: apply delta
@@ -977,7 +977,7 @@ Vector2 Box2DBody2D::get_linear_velocity() const {
977977
return linear_velocity;
978978
}
979979

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

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

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

10051005
// TODO: apply delta
@@ -1012,7 +1012,7 @@ real_t Box2DBody2D::get_angular_velocity() const {
10121012
return angular_velocity;
10131013
}
10141014

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

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

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

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

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

10581058
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));
@@ -1064,7 +1064,7 @@ void Box2DBody2D::_apply_gravity_scale(real_t new_value) {
10641064
return;
10651065
}
10661066

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

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

12071207
Vector2 gravity_impulse = total_gravity * mass * p_step;
12081208

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

12121212
ERR_FAIL_COND(!box2d::is_handle_valid(body_handle));

0 commit comments

Comments
 (0)