Parent/child multiple entities (WIP)

This commit is contained in:
Sri Sham Haran 2022-10-16 18:16:05 +08:00
parent 7f2935dcf6
commit 7fc417e35a
1 changed files with 10 additions and 5 deletions

View File

@ -149,16 +149,21 @@ namespace SHADE
if (SHDragDrop::BeginSource())
{
ImGui::Text("Moving EID: %zu", eid);
SHDragDrop::SetPayload<EntityID>(DRAG_EID, &eid);
SHDragDrop::SetPayload<std::vector<EntityID>>(DRAG_EID, &editor->selectedEntities);
SHDragDrop::EndSource();
}
else if (SHDragDrop::BeginTarget()) //If Received DragDrop
{
if (const EntityID* eidPayload = SHDragDrop::AcceptPayload<EntityID>(DRAG_EID)) //If payload is valid
if (const std::vector<EntityID>* eidPayload = SHDragDrop::AcceptPayload<std::vector<EntityID>>(DRAG_EID)) //If payload is valid
{
EntityID const dropEID = *eidPayload;
if(!sceneGraph.GetChild(dropEID, eid))
sceneGraph.SetParent(dropEID, eid); //Set dropEID parent to eid (belonging to current Node)
std::vector<EntityID> const droppedEIDs = *eidPayload;
for(auto const& dropEID : droppedEIDs)
{
if(!sceneGraph.GetChild(dropEID, eid))
sceneGraph.SetParent(dropEID, eid);
}
//if(!sceneGraph.GetChild(dropEID, eid))
// sceneGraph.SetParent(dropEID, eid); //Set dropEID parent to eid (belonging to current Node)
SHDragDrop::EndTarget();
}
}