Physics module — Box2D (2D) + Box3D (3D) rigid bodies and SPH fluid. Script: physics <- eve.Physics(); world <- physics.newWorld(0, 900); world3 <- physics.newWorld3D(0, -9.8, 0);
更多...
#include <Physics.h>
Public 成员函数 | |
| Module_REG (Physics) | |
| Physics () | |
| Physics. | |
| ~Physics () override=default | |
| Physics. | |
| void | setMeter (float pixelsPerMeter) |
| Pixels per meter for 2D Box2D worlds (default 30, same as LÖVE). | |
| float | getMeter () const |
| Returns the meter. | |
| World * | newWorld (float gravityX, float gravityY, bool sleep=true) |
| Create a 2D Box2D physics world. | |
| World3D * | newWorld3D (float gravityX, float gravityY, float gravityZ, bool sleep=true) |
| Create a 3D Box3D physics world. Coordinates are meters (Box3D native); +Y is up by convention. | |
| DistanceField3D * | newDistanceField3D (int width, int height, int depth, float cellSize, float originX=0.f, float originY=0.f, float originZ=0.f, float outsideDistance=1e6f) |
| Create a regular 3D signed-distance grid for map collision queries. | |
| SoftBody3D * | newSoftBody3D (int cols, int rows, int layers, float spacing, float originX, float originY, float originZ) |
| Compatibility factory for a volumetric shape-matching soft body. | |
| SoftBody3DRenderer * | newSoftBody3DRenderer (SoftBody3D *body) |
| Create a presentation satellite observing a soft-body runtime. | |
| Fluid2D * | newFluid2D (int capacity=512) |
| Creates an interactive 2D particle fluid in pixel space. | |
Public 成员函数 继承自 eve::Module | |
| virtual | ~Module () |
| Module. | |
| virtual std::string | getName () const =0 |
| Returns the name. | |
详细描述
Physics module — Box2D (2D) + Box3D (3D) rigid bodies and SPH fluid. Script: physics <- eve.Physics(); world <- physics.newWorld(0, 900); world3 <- physics.newWorld3D(0, -9.8, 0);
构造及析构函数说明
◆ Physics()
| eve::physics::Physics::Physics | ( | ) |
◆ ~Physics()
|
overridedefault |
成员函数说明
◆ getMeter()
| float eve::physics::Physics::getMeter | ( | ) | const |
Returns the meter.
在文件 Physics.cpp 第 39 行定义.
◆ Module_REG()
| eve::physics::Physics::Module_REG | ( | Physics | ) |
◆ newDistanceField3D()
| DistanceField3D * eve::physics::Physics::newDistanceField3D | ( | int | width, |
| int | height, | ||
| int | depth, | ||
| float | cellSize, | ||
| float | originX = 0.f, |
||
| float | originY = 0.f, |
||
| float | originZ = 0.f, |
||
| float | outsideDistance = 1e6f |
||
| ) |
Create a regular 3D signed-distance grid for map collision queries.
- 返回
- Owning nullable field pointer transferred to the caller. @ownership The caller owns the returned field and must delete it after use. @lifetime Valid until caller destruction; it is not retained by Physics. @thread Create and use on the owning physics thread. @reentrancy The factory invokes no callbacks.
在文件 Physics.cpp 第 49 行定义.
◆ newFluid2D()
| Fluid2D * eve::physics::Physics::newFluid2D | ( | int | capacity = 512 | ) |
Creates an interactive 2D particle fluid in pixel space.
- 参数
-
capacity maximum number of particles (>= 1)
- 返回
- Owning nullable fluid pointer transferred to the caller. @ownership The caller owns the returned fluid and must delete it after use. @lifetime Valid until caller destruction; it is not retained by Physics. @thread Create and use on the owning physics thread. @reentrancy The factory invokes no callbacks.
在文件 Physics.cpp 第 67 行定义.
引用了 capacity.
◆ newSoftBody3D()
| SoftBody3D * eve::physics::Physics::newSoftBody3D | ( | int | cols, |
| int | rows, | ||
| int | layers, | ||
| float | spacing, | ||
| float | originX, | ||
| float | originY, | ||
| float | originZ | ||
| ) |
Compatibility factory for a volumetric shape-matching soft body.
The canonical C++ creation API is SoftBody3D::create(), which returns a checked owning unique_ptr. This adapter exists for the script binding, whose VM assumes ownership of the returned wrapper.
- 返回
- Owning pointer transferred to the script VM/caller. @ownership The caller owns the returned object and must destroy it. @lifetime Valid until caller destruction; a borrowed World3D must be cleared first. @thread Create and use on the owning simulation thread. @reentrancy No callbacks are invoked.
- 异常
-
eve::Exception when dimensions or coordinates are invalid.
在文件 Physics.cpp 第 56 行定义.
引用了 cols, eve::physics::SoftBody3D::create(), created, rows , 以及 spacing.
◆ newSoftBody3DRenderer()
| SoftBody3DRenderer * eve::physics::Physics::newSoftBody3DRenderer | ( | SoftBody3D * | body | ) |
Create a presentation satellite observing a soft-body runtime.
- 参数
-
body Borrowed nullable runtime; clear it on the renderer before destroying the body.
- 返回
- Owning renderer transferred to the script VM/caller. @ownership The caller owns the renderer; it never owns body or Graphics. @thread Create and use on the owning render thread.
在文件 Physics.cpp 第 63 行定义.
引用了 body.
◆ newWorld()
| World * eve::physics::Physics::newWorld | ( | float | gravityX, |
| float | gravityY, | ||
| bool | sleep = true |
||
| ) |
Create a 2D Box2D physics world.
- 参数
-
gravityX gravity X in pixels/s² gravityY gravity Y in pixels/s² sleep allow sleeping bodies
- 返回
- Owning nullable world pointer; the caller is responsible for deleting the wrapper. @ownership Ownership transfers to the caller; the Physics module does not retain the wrapper. @lifetime Valid until caller destruction; call World::destroy() before releasing backend resources. @thread Create and use on the owning physics thread. @reentrancy The factory invokes no callbacks; do not re-enter physics mutation while using the result.
在文件 Physics.cpp 第 41 行定义.
◆ newWorld3D()
| World3D * eve::physics::Physics::newWorld3D | ( | float | gravityX, |
| float | gravityY, | ||
| float | gravityZ, | ||
| bool | sleep = true |
||
| ) |
Create a 3D Box3D physics world. Coordinates are meters (Box3D native); +Y is up by convention.
- 参数
-
gravityX gravity X in m/s² gravityY gravity Y in m/s² gravityZ gravity Z in m/s² sleep allow sleeping bodies
- 返回
- Owning nullable world pointer; the caller is responsible for deleting the wrapper. @ownership Ownership transfers to the caller; the Physics module does not retain the wrapper. @lifetime Valid until caller destruction; call World3D::destroy() before releasing backend resources. @thread Create and use on the owning physics thread. @reentrancy The factory invokes no callbacks; do not re-enter physics mutation while using the result.
在文件 Physics.cpp 第 45 行定义.
◆ setMeter()
| void eve::physics::Physics::setMeter | ( | float | pixelsPerMeter | ) |
Pixels per meter for 2D Box2D worlds (default 30, same as LÖVE).
在文件 Physics.cpp 第 33 行定义.
该类的文档由以下文件生成:
- src/modules/physics/Physics.h
- src/modules/physics/Physics.cpp
Public 成员函数 继承自