Skip to main content

Inb4 Clip Space

· 2 min read

Updates from the commit log

helios now implements core vector operations, including subtraction for directional calculations, dot product for scalar projections, and cross product for normal vector computation and creating orthonormal bases, respectively. The cross product implementation utilizes constexpr specifications for compile-time evaluation when operands are constant expressions. The lookAt function constructs view matrices for camera-space transformations following standard computer graphics methodology. The implementation creates an orthonormal basis from eye, target, and up vectors, then formulates the change-of-basis matrix with integrated translation components for camera positioning to the origin.

Performance and Technical Considerations

Benchmarking was implemented for the cross product and lookAt functions due to their frequent invocation in rendering contexts. The results validate the effectiveness of constexpr optimizations, but I'm not close to glm in this regard, as their optimizations go several steps further than helios' userland code implementation.

BenchmarkTimeCPUIterations
BM_vec3Constructor/real_time5.04 ns4.89 ns127,890,789
BM_glm_vec3Constructor/real_time4.25 ns4.07 ns161,100,528
BM_vec3Cross/real_time20.1 ns19.7 ns34,872,072
BM_glm_vec3Cross/real_time7.28 ns7.29 ns94,326,910
BM_vec3Dot/real_time12.2 ns11.8 ns57,045,623
BM_glm_vec3Dot/real_time10.1 ns9.81 ns70,071,613

Static

Some symbol collisions from duplicate test function definitions happened during compilation. I remembered from C that static limits symbol scope to file level, which resolved the issue without further changes - it's always nice when simple concepts provide quick solutions without requiring the introduction of new namespaces.