refactor(new_editor): snapshot hosted editor restructuring
This commit is contained in:
@@ -174,6 +174,7 @@ bool EditorSceneRuntime::Initialize(const std::filesystem::path& projectRoot) {
|
||||
m_projectRoot = projectRoot;
|
||||
m_ownedSelectionService = {};
|
||||
m_selectionService = &m_ownedSelectionService;
|
||||
m_inspectorRevision = 0u;
|
||||
m_startupSceneResult = EnsureEditorStartupScene(projectRoot);
|
||||
EnsureSceneViewCamera();
|
||||
ResetTransformEditHistory();
|
||||
@@ -334,6 +335,10 @@ std::uint64_t EditorSceneRuntime::GetSelectionStamp() const {
|
||||
return SelectionService().GetStamp();
|
||||
}
|
||||
|
||||
std::uint64_t EditorSceneRuntime::GetInspectorRevision() const {
|
||||
return m_inspectorRevision;
|
||||
}
|
||||
|
||||
bool EditorSceneRuntime::SetSelection(std::string_view itemId) {
|
||||
const std::optional<GameObject::ID> gameObjectId =
|
||||
ParseEditorGameObjectItemId(itemId);
|
||||
@@ -393,6 +398,7 @@ bool EditorSceneRuntime::OpenSceneAsset(const std::filesystem::path& scenePath)
|
||||
ResetTransformEditHistory();
|
||||
ResetToolInteractionState();
|
||||
SelectionService().ClearSelection();
|
||||
IncrementInspectorRevision();
|
||||
RefreshScene();
|
||||
EnsureSceneSelection();
|
||||
return true;
|
||||
@@ -406,6 +412,9 @@ bool EditorSceneRuntime::RenameGameObject(
|
||||
std::string_view itemId,
|
||||
std::string_view newName) {
|
||||
const bool renamed = RenameEditorGameObject(itemId, newName);
|
||||
if (renamed) {
|
||||
IncrementInspectorRevision();
|
||||
}
|
||||
RefreshScene();
|
||||
return renamed;
|
||||
}
|
||||
@@ -413,6 +422,9 @@ bool EditorSceneRuntime::RenameGameObject(
|
||||
bool EditorSceneRuntime::DeleteGameObject(std::string_view itemId) {
|
||||
ResetTransformEditHistory();
|
||||
const bool deleted = DeleteEditorGameObject(itemId);
|
||||
if (deleted) {
|
||||
IncrementInspectorRevision();
|
||||
}
|
||||
RefreshScene();
|
||||
EnsureSceneSelection();
|
||||
return deleted;
|
||||
@@ -422,6 +434,7 @@ std::string EditorSceneRuntime::DuplicateGameObject(std::string_view itemId) {
|
||||
ResetTransformEditHistory();
|
||||
const std::string duplicatedItemId = DuplicateEditorGameObject(itemId);
|
||||
if (!duplicatedItemId.empty()) {
|
||||
IncrementInspectorRevision();
|
||||
SetSelection(duplicatedItemId);
|
||||
} else {
|
||||
RefreshScene();
|
||||
@@ -435,6 +448,9 @@ bool EditorSceneRuntime::ReparentGameObject(
|
||||
ResetTransformEditHistory();
|
||||
const bool reparented =
|
||||
ReparentEditorGameObject(itemId, parentItemId);
|
||||
if (reparented) {
|
||||
IncrementInspectorRevision();
|
||||
}
|
||||
RefreshScene();
|
||||
return reparented;
|
||||
}
|
||||
@@ -442,6 +458,9 @@ bool EditorSceneRuntime::ReparentGameObject(
|
||||
bool EditorSceneRuntime::MoveGameObjectToRoot(std::string_view itemId) {
|
||||
ResetTransformEditHistory();
|
||||
const bool moved = MoveEditorGameObjectToRoot(itemId);
|
||||
if (moved) {
|
||||
IncrementInspectorRevision();
|
||||
}
|
||||
RefreshScene();
|
||||
return moved;
|
||||
}
|
||||
@@ -475,6 +494,9 @@ bool EditorSceneRuntime::RemoveSelectedComponent(std::string_view componentId) {
|
||||
|
||||
ResetTransformEditHistory();
|
||||
const bool removed = gameObject->RemoveComponent(component);
|
||||
if (removed) {
|
||||
IncrementInspectorRevision();
|
||||
}
|
||||
RefreshScene();
|
||||
return removed;
|
||||
}
|
||||
@@ -500,7 +522,10 @@ bool EditorSceneRuntime::SetSelectedTransformLocalPosition(
|
||||
|
||||
SceneTransformSnapshot afterSnapshot = {};
|
||||
CaptureSelectedTransformSnapshot(afterSnapshot);
|
||||
RecordTransformEdit(beforeSnapshot, afterSnapshot);
|
||||
if (!TransformSnapshotsMatch(beforeSnapshot, afterSnapshot)) {
|
||||
RecordTransformEdit(beforeSnapshot, afterSnapshot);
|
||||
IncrementInspectorRevision();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -525,7 +550,10 @@ bool EditorSceneRuntime::SetSelectedTransformLocalEulerAngles(
|
||||
|
||||
SceneTransformSnapshot afterSnapshot = {};
|
||||
CaptureSelectedTransformSnapshot(afterSnapshot);
|
||||
RecordTransformEdit(beforeSnapshot, afterSnapshot);
|
||||
if (!TransformSnapshotsMatch(beforeSnapshot, afterSnapshot)) {
|
||||
RecordTransformEdit(beforeSnapshot, afterSnapshot);
|
||||
IncrementInspectorRevision();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -550,7 +578,10 @@ bool EditorSceneRuntime::SetSelectedTransformLocalScale(
|
||||
|
||||
SceneTransformSnapshot afterSnapshot = {};
|
||||
CaptureSelectedTransformSnapshot(afterSnapshot);
|
||||
RecordTransformEdit(beforeSnapshot, afterSnapshot);
|
||||
if (!TransformSnapshotsMatch(beforeSnapshot, afterSnapshot)) {
|
||||
RecordTransformEdit(beforeSnapshot, afterSnapshot);
|
||||
IncrementInspectorRevision();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -568,7 +599,12 @@ bool EditorSceneRuntime::ApplySelectedComponentMutation(
|
||||
return false;
|
||||
}
|
||||
|
||||
return mutation(*component);
|
||||
if (!mutation(*component)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IncrementInspectorRevision();
|
||||
return true;
|
||||
}
|
||||
|
||||
const SceneToolState& EditorSceneRuntime::GetToolState() const {
|
||||
@@ -682,6 +718,7 @@ bool EditorSceneRuntime::ApplyTransformSnapshot(
|
||||
transform->SetPosition(snapshot.position);
|
||||
transform->SetRotation(snapshot.rotation);
|
||||
transform->SetScale(snapshot.scale);
|
||||
IncrementInspectorRevision();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -939,6 +976,10 @@ void EditorSceneRuntime::ResetTransformEditHistory() {
|
||||
m_transformRedoStack.clear();
|
||||
}
|
||||
|
||||
void EditorSceneRuntime::IncrementInspectorRevision() {
|
||||
++m_inspectorRevision;
|
||||
}
|
||||
|
||||
void EditorSceneRuntime::ResetToolInteractionTransientState() {
|
||||
m_toolState.hoveredHandle = SceneToolHandle::None;
|
||||
m_toolState.activeHandle = SceneToolHandle::None;
|
||||
|
||||
Reference in New Issue
Block a user