| 1187 | } |
| 1188 | |
| 1189 | bool PhysicsDemoSlice::slice(PhysicsWorld& /*world*/, const PhysicsRayCastInfo& info, void* /*data*/) |
| 1190 | { |
| 1191 | if (info.shape->getBody()->getTag() != _sliceTag) |
| 1192 | { |
| 1193 | return true; |
| 1194 | } |
| 1195 | |
| 1196 | if (!info.shape->containsPoint(info.start) && !info.shape->containsPoint(info.end)) |
| 1197 | { |
| 1198 | Vec2 normal = info.end - info.start; |
| 1199 | normal = normal.getPerp().getNormalized(); |
| 1200 | float dist = info.start.dot(normal); |
| 1201 | |
| 1202 | clipPoly(dynamic_cast<PhysicsShapePolygon*>(info.shape), normal, dist); |
| 1203 | clipPoly(dynamic_cast<PhysicsShapePolygon*>(info.shape), -normal, -dist); |
| 1204 | |
| 1205 | info.shape->getBody()->removeFromWorld(); |
| 1206 | } |
| 1207 | |
| 1208 | return true; |
| 1209 | } |
| 1210 | |
| 1211 | void PhysicsDemoSlice::clipPoly(PhysicsShapePolygon* shape, Vec2 normal, float distance) |
| 1212 | { |
no test coverage detected