Skip to content

Commit 623eb76

Browse files
committed
fix area callback
1 parent 7413e67 commit 623eb76

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/spaces/rapier_space_2d.cpp

+10-14
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void RapierSpace2D::collision_event_callback(rapier2d::Handle world_handle, cons
216216

217217
if (event_info->is_sensor) {
218218
if (!instanceId1.is_valid()) {
219-
ERR_FAIL_COND_MSG(pObject2, "Should be able to get info about a removed object if the other one is still valid.");
219+
ERR_FAIL_COND_MSG(pObject1, "Should be able to get info about a removed object if the other one is still valid.");
220220
return;
221221
}
222222
if (!instanceId2.is_valid()) {
@@ -235,52 +235,48 @@ void RapierSpace2D::collision_event_callback(rapier2d::Handle world_handle, cons
235235
}
236236

237237
RapierArea2D *pArea = static_cast<RapierArea2D *>(pObject1);
238-
uint32_t area_shape = shape1;
239-
uint32_t other_shape = shape2;
240-
RID other_rid = rid2;
241-
ObjectID other_instance_id = instanceId2;
242238
if (type2 == RapierCollisionObject2D::TYPE_AREA) {
243239
RapierArea2D *pArea2 = static_cast<RapierArea2D *>(pObject2);
244240
if (event_info->is_started) {
245241
ERR_FAIL_COND(!pArea);
246242
ERR_FAIL_COND(!pArea2);
247-
pArea->on_area_enter(collider_handle2, pArea2, other_shape, other_rid, other_instance_id, collider_handle1, area_shape);
248-
pArea2->on_area_enter(collider_handle1, pArea, area_shape, other_rid, other_instance_id, collider_handle2, other_shape);
243+
pArea->on_area_enter(collider_handle2, pArea2, shape2, rid2, instanceId2, collider_handle1, shape1);
244+
pArea2->on_area_enter(collider_handle1, pArea, shape1, rid1, instanceId1, collider_handle2, shape2);
249245
} else {
250246
if (pArea) {
251-
pArea->on_area_exit(collider_handle2, pArea2, other_shape, other_rid, other_instance_id, collider_handle1, area_shape);
247+
pArea->on_area_exit(collider_handle2, pArea2, shape2, rid2, instanceId2, collider_handle1, shape1);
252248
} else {
253249
// Try to retrieve area if not destroyed yet
254250
pArea = space->get_area_from_rid(rid1);
255251
if (pArea) {
256252
// Use invalid area case to keep counters consistent for already removed collider
257-
pArea->on_area_exit(collider_handle2, nullptr, other_shape, other_rid, other_instance_id, collider_handle1, area_shape);
253+
pArea->on_area_exit(collider_handle2, nullptr, shape2, rid2, instanceId2, collider_handle1, shape1);
258254
}
259255
}
260256
if (pArea2) {
261-
pArea2->on_area_exit(collider_handle1, pArea, area_shape, other_rid, other_instance_id, collider_handle2, other_shape);
257+
pArea2->on_area_exit(collider_handle1, pArea, shape1, rid1, instanceId1, collider_handle2, shape2);
262258
} else {
263259
// Try to retrieve area if not destroyed yet
264260
pArea2 = space->get_area_from_rid(rid2);
265261
if (pArea2) {
266262
// Use invalid area case to keep counters consistent for already removed collider
267-
pArea2->on_area_exit(collider_handle1, nullptr, area_shape, other_rid, other_instance_id, collider_handle2, other_shape);
263+
pArea2->on_area_exit(collider_handle1, nullptr, shape1, rid1, instanceId1, collider_handle2, shape2);
268264
}
269265
}
270266
}
271267
} else {
272268
RapierBody2D *pBody = static_cast<RapierBody2D *>(pObject2);
273269
if (event_info->is_started) {
274270
ERR_FAIL_COND(!pArea);
275-
pArea->on_body_enter(collider_handle2, pBody, other_shape, other_rid, other_instance_id, collider_handle1, area_shape);
271+
pArea->on_body_enter(collider_handle2, pBody, shape2, rid2, instanceId2, collider_handle1, shape1);
276272
} else if (pArea) {
277-
pArea->on_body_exit(collider_handle2, pBody, other_shape, other_rid, other_instance_id, collider_handle1, area_shape);
273+
pArea->on_body_exit(collider_handle2, pBody, shape2, rid2, instanceId2, collider_handle1, shape1);
278274
} else {
279275
// Try to retrieve area if not destroyed yet
280276
pArea = space->get_area_from_rid(rid1);
281277
if (pArea) {
282278
// Use invalid body case to keep counters consistent for already removed collider
283-
pArea->on_body_exit(collider_handle2, nullptr, other_shape, other_rid, other_instance_id, collider_handle1, area_shape, false);
279+
pArea->on_body_exit(collider_handle2, nullptr, shape2, rid2, instanceId2, collider_handle1, shape1, false);
284280
}
285281
}
286282
}

0 commit comments

Comments
 (0)