Merge pull request #50932 from lawnjelly/portals_fix_margin_loading
Portals - Fix default portal margin loading
This commit is contained in:
commit
717ba8f9d8
|
@ -54,8 +54,7 @@ Portal::Portal() {
|
|||
_pts_local_raw.resize(0);
|
||||
_pt_center_world = Vector3();
|
||||
_plane = Plane();
|
||||
_margin = 1.0f;
|
||||
_default_margin = 1.0f;
|
||||
_margin = 1.0;
|
||||
_use_default_margin = true;
|
||||
|
||||
// the visual server portal lifetime is linked to the lifetime of this object
|
||||
|
@ -508,7 +507,7 @@ void Portal::portal_update() {
|
|||
|
||||
real_t Portal::get_active_portal_margin() const {
|
||||
if (_use_default_margin) {
|
||||
return _default_margin;
|
||||
return RoomManager::_get_default_portal_margin();
|
||||
}
|
||||
return _margin;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,6 @@ private:
|
|||
|
||||
// extension margin
|
||||
real_t _margin;
|
||||
real_t _default_margin;
|
||||
bool _use_default_margin;
|
||||
|
||||
// for editing
|
||||
|
|
|
@ -58,6 +58,10 @@
|
|||
RoomManager *RoomManager::active_room_manager = nullptr;
|
||||
#endif
|
||||
|
||||
// This needs to be static because it cannot easily be propagated to portals
|
||||
// during load (as the RoomManager may be loaded before Portals enter the scene tree)
|
||||
real_t RoomManager::_default_portal_margin = 1.0;
|
||||
|
||||
RoomManager::RoomManager() {
|
||||
// some high value, we want room manager to be processed after other
|
||||
// nodes because the camera should be moved first
|
||||
|
@ -343,14 +347,13 @@ void RoomManager::set_default_portal_margin(real_t p_dist) {
|
|||
return;
|
||||
}
|
||||
|
||||
_update_portal_margins(roomlist, _default_portal_margin);
|
||||
_update_portal_gizmos(roomlist);
|
||||
}
|
||||
|
||||
void RoomManager::_update_portal_margins(Spatial *p_node, real_t p_margin) {
|
||||
void RoomManager::_update_portal_gizmos(Spatial *p_node) {
|
||||
Portal *portal = Object::cast_to<Portal>(p_node);
|
||||
|
||||
if (portal) {
|
||||
portal->_default_margin = p_margin;
|
||||
portal->update_gizmo();
|
||||
}
|
||||
|
||||
|
@ -359,7 +362,7 @@ void RoomManager::_update_portal_margins(Spatial *p_node, real_t p_margin) {
|
|||
Spatial *child = Object::cast_to<Spatial>(p_node->get_child(n));
|
||||
|
||||
if (child) {
|
||||
_update_portal_margins(child, p_margin);
|
||||
_update_portal_gizmos(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ private:
|
|||
|
||||
// misc
|
||||
bool _add_plane_if_unique(const Room *p_room, LocalVector<Plane, int32_t> &r_planes, const Plane &p);
|
||||
void _update_portal_margins(Spatial *p_node, real_t p_margin);
|
||||
void _update_portal_gizmos(Spatial *p_node);
|
||||
bool _check_roomlist_validity(Node *p_node);
|
||||
void _cleanup_after_conversion();
|
||||
Error _build_room_convex_hull(const Room *p_room, const Vector<Vector3> &p_points, Geometry::MeshData &r_mesh);
|
||||
|
@ -217,6 +217,7 @@ private:
|
|||
public:
|
||||
static String _find_name_after(Node *p_node, String p_string_start);
|
||||
static void show_warning(const String &p_string, const String &p_extra_string = "", bool p_alert = true);
|
||||
static real_t _get_default_portal_margin() { return _default_portal_margin; }
|
||||
|
||||
private:
|
||||
// accessible from UI
|
||||
|
@ -256,7 +257,7 @@ private:
|
|||
LocalVector<Room *, int32_t> _rooms;
|
||||
|
||||
// advanced params
|
||||
real_t _default_portal_margin = 1.0;
|
||||
static real_t _default_portal_margin;
|
||||
real_t _overlap_warning_threshold = 1.0;
|
||||
Room::SimplifyInfo _room_simplify_info;
|
||||
int _settings_portal_depth_limit = 16;
|
||||
|
|
Loading…
Reference in New Issue