Unify editor scene edit history

This commit is contained in:
2026-04-29 17:30:44 +08:00
parent 2e50c90167
commit 4a125cbe7f
8 changed files with 708 additions and 225 deletions

View File

@@ -218,21 +218,16 @@ public:
}
void BeginInteractiveChange(const std::string& label) override {
if (m_sceneRuntime == nullptr || HasPendingInteractiveChange()) {
if (m_sceneRuntime == nullptr) {
return;
}
SceneTransformSnapshot snapshot = {};
if (!m_sceneRuntime->CaptureSelectedTransformSnapshot(snapshot)) {
return;
}
m_pendingLabel = label;
m_beforeSnapshot = snapshot;
m_sceneRuntime->BeginSceneEditTransaction(label);
}
bool HasPendingInteractiveChange() const override {
return m_beforeSnapshot.IsValid();
return m_sceneRuntime != nullptr &&
m_sceneRuntime->HasPendingSceneEditTransaction();
}
bool ApplyWorldTransformPreview(
@@ -256,31 +251,23 @@ public:
}
void FinalizeInteractiveChange() override {
if (m_sceneRuntime == nullptr || !HasPendingInteractiveChange()) {
if (m_sceneRuntime == nullptr) {
return;
}
SceneTransformSnapshot afterSnapshot = {};
m_sceneRuntime->CaptureSelectedTransformSnapshot(afterSnapshot);
m_sceneRuntime->RecordTransformEdit(m_beforeSnapshot, afterSnapshot);
m_pendingLabel.clear();
m_beforeSnapshot = {};
m_sceneRuntime->CommitSceneEditTransaction();
}
void CancelInteractiveChange() override {
if (m_sceneRuntime == nullptr || !HasPendingInteractiveChange()) {
if (m_sceneRuntime == nullptr) {
return;
}
m_sceneRuntime->ApplyTransformSnapshot(m_beforeSnapshot);
m_pendingLabel.clear();
m_beforeSnapshot = {};
m_sceneRuntime->CancelSceneEditTransaction();
}
private:
EditorSceneRuntime* m_sceneRuntime = nullptr;
std::string m_pendingLabel = {};
SceneTransformSnapshot m_beforeSnapshot = {};
};
} // namespace