Regular 3D signed-distance grid for terrain and voxel collision queries. Negative samples are solid, positive samples are empty. Samples are stored at grid vertices and queried with trilinear interpolation. 更多...
#include <DistanceField3D.h>
Public 成员函数 | |
| DistanceField3D (int width, int height, int depth, float cellSize, float originX, float originY, float originZ, float outsideDistance) | |
| Distance field 3 d. | |
| void | setDistances (const std::vector< float > &distances) |
| Replace every sample in x-fastest, then y, then z order. | |
| void | fill (float distance) |
| Set every grid sample to the same finite distance. | |
| void | setDistanceRegion (int x, int y, int z, int width, int height, int depth, const std::vector< float > &distances) |
| Atomically replace a grid subregion in x-fastest, then y, then z order. | |
| void | fillRegion (int x, int y, int z, int width, int height, int depth, float distance) |
| Fill an in-bounds grid subregion with one finite signed distance. | |
| void | setDistance (int x, int y, int z, float distance) |
| Set a signed-distance sample at a grid vertex. | |
| float | getDistance (int x, int y, int z) const |
| Read a grid vertex; out-of-range vertices return the outside distance. | |
| float | sample (float x, float y, float z) const |
| Trilinearly sample the field in world coordinates. | |
| int | getWidth () const |
| Number of grid vertices along the X axis. | |
| int | getHeight () const |
| Number of grid vertices along the Y axis. | |
| int | getDepth () const |
| Number of grid vertices along the Z axis. | |
| int | getSampleCount () const |
| Total number of signed-distance samples. | |
| float | getCellSize () const |
| World-space distance between adjacent grid vertices. | |
| float | getOriginX () const |
| World-space X coordinate of grid vertex (0,0,0). | |
| float | getOriginY () const |
| World-space Y coordinate of grid vertex (0,0,0). | |
| float | getOriginZ () const |
| World-space Z coordinate of grid vertex (0,0,0). | |
| float | getOutsideDistance () const |
| Distance returned for world samples outside the grid. | |
| unsigned int | getRevision () const |
| Monotonic wrapping counter incremented once after each successful mutation. | |
| void | sampleNormal (float x, float y, float z) |
| Estimate the normalized outward field gradient at a world position. | |
| float | getNormalX () const |
| X component of the most recently sampled collision normal. | |
| float | getNormalY () const |
| Y component of the most recently sampled collision normal. | |
| float | getNormalZ () const |
| Z component of the most recently sampled collision normal. | |
| bool | checkSphere (float x, float y, float z, float radius) |
| Test a sphere against the solid (distance <= radius). | |
| bool | checkCapsule (float ax, float ay, float az, float bx, float by, float bz, float radius) |
| Test a capsule defined by two sphere centers against the solid. | |
| bool | castSphere (float x, float y, float z, float radius, float deltaX, float deltaY, float deltaZ) |
| Sweep a sphere through the field and cache the earliest contact. | |
| bool | castCapsule (float ax, float ay, float az, float bx, float by, float bz, float radius, float deltaX, float deltaY, float deltaZ) |
| Sweep a capsule through the field and cache the earliest contact. | |
| bool | moveCapsule (float ax, float ay, float az, float bx, float by, float bz, float radius, float deltaX, float deltaY, float deltaZ) |
| Resolve a capsule displacement against the field with sliding and depenetration. The capsule coordinates are not stored; apply getMoverDeltaX/Y/Z to both endpoints. | |
| void | setMoverUp (float x, float y, float z) |
| Set the normalized reference-up direction used for ground classification. | |
| void | setMoverSlopeLimit (float degrees) |
| Set the maximum walkable slope angle in degrees, clamped to [0, 89.9]. | |
| void | setMoverSkinWidth (float width) |
| Set the non-negative separation retained from surfaces by moveCapsule. | |
| float | getMoverSkinWidth () const |
| Current mover separation from collision surfaces. | |
| void | setMoverGroundSnap (float distance) |
| Set the non-negative distance used to snap onto walkable ground after movement. | |
| float | getMoverGroundSnap () const |
| Current post-move ground-snap distance. | |
| void | setMoverStepHeight (float height) |
| Set the maximum non-negative ledge height automatically climbed by moveCapsule. | |
| float | getMoverStepHeight () const |
| Current automatic step height; zero disables step climbing. | |
| float | getCollisionDistance () const |
| Signed clearance from the last check (negative means penetration). | |
| float | getCollisionX () const |
| X coordinate of the closest sampled point from the last collision check. | |
| float | getCollisionY () const |
| Y coordinate of the closest sampled point from the last collision check. | |
| float | getCollisionZ () const |
| Z coordinate of the closest sampled point from the last collision check. | |
| float | getSurfaceX () const |
| X coordinate of the projected signed-distance-field surface point. | |
| float | getSurfaceY () const |
| Y coordinate of the projected signed-distance-field surface point. | |
| float | getSurfaceZ () const |
| Z coordinate of the projected signed-distance-field surface point. | |
| float | getShapeContactX () const |
| X coordinate on the sphere or capsule surface along the contact normal. | |
| float | getShapeContactY () const |
| Y coordinate on the sphere or capsule surface along the contact normal. | |
| float | getShapeContactZ () const |
| Z coordinate on the sphere or capsule surface along the contact normal. | |
| float | getPenetrationDepth () const |
| Non-negative overlap depth from the most recent overlap, cast, or move query. | |
| float | getCastFraction () const |
| Fraction in [0,1] of the requested displacement at the last cast hit. | |
| float | getCastDistance () const |
| World-space travel distance at the last cast hit. | |
| bool | didCastStartInside () const |
| Whether the most recent cast began overlapping the solid. | |
| float | getMoverDeltaX () const |
| Resolved X displacement from the most recent moveCapsule call. | |
| float | getMoverDeltaY () const |
| Resolved Y displacement from the most recent moveCapsule call. | |
| float | getMoverDeltaZ () const |
| Resolved Z displacement from the most recent moveCapsule call. | |
| float | getMoverNormalX () const |
| X component of the most recent blocking or recovery normal. | |
| float | getMoverNormalY () const |
| Y component of the most recent blocking or recovery normal. | |
| float | getMoverNormalZ () const |
| Z component of the most recent blocking or recovery normal. | |
| int | getMoverIterations () const |
| Number of solver passes used by the most recent moveCapsule call. | |
| bool | isMoverGrounded () const |
| Whether the latest move encountered a normal within the walkable slope limit. | |
| float | getMoverGroundDot () const |
| Greatest dot product between mover Up and a normal from the latest move. | |
| bool | didMoverHitWall () const |
| Whether the latest move encountered a non-walkable contact normal. | |
详细描述
Regular 3D signed-distance grid for terrain and voxel collision queries. Negative samples are solid, positive samples are empty. Samples are stored at grid vertices and queried with trilinear interpolation.
在文件 DistanceField3D.h 第 16 行定义.
构造及析构函数说明
◆ DistanceField3D()
| eve::physics::DistanceField3D::DistanceField3D | ( | int | width, |
| int | height, | ||
| int | depth, | ||
| float | cellSize, | ||
| float | originX, | ||
| float | originY, | ||
| float | originZ, | ||
| float | outsideDistance | ||
| ) |
成员函数说明
◆ castCapsule()
| bool eve::physics::DistanceField3D::castCapsule | ( | float | ax, |
| float | ay, | ||
| float | az, | ||
| float | bx, | ||
| float | by, | ||
| float | bz, | ||
| float | radius, | ||
| float | deltaX, | ||
| float | deltaY, | ||
| float | deltaZ | ||
| ) |
◆ castSphere()
| bool eve::physics::DistanceField3D::castSphere | ( | float | x, |
| float | y, | ||
| float | z, | ||
| float | radius, | ||
| float | deltaX, | ||
| float | deltaY, | ||
| float | deltaZ | ||
| ) |
Sweep a sphere through the field and cache the earliest contact.
- 参数
-
x Initial sphere-center X coordinate. y Initial sphere-center Y coordinate. z Initial sphere-center Z coordinate. radius Sphere radius. deltaX Sweep displacement along X. deltaY Sweep displacement along Y. deltaZ Sweep displacement along Z.
- 返回
- True when the swept sphere starts in or reaches the solid.
在文件 DistanceField3D.cpp 第 265 行定义.
引用了 previous, px, py, pz, radius, sample(), steps, x, y , 以及 z.
◆ checkCapsule()
| bool eve::physics::DistanceField3D::checkCapsule | ( | float | ax, |
| float | ay, | ||
| float | az, | ||
| float | bx, | ||
| float | by, | ||
| float | bz, | ||
| float | radius | ||
| ) |
Test a capsule defined by two sphere centers against the solid.
在文件 DistanceField3D.cpp 第 210 行定义.
引用了 ax, ay, az, best, bx, by, bz, radius , 以及 sampleNormal().
被这些函数引用 moveCapsule().
◆ checkSphere()
| bool eve::physics::DistanceField3D::checkSphere | ( | float | x, |
| float | y, | ||
| float | z, | ||
| float | radius | ||
| ) |
◆ didCastStartInside()
|
inline |
Whether the most recent cast began overlapping the solid.
在文件 DistanceField3D.h 第 151 行定义.
◆ didMoverHitWall()
|
inline |
Whether the latest move encountered a non-walkable contact normal.
在文件 DistanceField3D.h 第 171 行定义.
◆ fill()
| void eve::physics::DistanceField3D::fill | ( | float | distance | ) |
◆ fillRegion()
| void eve::physics::DistanceField3D::fillRegion | ( | int | x, |
| int | y, | ||
| int | z, | ||
| int | width, | ||
| int | height, | ||
| int | depth, | ||
| float | distance | ||
| ) |
◆ getCastDistance()
|
inline |
World-space travel distance at the last cast hit.
在文件 DistanceField3D.h 第 149 行定义.
◆ getCastFraction()
|
inline |
Fraction in [0,1] of the requested displacement at the last cast hit.
在文件 DistanceField3D.h 第 147 行定义.
◆ getCellSize()
|
inline |
World-space distance between adjacent grid vertices.
在文件 DistanceField3D.h 第 56 行定义.
◆ getCollisionDistance()
|
inline |
Signed clearance from the last check (negative means penetration).
在文件 DistanceField3D.h 第 125 行定义.
◆ getCollisionX()
|
inline |
X coordinate of the closest sampled point from the last collision check.
在文件 DistanceField3D.h 第 127 行定义.
◆ getCollisionY()
|
inline |
Y coordinate of the closest sampled point from the last collision check.
在文件 DistanceField3D.h 第 129 行定义.
◆ getCollisionZ()
|
inline |
Z coordinate of the closest sampled point from the last collision check.
在文件 DistanceField3D.h 第 131 行定义.
◆ getDepth()
|
inline |
Number of grid vertices along the Z axis.
在文件 DistanceField3D.h 第 52 行定义.
◆ getDistance()
| float eve::physics::DistanceField3D::getDistance | ( | int | x, |
| int | y, | ||
| int | z | ||
| ) | const |
◆ getHeight()
|
inline |
Number of grid vertices along the Y axis.
在文件 DistanceField3D.h 第 50 行定义.
◆ getMoverDeltaX()
|
inline |
Resolved X displacement from the most recent moveCapsule call.
在文件 DistanceField3D.h 第 153 行定义.
◆ getMoverDeltaY()
|
inline |
Resolved Y displacement from the most recent moveCapsule call.
在文件 DistanceField3D.h 第 155 行定义.
◆ getMoverDeltaZ()
|
inline |
Resolved Z displacement from the most recent moveCapsule call.
在文件 DistanceField3D.h 第 157 行定义.
◆ getMoverGroundDot()
|
inline |
Greatest dot product between mover Up and a normal from the latest move.
在文件 DistanceField3D.h 第 169 行定义.
◆ getMoverGroundSnap()
|
inline |
Current post-move ground-snap distance.
在文件 DistanceField3D.h 第 119 行定义.
◆ getMoverIterations()
|
inline |
Number of solver passes used by the most recent moveCapsule call.
在文件 DistanceField3D.h 第 165 行定义.
◆ getMoverNormalX()
|
inline |
X component of the most recent blocking or recovery normal.
在文件 DistanceField3D.h 第 159 行定义.
◆ getMoverNormalY()
|
inline |
Y component of the most recent blocking or recovery normal.
在文件 DistanceField3D.h 第 161 行定义.
◆ getMoverNormalZ()
|
inline |
Z component of the most recent blocking or recovery normal.
在文件 DistanceField3D.h 第 163 行定义.
◆ getMoverSkinWidth()
|
inline |
Current mover separation from collision surfaces.
在文件 DistanceField3D.h 第 115 行定义.
◆ getMoverStepHeight()
|
inline |
Current automatic step height; zero disables step climbing.
在文件 DistanceField3D.h 第 123 行定义.
◆ getNormalX()
|
inline |
X component of the most recently sampled collision normal.
在文件 DistanceField3D.h 第 71 行定义.
◆ getNormalY()
|
inline |
Y component of the most recently sampled collision normal.
在文件 DistanceField3D.h 第 73 行定义.
◆ getNormalZ()
|
inline |
Z component of the most recently sampled collision normal.
在文件 DistanceField3D.h 第 75 行定义.
◆ getOriginX()
|
inline |
World-space X coordinate of grid vertex (0,0,0).
在文件 DistanceField3D.h 第 58 行定义.
◆ getOriginY()
|
inline |
World-space Y coordinate of grid vertex (0,0,0).
在文件 DistanceField3D.h 第 60 行定义.
◆ getOriginZ()
|
inline |
World-space Z coordinate of grid vertex (0,0,0).
在文件 DistanceField3D.h 第 62 行定义.
◆ getOutsideDistance()
|
inline |
Distance returned for world samples outside the grid.
在文件 DistanceField3D.h 第 64 行定义.
◆ getPenetrationDepth()
|
inline |
Non-negative overlap depth from the most recent overlap, cast, or move query.
在文件 DistanceField3D.h 第 145 行定义.
◆ getRevision()
|
inline |
Monotonic wrapping counter incremented once after each successful mutation.
在文件 DistanceField3D.h 第 66 行定义.
◆ getSampleCount()
|
inline |
Total number of signed-distance samples.
在文件 DistanceField3D.h 第 54 行定义.
◆ getShapeContactX()
|
inline |
X coordinate on the sphere or capsule surface along the contact normal.
在文件 DistanceField3D.h 第 139 行定义.
◆ getShapeContactY()
|
inline |
Y coordinate on the sphere or capsule surface along the contact normal.
在文件 DistanceField3D.h 第 141 行定义.
◆ getShapeContactZ()
|
inline |
Z coordinate on the sphere or capsule surface along the contact normal.
在文件 DistanceField3D.h 第 143 行定义.
◆ getSurfaceX()
|
inline |
X coordinate of the projected signed-distance-field surface point.
在文件 DistanceField3D.h 第 133 行定义.
◆ getSurfaceY()
|
inline |
Y coordinate of the projected signed-distance-field surface point.
在文件 DistanceField3D.h 第 135 行定义.
◆ getSurfaceZ()
|
inline |
Z coordinate of the projected signed-distance-field surface point.
在文件 DistanceField3D.h 第 137 行定义.
◆ getWidth()
|
inline |
Number of grid vertices along the X axis.
在文件 DistanceField3D.h 第 48 行定义.
◆ isMoverGrounded()
|
inline |
Whether the latest move encountered a normal within the walkable slope limit.
在文件 DistanceField3D.h 第 167 行定义.
◆ moveCapsule()
| bool eve::physics::DistanceField3D::moveCapsule | ( | float | ax, |
| float | ay, | ||
| float | az, | ||
| float | bx, | ||
| float | by, | ||
| float | bz, | ||
| float | radius, | ||
| float | deltaX, | ||
| float | deltaY, | ||
| float | deltaZ | ||
| ) |
Resolve a capsule displacement against the field with sliding and depenetration. The capsule coordinates are not stored; apply getMoverDeltaX/Y/Z to both endpoints.
- 返回
- True when solid geometry constrained or depenetrated the capsule.
在文件 DistanceField3D.cpp 第 407 行定义.
引用了 a, ax, ay, az, b, bx, by, bz, castCapsule(), checkCapsule(), dx, dy, dz, iterations, length, moveCapsule(), normal, nx, ny, nz, planes, position, radius, state, up, value, x, y , 以及 z.
被这些函数引用 moveCapsule().
◆ sample()
| float eve::physics::DistanceField3D::sample | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) | const |
Trilinearly sample the field in world coordinates.
在文件 DistanceField3D.cpp 第 126 行定义.
引用了 a, b, getDistance(), t, x, y , 以及 z.
被这些函数引用 castSphere() , 以及 sampleNormal().
◆ sampleNormal()
| void eve::physics::DistanceField3D::sampleNormal | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) |
◆ setDistance()
| void eve::physics::DistanceField3D::setDistance | ( | int | x, |
| int | y, | ||
| int | z, | ||
| float | distance | ||
| ) |
◆ setDistanceRegion()
| void eve::physics::DistanceField3D::setDistanceRegion | ( | int | x, |
| int | y, | ||
| int | z, | ||
| int | width, | ||
| int | height, | ||
| int | depth, | ||
| const std::vector< float > & | distances | ||
| ) |
Atomically replace a grid subregion in x-fastest, then y, then z order.
- 参数
-
x First grid-vertex X index. y First grid-vertex Y index. z First grid-vertex Z index. width Number of vertices along X; must be positive and in bounds. height Number of vertices along Y; must be positive and in bounds. depth Number of vertices along Z; must be positive and in bounds. distances Exactly width*height*depth finite samples.
在文件 DistanceField3D.cpp 第 73 行定义.
引用了 count, depth, distance, height, index, source, width, x, y , 以及 z.
◆ setDistances()
| void eve::physics::DistanceField3D::setDistances | ( | const std::vector< float > & | distances | ) |
Replace every sample in x-fastest, then y, then z order.
在文件 DistanceField3D.cpp 第 56 行定义.
引用了 distance.
◆ setMoverGroundSnap()
| void eve::physics::DistanceField3D::setMoverGroundSnap | ( | float | distance | ) |
Set the non-negative distance used to snap onto walkable ground after movement.
在文件 DistanceField3D.cpp 第 393 行定义.
引用了 distance.
◆ setMoverSkinWidth()
| void eve::physics::DistanceField3D::setMoverSkinWidth | ( | float | width | ) |
Set the non-negative separation retained from surfaces by moveCapsule.
在文件 DistanceField3D.cpp 第 387 行定义.
引用了 width.
◆ setMoverSlopeLimit()
| void eve::physics::DistanceField3D::setMoverSlopeLimit | ( | float | degrees | ) |
Set the maximum walkable slope angle in degrees, clamped to [0, 89.9].
在文件 DistanceField3D.cpp 第 380 行定义.
引用了 degrees.
◆ setMoverStepHeight()
| void eve::physics::DistanceField3D::setMoverStepHeight | ( | float | height | ) |
Set the maximum non-negative ledge height automatically climbed by moveCapsule.
在文件 DistanceField3D.cpp 第 400 行定义.
引用了 height.
◆ setMoverUp()
| void eve::physics::DistanceField3D::setMoverUp | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) |
Set the normalized reference-up direction used for ground classification.
在文件 DistanceField3D.cpp 第 369 行定义.
该类的文档由以下文件生成:
- src/modules/physics/DistanceField3D.h
- src/modules/physics/DistanceField3D.cpp