载入中...
搜索中...
未找到
SceneNodes.cpp
浏览该文件的文档.
1// Scene node / link / bounds / picking implementation.
2//
3// Split out of the original Scene.cpp so the script binding layer
4// (Scene.cpp) and the node manipulation methods live in separate
5// translation units. Pure move: no behavior change.
6
7#include "scene/Scene.h"
8#include "scene/SceneBounds.h"
11#include "spatial/Octree.h"
12
13#include <simplesquirrel/simplesquirrel.hpp>
14
15#include <glm/glm.hpp>
16#include <glm/gtc/matrix_transform.hpp>
17#include <glm/gtc/quaternion.hpp>
18
19#include <limits>
20#include <string>
21#include <utility>
22#include <vector>
23
24namespace eve::scene {
25
26namespace {
27
28template <class T>
29T *borrowSceneResult(eve::Result<T *> result) {
30 if (!result.ok()) return nullptr;
31 return std::move(result).takeValue();
32}
33
34} // namespace
35
36bool Scene::setNodePosition(const std::string &id, float x, float y, float z) {
37 SceneHost *h = selected_;
38 if (!h) return false;
39 SceneNode *n = borrowSceneResult(h->findById(id));
40 if (!n) return false;
41 n->x = x;
42 n->y = y;
43 n->z = z;
44 h->markSubtreeDirtyById(id);
45 return true;
46}
47
48bool Scene::setNodeRotation(const std::string &id, float yaw, float pitch, float roll) {
49 SceneHost *h = selected_;
50 if (!h) return false;
51 SceneNode *n = borrowSceneResult(h->findById(id));
52 if (!n) return false;
53 n->yaw = yaw;
54 n->pitch = pitch;
55 n->roll = roll;
56 h->markSubtreeDirtyById(id);
57 return true;
58}
59
60bool Scene::setNodeScale(const std::string &id, float sx, float sy, float sz) {
61 SceneHost *h = selected_;
62 if (!h) return false;
63 SceneNode *n = borrowSceneResult(h->findById(id));
64 if (!n) return false;
65 n->sx = sx;
66 n->sy = sy;
67 n->sz = sz;
68 h->markSubtreeDirtyById(id);
69 return true;
70}
71
72bool Scene::setNodeVisible(const std::string &id, bool visible) {
73 SceneHost *h = selected_;
74 if (!h) return false;
75 SceneNode *n = borrowSceneResult(h->findById(id));
76 if (!n) return false;
77 n->visible = visible;
78 h->markSubtreeDirtyById(id); // resync renderable visibility via links
79 return true;
80}
81
85
89
90bool Scene::unlinkNode(const std::string &nodeId) {
92}
93
94// ---------------------------------------------------------------------------
95// Generic link system (host-scoped primitives)
96// ---------------------------------------------------------------------------
97
98bool Scene::linkRenderable2DAt(const std::string &hostName, const std::string &nodeId,
100 SceneHost *h = resolveHost(hostName);
101 if (!h) return false;
102 if (!h->linkRenderable2D(nodeId, r)) return false;
104 return true;
105}
106
107bool Scene::linkRenderable3DAt(const std::string &hostName, const std::string &nodeId,
109 SceneHost *h = resolveHost(hostName);
110 if (!h) return false;
111 if (!h->linkRenderable3D(nodeId, r)) return false;
113 return true;
114}
115
116bool Scene::linkPhysics2DAt(const std::string &hostName, const std::string &nodeId,
117 physics::Body *b, const std::string &mode) {
118 SceneHost *h = resolveHost(hostName);
119 if (!h) return false;
120 if (!h->linkPhysics2D(nodeId, b, syncModeFromString(mode))) return false;
122 return true;
123}
124
125bool Scene::linkPhysics3DAt(const std::string &hostName, const std::string &nodeId,
126 physics::Body3D *b, const std::string &mode) {
127 SceneHost *h = resolveHost(hostName);
128 if (!h) return false;
129 if (!h->linkPhysics3D(nodeId, b, syncModeFromString(mode))) return false;
131 return true;
132}
133
134bool Scene::linkCamera3DAt(const std::string &hostName, const std::string &nodeId,
136 SceneHost *h = resolveHost(hostName);
137 if (!h) return false;
138 if (!h->linkCamera3D(nodeId, c)) return false;
140 return true;
141}
142
143bool Scene::linkAudio3DAt(const std::string &hostName, const std::string &nodeId,
144 audio::Source *s) {
145 SceneHost *h = resolveHost(hostName);
146 if (!h) return false;
147 if (!h->linkAudio3D(nodeId, s)) return false;
149 return true;
150}
151
152bool Scene::unlinkNodeAt(const std::string &hostName, const std::string &nodeId) {
153 SceneHost *h = resolveHost(hostName);
154 return h ? h->unlink(nodeId) : false;
155}
156
157bool Scene::unlinkNodeKindAt(const std::string &hostName, const std::string &nodeId,
158 const std::string &kind) {
159 SceneHost *h = resolveHost(hostName);
160 if (!h) return false;
161 const int k = linkKindFromString(kind);
162 if (k < 0) return false;
163 const bool removed = h->unlink(nodeId, k);
165 return removed;
166}
167
168int Scene::linkCountAt(const std::string &hostName, const std::string &nodeId) {
169 SceneHost *h = resolveHost(hostName);
170 return h ? h->linkCount(nodeId) : 0;
171}
172
173// ---------------------------------------------------------------------------
174// Script-API completeness: transform getters / hierarchy / math / tags / layer
175// ---------------------------------------------------------------------------
176
177std::vector<float> Scene::getNodePositionAt(const std::string &hostName,
178 const std::string &nodeId) const {
179 SceneHost *h = resolveHost(hostName);
180 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
181 if (!n) return {0.f, 0.f, 0.f};
182 return {n->x, n->y, n->z};
183}
184
185std::vector<float> Scene::getNodeRotationAt(const std::string &hostName,
186 const std::string &nodeId) const {
187 SceneHost *h = resolveHost(hostName);
188 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
189 if (!n) return {0.f, 0.f, 0.f};
190 return {n->yaw, n->pitch, n->roll};
191}
192
193std::vector<float> Scene::getNodeScaleAt(const std::string &hostName,
194 const std::string &nodeId) const {
195 SceneHost *h = resolveHost(hostName);
196 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
197 if (!n) return {0.f, 0.f, 0.f};
198 return {n->sx, n->sy, n->sz};
199}
200
201bool Scene::getNodeVisibleAt(const std::string &hostName,
202 const std::string &nodeId) const {
203 SceneHost *h = resolveHost(hostName);
204 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
205 return n ? n->visible : false;
206}
207
208std::vector<float> Scene::getNodeWorldPositionAt(const std::string &hostName,
209 const std::string &nodeId) const {
210 SceneHost *h = resolveHost(hostName);
211 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
212 if (!n) return {0.f, 0.f, 0.f};
213 return {n->world[3][0], n->world[3][1], n->world[3][2]};
214}
215
216std::vector<float> Scene::getNodeWorldRotationAt(const std::string &hostName,
217 const std::string &nodeId) const {
218 SceneHost *h = resolveHost(hostName);
219 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
220 if (!n) return {0.f, 0.f, 0.f};
221 glm::vec3 pos, euler, scale;
222 decomposeWorld(n->world, pos, euler, scale);
223 return {euler.x, euler.y, euler.z};
224}
225
226std::vector<float> Scene::getNodeWorldScaleAt(const std::string &hostName,
227 const std::string &nodeId) const {
228 SceneHost *h = resolveHost(hostName);
229 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
230 if (!n) return {0.f, 0.f, 0.f};
231 glm::vec3 pos, euler, scale;
232 decomposeWorld(n->world, pos, euler, scale);
233 return {scale.x, scale.y, scale.z};
234}
235
236std::vector<float> Scene::localToWorldAt(const std::string &hostName,
237 const std::string &nodeId, float x, float y,
238 float z) const {
239 SceneHost *h = resolveHost(hostName);
240 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
241 if (!n) return {x, y, z};
242 glm::vec4 p = n->world * glm::vec4(x, y, z, 1.f);
243 return {p.x, p.y, p.z};
244}
245
246std::vector<float> Scene::worldToLocalAt(const std::string &hostName,
247 const std::string &nodeId, float x, float y,
248 float z) const {
249 SceneHost *h = resolveHost(hostName);
250 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
251 if (!n) return {x, y, z};
252 glm::vec4 p = glm::inverse(n->world) * glm::vec4(x, y, z, 1.f);
253 return {p.x, p.y, p.z};
254}
255
256bool Scene::setNodeParentAt(const std::string &hostName, const std::string &childId,
257 const std::string &parentId) {
258 SceneHost *h = resolveHost(hostName);
259 if (!h) return false;
260 const bool ok = h->setParentById(childId, parentId);
262 return ok;
263}
264
265bool Scene::removeNodeAt(const std::string &hostName, const std::string &nodeId) {
266 SceneHost *h = resolveHost(hostName);
267 if (!h) return false;
268 const bool ok = h->setParentById(nodeId, "");
270 return ok;
271}
272
273bool Scene::addChildAt(const std::string &hostName, const std::string &parentId,
274 const std::string &childId) {
275 SceneHost *h = resolveHost(hostName);
276 if (!h) return false;
277 const bool ok = h->setParentById(childId, parentId);
279 return ok;
280}
281
282bool Scene::removeChildAt(const std::string &hostName, const std::string &parentId,
283 const std::string &childId) {
284 SceneHost *h = resolveHost(hostName);
285 if (!h) return false;
286 const bool ok = h->removeChildById(parentId, childId);
288 return ok;
289}
290
291bool Scene::setNodeQuaternionAt(const std::string &hostName, const std::string &nodeId,
292 float qx, float qy, float qz, float qw) {
293 SceneHost *h = resolveHost(hostName);
294 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
295 if (!h || !n) return false;
296 glm::quat q(qw, qx, qy, qz);
297 glm::vec3 e = glm::eulerAngles(q); // pitch(x), yaw(y), roll(z)
298 n->yaw = e.y;
299 n->pitch = e.x;
300 n->roll = e.z;
301 h->markSubtreeDirtyById(nodeId);
302 return true;
303}
304
305std::vector<float> Scene::getNodeQuaternionAt(const std::string &hostName,
306 const std::string &nodeId) const {
307 SceneHost *h = resolveHost(hostName);
308 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
309 if (!n) return {0.f, 0.f, 0.f, 1.f};
310 glm::quat q = nodeQuaternion(*n);
311 return {q.x, q.y, q.z, q.w};
312}
313
314bool Scene::setNodeLookAtAt(const std::string &hostName, const std::string &nodeId,
315 float tx, float ty, float tz) {
316 SceneHost *h = resolveHost(hostName);
317 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
318 if (!h || !n) return false;
319 glm::vec3 pos(n->x, n->y, n->z);
320 glm::vec3 target(tx, ty, tz);
321 glm::vec3 f = target - pos;
322 if (glm::dot(f, f) < 1e-8f) return false;
323 f = glm::normalize(f);
324 glm::vec3 up(0.f, 1.f, 0.f);
325 glm::vec3 right = glm::normalize(glm::cross(up, f));
326 if (glm::dot(right, right) < 1e-8f) right = glm::vec3(1.f, 0.f, 0.f); // f ∥ up
327 glm::vec3 up2 = glm::normalize(glm::cross(f, right));
328 glm::mat3 rot(right, up2, f);
329 glm::quat q = glm::quat_cast(rot);
330 glm::vec3 e = glm::eulerAngles(q);
331 n->yaw = e.y;
332 n->pitch = e.x;
333 n->roll = e.z;
334 h->markSubtreeDirtyById(nodeId);
335 return true;
336}
337
338bool Scene::addNodeTagAt(const std::string &hostName, const std::string &nodeId,
339 const std::string &tag) {
340 SceneHost *h = resolveHost(hostName);
341 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
342 return h ? h->addTag(n, tag) : false;
343}
344
345bool Scene::removeNodeTagAt(const std::string &hostName, const std::string &nodeId,
346 const std::string &tag) {
347 SceneHost *h = resolveHost(hostName);
348 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
349 return h ? h->removeTag(n, tag) : false;
350}
351
352bool Scene::hasNodeTagAt(const std::string &hostName, const std::string &nodeId,
353 const std::string &tag) const {
354 SceneHost *h = resolveHost(hostName);
355 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
356 return h ? h->hasTag(n, tag) : false;
357}
358
359std::vector<std::string> Scene::getNodeTagsAt(const std::string &hostName,
360 const std::string &nodeId) const {
361 SceneHost *h = resolveHost(hostName);
362 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
363 if (!n) return {};
364 return n->tags;
365}
366
367std::vector<std::string> Scene::collectIdsByTagAt(const std::string &hostName,
368 const std::string &tag) const {
369 SceneHost *h = resolveHost(hostName);
370 if (!h) return {};
371 std::vector<std::string> out;
372 for (SceneNode *n : h->findAllByTag(tag)) {
373 if (n) out.push_back(n->id);
374 }
375 return out;
376}
377
378bool Scene::setNodeLayerAt(const std::string &hostName, const std::string &nodeId,
379 int layer) {
380 SceneHost *h = resolveHost(hostName);
381 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
382 if (!n) return false;
383 n->layer = layer;
384 return true;
385}
386
387int Scene::getNodeLayerAt(const std::string &hostName, const std::string &nodeId) const {
388 SceneHost *h = resolveHost(hostName);
389 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
390 return n ? n->layer : 0;
391}
392
393bool Scene::setNodeEventHandlerAt(const std::string &hostName, ssq::Object cb) {
394 if (!vm_) return false;
395 SceneHost *h = resolveHost(hostName);
396 if (!h) return false;
397 const std::string name = hostName.empty() ? h->getName() : hostName;
398
399 auto it = eventCbs_.find(name);
400 if (it != eventCbs_.end()) {
401 sq_release(vm_, &it->second);
402 eventCbs_.erase(it);
403 }
404 HSQOBJECT raw = cb.getRaw();
405 if (raw._type == OT_NULL) { // clear handler
406 h->setEventHandler({});
407 return true;
408 }
409 if (raw._type != OT_CLOSURE && raw._type != OT_NATIVECLOSURE) return false;
410 sq_addref(vm_, &raw);
411 eventCbs_[name] = raw;
412 h->setEventHandler(
413 [this, name](SceneHost *, const std::string &action, const std::string &nodeId,
414 const std::string &parentId) {
415 callEventCallback(name, action, nodeId, parentId);
416 });
417 return true;
418}
419
420void Scene::callEventCallback(const std::string &hostName, const std::string &action,
421 const std::string &nodeId, const std::string &parentId) {
422 if (!vm_) return;
423 auto it = eventCbs_.find(hostName);
424 if (it == eventCbs_.end()) return;
425 const SQInteger top = sq_gettop(vm_);
426 sq_pushobject(vm_, it->second);
427 sq_pushstring(vm_, action.c_str(), -1);
428 sq_pushstring(vm_, nodeId.c_str(), -1);
429 sq_pushstring(vm_, parentId.c_str(), -1);
430 if (SQ_FAILED(sq_call(vm_, 3, SQFalse, SQTrue))) {
431 sq_settop(vm_, top);
432 return;
433 }
434 sq_settop(vm_, top);
435}
436
437// ---------------------------------------------------------------------------
438// Bounds / serialization / picking / culling
439// ---------------------------------------------------------------------------
440
441bool Scene::setNodeBoundsAt(const std::string &hostName, const std::string &nodeId,
442 float minX, float minY, float minZ, float maxX, float maxY,
443 float maxZ) {
444 SceneHost *h = resolveHost(hostName);
445 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
446 if (!n) return false;
447 n->bminX = minX;
448 n->bminY = minY;
449 n->bminZ = minZ;
450 n->bmaxX = maxX;
451 n->bmaxY = maxY;
452 n->bmaxZ = maxZ;
453 n->hasBounds = true;
454 return true;
455}
456
457bool Scene::hasNodeBoundsAt(const std::string &hostName, const std::string &nodeId) const {
458 SceneHost *h = resolveHost(hostName);
459 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
460 return n ? n->hasBounds : false;
461}
462
463std::vector<float> Scene::getNodeBoundsAt(const std::string &hostName,
464 const std::string &nodeId) const {
465 SceneHost *h = resolveHost(hostName);
466 SceneNode *n = h ? borrowSceneResult(h->findById(nodeId)) : nullptr;
467 if (!n || !n->hasBounds) return {0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
468 return {n->bminX, n->bminY, n->bminZ, n->bmaxX, n->bmaxY, n->bmaxZ};
469}
470
471
472std::string Scene::pickRayAt(const std::string &hostName, float ox, float oy, float oz,
473 float dx, float dy, float dz) const {
474 SceneHost *h = resolveHost(hostName);
475 if (!h) return {};
476 const glm::vec3 origin(ox, oy, oz);
477 glm::vec3 dir(dx, dy, dz);
478 if (glm::dot(dir, dir) < 1e-12f) return {};
479 dir = glm::normalize(dir);
480
481 float bestT = std::numeric_limits<float>::max();
482 std::string best;
483 h->walkDepthFirst([&](SceneHost *, int, SceneNode &n) {
484 if (!n.hasBounds) return;
485 const AABB3f w = worldBoundsOf(n);
486 float t0 = 0.f, t1 = 0.f;
487 if (rayAABB(origin, dir, w, t0, t1) && t1 >= 0.f && t0 < bestT) {
488 bestT = std::max(t0, 0.f);
489 best = n.id;
490 }
491 });
492 return best;
493}
494
495bool Scene::syncSpatialIndexAt(const std::string &hostName, spatial::Octree *ot) const {
496 SceneHost *h = resolveHost(hostName);
497 if (!h || !ot) return false;
498 bool any = false;
499 h->walkDepthFirst([&](SceneHost *, int index, SceneNode &n) {
500 if (!n.hasBounds) return;
501 const AABB3f w = worldBoundsOf(n);
502 ot->insert(index, w.min.x, w.min.y, w.min.z, w.max.x, w.max.y, w.max.z);
503 any = true;
504 });
505 return any;
506}
507
508std::string Scene::nodeIdFromSpatialIdAt(const std::string &hostName, int index) const {
509 SceneHost *h = resolveHost(hostName);
510 SceneNode *n = h ? h->getNode(index) : nullptr;
511 return n ? n->id : std::string{};
512}
513
514bool Scene::hasNode(const std::string &id) {
515 SceneHost *h = selected_;
516 return h ? h->hasNode(id) : false;
517}
518
520 SceneHost *h = selected_;
521 return h ? h->getNodeCount() : 0;
522}
523
524std::string Scene::getRootId() {
525 SceneHost *h = selected_;
526 if (!h) return {};
527 SceneNode *r = h->getRoot();
528 return r ? r->id : std::string{};
529}
530
531std::string Scene::getParentId(const std::string &id) {
532 SceneHost *h = selected_;
533 if (!h) return {};
534 SceneNode *p = h->getParentById(id);
535 return p ? p->id : std::string{};
536}
537
538int Scene::getChildCount(const std::string &id) {
539 SceneHost *h = selected_;
540 return h ? h->getChildCountById(id) : 0;
541}
542
543std::string Scene::getChildIdAt(const std::string &parentId, int childOrdinal) {
544 SceneHost *h = selected_;
545 if (!h) return {};
546 SceneNode *c = h->getChildAtById(parentId, childOrdinal);
547 return c ? c->id : std::string{};
548}
549
550std::string Scene::findIdByName(const std::string &name) {
551 SceneHost *h = selected_;
552 if (!h) return {};
553 SceneNode *n = borrowSceneResult(h->findByName(name));
554 return n ? n->id : std::string{};
555}
556
557std::string Scene::findIdByPath(const std::string &path) {
558 SceneHost *h = selected_;
559 if (!h) return {};
560 SceneNode *n = borrowSceneResult(h->findByPath(path));
561 return n ? n->id : std::string{};
562}
563
564std::string Scene::getNodePath(const std::string &id) {
565 SceneHost *h = selected_;
566 return h ? h->getPathById(id) : std::string{};
567}
568
569bool Scene::isAncestor(const std::string &ancestorId, const std::string &nodeId) {
570 SceneHost *h = selected_;
571 return h ? h->isAncestorOfById(ancestorId, nodeId) : false;
572}
573
574bool Scene::isDescendant(const std::string &nodeId, const std::string &ancestorId) {
575 SceneHost *h = selected_;
576 return h ? h->isDescendantOfById(nodeId, ancestorId) : false;
577}
578
579std::vector<std::string> Scene::collectIds() {
580 SceneHost *h = selected_;
581 return h ? h->collectIds() : std::vector<std::string>{};
582}
583
584std::vector<std::string> Scene::collectIdsFrom(const std::string &id) {
585 SceneHost *h = selected_;
586 if (!h) return {};
587 return h->collectIdsFrom(h->findIndexById(id));
588}
589
590std::vector<std::string> Scene::collectIdsByName(const std::string &name) {
591 SceneHost *h = selected_;
592 return h ? h->collectIdsByName(name) : std::vector<std::string>{};
593}
594
595std::vector<std::string> Scene::collectIdsVisible(bool visible) {
596 SceneHost *h = selected_;
597 return h ? h->collectIdsVisible(visible) : std::vector<std::string>{};
598}
599
600std::vector<std::string> Scene::collectChildIds(const std::string &parentId) {
601 SceneHost *h = selected_;
602 return h ? h->getChildIds(parentId) : std::vector<std::string>{};
603}
604
605std::vector<std::string> Scene::walkDepthFirstIds() { return collectIds(); }
606
607std::vector<std::string> Scene::walkBreadthFirstIds() {
608 SceneHost *h = selected_;
609 if (!h) return {};
610 std::vector<std::string> out;
611 h->walkBreadthFirst([&](SceneHost *, int, SceneNode &n) { out.push_back(n.id); });
612 return out;
613}
614
615} // namespace eve::scene
LogicalId target
SQInteger top
float w
Definition AnimClip.cpp:738
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
const std::string & s
glm::vec4 p[6]
std::string nodeId
std::uint64_t parentId
glm::vec3 n
Definition Grass.cpp:63
std::array< double, 10 > q
double r
HexVec3 up
HexVec3 right
std::int32_t c
int h
TokenKind kind
std::array< float, 3 > scale
std::string name
MeleePoint3 b
Definition MeleeHit.cpp:41
const std::string * tag
TileLayer * layer
float f
std::string action
Definition PlayHost.cpp:117
std::string path
Definition PlayHost.cpp:110
V3 origin
Definition RoadBake.cpp:138
int removed
float dz
float dy
float dx
std::map< Cell, int > best
bool visible
V3 dir
Definition TreeMesh.cpp:150
uint32_t index
double oy
double ox
float qy
float qx
float qw
float qz
Move-only operation result carrying either a value or Status.
Definition Result.h:155
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:255
A playable audio source (static buffer or streaming decoder). Not thread-safe for playback control ex...
Definition Source.h:30
EVENGINE_API_BACKENDS public API.
Default renderable entity for declarative 2D sprites / solid quads.
EVENGINE_API_BACKENDS public API.
3D rigid body (Box3D) in meter-space coordinates (+Y up by convention). Owned by a World3D; create pr...
Definition Body3D.h:24
2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFi...
Definition Body.h:21
ECS mount point for one scene graph (full scene or nested subtree root). Isomorphic to eve::ui::UIHos...
Definition SceneHost.h:89
bool isAncestorOfById(const std::string &ancestorId, const std::string &nodeId)
bool isDescendantOfById(const std::string &nodeId, const std::string &ancestorId)
int getChildCountById(const std::string &id)
std::vector< std::string > collectIdsVisible(bool visible=true)
std::vector< std::string > getChildIds(const std::string &parentId)
std::vector< std::string > collectIdsFrom(int nodeIndex)
std::vector< std::string > collectIdsByName(const std::string &name)
std::string getPathById(const std::string &id)
std::vector< std::string > collectIds()
void walkBreadthFirst(NodeVisitFn fn)
BFS from root (or from nodeIndex), inclusive.
bool hasNode(const std::string &id)
bool linkPhysics3DAt(const std::string &hostName, const std::string &nodeId, physics::Body3D *b, const std::string &mode)
Link physics 3 d at.
SceneHost * resolveHost(const std::string &hostName) const
Host-qualified resolution: empty hostName → currently selected host.
Definition Scene.cpp:948
std::vector< std::string > collectIdsFrom(const std::string &id)
Collect ids from.
bool setNodeParentAt(const std::string &hostName, const std::string &childId, const std::string &parentId)
Reparent by id; empty parentId detaches. Cycle-safe.
std::vector< std::string > collectIds()
Collect ids.
bool linkCamera3DAt(const std::string &hostName, const std::string &nodeId, graphics::Camera3D *c)
Link camera 3 d at.
std::vector< std::string > collectIdsByTagAt(const std::string &hostName, const std::string &tag) const
Collect ids by tag at.
std::vector< float > getNodeRotationAt(const std::string &hostName, const std::string &nodeId) const
Returns the node rotation at.
std::string findIdByPath(const std::string &path)
Finds id by path.
bool setNodeQuaternionAt(const std::string &hostName, const std::string &nodeId, float qx, float qy, float qz, float qw)
Sets the node quaternion at.
bool getNodeVisibleAt(const std::string &hostName, const std::string &nodeId) const
Returns the node visible at.
std::vector< float > worldToLocalAt(const std::string &hostName, const std::string &nodeId, float x, float y, float z) const
World to local at.
std::vector< float > getNodePositionAt(const std::string &hostName, const std::string &nodeId) const
Returns the node position at.
std::vector< float > getNodeWorldPositionAt(const std::string &hostName, const std::string &nodeId) const
Returns the node world position at.
int getNodeLayerAt(const std::string &hostName, const std::string &nodeId) const
Returns the node layer at.
bool linkPhysics2DAt(const std::string &hostName, const std::string &nodeId, physics::Body *b, const std::string &mode)
Link physics 2 d at.
bool removeNodeAt(const std::string &hostName, const std::string &nodeId)
Detach node from its parent (arena node stays; rebuild to delete).
std::vector< std::string > collectChildIds(const std::string &parentId)
Collect child ids.
bool unlinkNodeAt(const std::string &hostName, const std::string &nodeId)
Remove every link on the node.
bool setNodePosition(const std::string &id, float x, float y, float z)
Script-friendly TRS setters on the current host; each marks the transform dirty.
std::vector< std::string > collectIdsVisible(bool visible)
Collect ids visible.
bool linkAudio3DAt(const std::string &hostName, const std::string &nodeId, audio::Source *s)
Link audio 3 d at.
bool setNodeLookAtAt(const std::string &hostName, const std::string &nodeId, float tx, float ty, float tz)
Orient node so its local +Z axis points at (tx,ty,tz).
std::string currentHostName() const
Current host name.
Definition Scene.cpp:1174
std::vector< float > getNodeWorldRotationAt(const std::string &hostName, const std::string &nodeId) const
Returns the node world rotation at.
bool hasNode(const std::string &id)
True when node.
std::string getNodePath(const std::string &id)
Returns the node path.
std::string findIdByName(const std::string &name)
Finds id by name.
int getChildCount(const std::string &id)
Returns the child count.
bool removeNodeTagAt(const std::string &hostName, const std::string &nodeId, const std::string &tag)
Removes node tag at.
bool linkRenderable3DAt(const std::string &hostName, const std::string &nodeId, graphics::Renderable3D *r)
Link renderable 3 d at.
bool isAncestor(const std::string &ancestorId, const std::string &nodeId)
True when ancestor.
bool setNodeScale(const std::string &id, float sx, float sy, float sz)
Sets the local scale of a node.
std::string getParentId(const std::string &id)
Returns the parent id.
std::vector< std::string > collectIdsByName(const std::string &name)
Collect ids by name.
bool unlinkNodeKindAt(const std::string &hostName, const std::string &nodeId, const std::string &kind)
Remove links of one kind ("renderable2d"|"renderable3d"|"physics2d"|...).
std::vector< float > getNodeScaleAt(const std::string &hostName, const std::string &nodeId) const
Returns the node scale at.
std::string nodeIdFromSpatialIdAt(const std::string &hostName, int index) const
Map a spatial-index id (arena index) back to a node id.
std::vector< std::string > getNodeTagsAt(const std::string &hostName, const std::string &nodeId) const
Returns the node tags at.
int linkCountAt(const std::string &hostName, const std::string &nodeId)
Link count at.
bool hasNodeBoundsAt(const std::string &hostName, const std::string &nodeId) const
True when node bounds at.
std::vector< std::string > walkBreadthFirstIds()
Walk breadth first ids.
bool linkRenderable3D(const std::string &nodeId, graphics::Renderable3D *r)
Links a 3D renderable to a node in the current host.
bool setNodeLayerAt(const std::string &hostName, const std::string &nodeId, int layer)
Sets the node layer at.
bool setNodeRotation(const std::string &id, float yaw, float pitch, float roll)
Sets the local rotation (yaw/pitch/roll in degrees) of a node.
bool unlinkNode(const std::string &nodeId)
Removes every link on a node in the current host.
bool syncSpatialIndexAt(const std::string &hostName, spatial::Octree *ot) const
Insert every bounded node's world AABB into an octree (id = arena index).
bool setNodeEventHandlerAt(const std::string &hostName, ssq::Object cb)
Register a script callback for node lifecycle events on a host: The callback receives action,...
std::vector< float > getNodeQuaternionAt(const std::string &hostName, const std::string &nodeId) const
Returns the node quaternion at.
bool removeChildAt(const std::string &hostName, const std::string &parentId, const std::string &childId)
Removes child at.
bool setNodeBoundsAt(const std::string &hostName, const std::string &nodeId, float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
Sets the node bounds at.
bool setNodeVisible(const std::string &id, bool visible)
Shows/hides a node.
std::string getRootId()
Returns the root id.
bool addChildAt(const std::string &hostName, const std::string &parentId, const std::string &childId)
Adds child at.
std::string getChildIdAt(const std::string &parentId, int childOrdinal)
Returns the child id at.
bool linkRenderable2DAt(const std::string &hostName, const std::string &nodeId, graphics::Renderable2D *r)
Link renderable 2 d at.
std::vector< float > localToWorldAt(const std::string &hostName, const std::string &nodeId, float x, float y, float z) const
Local to world at.
std::vector< float > getNodeWorldScaleAt(const std::string &hostName, const std::string &nodeId) const
Returns the node world scale at.
bool isDescendant(const std::string &nodeId, const std::string &ancestorId)
True when descendant.
bool hasNodeTagAt(const std::string &hostName, const std::string &nodeId, const std::string &tag) const
True when node tag at.
int getNodeCount()
Returns the node count.
std::vector< std::string > walkDepthFirstIds()
DFS order of ids under root (same as collectIds). Kept for script naming clarity.
std::vector< float > getNodeBoundsAt(const std::string &hostName, const std::string &nodeId) const
Returns the node bounds at.
std::string pickRayAt(const std::string &hostName, float ox, float oy, float oz, float dx, float dy, float dz) const
Nearest node id hit by a world ray (nodes with bounds), or "".
bool addNodeTagAt(const std::string &hostName, const std::string &nodeId, const std::string &tag)
Adds node tag at.
bool linkRenderable2D(const std::string &nodeId, graphics::Renderable2D *r)
Links a 2D renderable to a node in the current host.
static void updateHost(SceneHost *host)
Updates host.
Region octree for 3D AABB broad-phase / scene culling. Same storage rules as QuadTree (smallest fully...
Definition Octree.h:18
bool insert(int id, float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
Inserts an item AABB; false if out of bounds or id already present.
Definition Octree.cpp:37
bool rayAABB(const glm::vec3 &o, const glm::vec3 &d, const AABB3f &b, float &t0, float &t1)
Slab ray-AABB intersection; fills entry/exit t (t0 <= t1).
Definition SceneBounds.h:49
AABB3f worldBoundsOf(const SceneNode &n)
World-space AABB of a node's local bounds (8 corners through world matrix).
Definition SceneBounds.h:26
Axis-aligned box in world space.
Definition SceneBounds.h:20
Retained scene node (arena). Conceptual GameObject; isomorphic to eve::ui::UINode.
Definition SceneHost.h:46