载入中...
搜索中...
未找到
SceneLink.h
浏览该文件的文档.
1#pragma once
2
3// Attaching things to scene nodes.
4//
5// A link keeps an external object -- a renderable, a physics body, a camera, an
6// audio source -- in step with the node it hangs off. The set of kinds used to
7// be a closed enum with a switch in TransformSystem, so scene had to include
8// graphics, physics and audio, and no other module could ever attach to the
9// tree without editing this file.
10//
11// Kinds are registered instead. The module that owns the target type supplies
12// the three operations, keeps the casts on its own side where the type is
13// complete, and scene never learns what a Renderable3D is.
14//
15// Dispatch is through a function-pointer table, not virtual calls: link sync
16// runs for every dirty node every frame.
17
18#include "common/Export.h"
19
20#include <cstddef>
21
22namespace eve::scene {
23
24struct SceneNode;
25
28struct LinkOps {
30 const char* kind = nullptr;
31
34 void (*pushWorld)(const SceneNode& node, void* target) = nullptr;
35
41 void (*pullWorld)(SceneNode& node, void* target) = nullptr;
42
48 bool (*alive)(const void* target) = nullptr;
49};
50
58
62
65EVENGINE_API_PLATFORM const LinkOps* linkOps(int kindId);
66
69EVENGINE_API_PLATFORM const char* linkKindName(int kindId);
70
77struct SceneLink {
78 int kind = -1;
79 void* target = nullptr;
80 int syncMode = 0;
81};
82
83} // namespace eve::scene
LogicalId target
#define EVENGINE_API_PLATFORM
Definition Export.h:107
TokenKind kind
const RoadNode * node
const char * linkKindName(int kindId)
Link kind name.
Definition SceneLink.cpp:53
int registerLinkKind(const LinkOps &ops)
Registers link kind.
Definition SceneLink.cpp:27
int findLinkKind(const char *kind)
Finds link kind.
Definition SceneLink.cpp:39
const LinkOps * linkOps(int kindId)
Link ops.
Definition SceneLink.cpp:47
LinkOps public API.
Definition SceneLink.h:28
void(* pushWorld)(const SceneNode &node, void *target)
Void.
Definition SceneLink.h:34
void(* pullWorld)(SceneNode &node, void *target)
Void.
Definition SceneLink.h:41
bool(* alive)(const void *target)
Bool.
Definition SceneLink.h:48
const char * kind
Definition SceneLink.h:30
Retained scene node (arena). Conceptual GameObject; isomorphic to eve::ui::UINode.
Definition SceneHost.h:46