| 448 | } |
| 449 | |
| 450 | void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vec2& point1, const Vec2& point2, void* data) |
| 451 | { |
| 452 | AXASSERT(func != nullptr, "func shouldn't be nullptr"); |
| 453 | |
| 454 | if (func != nullptr) |
| 455 | { |
| 456 | if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty()) |
| 457 | { |
| 458 | updateBodies(); |
| 459 | } |
| 460 | RayCastCallbackInfo info = {this, func, point1, point2, data}; |
| 461 | |
| 462 | PhysicsWorldCallback::continues = true; |
| 463 | cpSpaceSegmentQuery(_cpSpace, PhysicsHelper::vec22cpv(point1), PhysicsHelper::vec22cpv(point2), 0.0f, |
| 464 | CP_SHAPE_FILTER_ALL, (cpSpaceSegmentQueryFunc)PhysicsWorldCallback::rayCastCallbackFunc, |
| 465 | &info); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect, void* data) |
| 470 | { |