Unify editor scene edit history
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user