feat(new_editor): wire project, inspector, and viewport runtime
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#include "HierarchyModel.h"
|
||||
|
||||
#include "Scene/EditorSceneBridge.h"
|
||||
|
||||
#include <XCEngine/Components/GameObject.h>
|
||||
#include <XCEngine/Scene/Scene.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
@@ -136,35 +141,46 @@ void BuildTreeItemsRecursive(
|
||||
}
|
||||
}
|
||||
|
||||
HierarchyNode BuildSceneNodeRecursive(
|
||||
const ::XCEngine::Components::GameObject& gameObject) {
|
||||
HierarchyNode node = {};
|
||||
node.nodeId = MakeEditorGameObjectItemId(gameObject.GetID());
|
||||
node.label = gameObject.GetName().empty()
|
||||
? std::string("GameObject")
|
||||
: gameObject.GetName();
|
||||
node.children.reserve(gameObject.GetChildCount());
|
||||
for (std::size_t childIndex = 0u;
|
||||
childIndex < gameObject.GetChildCount();
|
||||
++childIndex) {
|
||||
const auto* child = gameObject.GetChild(childIndex);
|
||||
if (child == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
node.children.push_back(BuildSceneNodeRecursive(*child));
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
HierarchyModel HierarchyModel::BuildDefault() {
|
||||
HierarchyModel HierarchyModel::BuildFromScene(
|
||||
const ::XCEngine::Components::Scene* scene) {
|
||||
HierarchyModel model = {};
|
||||
model.m_roots = {
|
||||
HierarchyNode{ "main_camera", "Main Camera", {} },
|
||||
HierarchyNode{ "directional_light", "Directional Light", {} },
|
||||
HierarchyNode{
|
||||
"player",
|
||||
"Player",
|
||||
{
|
||||
HierarchyNode{ "camera_pivot", "Camera Pivot", {} },
|
||||
HierarchyNode{ "player_mesh", "Mesh", {} }
|
||||
} },
|
||||
HierarchyNode{
|
||||
"environment",
|
||||
"Environment",
|
||||
{
|
||||
HierarchyNode{ "ground", "Ground", {} },
|
||||
HierarchyNode{
|
||||
"props",
|
||||
"Props",
|
||||
{
|
||||
HierarchyNode{ "crate_01", "Crate_01", {} },
|
||||
HierarchyNode{ "barrel_01", "Barrel_01", {} }
|
||||
} }
|
||||
} }
|
||||
};
|
||||
model.m_nextGeneratedNodeId = 1u;
|
||||
if (scene == nullptr) {
|
||||
return model;
|
||||
}
|
||||
|
||||
const auto roots = scene->GetRootGameObjects();
|
||||
model.m_roots.reserve(roots.size());
|
||||
for (const auto* root : roots) {
|
||||
if (root == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
model.m_roots.push_back(BuildSceneNodeRecursive(*root));
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -172,6 +188,10 @@ bool HierarchyModel::Empty() const {
|
||||
return m_roots.empty();
|
||||
}
|
||||
|
||||
bool HierarchyModel::HasSameTree(const HierarchyModel& other) const {
|
||||
return m_roots == other.m_roots;
|
||||
}
|
||||
|
||||
bool HierarchyModel::ContainsNode(std::string_view nodeId) const {
|
||||
return FindNode(nodeId) != nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user