void Body::update(float mFrameTime) { onPreUpdate(); if(_static) { spatialInfo.preUpdate(); return; } if(outOfBounds) { onOutOfBounds(); outOfBounds = false; return; } oldShape = shape; integrate(mFrameTime); spatialInfo.preUpdate(); bodiesToResolve.clear(); for(const auto& body : spatialInfo.getBodiesToCheck()) { if(body == this || !isOverlapping(shape, body->getShape())) continue; auto intersection(getMinIntersection(shape, body->getShape())); onDetection({*body, mFrameTime, body->getUserData(), intersection}); body->onDetection({*this, mFrameTime, userData, -intersection}); if(!resolve || containsAny(body->getGroups(), getGroupsNoResolve())) continue; bodiesToResolve.push_back(body); } if(!bodiesToResolve.empty()) resolver.resolve(*this, bodiesToResolve); if(oldShape != shape) spatialInfo.invalidate(); spatialInfo.postUpdate(); onPostUpdate(); }
bool Geom::Box::intersect( Box other ) { return containsAny(other.getEdgeSamples(100)); }