载入中...
搜索中...
未找到
UnitySourceInternal.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
7
8#include <algorithm>
9
10namespace eve::asset_import {
11struct UnityProjectImportRequest;
14 std::vector<std::uint8_t> bytes;
15 std::vector<ImportFinding> findings;
16};
19 const UnitySourceIndex&,
20 const UnitySourceAsset&);
26 const UnitySourceIndex& index);
29 const std::string& path);
35 const UnitySourceAsset&);
41 const UnitySourceAsset&);
47 const UnitySourceAsset&);
66} // namespace eve::asset_import
67
69
71inline std::string foldAscii(std::string value) {
72 for (char& c : value)
73 if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
74 return value;
75}
76
78inline bool validGuid(std::string_view value) {
79 return value.size() == 32 && std::all_of(value.begin(), value.end(), [](char c) {
80 return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
81 });
82}
83
85inline bool validPath(std::string_view path, const AssetImportLimits& limits) {
86 if (path.empty() || path.size() > limits.maximumStringBytes || path.front() == '/' ||
87 path.find_first_of("\\:<>\"|?*") != std::string_view::npos || !isValidUtf8(path, Utf8NullPolicy::Reject))
88 return false;
89 for (unsigned char c : path)
90 if (c < 32 || c == 127) return false;
91 std::size_t start = 0;
92 while (start < path.size()) {
93 auto end = path.find('/', start);
94 if (end == std::string_view::npos) end = path.size();
95 const auto part = path.substr(start, end - start);
96 if (part.empty() || part == "." || part == ".." || part.back() == '.' || part.back() == ' ') return false;
97 start = end + 1;
98 }
99 return path.back() != '/';
100}
101
103[[nodiscard]] Result<std::string> metaScalar(std::span<const std::uint8_t> bytes, std::string_view key,
104 std::string_view path);
105
106} // namespace eve::asset_import::unity_detail
double value
Duration start
std::string output
#define EVENGINE_API_PLATFORM
Definition Export.h:107
const GltfImportRequest & request
std::uint32_t key
std::int32_t c
std::uint64_t bytes
std::string path
Definition PlayHost.cpp:110
Bounded Unity package ingestion and project identity index.
uint32_t index
const UnitySourceAsset & source
const AssetImportLimits & limits
Strict allocation-free UTF-8 validation.
Move-only operation result carrying either a value or Status.
Definition Result.h:155
std::string foldAscii(std::string value)
Fold ascii.
bool validPath(std::string_view path, const AssetImportLimits &limits)
Valid path.
Result< std::string > metaScalar(std::span< const std::uint8_t > bytes, std::string_view key, std::string_view path)
Read an unindented scalar from .meta; rejects duplicate keys and binary metadata.
bool validGuid(std::string_view value)
Valid guid.
Result< PreparedAssetImport > prepareUnityPrefab(const UnityProjectImportRequest &request, const std::string &path)
Prepare one prefab without copying or re-indexing the source collection.
Result< PreparedAssetImport > prepareUnityMaterial(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Dispatch built-in Standard and admitted vegetation materials to canonical PBR data.
Result< PreparedAssetImport > prepareUnityCollection(const UnityProjectImportRequest &request, const UnitySourceIndex &index)
Prepare an owning collection candidate using a validated source index.
Result< PreparedAssetImport > prepareUnityVegetationScene(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Convert a complete TVE manager component set from one Unity scene.
Result< PreparedAssetImport > prepareUnityNativeVolumeTexture(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Convert embedded linear R8 Unity Texture3D to an owning canonical volume candidate.
EVENGINE_API_PLATFORM Result< PreparedAssetImport > prepareUnityVegetationPreset(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Parse one TVE conversion preset into a bounded versioned command tree.
Result< PreparedAssetImport > prepareUnityVegetationMaterial(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Convert admitted TVE primary material data; remaining source features are reported explicitly.
Result< PreparedAssetImport > prepareUnityNativeTexture(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Convert embedded BC3 text Texture2D to an owning image candidate.
Result< PreparedAssetImport > prepareUnitySpriteAnimation(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Convert an explicit SpriteRenderer timeline and referenced metadata into an owning canonical candidat...
Result< PreparedAssetImport > prepareUnityFbx(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Convert a static FBX with explicit Unity importer settings and hashed subasset identities.
Definition UnityFbx.cpp:210
Result< UnityExpandedPrefab > expandUnityPrefab(const UnityProjectImportRequest &request, const UnitySourceIndex &index, const UnitySourceAsset &source)
Resolve bounded nested prefab references into an unpublished owning text candidate.
Result< void > bindUnityRenderers(const UnityProjectImportRequest &request, const UnitySourceIndex &index, PreparedAssetImport &out)
Resolve renderer references after all collection assets are prepared; unpublished candidate only.
Result< PreparedAssetImport > prepareUnityNativeMesh(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Decode a bounded static Unity text Mesh into owning canonical submesh candidates.
bool isValidUtf8(std::string_view text, Utf8NullPolicy nullPolicy) noexcept
Validate shortest-form UTF-8, Unicode scalar range and optional NUL exclusion.
Parser and allocation budgets applied to untrusted importer inputs.
Owning, validated source archive candidate not yet published to disk/database.
Owning import-only expansion; original source bytes remain authoritative for archival.
std::vector< ImportFinding > findings
In-memory Unity project slice; keys are normalized project-relative paths.
Immutable-by-convention owning source index entry; no borrowed source addresses.
Definition UnitySource.h:38
Owning deterministic index sorted by path, plus missing-reference diagnostics.
Definition UnitySource.h:47