载入中...
搜索中...
未找到
SceneComponent.cpp
浏览该文件的文档.
2
3#include "scene/Scene.h"
5
6#include <utility>
7
8namespace eve::scene {
9
11 if (host_ != host) {
12 host_ = host;
14 }
15 dirty_ = true;
16}
17
18void SceneComponent::mountAs(const std::string &hostName) {
19 SceneHost *h = nullptr;
20 auto found = Scene::create()->findHost(hostName);
21 if (found.ok()) {
22 h = std::move(found).takeValue();
23 } else {
24 auto created = SceneHost::createHost(hostName);
25 if (!created.ok()) return;
26 h = std::move(created).takeValue();
27 }
28 attach(h);
29 rebuild(true);
30}
31
32void SceneComponent::rebuild(bool forceFull) {
33 if (!host_) return;
34 NodeDesc tree = build();
35 if (forceFull) host_->setTree(std::move(tree));
36 else host_->setTreeReconcile(std::move(tree));
38 dirty_ = false;
39}
40
42 if (!dirty_ || !host_) return false;
43 rebuild(false);
44 return true;
45}
46
47} // namespace eve::scene
int h
bool found
int created
UIHostHandle host
SceneHost * host() const
Returns the currently attached host, or null before attach.
void mountAs(const std::string &hostName)
Mounts as.
void attach(SceneHost *host)
Attaches .
virtual void onMount(SceneHost *host)
Called once when the component is attached to a host.
bool updateIfDirty()
If dirty, rebuild and clear flag. Returns true if rebuilt.
virtual NodeDesc build()=0
Builds .
void rebuild(bool forceFull=false)
Rebuild tree onto host (reconcile by key when possible).
ECS mount point for one scene graph (full scene or nested subtree root). Isomorphic to eve::ui::UIHos...
Definition SceneHost.h:89
void setTree(NodeDesc root)
Full replace.
bool setTreeReconcile(NodeDesc root)
Key-aware patch when structure matches; else full replace.
static eve::Result< SceneHost * > createHost(const std::string &name="")
Creates an ECS-owned scene host with an explicit Result contract.
static void updateHost(SceneHost *host)
Updates host.
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:19