Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portals - add support for Sprite3D #51396

Merged
merged 1 commit into from
Aug 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions scene/3d/room_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "room_group.h"
#include "scene/3d/camera.h"
#include "scene/3d/light.h"
#include "scene/3d/sprite_3d.h"
#include "visibility_notifier.h"

#ifdef TOOLS_ENABLED
Expand Down Expand Up @@ -1728,11 +1729,11 @@ bool RoomManager::_bound_findpoints_geom_instance(GeometryInstance *p_gi, Vector

// convert to world space
for (int n = 0; n < vertices.size(); n++) {
Vector3 ptWorld = trans.xform(vertices[n]);
r_room_pts.push_back(ptWorld);
Vector3 pt_world = trans.xform(vertices[n]);
r_room_pts.push_back(pt_world);

// keep the bound up to date
r_aabb.expand_to(ptWorld);
r_aabb.expand_to(pt_world);
}

} // for through the surfaces
Expand Down Expand Up @@ -1788,16 +1789,37 @@ bool RoomManager::_bound_findpoints_geom_instance(GeometryInstance *p_gi, Vector
trans = mmi->get_global_transform() * trans;

for (int n = 0; n < local_verts.size(); n++) {
Vector3 ptWorld = trans.xform(local_verts[n]);
r_room_pts.push_back(ptWorld);
Vector3 pt_world = trans.xform(local_verts[n]);
r_room_pts.push_back(pt_world);

// keep the bound up to date
r_aabb.expand_to(ptWorld);
r_aabb.expand_to(pt_world);
}
}
return true;
}

// Sprite3D
SpriteBase3D *sprite = Object::cast_to<SpriteBase3D>(p_gi);
if (sprite) {
Ref<TriangleMesh> tmesh = sprite->generate_triangle_mesh();
PoolVector<Vector3> vertices = tmesh->get_vertices();

// for converting meshes to world space
Transform trans = p_gi->get_global_transform();

// convert to world space
for (int n = 0; n < vertices.size(); n++) {
Vector3 pt_world = trans.xform(vertices[n]);
r_room_pts.push_back(pt_world);

// keep the bound up to date
r_aabb.expand_to(pt_world);
}

return true;
}

return false;
}

Expand Down