Check whether stuff is visible before baking it, closes #10525
This commit is contained in:
parent
c771e03ee2
commit
36e91b07d8
@ -1092,7 +1092,7 @@ void GIProbe::_plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_b
|
|||||||
void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
|
void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
|
||||||
|
|
||||||
MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node);
|
MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node);
|
||||||
if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) {
|
if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT) && mi->is_visible_in_tree()) {
|
||||||
Ref<Mesh> mesh = mi->get_mesh();
|
Ref<Mesh> mesh = mi->get_mesh();
|
||||||
if (mesh.is_valid()) {
|
if (mesh.is_valid()) {
|
||||||
|
|
||||||
@ -1115,23 +1115,26 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
|
|||||||
|
|
||||||
if (Spatial *s = Object::cast_to<Spatial>(p_at_node)) {
|
if (Spatial *s = Object::cast_to<Spatial>(p_at_node)) {
|
||||||
|
|
||||||
Array meshes = p_at_node->call("get_meshes");
|
if (s->is_visible_in_tree()) {
|
||||||
for (int i = 0; i < meshes.size(); i += 2) {
|
|
||||||
|
|
||||||
Transform mxf = meshes[i];
|
Array meshes = p_at_node->call("get_meshes");
|
||||||
Ref<Mesh> mesh = meshes[i + 1];
|
for (int i = 0; i < meshes.size(); i += 2) {
|
||||||
if (!mesh.is_valid())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Rect3 aabb = mesh->get_aabb();
|
Transform mxf = meshes[i];
|
||||||
|
Ref<Mesh> mesh = meshes[i + 1];
|
||||||
|
if (!mesh.is_valid())
|
||||||
|
continue;
|
||||||
|
|
||||||
Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
|
Rect3 aabb = mesh->get_aabb();
|
||||||
|
|
||||||
if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
|
Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
|
||||||
Baker::PlotMesh pm;
|
|
||||||
pm.local_xform = xf;
|
if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
|
||||||
pm.mesh = mesh;
|
Baker::PlotMesh pm;
|
||||||
p_baker->mesh_list.push_back(pm);
|
pm.local_xform = xf;
|
||||||
|
pm.mesh = mesh;
|
||||||
|
p_baker->mesh_list.push_back(pm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user