Removed redundant overloads to restrict potential bad function calls

This commit is contained in:
Diren D Bharwani 2022-11-10 10:24:09 +08:00
parent 08b3cbafcd
commit 578f384808
2 changed files with 1 additions and 110 deletions

View File

@ -244,21 +244,6 @@ namespace SHADE
SHEventManager::BroadcastEvent<SHSceneGraphChangeParentEvent>(EVENT_DATA, SH_SCENEGRAPH_CHANGE_PARENT_EVENT);
}
void SHSceneGraph::SetParent(SHSceneNode* node, SHSceneNode* newParent) noexcept
{
const SHSceneGraphChangeParentEvent EVENT_DATA
{
.node = node
, .oldParent = node->parent
, .newParent = newParent ? newParent : root
};
if (newParent == nullptr)
newParent = root;
ChangeParent(node, newParent);
}
void SHSceneGraph::SetParent(EntityID entityID, EntityID newParent) noexcept
{
////////////////////////////////////////
@ -304,38 +289,6 @@ namespace SHADE
SHEventManager::BroadcastEvent<SHSceneGraphChangeParentEvent>(EVENT_DATA, SH_SCENEGRAPH_CHANGE_PARENT_EVENT);
}
void SHSceneGraph::SetParent(SHSceneNode* node, EntityID newParent) noexcept
{
////////////////////////////////////////
// Error Handling
if (!SHEntityManager::IsValidEID(newParent))
{
SHLOG_ERROR("Parent Entity {} is invalid! Unable to set Entity {}'s parent!", newParent, node->entityID)
return;
}
auto PARENT_ITER = entityNodeMap.find(newParent);
if (PARENT_ITER == entityNodeMap.end())
{
SHLOG_ERROR("Entity {} cannot be found in the scene! Unable to parent to Entity {}", newParent, node->entityID)
return;
}
////////////////////////////////////////
const SHSceneGraphChangeParentEvent EVENT_DATA
{
.node = node
, .oldParent = node->parent
, .newParent = PARENT_ITER->second
};
ChangeParent(node, PARENT_ITER->second);
SHEventManager::BroadcastEvent<SHSceneGraphChangeParentEvent>(EVENT_DATA, SH_SCENEGRAPH_CHANGE_PARENT_EVENT);
}
/*-----------------------------------------------------------------------------------*/
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
@ -456,32 +409,6 @@ namespace SHADE
return false;
}
bool SHSceneGraph::IsChildOf(SHSceneNode* node, SHSceneNode* targetNode) noexcept
{
if (!node || !targetNode)
{
SHLOG_ERROR("Attempting to check for invalid scene nodes!")
return false;
}
if (node == targetNode)
{
SHLOG_WARNING("Entity {} cannot be a child of itself!", node->entityID)
return false;
}
const SHSceneNode* CURRENT_TARGET = node->parent;
while (CURRENT_TARGET != root)
{
if (CURRENT_TARGET == targetNode)
return true;
CURRENT_TARGET = CURRENT_TARGET->parent;
}
return false;
}
bool SHSceneGraph::IsChildOf(EntityID entityID, EntityID targetID) noexcept
{
////////////////////////////////////////
@ -527,38 +454,6 @@ namespace SHADE
return false;
}
bool SHSceneGraph::IsChildOf(SHSceneNode* node, EntityID targetID) noexcept
{
////////////////////////////////////////
// Error Handling
if (!SHEntityManager::IsValidEID(targetID))
{
SHLOG_ERROR("Entity {} is invalid!", targetID)
return false;
}
auto TARGET_ITER = entityNodeMap.find(targetID);
if (TARGET_ITER == entityNodeMap.end())
{
SHLOG_ERROR("Entity {} cannot be found in the scene! Unable to check child!", targetID)
return false;
}
////////////////////////////////////////
const SHSceneNode* CURRENT_TARGET = node->parent;
while (CURRENT_TARGET != root)
{
if (CURRENT_TARGET == TARGET_ITER->second)
return true;
CURRENT_TARGET = CURRENT_TARGET->parent;
}
return false;
}
void SHSceneGraph::Traverse (const UnaryFunction& function) const
{
TraverseAndInvokeFunction(root, function);

View File

@ -65,9 +65,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
void SetParent (EntityID entityID, SHSceneNode* newParent) noexcept;
void SetParent (SHSceneNode* node, SHSceneNode* newParent) noexcept;
void SetParent (EntityID entityID, EntityID newParent) noexcept;
void SetParent (SHSceneNode* node, EntityID newParent) noexcept;
/*---------------------------------------------------------------------------------*/
/* Function Members */
@ -79,9 +77,7 @@ namespace SHADE
void Reset () noexcept;
bool IsChildOf (EntityID entityID, SHSceneNode* targetNode) noexcept;
bool IsChildOf (SHSceneNode* node, SHSceneNode* targetNode) noexcept;
bool IsChildOf (EntityID entityID, EntityID targetID) noexcept;
bool IsChildOf (SHSceneNode* node, EntityID targetID) noexcept;
void Traverse (const UnaryFunction& function) const;