Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixels + Physics.setMeter. 更多...
#include <World3D.h>
Public 成员函数 | |
| World3D (float gravityX, float gravityY, float gravityZ, bool sleep) | |
| ~World3D () | |
| World3D (const World3D &)=delete | |
| World3D & | operator= (const World3D &)=delete |
| void | update (float dt) |
| Steps the simulation by dt seconds (default substep count). | |
| void | updateFull (float dt, int subStepCount) |
| Steps with an explicit substep count. | |
| void | setGravity (float gx, float gy, float gz) |
| Gravity in m/s². | |
| float | getGravityX () const |
| float | getGravityY () const |
| float | getGravityZ () const |
| Body3D * | newBody (const std::string &bodyType, float x, float y, float z) |
| bodyType: "static" | "kinematic" | "dynamic". Position in meters. | |
| void | destroyBody (Body3D *body) |
| Destroys a body (null is ignored). | |
| void | destroy () |
| Destroys the world and invalidates all wrappers. | |
| int | rayCast (float x1, float y1, float z1, float x2, float y2, float z2) |
| Closest raycast from (x1,y1,z1) to (x2,y2,z2) in meters. Returns hit body id, or -1. Read hit details via getRayHit*. | |
| bool | hasRayHit () const |
| int | getRayHitBodyId () const |
| float | getRayHitX () const |
| float | getRayHitY () const |
| float | getRayHitZ () const |
| float | getRayHitNormalX () const |
| float | getRayHitNormalY () const |
| float | getRayHitNormalZ () const |
| float | getRayHitFraction () const |
| int | queryAABB (float minX, float minY, float minZ, float maxX, float maxY, float maxZ) |
| Query shapes overlapping an AABB in meters (min/max corners). Returns match count; read ids with getQueryBodyId(i). | |
| int | getQueryCount () const |
| Number of bodies hit by the last queryAABB(). | |
| int | getQueryBodyId (int index) const |
| Body id of the i-th query hit. | |
| bool | isValid () const |
| True while the underlying Box3D world is alive. | |
| b3WorldId | raw () const |
| Raw Box3D world id. | |
| void | forgetBody (Body3D *body) |
| Internal: wrapper teardown bookkeeping. | |
| void | forgetShape (Shape3D *shape) |
| int | nextBodyId () |
| Internal: next stable body id. | |
| void | emitContactEvents () |
| Internal: collects Box3D contact events into the event buffers. | |
友元 | |
| class | Body3D |
| class | Shape3D |
详细描述
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixels + Physics.setMeter.
构造及析构函数说明
◆ World3D() [1/2]
| eve::physics::World3D::World3D | ( | float | gravityX, |
| float | gravityY, | ||
| float | gravityZ, | ||
| bool | sleep | ||
| ) |
在文件 World3D.cpp 第 32 行定义.
◆ ~World3D()
| eve::physics::World3D::~World3D | ( | ) |
在文件 World3D.cpp 第 39 行定义.
引用了 destroy().
◆ World3D() [2/2]
|
delete |
成员函数说明
◆ destroy()
| void eve::physics::World3D::destroy | ( | ) |
◆ destroyBody()
| void eve::physics::World3D::destroyBody | ( | Body3D * | body | ) |
◆ emitContactEvents()
| void eve::physics::World3D::emitContactEvents | ( | ) |
Internal: collects Box3D contact events into the event buffers.
在文件 World3D.cpp 第 121 行定义.
引用了 a, b, isValid() , 以及 eve::event::Variant::makeInt().
被这些函数引用 updateFull().
◆ forgetBody()
| void eve::physics::World3D::forgetBody | ( | Body3D * | body | ) |
Internal: wrapper teardown bookkeeping.
在文件 World3D.cpp 第 118 行定义.
引用了 body.
被这些函数引用 eve::physics::Body3D::destroy() , 以及 eve::physics::Body3D::~Body3D().
◆ forgetShape()
| void eve::physics::World3D::forgetShape | ( | Shape3D * | shape | ) |
◆ getGravityX()
| float eve::physics::World3D::getGravityX | ( | ) | const |
在文件 World3D.cpp 第 81 行定义.
引用了 isValid().
◆ getGravityY()
| float eve::physics::World3D::getGravityY | ( | ) | const |
在文件 World3D.cpp 第 86 行定义.
引用了 isValid().
◆ getGravityZ()
| float eve::physics::World3D::getGravityZ | ( | ) | const |
在文件 World3D.cpp 第 91 行定义.
引用了 isValid().
◆ getQueryBodyId()
| int eve::physics::World3D::getQueryBodyId | ( | int | index | ) | const |
Body id of the i-th query hit.
在文件 World3D.cpp 第 204 行定义.
◆ getQueryCount()
|
inline |
Number of bodies hit by the last queryAABB().
◆ getRayHitBodyId()
◆ getRayHitFraction()
◆ getRayHitNormalX()
◆ getRayHitNormalY()
◆ getRayHitNormalZ()
◆ getRayHitX()
◆ getRayHitY()
◆ getRayHitZ()
◆ hasRayHit()
◆ isValid()
| bool eve::physics::World3D::isValid | ( | ) | const |
True while the underlying Box3D world is alive.
在文件 World3D.cpp 第 41 行定义.
被这些函数引用 eve::physics::Body3D::destroy(), emitContactEvents(), getGravityX(), getGravityY(), getGravityZ(), newBody(), queryAABB(), rayCast(), setGravity(), updateFull() , 以及 eve::physics::Body3D::~Body3D().
◆ newBody()
| Body3D * eve::physics::World3D::newBody | ( | const std::string & | bodyType, |
| float | x, | ||
| float | y, | ||
| float | z | ||
| ) |
bodyType: "static" | "kinematic" | "dynamic". Position in meters.
在文件 World3D.cpp 第 98 行定义.
引用了 body, Body3D, isValid(), nextBodyId(), raw(), x, y , 以及 z.
◆ nextBodyId()
| int eve::physics::World3D::nextBodyId | ( | ) |
◆ operator=()
◆ queryAABB()
| int eve::physics::World3D::queryAABB | ( | float | minX, |
| float | minY, | ||
| float | minZ, | ||
| float | maxX, | ||
| float | maxY, | ||
| float | maxZ | ||
| ) |
Query shapes overlapping an AABB in meters (min/max corners). Returns match count; read ids with getQueryBodyId(i).
在文件 World3D.cpp 第 177 行定义.
◆ raw()
|
inline |
◆ rayCast()
| int eve::physics::World3D::rayCast | ( | float | x1, |
| float | y1, | ||
| float | z1, | ||
| float | x2, | ||
| float | y2, | ||
| float | z2 | ||
| ) |
Closest raycast from (x1,y1,z1) to (x2,y2,z2) in meters. Returns hit body id, or -1. Read hit details via getRayHit*.
在文件 World3D.cpp 第 146 行定义.
◆ setGravity()
| void eve::physics::World3D::setGravity | ( | float | gx, |
| float | gy, | ||
| float | gz | ||
| ) |
◆ update()
| void eve::physics::World3D::update | ( | float | dt | ) |
Steps the simulation by dt seconds (default substep count).
在文件 World3D.cpp 第 65 行定义.
引用了 updateFull().
◆ updateFull()
| void eve::physics::World3D::updateFull | ( | float | dt, |
| int | subStepCount | ||
| ) |
Steps with an explicit substep count.
在文件 World3D.cpp 第 67 行定义.
引用了 emitContactEvents() , 以及 isValid().
被这些函数引用 update().
友元及相关函数文档
◆ Body3D
◆ Shape3D
该类的文档由以下文件生成:
- src/modules/physics/World3D.h
- src/modules/physics/World3D.cpp