Added controls to adjust editor camera movement speed and turn speed #216
|
@ -143,6 +143,18 @@ namespace SHADE
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AssetType SHAssetManager::GetType(AssetID id) noexcept
|
||||||
|
{
|
||||||
|
if (assetCollection.contains(id))
|
||||||
|
{
|
||||||
|
return assetCollection[id].type;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("AssetID {}, does not belong to an asset", id)
|
||||||
|
|
||||||
|
return AssetType::INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* \brief Create record for new asset. CAN ONLY CREATE FOR CUSTOM
|
* \brief Create record for new asset. CAN ONLY CREATE FOR CUSTOM
|
||||||
* ASSETS CREATED BY THE ENGINE.
|
* ASSETS CREATED BY THE ENGINE.
|
||||||
|
|
|
@ -51,6 +51,8 @@ namespace SHADE
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static std::vector<SHAsset> GetAllAssets() noexcept;
|
static std::vector<SHAsset> GetAllAssets() noexcept;
|
||||||
|
|
||||||
|
static AssetType GetType(AssetID id) noexcept;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* \brief Create record for new resource. CAN ONLY CREATE FOR CUSTOM
|
* \brief Create record for new resource. CAN ONLY CREATE FOR CUSTOM
|
||||||
* RESOURCES CREATED BY THE ENGINE.
|
* RESOURCES CREATED BY THE ENGINE.
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
bool SHDragDrop::hasDragDrop = false;
|
bool SHDragDrop::hasDragDrop = false;
|
||||||
|
SHDragDrop::DragDropTag SHDragDrop::currentDragDropTag{};
|
||||||
|
|
||||||
bool SHDragDrop::BeginSource(ImGuiDragDropFlags const flags)
|
bool SHDragDrop::BeginSource(ImGuiDragDropFlags const flags)
|
||||||
{ return ImGui::BeginDragDropSource(flags); }
|
{ return ImGui::BeginDragDropSource(flags); }
|
||||||
|
@ -16,6 +17,10 @@ namespace SHADE
|
||||||
{ return ImGui::BeginDragDropTarget(); }
|
{ return ImGui::BeginDragDropTarget(); }
|
||||||
|
|
||||||
void SHDragDrop::EndTarget()
|
void SHDragDrop::EndTarget()
|
||||||
{ ImGui::EndDragDropTarget(); hasDragDrop = false;}
|
{
|
||||||
|
ImGui::EndDragDropTarget();
|
||||||
|
hasDragDrop = false;
|
||||||
|
currentDragDropTag = {};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,13 @@ namespace SHADE
|
||||||
static void EndSource();
|
static void EndSource();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool SetPayload(std::string_view const type, T* object, ImGuiCond const cond = 0)
|
static bool SetPayload(DragDropTag const& type, T* object, ImGuiCond const cond = 0)
|
||||||
{
|
{
|
||||||
hasDragDrop = ImGui::SetDragDropPayload(type.data(), static_cast<void*>(object), sizeof(T), cond);
|
ImGui::SetDragDropPayload(type.data(), static_cast<void*>(object), sizeof(T), cond);
|
||||||
|
|
||||||
|
hasDragDrop = true;
|
||||||
|
currentDragDropTag = type;
|
||||||
|
|
||||||
return hasDragDrop;
|
return hasDragDrop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,13 +36,16 @@ namespace SHADE
|
||||||
static void EndTarget();
|
static void EndTarget();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T* AcceptPayload(std::string_view const type, ImGuiDragDropFlags const flags = 0)
|
static T* AcceptPayload(DragDropTag const& type, ImGuiDragDropFlags const flags = 0)
|
||||||
{
|
{
|
||||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(type.data(), flags))
|
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(type.data(), flags))
|
||||||
|
{
|
||||||
return static_cast<T*>(payload->Data);
|
return static_cast<T*>(payload->Data);
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasDragDrop;
|
static bool hasDragDrop;
|
||||||
|
static DragDropTag currentDragDropTag;
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -117,9 +117,12 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
if(ImGui::IsDragDropActive())
|
if(ImGui::IsDragDropActive())
|
||||||
{
|
{
|
||||||
ParentSelectedEntities(MAX_EID, draggingEntities);
|
if (SHDragDrop::currentDragDropTag == SHDragDrop::DRAG_EID)
|
||||||
draggingEntities.clear();
|
{
|
||||||
ImGui::ClearDragDrop();
|
ParentSelectedEntities(MAX_EID, draggingEntities);
|
||||||
|
draggingEntities.clear();
|
||||||
|
ImGui::ClearDragDrop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -233,8 +236,9 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
ParentSelectedEntities(eid, draggingEntities);
|
ParentSelectedEntities(eid, draggingEntities);
|
||||||
draggingEntities.clear();
|
draggingEntities.clear();
|
||||||
SHDragDrop::EndTarget();
|
//ImGui::ClearDragDrop();
|
||||||
}
|
}
|
||||||
|
SHDragDrop::EndTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Context menu
|
//Context menu
|
||||||
|
@ -342,17 +346,12 @@ namespace SHADE
|
||||||
SHEntityManager::CreateEntity(MAX_EID, "DefaultChild", parentEID);
|
SHEntityManager::CreateEntity(MAX_EID, "DefaultChild", parentEID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHHierarchyPanel::ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) const noexcept
|
void SHHierarchyPanel::ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) noexcept
|
||||||
{
|
{
|
||||||
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
||||||
|
|
||||||
std::vector<EntityID> entitiesToParent{};
|
std::vector<EntityID> entitiesToParent = CleanUpEIDList(entities);
|
||||||
std::ranges::copy_if(entities, std::back_inserter(entitiesToParent), [&sceneGraph](EntityID const& eid)
|
|
||||||
{
|
|
||||||
if (sceneGraph.GetParent(eid)->GetEntityID() == MAX_EID)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
//auto const editor = SHSystemManager::GetSystem<SHEditor>();
|
//auto const editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
SHEntityParentCommand::EntityParentData entityParentData;
|
SHEntityParentCommand::EntityParentData entityParentData;
|
||||||
std::vector<EntityID> parentedEIDS;
|
std::vector<EntityID> parentedEIDS;
|
||||||
|
@ -419,14 +418,7 @@ namespace SHADE
|
||||||
void SHHierarchyPanel::CopySelectedEntities()
|
void SHHierarchyPanel::CopySelectedEntities()
|
||||||
{
|
{
|
||||||
const auto editor = SHSystemManager::GetSystem<SHEditor>();
|
const auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
std::vector<EntityID> entitiesToCopy = CleanUpEIDList(editor->selectedEntities);
|
||||||
std::vector<EntityID> entitiesToCopy{};
|
|
||||||
std::ranges::copy_if(editor->selectedEntities, std::back_inserter(entitiesToCopy), [&sceneGraph](EntityID const& eid)
|
|
||||||
{
|
|
||||||
if(sceneGraph.GetParent(eid)->GetEntityID() == MAX_EID)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
SHClipboardUtilities::WriteToClipboard(SHSerialization::SerializeEntitiesToString(entitiesToCopy));
|
SHClipboardUtilities::WriteToClipboard(SHSerialization::SerializeEntitiesToString(entitiesToCopy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,19 +431,25 @@ namespace SHADE
|
||||||
void SHHierarchyPanel::DeleteSelectedEntities()
|
void SHHierarchyPanel::DeleteSelectedEntities()
|
||||||
{
|
{
|
||||||
const auto editor = SHSystemManager::GetSystem<SHEditor>();
|
const auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
|
std::vector<EntityID> entitiesToDelete = CleanUpEIDList(editor->selectedEntities);
|
||||||
|
SHCommandManager::PerformCommand(std::make_shared<SHDeleteEntitiesCommand>(entitiesToDelete));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<EntityID> SHHierarchyPanel::CleanUpEIDList(std::vector<EntityID> const& entities)
|
||||||
|
{
|
||||||
|
std::vector<EntityID> result;
|
||||||
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
||||||
|
|
||||||
std::vector<EntityID> entitiesToDelete{};
|
std::ranges::copy_if(entities, std::back_inserter(result), [&sceneGraph, &entities](EntityID const& eid)
|
||||||
std::ranges::copy_if(editor->selectedEntities, std::back_inserter(entitiesToDelete), [&sceneGraph, &selectedEntities = editor->selectedEntities](EntityID const& eid)
|
|
||||||
{
|
{
|
||||||
EntityID parentEID = sceneGraph.GetParent(eid)->GetEntityID();
|
EntityID parentEID = sceneGraph.GetParent(eid)->GetEntityID();
|
||||||
if (parentEID == MAX_EID)
|
if (parentEID == MAX_EID)
|
||||||
return true;
|
return true;
|
||||||
else if(std::ranges::find(selectedEntities, parentEID) == selectedEntities.end())
|
if (std::ranges::find(entities, parentEID) == entities.end())
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
SHCommandManager::PerformCommand(std::make_shared<SHDeleteEntitiesCommand>(entitiesToDelete));
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
|
@ -27,12 +27,13 @@ namespace SHADE
|
||||||
void DrawMenuBar() const noexcept;
|
void DrawMenuBar() const noexcept;
|
||||||
ImRect RecursivelyDrawEntityNode(SHSceneNode* const);
|
ImRect RecursivelyDrawEntityNode(SHSceneNode* const);
|
||||||
void CreateChildEntity(EntityID parentEID) const noexcept;
|
void CreateChildEntity(EntityID parentEID) const noexcept;
|
||||||
void ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) const noexcept;
|
void ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) noexcept;
|
||||||
void SelectRangeOfEntities(EntityID beginEID, EntityID EndEID);
|
void SelectRangeOfEntities(EntityID beginEID, EntityID EndEID);
|
||||||
void SelectAllEntities();
|
void SelectAllEntities();
|
||||||
void CopySelectedEntities();
|
void CopySelectedEntities();
|
||||||
void PasteEntities(EntityID parentEID = MAX_EID);
|
void PasteEntities(EntityID parentEID = MAX_EID);
|
||||||
void DeleteSelectedEntities();
|
void DeleteSelectedEntities();
|
||||||
|
std::vector<EntityID> CleanUpEIDList(std::vector<EntityID> const& entities);
|
||||||
bool skipFrame = false;
|
bool skipFrame = false;
|
||||||
std::string filter;
|
std::string filter;
|
||||||
bool isAnyNodeSelected = false;
|
bool isAnyNodeSelected = false;
|
||||||
|
|
|
@ -454,6 +454,11 @@ namespace SHADE
|
||||||
},
|
},
|
||||||
[component](AssetID const& id)
|
[component](AssetID const& id)
|
||||||
{
|
{
|
||||||
|
if(SHAssetManager::GetType(id) != AssetType::MESH)
|
||||||
|
{
|
||||||
|
SHLOG_WARNING("Attempted to assign non mesh asset to Renderable Mesh property!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
component->SetMesh(SHResourceManager::LoadOrGet<SHMesh>(id));
|
component->SetMesh(SHResourceManager::LoadOrGet<SHMesh>(id));
|
||||||
SHResourceManager::FinaliseChanges();
|
SHResourceManager::FinaliseChanges();
|
||||||
}, SHDragDrop::DRAG_RESOURCE);
|
}, SHDragDrop::DRAG_RESOURCE);
|
||||||
|
@ -467,6 +472,11 @@ namespace SHADE
|
||||||
},
|
},
|
||||||
[component](AssetID const& id)
|
[component](AssetID const& id)
|
||||||
{
|
{
|
||||||
|
if (SHAssetManager::GetType(id) != AssetType::MATERIAL)
|
||||||
|
{
|
||||||
|
SHLOG_WARNING("Attempted to assign non material asset to Renderable Mesh property!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
component->SetMaterial(gfxSystem->AddOrGetBaseMaterialInstance(SHResourceManager::LoadOrGet<SHMaterial>(id)));
|
component->SetMaterial(gfxSystem->AddOrGetBaseMaterialInstance(SHResourceManager::LoadOrGet<SHMaterial>(id)));
|
||||||
}, SHDragDrop::DRAG_RESOURCE);
|
}, SHDragDrop::DRAG_RESOURCE);
|
||||||
|
|
Loading…
Reference in New Issue