载入中...
搜索中...
未找到
SceneComponent.cpp
浏览该文件的文档.
2
3#include "scene/Scene.h"
5
6namespace eve::scene {
7
9 if (host_ != host) {
10 host_ = host;
12 }
13 dirty_ = true;
14}
15
16void SceneComponent::mountAs(const std::string &hostName) {
17 SceneHost *h = Scene::create()->findHost(hostName);
18 if (!h) h = SceneHost::createHost(hostName);
19 attach(h);
20 rebuild(true);
21}
22
23void SceneComponent::rebuild(bool forceFull) {
24 if (!host_) return;
25 NodeDesc tree = build();
26 if (forceFull) host_->setTree(std::move(tree));
27 else host_->setTreeReconcile(std::move(tree));
29 dirty_ = false;
30}
31
33 if (!dirty_ || !host_) return false;
34 rebuild(false);
35 return true;
36}
37
38} // namespace eve::scene
int h
SceneHost * host() const
void mountAs(const std::string &hostName)
void attach(SceneHost *host)
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
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:80
void setTree(NodeDesc root)
Full replace.
bool setTreeReconcile(NodeDesc root)
Key-aware patch when structure matches; else full replace.
static SceneHost * createHost(const std::string &name="")
static void updateHost(SceneHost *host)
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:15