载入中...
搜索中...
未找到
PhysicsLink.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
14#include "common/BorrowedRef.h"
15#include "common/Result.h"
17
18namespace eve::physics {
19
20class Body;
21class Body3D;
22class Joint3D;
23class Joint2D;
24class Shape3D;
25class World;
26class World3D;
27
37 PhysicsWorldHandle world = PhysicsWorldHandle::invalid();
39 PhysicsBodyHandle body = PhysicsBodyHandle::invalid();
40
42 [[nodiscard]] bool isValid() const noexcept { return world.isValid() && body.isValid(); }
43
48 [[nodiscard("check the link construction outcome")]]
50
52 [[nodiscard("check the link construction outcome")]]
53 static eve::Result<PhysicsLink> fromBody(const Body& body);
55 [[nodiscard("check the link construction outcome")]]
56 static eve::Result<PhysicsLink> fromBody(const Body3D& body);
57
59 [[nodiscard("check stale-link resolution")]]
60 eve::Result<Body*> resolve(World& world) const;
62 [[nodiscard("check stale-link resolution")]]
63 eve::Result<Body3D*> resolve(World3D& world) const;
64};
65
73 PhysicsWorldHandle world = PhysicsWorldHandle::invalid();
74 PhysicsShapeHandle shape = PhysicsShapeHandle::invalid();
75
77 [[nodiscard]] bool isValid() const noexcept { return world.isValid() && shape.isValid(); }
79 [[nodiscard("check the shape-link construction outcome")]]
82 [[nodiscard("check the shape-link construction outcome")]]
83 static eve::Result<PhysicsShapeLink> fromShape(const Shape3D& shape);
85 [[nodiscard("check stale shape-link resolution")]]
86 eve::Result<Shape3D*> resolve(World3D& world) const;
87};
88
96 PhysicsWorldHandle world = PhysicsWorldHandle::invalid();
97 PhysicsJointHandle joint = PhysicsJointHandle::invalid();
98
100 [[nodiscard]] bool isValid() const noexcept { return world.isValid() && joint.isValid(); }
102 [[nodiscard("check the joint-link construction outcome")]]
105 [[nodiscard("check the joint-link construction outcome")]]
106 static eve::Result<PhysicsJointLink> fromJoint(const Joint3D& joint);
108 [[nodiscard]] static eve::Result<PhysicsJointLink> fromJoint(const Joint2D& joint);
112 [[nodiscard]] eve::ResultRef<Joint2D> resolve(World& world) const;
114 [[nodiscard("check stale joint-link resolution")]]
115 eve::Result<Joint3D*> resolve(World3D& world) const;
116};
117
118} // namespace eve::physics
Vocabulary aliases for nullable and checked borrowed references.
#define EVENGINE_API_WORLD
Definition Export.h:109
ShaderImageInput shape
Process-local, generation-qualified handles owned by the physics domain.
std::string body
Move-only, checked operation results for the common layer.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
constexpr bool isValid() const noexcept
Returns whether both coordinates are usable handle values.
Backend-neutral 3D rigid body in meter-space coordinates (+Y up by convention). Owned by a World3D; c...
Definition Body3D.h:31
2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFi...
Definition Body.h:21
Owning planar joint wrapper observing World-owned backend state. @ownership Caller/VM owns factory wr...
Definition Joint2D.h:58
Script-facing joint owned by a World3D. Legacy scalar/void methods adapt the checked backend contract...
Definition Joint3D.h:27
3D shape (box/sphere/capsule) attached to a Body3D with material settings. Created via Body3D::new*Sh...
Definition Shape3D.h:34
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:47
Box2D world wrapper (2D physics) with pixel-space coordinates. Handles stepping, gravity,...
Definition World.h:44
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36