载入中...
搜索中...
未找到
ArtifactProvider.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
13
14#include <cstddef>
15#include <cstdint>
16#include <memory>
17#include <string>
18#include <vector>
19
20namespace eve::physics {
21
22class Body3D;
23class Shape3D;
24class World3D;
25
30
33 bool hit = false;
34 float fraction = 0.f;
35 float x = 0.f;
36 float y = 0.f;
37 float z = 0.f;
38 float normalX = 0.f;
39 float normalY = 0.f;
40 float normalZ = 0.f;
41};
42
57
68public:
72 ~PhysicsArtifactProvider() override;
73
76 const eve::artifact::PublicationView& publication) override;
78 [[nodiscard]] eve::Result<eve::Value> snapshotState() const override;
80 [[nodiscard]] eve::Result<void> restoreState(const eve::Value& state) override;
82 [[nodiscard]] bool emptyState() const noexcept override;
84 void clearState() noexcept override { clear(); }
85
95 [[nodiscard]] const PhysicsArtifactCollider* find(eve::PersistentId id) const noexcept;
104 [[nodiscard]] const PhysicsArtifactCollider* find(PhysicsArtifactHandle handle) const noexcept;
106 [[nodiscard]] bool isHandleLive(PhysicsArtifactHandle handle) const noexcept;
108 [[nodiscard]] PhysicsArtifactRayHit rayCast(eve::PersistentId id, float ox, float oy, float oz, float dx, float dy,
109 float dz) const noexcept;
111 [[nodiscard]] std::size_t size() const noexcept;
113 [[nodiscard]] std::string backendName(eve::PersistentId id) const;
115 [[nodiscard]] bool isBox3DBacked(eve::PersistentId id) const noexcept;
128 [[nodiscard]] eve::Result<void> bindWorld(World3D& world);
134 [[nodiscard]] eve::Result<void> unbindWorld(PhysicsWorldHandle world);
136 [[nodiscard]] PhysicsWorldHandle boundWorld() const noexcept;
138 [[nodiscard]] bool isSharedWorldBacked(eve::PersistentId id) const noexcept;
140 void clear() noexcept;
142 void setPrepareFailure(bool enabled) noexcept { failPrepare_ = enabled; }
143
144private:
145 struct State;
147 void commit(PhysicsArtifactCollider collider, std::unique_ptr<World3D> world, std::unique_ptr<Body3D> body,
148 std::unique_ptr<Shape3D> shape) noexcept;
149 void release(PhysicsArtifactCollider& collider, std::unique_ptr<World3D>& world, std::unique_ptr<Body3D>& body,
150 std::unique_ptr<Shape3D>& shape) noexcept;
151 std::unique_ptr<State> state_;
152 std::uint32_t nextIndex_ = 0;
153 bool failPrepare_ = false;
154 World3D* boundWorld_ = nullptr;
155 PhysicsWorldHandle boundWorldHandle_ = PhysicsWorldHandle::invalid();
156 std::weak_ptr<const void> boundWorldLifetime_;
157 std::shared_ptr<const void> providerLifetime_ = std::make_shared<int>(0);
158};
159
164
165} // namespace eve::physics
Low-level capability contracts for publishing backend-neutral artifacts.
#define EVENGINE_API_WORLD
Definition Export.h:109
ShaderImageInput shape
World3D * world
Process-local, generation-qualified handles owned by the physics domain.
PrimitiveHandle handle
std::function< eve::Result< void >()> release
Definition Procgen.cpp:86
Strong generation-qualified handles for non-ECS runtime registries.
float dz
float dy
float dx
float size
Definition TreeMesh.cpp:156
std::string body
double oy
double ox
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static constexpr RuntimeHandle invalid() noexcept
Returns the canonical invalid handle.
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
Collider publication capability, implemented by physics.
Id128 public API.
Definition Identity.h:112
Real physics-module provider for generated collider publication.
void clearState() noexcept override
Clear provider state through the common restore-cleanup hook.
Staged, owning Box3D construction for one provider mutation.
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:63
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36
PhysicsArtifactProvider & physicsArtifactProvider() noexcept
Return the process-owned physics artifact provider singleton.
void registerPhysicsArtifactProvider()
Register the physics provider in the common capability registry.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
bool enabled
Backend-neutral axis-aligned bounds copied from a generated part.
Borrowed immutable view of one complete generated publication.
Queryable CPU collider resource owned by the physics module.
PhysicsWorldHandle world
Shared or compatibility-world identity that owns the live collider.
std::string backend
Backend family that owns the live shape, normally box3d.
std::vector< std::uint32_t > indices
Owner tag for physics artifact runtime handles.
Backend-neutral ray-query result used for parity tests.