Skip to content
This repository was archived by the owner on Jun 29, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Binaries
*.os
*.os.tmp
*.o
*.dblite
Expand All @@ -10,3 +9,4 @@ bin/addons/godot-box2d/bin/libgodot-box2d.macos.template_release.framework/libgo

.DS_Store
.vscode
*.os
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
branch = 4.1
[submodule "box2d"]
path = box2d
url = https://github.com/appsinacup/box2d
branch = common-assert-noop
url = https://github.com/erincatto/box2c
branch = main
[submodule "Godot-Physics-Tests"]
path = Godot-Physics-Tests
url = https://github.com/fabriceci/Godot-Physics-Tests
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<a href="https://github.com/appsinacup/godot-box2d/actions/workflows/runner.yml">
<img src="https://github.com/appsinacup/godot-box2d/actions/workflows/runner.yml/badge.svg?branch=main"
alt="chat on Discord"></a>
<a href="https://github.com/erincatto/box2d" alt="Box2D Version">
<img src="https://img.shields.io/badge/Box2D-v2.4.1-%23478cbf?logoColor=white" /></a>
<a href="https://github.com/erincatto/box2c" alt="Box2C Version">
<img src="https://img.shields.io/badge/Box2C-v3.0.0-%23478cbf?logoColor=white" /></a>
<a href="https://github.com/godotengine/godot-cpp" alt="Godot Version">
<img src="https://img.shields.io/badge/Godot-v4.2-%23478cbf?logo=godot-engine&logoColor=white" /></a>
<a href="https://github.com/appsinacup/godot-box2d/graphs/contributors" alt="Contributors">
Expand Down
66 changes: 11 additions & 55 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,22 @@ import os
import sys

env = SConscript("godot-cpp/SConstruct")
box2d_folder = "box2d/"
box2d_include = [
"include/",
"src/"
]
box2d_src = [
"collision/b2_broad_phase.cpp",
"collision/b2_chain_shape.cpp",
"collision/b2_circle_shape.cpp",
"collision/b2_collide_circle.cpp",
"collision/b2_collide_edge.cpp",
"collision/b2_collide_polygon.cpp",
"collision/b2_collision.cpp",
"collision/b2_distance.cpp",
"collision/b2_dynamic_tree.cpp",
"collision/b2_edge_shape.cpp",
"collision/b2_polygon_shape.cpp",
"collision/b2_time_of_impact.cpp",
"common/b2_block_allocator.cpp",
"common/b2_draw.cpp",
"common/b2_math.cpp",
"common/b2_settings.cpp",
"common/b2_stack_allocator.cpp",
"common/b2_timer.cpp",
"dynamics/b2_body.cpp",
"dynamics/b2_chain_circle_contact.cpp",
"dynamics/b2_chain_polygon_contact.cpp",
"dynamics/b2_circle_contact.cpp",
"dynamics/b2_contact.cpp",
"dynamics/b2_contact_manager.cpp",
"dynamics/b2_contact_solver.cpp",
"dynamics/b2_distance_joint.cpp",
"dynamics/b2_edge_circle_contact.cpp",
"dynamics/b2_edge_polygon_contact.cpp",
"dynamics/b2_fixture.cpp",
"dynamics/b2_friction_joint.cpp",
"dynamics/b2_gear_joint.cpp",
"dynamics/b2_island.cpp",
"dynamics/b2_joint.cpp",
"dynamics/b2_motor_joint.cpp",
"dynamics/b2_mouse_joint.cpp",
"dynamics/b2_polygon_circle_contact.cpp",
"dynamics/b2_polygon_contact.cpp",
"dynamics/b2_prismatic_joint.cpp",
"dynamics/b2_pulley_joint.cpp",
"dynamics/b2_revolute_joint.cpp",
"dynamics/b2_weld_joint.cpp",
"dynamics/b2_wheel_joint.cpp",
"dynamics/b2_world.cpp",
"dynamics/b2_world_callbacks.cpp",
"rope/b2_rope.cpp",
]
env.Prepend(CPPPATH=[box2d_folder + folder for folder in box2d_include])
env.Append(CPPDEFINES="B2_USER_SETTINGS")

env.Append(
CPPDEFINES=[
"BOX2D_LENGTH_UNIT_PER_METER=100.0",
"BOX2D_MAX_POLYGON_VERTICES=64",
"BOX2D_AVX2=ON"
]
)

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.
env.Append(CPPPATH=["src/"])
sources = [Glob("src/*.cpp"),Glob("src/bodies/*.cpp"),Glob("src/joints/*.cpp"),Glob("src/servers/*.cpp"),Glob("src/shapes/*.cpp"),Glob("src/spaces/*.cpp"),Glob("src/box2d-wrapper/*.cpp")]
sources.extend([box2d_folder + 'src/' + box2d_src_file for box2d_src_file in box2d_src])
sources.extend([Glob("box2d/src/*.c")])

if env["platform"] == "macos":
library = env.SharedLibrary(
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"
2 changes: 1 addition & 1 deletion box2d
Submodule box2d updated from b31e89 to 29adfc
21 changes: 21 additions & 0 deletions godot.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,26 @@
"string_view": "cpp",
"__config": "cpp"
}
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"program": "/Users/dragosdaian/Documents/GitHub/godot/bin/godot.macos.editor.arm64",
"type": "cppdbg",
"request": "launch",
"cwd": "/Users/dragosdaian/Documents/GitHub/godot-box2d",
"osx": {
"MIMode": "lldb"
},
"args": [
"--path",
"/Users/dragosdaian/Documents/GitHub/godot-box2d/Godot-Physics-Tests",
"--debug-collisions",
"test.tscn"
]
}
]
}
}
76 changes: 0 additions & 76 deletions src/b2_user_settings.h

This file was deleted.

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
Loading