载入中...
搜索中...
未找到
Scene.cpp
浏览该文件的文档.
325 return getNodeRefByPathAt(currentHostName(), path)
}
eve.Scene["attachEntity"] <- function(nodeId, cls) {
326 return attachEntityAt(currentHostName(), nodeId, cls)
}
eve.Scene["attachEntityAt"] <- function(hostName, nodeId, cls) {
344 return detachEntityAt(currentHostName(), nodeId, inst)
}
eve.Scene["detachEntityAt"] <- function(hostName, nodeId, inst) {
353 return unrootEntityAt(hostName, nodeId, idx)
}
eve.Scene["scheduleDetachEntity"] <- function(nodeId, inst) {
355 return scheduleDetachEntityAt(currentHostName(), nodeId, inst)
}
eve.Scene["collectIdsWith"] <- function(cls, hostName = null) {
365 return getEntityAt(currentHostName(), nodeId, cls)
}
eve.Scene["getEntityAt"] <- function(hostName, nodeId, cls) {
382 return entitiesOfAt(currentHostName(), nodeId)
}
eve.Scene["entitiesOfAt"] <- function(hostName, nodeId) {
395 return linkPhysics2DAt(currentHostName(), nodeId, body, mode)
}
eve.Scene["linkPhysics3D"] <- function(nodeId, body, mode = "node") {
396 return linkPhysics3DAt(currentHostName(), nodeId, body, mode)
}
eve.Scene["linkCamera3D"] <- function(nodeId, cam) {
397 return linkCamera3DAt(currentHostName(), nodeId, cam)
}
eve.Scene["linkAudio3D"] <- function(nodeId, source) {
398 return linkAudio3DAt(currentHostName(), nodeId, source)
}
eve.Scene["unlinkNodeKind"] <- function(nodeId, kind) {
399 return unlinkNodeKindAt(currentHostName(), nodeId, kind)
}
eve.Scene["linkCount"] <- function(nodeId) {
461 return getNodePositionAt(currentHostName(), nodeId)
}
eve.Scene["getNodeRotation"] <- function(nodeId) {
463 return getNodeRotationAt(currentHostName(), nodeId)
}
eve.Scene["getNodeScale"] <- function(nodeId) {
465 return getNodeScaleAt(currentHostName(), nodeId)
}
eve.Scene["getNodeVisible"] <- function(nodeId) {
467 return getNodeVisibleAt(currentHostName(), nodeId)
}
eve.Scene["getNodeWorldPosition"] <- function(nodeId) {
469 return getNodeWorldPositionAt(currentHostName(), nodeId)
}
eve.Scene["getNodeWorldRotation"] <- function(nodeId) {
471 return getNodeWorldRotationAt(currentHostName(), nodeId)
}
eve.Scene["getNodeWorldScale"] <- function(nodeId) {
473 return getNodeWorldScaleAt(currentHostName(), nodeId)
}
eve.Scene["localToWorld"] <- function(nodeId, x, y, z) {
475 return localToWorldAt(currentHostName(), nodeId, x, y, z)
}
eve.Scene["worldToLocal"] <- function(nodeId, x, y, z) {
477 return worldToLocalAt(currentHostName(), nodeId, x, y, z)
}
eve.Scene["setNodeParent"] <- function(nodeId, parentId) { return setNodeParentAt(currentHostName(), nodeId, parentId) }
479eve.Scene["addNodeChild"] <- function(parentId, childId) { return addChildAt(currentHostName(), parentId, childId) }
480eve.Scene["removeNodeChild"] <- function(parentId, childId) { return removeChildAt(currentHostName(), parentId, childId) }
481eve.Scene["setNodeQuaternion"] <- function(nodeId, qx, qy, qz, qw) { return setNodeQuaternionAt(currentHostName(), nodeId, qx, qy, qz, qw) }
484 return getNodeQuaternionAt(currentHostName(), nodeId)
}
eve.Scene["setNodeLookAt"] <- function(nodeId, tx, ty, tz) { return setNodeLookAtAt(currentHostName(), nodeId, tx, ty, tz) }
485eve.Scene["addNodeTag"] <- function(nodeId, tag) { return addNodeTagAt(currentHostName(), nodeId, tag) }
486eve.Scene["removeNodeTag"] <- function(nodeId, tag) { return removeNodeTagAt(currentHostName(), nodeId, tag) }
487eve.Scene["hasNodeTag"] <- function(nodeId, tag) { return hasNodeTagAt(currentHostName(), nodeId, tag) }
490 return getNodeTagsAt(currentHostName(), nodeId)
}
eve.Scene["collectIdsByTag"] <- function(tag) { return collectIdsByTagAt(currentHostName(), tag) }
491eve.Scene["setNodeLayer"] <- function(nodeId, layer) { return setNodeLayerAt(currentHostName(), nodeId, layer) }
494 return getNodeLayerAt(currentHostName(), nodeId)
}
eve.Scene["setNodeEventHandler"] <- function(cb) {
511eve.SceneNodeRef["setParent"] <- function(parentId) { return getScene().setNodeParentAt(getHostName(), getNodeId(), parentId) }
512eve.SceneNodeRef["removeNode"] <- function() { return getScene().removeNodeAt(getHostName(), getNodeId()) }
513eve.SceneNodeRef["setQuaternion"] <- function(qx, qy, qz, qw) { return getScene().setNodeQuaternionAt(getHostName(), getNodeId(), qx, qy, qz, qw) }
518eve.SceneNodeRef["lookAt"] <- function(tx, ty, tz) { return getScene().setNodeLookAtAt(getHostName(), getNodeId(), tx, ty, tz) }
519eve.SceneNodeRef["addTag"] <- function(tag) { return getScene().addNodeTagAt(getHostName(), getNodeId(), tag) }
520eve.SceneNodeRef["removeTag"] <- function(tag) { return getScene().removeNodeTagAt(getHostName(), getNodeId(), tag) }
521eve.SceneNodeRef["hasTag"] <- function(tag) { return getScene().hasNodeTagAt(getHostName(), getNodeId(), tag) }
526eve.SceneNodeRef["setLayer"] <- function(layer) { return getScene().setNodeLayerAt(getHostName(), getNodeId(), layer) }
535 return setNodeBoundsAt(currentHostName(), nodeId, minX, minY, minZ, maxX, maxY, maxZ)
}
eve.Scene["hasNodeBounds"] <- function(nodeId) {
536 return hasNodeBoundsAt(currentHostName(), nodeId)
}
eve.Scene["getNodeBounds"] <- function(nodeId) {
540 return deserializeHostAt(currentHostName(), json)
}
eve.Scene["pickRay"] <- function(ox, oy, oz, dx, dy, dz) {
541 return pickRayAt(currentHostName(), ox, oy, oz, dx, dy, dz)
}
eve.Scene["pickScreen"] <- function(cam, screenX, screenY, viewW, viewH) {
542 return pickScreenAt(currentHostName(), cam, screenX, screenY, viewW, viewH)
}
eve.Scene["collectFrustumIds"] <- function(cam, viewW, viewH) {
543 return collectFrustumIdsAt(currentHostName(), cam, viewW, viewH)
}
eve.Scene["applyPcgTerrainCulling"] <- function(cam, viewW, viewH, tag) {
544 return applyPcgTerrainCullingAt(currentHostName(), cam, viewW, viewH, tag)
}
eve.Scene["syncSpatialIndex"] <- function(octree) {
545 return syncSpatialIndexAt(currentHostName(), octree)
}
eve.Scene["nodeIdFromSpatialId"] <- function(index) {
550 return getScene().setNodeBoundsAt(getHostName(), getNodeId(), minX, minY, minZ, maxX, maxY, maxZ)
625 eve::DiagnosticCode::PreconditionViolation, std::string("scene mount rejected: ") + error.what(), "scene"));
631eve::Result<SceneHost *> Scene::mount(NodeDesc root) { return mountAs("default", std::move(root)); }
688 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "scene host name must not be empty", "scene"));
689 if (SceneHost *host = findHostByName(name)) return eve::Result<SceneHost *>::success(host, eve::Status::success());
691 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "scene host was not found: " + name, "scene"));
701 eve::DiagnosticCode::NotFound, "scene host owner id was not found: " + std::to_string(ownerId), "scene"));
711}
756}
856 }
882 }
918}
927 HSQOBJECT raw = instance.getRaw();
1018 ssq::Object instance) {
1094}
1353 cls.addFunc("applyPcgTerrainCullingAt", [vm=cls.getHandle()](Scene* self,const std::string& host,
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:255
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
static std::optional< Id128 > parse(std::string_view text) noexcept
Parses canonical UUID text.
Definition Identity.h:151
ECS mount point for one scene graph (full scene or nested subtree root). Isomorphic to eve::ui::UIHos...
Definition SceneHost.h:89
static eve::Result< SceneHost * > createHost(const std::string &name="")
Creates an ECS-owned scene host with an explicit Result contract.
Definition SceneHost.cpp:129
std::vector< float > getForward() const
Normalized local axes in world space (forward = +Z).
Definition SceneNodeRef.cpp:192
Scene * getScene() const
Returns the eve.Scene module instance for entity-binding forwarding.
Definition SceneNodeRef.cpp:49
std::vector< float > getWorldPosition() const
Returns the world position.
Definition SceneNodeRef.cpp:176
bool setRotation(float yaw, float pitch, float roll)
Sets the rotation.
Definition SceneNodeRef.cpp:83
std::vector< float > getWorldMatrix() const
Column-major 4x4 world matrix, 16 floats.
Definition SceneNodeRef.cpp:182
Per-node ECS identity (created lazily when a node needs script bindings or engine components)....
Definition SceneObject.h:25
static eve::Result< SceneObject * > createObject(const std::string &hostName, const std::string &nodeId, eve::SceneObjectId persistentId={})
Creates an ECS-owned companion object with an explicit ownership contract.
Definition SceneObject.cpp:7
void beginNode(const std::string &id, const std::string &name="")
Begins node.
Definition Scene.cpp:856
SceneNodeRef * getNodeRefByPathAt(const std::string &hostName, const std::string &path) const
Returns the node ref by path at.
Definition Scene.cpp:1186
bool linkPhysics3DAt(const std::string &hostName, const std::string &nodeId, physics::Body3D *b, const std::string &mode)
Link physics 3 d at.
Definition SceneNodes.cpp:125
SceneHost * resolveHost(const std::string &hostName) const
Host-qualified resolution: empty hostName → currently selected host.
Definition Scene.cpp:948
eve::Result< SceneHost * > findHostByOwner(uint32_t ownerId) const
Finds the host bound to an owner id with an explicit status.
Definition Scene.cpp:772
std::vector< std::string > collectIdsFrom(const std::string &id)
Collect ids from.
Definition SceneNodes.cpp:584
void updateTransforms()
Propagate transforms (+ link sync) for all hosts (or current if selected).
Definition Scene.cpp:795
bool setNodeParentAt(const std::string &hostName, const std::string &childId, const std::string &parentId)
Reparent by id; empty parentId detaches. Cycle-safe.
Definition SceneNodes.cpp:256
bool linkCamera3DAt(const std::string &hostName, const std::string &nodeId, graphics::Camera3D *c)
Link camera 3 d at.
Definition SceneNodes.cpp:134
std::string serializeHostAt(const std::string &hostName) const
Serialize host at.
Definition Scene.cpp:831
std::vector< std::string > collectIdsByTagAt(const std::string &hostName, const std::string &tag) const
Collect ids by tag at.
Definition SceneNodes.cpp:367
std::vector< float > getNodeRotationAt(const std::string &hostName, const std::string &nodeId) const
Returns the node rotation at.
Definition SceneNodes.cpp:185
bool rootEntity(const std::string &hostName, const std::string &nodeId, ssq::Object instance)
Root one script instance on a node (creates SceneObject lazily).
Definition Scene.cpp:998
std::string pickScreenAt(const std::string &hostName, graphics::Camera3D *cam, float screenX, float screenY, float viewW, float viewH) const
Screen-space picking through a Camera3D (camera.screenToRay).
Definition SceneCameraQueries.cpp:28
eve::Result< void > scheduleDetachEntityAt(const std::string &hostName, const std::string &nodeId, ssq::Object instance)
Queue a script instance for detach at the end of the current/next updateScripts.
Definition Scene.cpp:1094
bool setNodeQuaternionAt(const std::string &hostName, const std::string &nodeId, float qx, float qy, float qz, float qw)
Sets the node quaternion at.
Definition SceneNodes.cpp:291
eve::Result< SceneHost * > mountAs(const std::string &name, NodeDesc root)
Creates/replaces a named host from a NodeDesc tree and selects it.
Definition Scene.cpp:690
bool getNodeVisibleAt(const std::string &hostName, const std::string &nodeId) const
Returns the node visible at.
Definition SceneNodes.cpp:201
std::vector< float > worldToLocalAt(const std::string &hostName, const std::string &nodeId, float x, float y, float z) const
World to local at.
Definition SceneNodes.cpp:246
void setBuildRotation(float yaw, float pitch=0.f, float roll=0.f)
Sets the build rotation.
Definition Scene.cpp:889
eve::Result< SceneHost * > mount(NodeDesc root)
Mounts the tree as the default host and selects it.
Definition Scene.cpp:709
void updateScripts(float dt)
updateTransformsAll() + call update(dt) on every rooted instance.
Definition Scene.cpp:1062
std::vector< float > getNodePositionAt(const std::string &hostName, const std::string &nodeId) const
Returns the node position at.
Definition SceneNodes.cpp:177
std::vector< float > getNodeWorldPositionAt(const std::string &hostName, const std::string &nodeId) const
Returns the node world position at.
Definition SceneNodes.cpp:208
int getNodeLayerAt(const std::string &hostName, const std::string &nodeId) const
Returns the node layer at.
Definition SceneNodes.cpp:387
bool linkPhysics2DAt(const std::string &hostName, const std::string &nodeId, physics::Body *b, const std::string &mode)
Link physics 2 d at.
Definition SceneNodes.cpp:116
bool removeNodeAt(const std::string &hostName, const std::string &nodeId)
Detach node from its parent (arena node stays; rebuild to delete).
Definition SceneNodes.cpp:265
void flushDelayedDetaches()
Drain the delayed-detach queue (called automatically by updateScripts).
Definition Scene.cpp:1147
SceneNodeRef * getNodeRefAt(const std::string &hostName, const std::string &nodeId) const
Returns the node ref at.
Definition Scene.cpp:1178
std::vector< std::string > collectChildIds(const std::string &parentId)
Collect child ids.
Definition SceneNodes.cpp:600
void setHostVisible(bool visible)
Shows/hides every host (or the selected one when a host is selected).
Definition Scene.cpp:787
bool unlinkNodeAt(const std::string &hostName, const std::string &nodeId)
Remove every link on the node.
Definition SceneNodes.cpp:152
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.
Definition SceneNodes.cpp:36
std::vector< std::string > collectIdsVisible(bool visible)
Collect ids visible.
Definition SceneNodes.cpp:595
bool linkAudio3DAt(const std::string &hostName, const std::string &nodeId, audio::Source *s)
Link audio 3 d at.
Definition SceneNodes.cpp:143
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).
Definition SceneNodes.cpp:314
std::vector< float > getNodeWorldRotationAt(const std::string &hostName, const std::string &nodeId) const
Returns the node world rotation at.
Definition SceneNodes.cpp:216
void bindOwner(uint32_t ownerId)
Binds the selected host to a UI/scene owner id.
Definition Scene.cpp:782
bool removeNodeTagAt(const std::string &hostName, const std::string &nodeId, const std::string &tag)
Removes node tag at.
Definition SceneNodes.cpp:345
bool linkRenderable3DAt(const std::string &hostName, const std::string &nodeId, graphics::Renderable3D *r)
Link renderable 3 d at.
Definition SceneNodes.cpp:107
eve::Result< SceneHost * > remount(NodeDesc root)
Replaces the selected host's tree.
Definition Scene.cpp:711
void setBuildPosition(float x, float y, float z=0.f)
Sets the build position.
Definition Scene.cpp:882
bool isAncestor(const std::string &ancestorId, const std::string &nodeId)
True when ancestor.
Definition SceneNodes.cpp:569
bool setNodeScale(const std::string &id, float sx, float sy, float sz)
Sets the local scale of a node.
Definition SceneNodes.cpp:60
std::vector< std::string > collectIdsByName(const std::string &name)
Collect ids by name.
Definition SceneNodes.cpp:590
void setHostLayer(int layer)
Sets the render layer of every host (or the selected one).
Definition Scene.cpp:791
bool unlinkNodeKindAt(const std::string &hostName, const std::string &nodeId, const std::string &kind)
Remove links of one kind ("renderable2d"|"renderable3d"|"physics2d"|...).
Definition SceneNodes.cpp:157
std::vector< float > getNodeScaleAt(const std::string &hostName, const std::string &nodeId) const
Returns the node scale at.
Definition SceneNodes.cpp:193
std::string nodeIdFromSpatialIdAt(const std::string &hostName, int index) const
Map a spatial-index id (arena index) back to a node id.
Definition SceneNodes.cpp:508
eve::Result< SceneHost * > remountAs(const std::string &name, NodeDesc root)
Creates/replaces a named host through the canonical mount path.
Definition Scene.cpp:752
std::vector< std::string > getNodeTagsAt(const std::string &hostName, const std::string &nodeId) const
Returns the node tags at.
Definition SceneNodes.cpp:359
void updateTransformsAll()
Propagate transforms for every host regardless of selection.
Definition Scene.cpp:800
int linkCountAt(const std::string &hostName, const std::string &nodeId)
Link count at.
Definition SceneNodes.cpp:168
bool hasNodeBoundsAt(const std::string &hostName, const std::string &nodeId) const
True when node bounds at.
Definition SceneNodes.cpp:457
bool deserializeHostAt(const std::string &hostName, const std::string &json)
Deserialize host at.
Definition Scene.cpp:836
std::vector< std::string > walkBreadthFirstIds()
Walk breadth first ids.
Definition SceneNodes.cpp:607
bool unrootEntityAt(const std::string &hostName, const std::string &nodeId, int index)
Remove a rooted script instance by its index in the binding list.
Definition Scene.cpp:1018
bool linkRenderable3D(const std::string &nodeId, graphics::Renderable3D *r)
Links a 3D renderable to a node in the current host.
Definition SceneNodes.cpp:86
bool setNodeLayerAt(const std::string &hostName, const std::string &nodeId, int layer)
Sets the node layer at.
Definition SceneNodes.cpp:378
bool setNodeRotation(const std::string &id, float yaw, float pitch, float roll)
Sets the local rotation (yaw/pitch/roll in degrees) of a node.
Definition SceneNodes.cpp:48
bool unlinkNode(const std::string &nodeId)
Removes every link on a node in the current host.
Definition SceneNodes.cpp:90
bool syncSpatialIndexAt(const std::string &hostName, spatial::Octree *ot) const
Insert every bounded node's world AABB into an octree (id = arena index).
Definition SceneNodes.cpp:495
std::vector< float > getNodeQuaternionAt(const std::string &hostName, const std::string &nodeId) const
Returns the node quaternion at.
Definition SceneNodes.cpp:305
bool removeChildAt(const std::string &hostName, const std::string &parentId, const std::string &childId)
Removes child at.
Definition SceneNodes.cpp:282
eve::Result< SceneHost * > findHost(const std::string &name) const
Finds a host by name with an explicit not-found status.
Definition Scene.cpp:763
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.
Definition SceneNodes.cpp:441
bool setNodeVisible(const std::string &id, bool visible)
Shows/hides a node.
Definition SceneNodes.cpp:72
bool addChildAt(const std::string &hostName, const std::string &parentId, const std::string &childId)
Adds child at.
Definition SceneNodes.cpp:273
std::string getChildIdAt(const std::string &parentId, int childOrdinal)
Returns the child id at.
Definition SceneNodes.cpp:543
bool linkRenderable2DAt(const std::string &hostName, const std::string &nodeId, graphics::Renderable2D *r)
Link renderable 2 d at.
Definition SceneNodes.cpp:98
std::vector< float > localToWorldAt(const std::string &hostName, const std::string &nodeId, float x, float y, float z) const
Local to world at.
Definition SceneNodes.cpp:236
std::vector< float > getNodeWorldScaleAt(const std::string &hostName, const std::string &nodeId) const
Returns the node world scale at.
Definition SceneNodes.cpp:226
bool select(const std::string &name)
Selects a named host; false when it does not exist.
Definition Scene.cpp:756
bool isDescendant(const std::string &nodeId, const std::string &ancestorId)
True when descendant.
Definition SceneNodes.cpp:574
bool hasNodeTagAt(const std::string &hostName, const std::string &nodeId, const std::string &tag) const
True when node tag at.
Definition SceneNodes.cpp:352
std::vector< std::string > walkDepthFirstIds()
DFS order of ids under root (same as collectIds). Kept for script naming clarity.
Definition SceneNodes.cpp:605
std::vector< std::string > collectFrustumIdsAt(const std::string &hostName, graphics::Camera3D *cam, float viewW, float viewH) const
Ids of nodes whose world AABB intersects the camera frustum.
Definition SceneCameraQueries.cpp:39
eve::Result< SceneHost * > remountReconcile(NodeDesc root)
Reconciles the selected host, reporting whether replacement failed.
Definition Scene.cpp:731
std::vector< float > getNodeBoundsAt(const std::string &hostName, const std::string &nodeId) const
Returns the node bounds at.
Definition SceneNodes.cpp:463
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 "".
Definition SceneNodes.cpp:472
bool addNodeTagAt(const std::string &hostName, const std::string &nodeId, const std::string &tag)
Adds node tag at.
Definition SceneNodes.cpp:338
bool linkRenderable2D(const std::string &nodeId, graphics::Renderable2D *r)
Links a 2D renderable to a node in the current host.
Definition SceneNodes.cpp:82
int forEachEntity(const std::string &hostName, const std::string &nodeId, ssq::Object cb)
Call cb(instance, index) for every rooted instance; returns count.
Definition Scene.cpp:1039
Definition AvatarInstance.h:33
void registerSceneArtifactProvider()
Register the scene provider in the common capability registry.
Definition ArtifactProvider.cpp:267
void exposeFollowPlayerBindings(ssq::Table &table)
Register FollowPlayer value types and evaluator with the root script table.
Definition FollowPlayerBindings.cpp:9
void exposePcgBuildConfigBindings(ssq::Table &t)
Register Pcg build-config bindings.
Definition PcgBuildConfig.cpp:10
void exposeLocationProfileBindings(ssq::Table &table)
Register Pcg location profile value types and operations.
Definition LocationProfileBindings.cpp:21
@ InvalidArgument
@ NotFound
@ PreconditionViolation
@ NoOp
@ Applied
Definition Container.h:602
Scene-owned CPU registry provider for generated artifacts.
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:19
Retained scene node (arena). Conceptual GameObject; isomorphic to eve::ui::UINode.
Definition SceneHost.h:46