docs: sync rendering pass execution docs

This commit is contained in:
2026-04-03 15:10:37 +08:00
parent d4afa022c1
commit 19bd38ab15
59 changed files with 1544 additions and 420 deletions

View File

@@ -31,7 +31,9 @@ struct PendingGameObjectData {
GameObject::ID id = GameObject::INVALID_ID;
uint64_t uuid = 0;
std::string name = "GameObject";
std::string tag = "Untagged";
bool active = true;
uint8_t layer = 0;
GameObject::ID parentId = GameObject::INVALID_ID;
std::string transformPayload;
std::vector<PendingComponentData> components;
@@ -75,6 +77,28 @@ std::string UnescapeString(const std::string& value) {
return unescaped;
}
GameObject* FindInChildrenByTag(GameObject* parent, const std::string& tag) {
if (!parent) {
return nullptr;
}
for (GameObject* child : parent->GetChildren()) {
if (!child) {
continue;
}
if (child->CompareTag(tag)) {
return child;
}
if (GameObject* found = FindInChildrenByTag(child, tag)) {
return found;
}
}
return nullptr;
}
void SerializeGameObjectRecursive(std::ostream& os, GameObject* gameObject) {
if (!gameObject) {
return;
@@ -84,7 +108,9 @@ void SerializeGameObjectRecursive(std::ostream& os, GameObject* gameObject) {
os << "id=" << gameObject->GetID() << "\n";
os << "uuid=" << gameObject->GetUUID() << "\n";
os << "name=" << EscapeString(gameObject->GetName()) << "\n";
os << "tag=" << EscapeString(gameObject->GetTag()) << "\n";
os << "active=" << (gameObject->IsActive() ? 1 : 0) << "\n";
os << "layer=" << static_cast<uint32_t>(gameObject->GetLayer()) << "\n";
os << "parent=" << (gameObject->GetParent() ? gameObject->GetParent()->GetID() : GameObject::INVALID_ID) << "\n";
os << "transform=";
gameObject->GetTransform()->Serialize(os);
@@ -212,11 +238,11 @@ GameObject* Scene::FindInChildren(GameObject* parent, const std::string& name) c
GameObject* Scene::FindGameObjectWithTag(const std::string& tag) const {
for (auto* go : GetRootGameObjects()) {
if (go->GetName() == tag) {
if (go->CompareTag(tag)) {
return go;
}
GameObject* found = FindInChildren(go, tag);
if (found) {
if (GameObject* found = FindInChildrenByTag(go, tag)) {
return found;
}
}
@@ -312,8 +338,12 @@ void Scene::DeserializeFromString(const std::string& data) {
currentObject->uuid = std::stoull(value);
} else if (key == "name") {
currentObject->name = UnescapeString(value);
} else if (key == "tag") {
currentObject->tag = UnescapeString(value);
} else if (key == "active") {
currentObject->active = (value == "1");
} else if (key == "layer") {
currentObject->layer = static_cast<uint8_t>(std::min<uint32_t>(std::stoul(value), 31u));
} else if (key == "parent") {
currentObject->parentId = static_cast<GameObject::ID>(std::stoull(value));
} else if (key == "transform") {
@@ -340,7 +370,9 @@ void Scene::DeserializeFromString(const std::string& data) {
if (pending.uuid != 0) {
go->m_uuid = pending.uuid;
}
go->SetTag(pending.tag);
go->m_activeSelf = pending.active;
go->SetLayer(pending.layer);
go->m_scene = this;
if (!pending.transformPayload.empty()) {