载入中...
搜索中...
未找到
ScenePhysics.cpp
浏览该文件的文档.
2
4#include "physics/World3D.h"
5
6#include <simplesquirrel/simplesquirrel.hpp>
7
8#include <stdexcept>
9
11
13
19
22 if (bound.isInvalid())
25 if (!result) return eve::Result<void>::failure(result.status());
26 return result;
27}
28
32
33void ScenePhysics::expose(ssq::Table& table) {
34 auto module = table.addClass(name, ScenePhysics::create, false);
35 expose(module);
36}
37
38void ScenePhysics::expose(ssq::Class& cls) {
39 cls.addFunc("bindGeneratedColliders", [](ScenePhysics* self, eve::physics::World3D* world) {
40 if (!self || !world) throw std::runtime_error("shared collider binding requires a live World3D");
41 auto result = self->bindGeneratedColliders(*world);
42 if (!result) throw std::runtime_error(result.status().describe());
43 });
44 cls.addFunc("unbindGeneratedColliders", [](ScenePhysics* self) {
45 if (!self) throw std::runtime_error("scene physics module is unavailable");
46 auto result = self->unbindGeneratedColliders();
47 if (!result) throw std::runtime_error(result.status().describe());
48 });
49 cls.addFunc("isGeneratedColliderWorldBound", [](ScenePhysics* self) {
50 return self && !self->boundWorld().isInvalid();
51 });
52}
53
54} // namespace eve::scene_physics
HSQOBJECT cls
Definition ECS.cpp:21
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
World3D * world
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
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
eve::Result< void > unbindWorld(PhysicsWorldHandle world)
Remove an empty provider's matching shared-world binding.
eve::Result< void > bindWorld(World3D &world)
Bind future collider publications to a caller-owned shared world.
PhysicsWorldHandle boundWorld() const noexcept
Return the live shared-world binding, or invalid for compatibility-private mode/stale binding.
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:63
Scene/runtime composition entry point for generated colliders in a shared World3D.
eve::Result< void > unbindGeneratedColliders()
Remove the current empty shared-world binding.
eve::physics::PhysicsWorldHandle boundWorld() const noexcept
Current bound world identity, or invalid when unbound/stale.
eve::Result< void > bindGeneratedColliders(eve::physics::World3D &world)
Route future generated collider publications into a caller-owned gameplay world. @ownership The calle...
PhysicsArtifactProvider & physicsArtifactProvider() noexcept
Return the process-owned physics artifact provider singleton.
Physics-owned CPU collider provider for generated artifacts.