Fixed false positives in the culling system.

This fixes numerous false positives coming out of the culling system.

AABB checks are now a full separating-axis check against the frustum, with the points of the frustum being compared to the planes of the box just as the points of the box were being compared to the planes of the frustum. This fixes large objects behind the camera not being culled correctly.

Some systems that used frustums that were (sometimes mistakenly?) unbounded on one or more side have been modified to be fully enclosed.
This commit is contained in:
Kiri Jolly 2020-04-28 17:14:06 -07:00
parent 2c6e859c2d
commit bac44ee19f
8 changed files with 93 additions and 24 deletions

View file

@ -669,17 +669,13 @@ void SpatialEditorViewport::_select_region() {
}
}
if (!orthogonal) {
Plane near(cam_pos, -_get_camera_normal());
near.d -= get_znear();
Plane near(cam_pos, -_get_camera_normal());
near.d -= get_znear();
frustum.push_back(near);
frustum.push_back(near);
Plane far = -near;
far.d += get_zfar();
frustum.push_back(far);
}
Plane far = -near;
far.d += get_zfar();
frustum.push_back(far);
Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario());
Vector<Node *> selected;