rendered paste bodyPlane::Side AABB::intersect(const Plane& p) const { const Vec3 n = p.getNormal(); const Real d = p.getOrigoDistance(); const Vec3 bmax = getMax(); const Vec3 bmin = getMin(); Vec3 vmin; Vec3 vmax; // find min/max points for (int i = 0; i < 3; i++) { if (n[i] >= 0) { vmin[i] = bmin[i]; vmax[i] = bmax[i]; } else { vmin[i] = bmax[i]; vmax[i] = bmin[i]; } } if ((n*vmin - d) > 0) return Plane::POSITIVE_SIDE; if ((n*vmax - d) < 0) return Plane::NEGATIVE_SIDE; return Plane::ON_PLANE; // intersection!}