MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / intersects_plane

Method intersects_plane

core/math/aabb.cpp:257–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257bool AABB::intersects_plane(const Plane &p_plane) const {
258 Vector3 points[8] = {
259 Vector3(position.x, position.y, position.z),
260 Vector3(position.x, position.y, position.z + size.z),
261 Vector3(position.x, position.y + size.y, position.z),
262 Vector3(position.x, position.y + size.y, position.z + size.z),
263 Vector3(position.x + size.x, position.y, position.z),
264 Vector3(position.x + size.x, position.y, position.z + size.z),
265 Vector3(position.x + size.x, position.y + size.y, position.z),
266 Vector3(position.x + size.x, position.y + size.y, position.z + size.z),
267 };
268
269 bool over = false;
270 bool under = false;
271
272 for (int i = 0; i < 8; i++) {
273 if (p_plane.distance_to(points[i]) > 0) {
274 over = true;
275 } else {
276 under = true;
277 }
278 }
279
280 return under && over;
281}
282
283Vector3 AABB::get_longest_axis() const {
284 Vector3 axis(1, 0, 0);

Callers 2

intersects_aabbMethod · 0.45
test_aabb.hFile · 0.45

Calls 2

Vector3Function · 0.70
distance_toMethod · 0.45

Tested by

no test coverage detected