Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 1018 Bytes

File metadata and controls

22 lines (18 loc) · 1018 Bytes

ext-math

Native C++23 PHP extension porting pocketmine\math (Vector3, Vector2, AxisAlignedBB, Matrix, Facing, VoxelRayTrace, …). Drop-in replacement for the composer package: same FQCNs, same signatures, real public properties.

What it's for: all the game geometry — entity positions, collision boxes (AABB), ray tracing (picking the block you look at), movement math. These run millions of times per tick, so moving them to compiled code is the single biggest CPU win on a busy server.

Benchmarks (PHP 8.4 ZTS, GCC 15, -O2)

Operation PHP Native Speedup
Vector3::add 103 ns 57 ns 1.8×
Vector3::distanceSquared 46 ns 27 ns 1.7×
Vector3::getSide 156 ns 54 ns 2.9×
Vector3::floor 172 ns 46 ns 3.7×
AABB::intersectsWith 63 ns 31 ns 2.0×
AABB::calculateXOffset 53 ns 33 ns 1.6×
AABB::calculateIntercept 1100 ns 104 ns 10.6×
VoxelRayTrace (~20 blocks) 4576 ns 2316 ns 2.0×