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

Commit ec78b59

Browse files
committed
add missing todos
1 parent 24aa449 commit ec78b59

7 files changed

+19
-46
lines changed

src/bodies/box2d_body_2d.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ void Box2DBody2D::_init_collider(box2d::FixtureHandle collider_handle) const {
459459
if (mode >= PhysicsServer2D::BODY_MODE_KINEMATIC) {
460460
// Only send contacts if contact monitor is enabled
461461
bool send_contacts = can_report_contacts();
462-
// TODO set contacts callback only if needed
463-
//box2d::collider_set_contact_force_events_enabled(space_handle, collider_handle, send_contacts);
462+
box2d::collider_set_contact_force_events_enabled(collider_handle, send_contacts);
464463
}
465464
}
466465

src/bodies/box2d_collision_object_2d.cpp

-33
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ void Box2DCollisionObject2D::add_shape(Box2DShape2D *p_shape, const Transform2D
1919
shapes.push_back(shape);
2020
p_shape->add_owner(this);
2121

22-
//if (!pending_shape_update_list.in_list()) {
23-
// Box2DPhysicsServer2D::singleton->pending_shape_update_list.add(&pending_shape_update_list);
24-
//}
25-
2622
if (space) {
2723
_shapes_changed();
2824
}
@@ -45,10 +41,6 @@ void Box2DCollisionObject2D::set_shape(int p_index, Box2DShape2D *p_shape) {
4541
_update_shape_transform(shape);
4642
}
4743

48-
//if (!pending_shape_update_list.in_list()) {
49-
// Box2DPhysicsServer2D::singleton->pending_shape_update_list.add(&pending_shape_update_list);
50-
//}
51-
5244
if (space) {
5345
_shapes_changed();
5446
}
@@ -62,10 +54,6 @@ void Box2DCollisionObject2D::set_shape_transform(int p_index, const Transform2D
6254

6355
_update_shape_transform(shape);
6456

65-
//if (!pending_shape_update_list.in_list()) {
66-
// Box2DPhysicsServer2D::singleton->pending_shape_update_list.add(&pending_shape_update_list);
67-
//}
68-
6957
if (space) {
7058
_shapes_changed();
7159
}
@@ -88,22 +76,6 @@ void Box2DCollisionObject2D::set_shape_disabled(int p_index, bool p_disabled) {
8876
_update_shape_transform(shape);
8977
}
9078

91-
// if (p_disabled && shape.bpid != 0) {
92-
// space->get_broadphase()->remove(shape.bpid);
93-
// shape.bpid = 0;
94-
// if (!pending_shape_update_list.in_list()) {
95-
// Box2DPhysicsServer2D::singleton->pending_shape_update_list.add(&pending_shape_update_list);
96-
// }
97-
// } else if (!p_disabled && shape.bpid == 0) {
98-
// if (!pending_shape_update_list.in_list()) {
99-
// Box2DPhysicsServer2D::singleton->pending_shape_update_list.add(&pending_shape_update_list);
100-
// }
101-
// }
102-
103-
//if (!pending_shape_update_list.in_list()) {
104-
// Box2DPhysicsServer2D::singleton->pending_shape_update_list.add(&pending_shape_update_list);
105-
//}
106-
10779
if (space) {
10880
_shapes_changed();
10981
}
@@ -132,10 +104,6 @@ void Box2DCollisionObject2D::remove_shape(int p_index) {
132104
shape.shape->remove_owner(this);
133105
shapes.remove_at(p_index);
134106

135-
//if (!pending_shape_update_list.in_list()) {
136-
// Box2DPhysicsServer2D::singleton->pending_shape_update_list.add(&pending_shape_update_list);
137-
//}
138-
139107
if (space) {
140108
_shapes_changed();
141109
}
@@ -350,6 +318,5 @@ void Box2DCollisionObject2D::_shape_changed(Box2DShape2D *p_shape) {
350318
}
351319

352320
Box2DCollisionObject2D::Box2DCollisionObject2D(Type p_type) {
353-
//: pending_shape_update_list(this) {
354321
type = p_type;
355322
}

src/box2d-wrapper/box2d_wrapper.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ FixtureHandle box2d::collider_create_solid(b2WorldId world_handle,
418418
return fixture_handle;
419419
}
420420

421+
void box2d::collider_set_contact_force_events_enabled(FixtureHandle collider_handle, bool send_contacts) {
422+
for (int i = 0; i < collider_handle.handles.size(); i++) {
423+
b2ShapeId shape_id = collider_handle.handles[i];
424+
}
425+
}
426+
421427
void box2d::collider_destroy(b2WorldId world_handle, FixtureHandle handle) {
422428
for (b2ShapeId shapeId : handle.handles) {
423429
b2DestroyShape(shapeId);

src/box2d-wrapper/box2d_wrapper.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct ShapeInfo {
8585
struct QueryExcludedInfo {
8686
uint32_t query_collision_layer_mask;
8787
uint64_t query_canvas_instance_id;
88-
//b2ShapeId *query_exclude;
88+
b2ShapeId *query_exclude;
8989
uint32_t query_exclude_size;
9090
int64_t query_exclude_body;
9191
};
@@ -127,7 +127,7 @@ struct ShapeCastResult {
127127
b2Vec2 witness2;
128128
b2Vec2 normal1;
129129
b2Vec2 normal2;
130-
//b2ShapeId collider;
130+
b2ShapeId collider;
131131
b2FixtureUserData user_data;
132132
};
133133

@@ -461,6 +461,8 @@ void world_set_active_body_callback(b2WorldId world_handle, ActiveBodyCallback c
461461
void world_set_collision_filter_callback(b2WorldId world_handle,
462462
b2ContactFilter *callback);
463463

464+
void collider_set_contact_force_events_enabled(FixtureHandle collider_handle, bool send_contacts);
465+
464466
void world_step(b2WorldId world_handle, const SimulationSettings settings);
465467

466468
} // namespace box2d

src/servers/box2d_physics_server_2d.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ RID Box2DPhysicsServer2D::_shape_create(ShapeType p_shape) {
4747
case SHAPE_CONCAVE_POLYGON: {
4848
shape = memnew(Box2DConcavePolygonShape2D);
4949
} break;
50-
case SHAPE_CUSTOM: {
51-
ERR_FAIL_V_MSG(RID(), "Unsupported shape");
52-
} break;
5350
default:
5451
ERR_FAIL_V_MSG(RID(), "Unsupported shape");
5552
}

src/spaces/box2d_direct_space_state_2d.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ bool Box2DDirectSpaceState2D::_collide_shape(const RID &shape_rid, const Transfo
130130
box2d::ShapeInfo shape_info = box2d::shape_info_from_body_shape(shape_handle, Transform2D(), transform);
131131
box2d::QueryExcludedInfo query_excluded_info = box2d::default_query_excluded_info();
132132
query_excluded_info.query_collision_layer_mask = collision_mask;
133-
//query_excluded_info.query_exclude = (b2ShapeId *)memalloc((max_results) * sizeof(b2ShapeId));
133+
query_excluded_info.query_exclude = (b2ShapeId *)memalloc((max_results) * sizeof(b2ShapeId));
134134
query_excluded_info.query_exclude_size = 0;
135135

136136
int cpt = 0;
@@ -141,15 +141,15 @@ bool Box2DDirectSpaceState2D::_collide_shape(const RID &shape_rid, const Transfo
141141
break;
142142
}
143143
(*result_count)++;
144-
//query_excluded_info.query_exclude[query_excluded_info.query_exclude_size++] = result.collider;
144+
query_excluded_info.query_exclude[query_excluded_info.query_exclude_size++] = result.collider;
145145
if (results_out != nullptr) {
146146
results_out[array_idx++] = Vector2(result.witness1.x, result.witness1.y);
147147
results_out[array_idx++] = Vector2(result.witness2.x, result.witness2.y);
148148
}
149149

150150
cpt++;
151151
} while (cpt < max_results);
152-
//memfree(query_excluded_info.query_exclude);
152+
memfree(query_excluded_info.query_exclude);
153153
return array_idx > 0;
154154
}
155155

@@ -164,7 +164,7 @@ int Box2DDirectSpaceState2D::_intersect_shape(const RID &shape_rid, const Transf
164164

165165
box2d::QueryExcludedInfo query_excluded_info = box2d::default_query_excluded_info();
166166
query_excluded_info.query_collision_layer_mask = collision_mask;
167-
//query_excluded_info.query_exclude = (b2ShapeId *)memalloc((p_result_max) * sizeof(b2ShapeId));
167+
query_excluded_info.query_exclude = (b2ShapeId *)memalloc((p_result_max) * sizeof(b2ShapeId));
168168
query_excluded_info.query_exclude_size = 0;
169169

170170
int cpt = 0;
@@ -173,7 +173,7 @@ int Box2DDirectSpaceState2D::_intersect_shape(const RID &shape_rid, const Transf
173173
if (!result.collided) {
174174
break;
175175
}
176-
//query_excluded_info.query_exclude[query_excluded_info.query_exclude_size++] = result.collider;
176+
query_excluded_info.query_exclude[query_excluded_info.query_exclude_size++] = result.collider;
177177

178178
ERR_CONTINUE_MSG(!box2d::is_user_data_valid(result.user_data), "Invalid user data");
179179
uint32_t shape_index = 0;
@@ -194,7 +194,7 @@ int Box2DDirectSpaceState2D::_intersect_shape(const RID &shape_rid, const Transf
194194

195195
} while (cpt < p_result_max);
196196

197-
//memfree(query_excluded_info.query_exclude);
197+
memfree(query_excluded_info.query_exclude);
198198
return cpt;
199199
}
200200

src/spaces/box2d_space_2d.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ bool Box2DSpace2D::ShouldCollide(b2ShapeId fixtureA, b2ShapeId fixtureB, b2Manif
117117

118118
return true;
119119
}
120+
// TODO
120121
/*
121122
box2d::CollisionEventInfo event_info_from_contact(b2Contact *contact) {
122123
box2d::CollisionEventInfo event_info;
@@ -550,6 +551,7 @@ void Box2DSpace2D::step(real_t p_step) {
550551
active_objects = box2d::world_get_active_objects_count(handle);
551552
}
552553

554+
// TODO
553555
// Returns true to ignore the collider
554556
bool Box2DSpace2D::_is_handle_excluded_callback(b2WorldId world_handle, b2ShapeId collider_handle, b2FixtureUserData user_data, const box2d::QueryExcludedInfo *handle_excluded_info) {
555557
/*

0 commit comments

Comments
 (0)