chore: sync editor worktree changes

This commit is contained in:
2026-04-05 01:25:09 +08:00
parent 061e74d98f
commit b2774f1745
27 changed files with 1014 additions and 281 deletions

View File

@@ -29,6 +29,7 @@
#include <XCEngine/Scene/Scene.h>
#include <array>
#include <chrono>
#include <cstdint>
#include <memory>
#include <string>
@@ -60,6 +61,52 @@ Math::Vector3 GetSceneViewportOrientationAxisVector(SceneViewportOrientationAxis
}
}
std::uint64_t GetCurrentSceneLoadStatusTimeMs() {
return static_cast<std::uint64_t>(
std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch()).count());
}
std::uint64_t ResolveSceneLoadStatusElapsedMs(const SceneLoadProgressSnapshot& status) {
if (!status.HasValue() || status.startedAtMs == 0) {
return 0;
}
if (status.inProgress) {
const std::uint64_t nowMs = GetCurrentSceneLoadStatusTimeMs();
return nowMs >= status.startedAtMs ? nowMs - status.startedAtMs : 0;
}
if (status.streamingCompletedAtMs >= status.startedAtMs && status.streamingCompletedAtMs != 0) {
return status.streamingCompletedAtMs - status.startedAtMs;
}
if (status.firstFrameAtMs >= status.startedAtMs && status.firstFrameAtMs != 0) {
return status.firstFrameAtMs - status.startedAtMs;
}
if (status.structureReadyAtMs >= status.startedAtMs && status.structureReadyAtMs != 0) {
return status.structureReadyAtMs - status.startedAtMs;
}
return 0;
}
std::string BuildViewportSceneLoadStatusText(const SceneLoadProgressSnapshot& status) {
if (!status.HasValue() || !status.inProgress || status.message.empty()) {
return {};
}
std::string text = status.message;
const std::uint64_t elapsedMs = ResolveSceneLoadStatusElapsedMs(status);
if (elapsedMs > 0) {
text += " (";
text += std::to_string(elapsedMs);
text += " ms)";
}
return text;
}
} // namespace
class ViewportHostService : public IViewportHostService {
@@ -568,8 +615,10 @@ private:
MarkSceneViewportRenderSuccess(entry.renderTargets, requests[0]);
const Core::uint32 pendingAsyncLoads = Resources::ResourceManager::Get().GetAsyncPendingCount();
if (pendingAsyncLoads > 0) {
entry.statusText = "Loading scene assets... (" + std::to_string(pendingAsyncLoads) + ")";
context.GetSceneManager().NotifySceneViewportFramePresented(pendingAsyncLoads);
if (entry.statusText.empty()) {
entry.statusText = BuildViewportSceneLoadStatusText(
context.GetSceneManager().GetSceneLoadProgress());
}
return true;
}