Added option to use Godot hide instead of detach from scene tree

This commit is contained in:
lawnjelly 2020-01-09 14:08:27 +00:00 committed by GitHub
parent 46371dbe63
commit 1fcdeaa0e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 6 deletions

View File

@ -27,6 +27,8 @@
#include "scene/3d/light.h" #include "scene/3d/light.h"
bool LHidable::m_bDetach = true;
void LHidable::Hidable_Create(Node * pNode) void LHidable::Hidable_Create(Node * pNode)
{ {
// m_pNode = 0; m_pParent = 0; m_bShow = true; // m_pNode = 0; m_pParent = 0; m_bShow = true;
@ -47,15 +49,25 @@ void LHidable::Show(bool bShow)
assert (m_pParent); assert (m_pParent);
if (bShow) if (m_bDetach)
{ {
// add to tree if (bShow)
m_pParent->add_child(m_pNode); {
// add to tree
m_pParent->add_child(m_pNode);
}
else
{
// remove from tree
m_pParent->remove_child(m_pNode);
}
} }
else else
{ {
// remove from tree if (bShow)
m_pParent->remove_child(m_pNode); ((Spatial *) m_pNode)->show();
else
((Spatial *) m_pNode)->hide();
} }
} }

3
ldob.h
View File

@ -43,6 +43,9 @@ public:
// separate flag so we don't have to touch the godot lookup // separate flag so we don't have to touch the godot lookup
bool m_bShow; bool m_bShow;
// which method we are using to show and hide .. detaching from scene tree or just show / hide through godot
static bool m_bDetach;
}; };
// static object // static object

View File

@ -1232,6 +1232,12 @@ bool LRoomManager::rooms_single_room_convert(bool bVerbose, bool bDeleteLights)
} }
void LRoomManager::rooms_set_hide_method_detach(bool bDetach)
{
LHidable::m_bDetach = bDetach;
}
void LRoomManager::rooms_set_portal_plane_convention(bool bFlip) void LRoomManager::rooms_set_portal_plane_convention(bool bFlip)
{ {
m_bPortalPlane_Convention = bFlip; m_bPortalPlane_Convention = bFlip;
@ -2004,6 +2010,8 @@ void LRoomManager::_bind_methods()
ClassDB::bind_method(D_METHOD("rooms_single_room_convert", "verbose", "delete lights"), &LRoomManager::rooms_single_room_convert); ClassDB::bind_method(D_METHOD("rooms_single_room_convert", "verbose", "delete lights"), &LRoomManager::rooms_single_room_convert);
ClassDB::bind_method(D_METHOD("rooms_set_portal_plane_convention", "flip"), &LRoomManager::rooms_set_portal_plane_convention); ClassDB::bind_method(D_METHOD("rooms_set_portal_plane_convention", "flip"), &LRoomManager::rooms_set_portal_plane_convention);
ClassDB::bind_method(D_METHOD("rooms_set_hide_method_detach", "detach"), &LRoomManager::rooms_set_hide_method_detach);
ClassDB::bind_method(D_METHOD("rooms_release"), &LRoomManager::rooms_release); ClassDB::bind_method(D_METHOD("rooms_release"), &LRoomManager::rooms_release);
ClassDB::bind_method(D_METHOD("rooms_set_camera", "camera"), &LRoomManager::rooms_set_camera); ClassDB::bind_method(D_METHOD("rooms_set_camera", "camera"), &LRoomManager::rooms_set_camera);

View File

@ -60,7 +60,6 @@ public:
// convert empties and meshes to rooms and portals // convert empties and meshes to rooms and portals
bool rooms_convert(bool bVerbose, bool bDeleteLights); bool rooms_convert(bool bVerbose, bool bDeleteLights);
bool rooms_single_room_convert(bool bVerbose, bool bDeleteLights); bool rooms_single_room_convert(bool bVerbose, bool bDeleteLights);
void rooms_set_portal_plane_convention(bool bFlip);
// free memory for current set of rooms, prepare for converting a new game level // free memory for current set of rooms, prepare for converting a new game level
void rooms_release(); void rooms_release();
@ -72,6 +71,10 @@ public:
// (can be used to find the name etc of a room ID returned by dob_update) // (can be used to find the name etc of a room ID returned by dob_update)
Node * rooms_get_room(int room_id); Node * rooms_get_room(int room_id);
// CONVENTIONS
void rooms_set_portal_plane_convention(bool bFlip);
void rooms_set_hide_method_detach(bool bDetach);
//______________________________________________________________________________________ //______________________________________________________________________________________
// DOBS // DOBS
// Dynamic objects .. cameras, players, boxes etc // Dynamic objects .. cameras, players, boxes etc