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

Commit 847b5d3

Browse files
committed
small update
1 parent 7a53232 commit 847b5d3

7 files changed

+32
-20
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<a href="https://github.com/appsinacup/godot-box2d/actions/workflows/runner.yml">
88
<img src="https://github.com/appsinacup/godot-box2d/actions/workflows/runner.yml/badge.svg?branch=main"
99
alt="chat on Discord"></a>
10-
<a href="https://github.com/erincatto/box2d" alt="Box2D Version">
11-
<img src="https://img.shields.io/badge/Box2D-v2.4.1-%23478cbf?logoColor=white" /></a>
10+
<a href="https://github.com/erincatto/box2c" alt="Box2C Version">
11+
<img src="https://img.shields.io/badge/Box2C-v3.0.0-%23478cbf?logoColor=white" /></a>
1212
<a href="https://github.com/godotengine/godot-cpp" alt="Godot Version">
1313
<img src="https://img.shields.io/badge/Godot-v4.2-%23478cbf?logo=godot-engine&logoColor=white" /></a>
1414
<a href="https://github.com/appsinacup/godot-box2d/graphs/contributors" alt="Contributors">

SConstruct

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ import os
33
import sys
44

55
env = SConscript("godot-cpp/SConstruct")
6-
env.Prepend(CPPPATH=["box2d/include", "box2d/src"])
6+
7+
env.Append(
8+
CPPDEFINES=[
9+
"BOX2D_LENGTH_UNIT_PER_METER=100.0",
10+
"BOX2D_MAX_POLYGON_VERTICES=64",
11+
"BOX2D_AVX2=ON"
12+
]
13+
)
14+
15+
env.Prepend(CPPPATH=["box2d/extern/simde", "box2d/include", "box2d/src"])
716
# For the reference:
817
# - CCFLAGS are compilation flags shared between C and C++
918
# tweak this if you want to use different folders, or more folders, to store your source code in.

src/bodies/box2d_collision_object_2d.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "box2d_collision_object_2d.h"
22

3-
#include "../b2_user_settings.h"
43
#include "../servers/box2d_physics_server_2d.h"
54
#include "../spaces/box2d_space_2d.h"
65

src/bodies/box2d_collision_object_2d.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Box2DCollisionObject2D : public Box2DShapeOwner2D {
4949

5050
protected:
5151
PhysicsServer2D::BodyMode mode = PhysicsServer2D::BODY_MODE_RIGID;
52-
b2Body *body_handle = box2d::invalid_body_handle();
52+
b2BodyId body_handle = box2d::invalid_body_handle();
5353
uint32_t area_detection_counter = 0;
5454

5555
void _unregister_shapes();
@@ -70,7 +70,7 @@ class Box2DCollisionObject2D : public Box2DShapeOwner2D {
7070

7171
_FORCE_INLINE_ void set_instance_id(const ObjectID &p_instance_id) { instance_id = p_instance_id; }
7272
_FORCE_INLINE_ ObjectID get_instance_id() const { return instance_id; }
73-
_FORCE_INLINE_ b2Body *get_body_handle() { return body_handle; }
73+
_FORCE_INLINE_ b2BodyId get_body_handle() { return body_handle; }
7474

7575
_FORCE_INLINE_ void set_canvas_instance_id(const ObjectID &p_canvas_instance_id) { canvas_instance_id = p_canvas_instance_id; }
7676
_FORCE_INLINE_ ObjectID get_canvas_instance_id() const { return canvas_instance_id; }

src/box2d-wrapper/box2d_wrapper.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,13 @@ FixtureHandle box2d::collider_create_sensor(ShapeHandle shape_handles,
375375
b2BodyId body_handle,
376376
b2FixtureUserData *user_data) {
377377
b2MassData mass_data = b2Body_GetMassData(body_handle);
378-
for (int i = 0; i < shape_handles.size(); i++) {
379-
b2ShapeId shape_handle = shape_handles.handles[i];
378+
for (int i = 0; i < shape_handles.handles.size(); i++) {
379+
ShapeData shape_data = shape_handles.handles[i];
380+
switch(shape_data.type) {
381+
case b2ShapeType::e_polygon: {
382+
383+
}
384+
}
380385
b2FixtureDef fixture_def;
381386
fixture_def.shape = shape_handle.handles[i];
382387
fixture_def.density = 1.0;

src/box2d_include.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef BOX2D_INCLUDE_H
22
#define BOX2D_INCLUDE_H
33

4-
#include "b2_user_settings.h"
54
#include "box2d-wrapper/box2d_wrapper.h"
65

76
#include <godot_cpp/templates/hashfuncs.hpp>

src/user_constants.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919
// this too much because b2BlockAllocator has a maximum object size.
2020
#define b2_maxPolygonVertices 64
2121

22-
/*
2322
class Box2DCollisionObject2D;
2423
class Box2DShape2D;
2524

26-
// You can define this to inject whatever data you want in b2Body
25+
// You can define this to inject whatever data you want in b2Fixture
26+
struct b2FixtureUserData {
27+
b2FixtureUserData() :
28+
shape_idx(-1), transform(), collision_object(nullptr) {}
29+
30+
godot::Transform2D transform;
31+
int shape_idx;
32+
Box2DCollisionObject2D *collision_object;
33+
};
2734
struct b2BodyUserData {
2835
b2BodyUserData() :
2936
old_linear_velocity(0, 0), old_angular_velocity(0), constant_force(0, 0), constant_torque(0), collision_object(nullptr) {}
@@ -35,16 +42,9 @@ struct b2BodyUserData {
3542
real_t constant_torque;
3643
Box2DCollisionObject2D *collision_object;
3744
};
45+
/*
3846
39-
// You can define this to inject whatever data you want in b2Fixture
40-
struct b2FixtureUserData {
41-
b2FixtureUserData() :
42-
shape_idx(-1), transform(), collision_object(nullptr) {}
43-
44-
godot::Transform2D transform;
45-
int shape_idx;
46-
Box2DCollisionObject2D *collision_object;
47-
};
47+
// You can define this to inject whatever data you want in b2Body
4848
4949
// Memory Allocation using Godot's functions
5050
inline void *b2AllocGodot(uint32_t size) {

0 commit comments

Comments
 (0)