Commit Graph

56 Commits

Author SHA1 Message Date
Jack Punter
6603c796cc Update test Makefile to use NO_SIMD over NO_SSE 2023-12-12 01:53:43 +00:00
Ben Visness
e210d8729b Add HMM_RotateV2 2023-11-03 11:34:49 -05:00
dev_dwarf
a1c84320f9 Style tweaks to RotateV3Q + axis angle variant 2023-10-31 13:09:20 -06:00
Olivier Perret
149c18d449 Add HMM_RotateQV3(), for rotating a vec3 by a quaternion 2023-10-29 18:32:09 +01:00
Ben Visness
422bc588e9 Fix inverse perspective 2023-02-20 13:03:46 -06:00
Ben Visness
beb837a3c6 Tweak docs, add tests, find bugs 2023-02-02 19:18:24 -06:00
Ben Visness
22d743ce3d Change naming convention for NO/ZO (the update tool needs updating) 2023-01-26 22:27:09 -06:00
Logan Forman
d4918a514e Drop Projection Matrix Config; Make explicit. (#154)
* Add N0/Z0 projection

Remove configuration macro

* Update update_hmm.c

Co-authored-by: Ben Visness <bvisness@users.noreply.github.com>
2023-01-26 21:01:31 -06:00
dev_dwarf
7e493a5481 Fix LH perspective matrix
Off by a sign before.
2023-01-26 19:55:21 -06:00
Ben Visness
f106a0f5f3 Style and docs pass for release
Remove V2I, V3I, V4I (and style changes)

Totally useless.

Add update tool, update docs

Tweak docs

Create ci.yml

Big style pass

Maybe fix CI on Windows

Report coverage errors

Fix a missing coverage case

Try setting up MSVC another way

Update readmes

Fix remaining use of the name UpdateTool
2023-01-22 21:46:22 -06:00
Logan Forman
c24e4ff873 HMM2.0 (#149)
These changes were all made by @dev-dwarf. Many thanks for his work on this!

* Renaming

* First Pass on 2.0UpdateTool

* Another pass on UpdateTool, changed name

* Another pass on UpdateTool, changed name

* Do Renaming

* Working on Angles Consistency

* Passing Coverage

* Remove unused arc-tangent functions

* Change macro defaults

By default if user is overriding trig functions assume their input and internal units are the same.

* wrap in AngleDeg instead of AngleRad

* Remove HMM_PREFIX configuration

* Fix for Slerp

https://discord.com/channels/239737791225790464/489148972305350656/1055167647274246265

Justified by most implementations of Slerp. EX: http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/

* Handedness Changes

* More renaming. C11 _Generics

Generics enable by default when available (see lines 97-104). User can also force them by defining HANDMADE_MATH_C11_GENERICS

Also fixed some missed things w.r.t renaming. My old tool didn't catch cases like HMM_MultiplyVec3f needing to be HMM_MulV3F instead of HMM_MulV3f.

* Reuse more SSE codepaths for Quaternions

Also improved quaternion tests. More work could be done here, see discussion here about optimizing slerp: https://discord.com/channels/239737791225790464/489148972305350656/1055167647274246265

* Just saving these alternate versions of SLerp

* Reduce V4/M4 Linear Comb. codepaths

* Simple implementation of 2x2 and 3x3 basic matrix operations.

Also renamed Transpose to TransposeM4, so that we can have TransposeM2,M3

* Norm is dead! Long live Norm!

As can be seen from the tests, precision has declined quite a bit from using the FastNorm implementations for various things. We can only guarantee about 0.001f precision for anything where a norm happens now. If this is undesired we can change back easily.

* Started work on Matrix Inverses

TODO: Tests for simple 4x4 Inverses

* Matrix Inverses + Tests

* Generics for Matrices and Rename MXd/f functions

* Fixes + Better Output for UpdateTool

* I think I count as a contributor : )

* Ported UpdateTool, Inlined my library code.

* Moved tool to different repo

https://github.com/dev-dwarf/HMM2.0UpdateTool

* Remove small test change

* Found some more references to atan functions

* Standardize angle function names, use short names

* Remove other slerp comments

* woops that wasnt meant to be commited.

* Finish changing ToRadians to ToRad

* Fix [] overloads

per https://discord.com/channels/239737791225790464/600063880533770251/1051600188302692402

* Tests for 2x2, 3x3 Matrices and Other Matrix Ops

* Add an option to use Z: [0, 1] range for projection matrices.

This will make HMM more convenient to use with other graphics APIs such as Direct3d and Metal.

* Update test imports

* #if should've been #ifdef!

* Implement requested changes
2023-01-22 17:34:50 -06:00
Zak Strange
d69a859d73 Fully inlined HandmadeMath.h (#139)
* Fully inlined HandmadeMath.h, renamed test.bat to run_test_msvc.bat, and introduced run_test_clang.bat

* General Cleanup
2021-08-31 17:10:46 -07:00
Zak Strange
1d82b4f0bc Unary minus vectors (#130)
* Unary Minus operator for vec2, vec3, and vec4

* Update README.md

Co-authored-by: zak <zak@DESKTOP-V1AQ0IT>
2021-03-06 18:39:17 -06:00
Ben Visness
15bef820db Add ability to customize HMM_ prefix (#114)
* Add prefix macro and use it everywhere

* Add lightweight test for prefix

* Add a little doc blurb
2020-04-06 09:57:10 -05:00
Ben Visness
fe32f081f2 Suppress float equality warnings (#113)
* Add a macro to help with deprecations

* Suppress warnings about float equality
2020-04-06 09:55:40 -05:00
Ben Visness
a9b08b9147 Run tests on Linux, macOS, and Windows (#105)
* Try running tests on all three operating systems

* Try adding an MSVC build

* Make tests work on Windows

* Try reconfiguring Travis for this

* Maybe it's because we're in git bash

* Try explicitly doing something else for travis

* Remove a part I think is unnecessary

* Run the test EXEs as they compile
2019-07-31 17:22:33 -05:00
Ben Visness
f376f2a2a7 Add test coverage macros (#104)
* Add coverage features and add it, laboriously, to everything

* Fix easy tests

* Add tests for != operators

* Clean up test framework a little

* Add documentation of coverage macros

* Fix tests for mat4 to quaternion

* Slightly improve formatting of coverage output

* Trailing whitespace must die
2019-07-31 16:43:56 -05:00
Ben Visness
78e6feea82 Add HMM_Mat4ToQuaternion (#103)
* Add mat4 to quaternion method

* Capitalize variables
2019-07-31 16:38:03 -05:00
Ben Visness
93e56be543 Use vertical instead of horizontal FOV in HMM_Perspective (#101)
* Use vertical instead of horizontal FOV

* Update readme

* Fix tests
2019-07-10 11:29:51 -05:00
Ben Visness
f7c8e1f7d1 Add fast vector normalization (#94)
* Add fast normalization routines

* Update readme and remove version history from main file

* Update version at top of file
2018-11-29 22:02:41 -08:00
Ben Visness
295f6c476f Rename Rows to Columns on hmm_mat4 (#91) 2018-08-17 11:02:44 -07:00
Ben Visness
4e2f47db55 Add array subscript operators for all types (#88)
* Add array subscript operators for all types

* Taking the parameter for the operator[] as a reference. This should allow it to be inlined

* I guess you can't do that.

* Update version and readme
2018-06-10 15:26:48 -04:00
Ben Visness
bee0e0c569 WIP: Properly initialize all elements of LookAt matrix (#84)
* Properly initialize all elements of LookAt matrix

* Update version and readme

* Add a test for LookAt

good enough
2018-06-03 18:42:09 -05:00
Ben Visness
f8b3a84cec WIP: Make tests quite a lot nicer (#81)
Make tests quite a lot nicer
2018-02-18 14:19:31 -06:00
Ben Visness
afd726ab0b Automatically include C++ definitions (#67) 2017-08-02 10:12:06 -05:00
Ben Visness
efd9f2f4b7 Matrix Multiply SSE (#65)
* SSEd HMM_MultiplyMat4 and HMM_Transpose. And added HMM_LinearCombineSSE

* Maybe Travis doesn't support SSE?

* Fix compile process so the SSE option is consistently defined

* Fix link error

* Documentation

* Added function prototype for operator ==

* Added != operator for hmm_vec2, hmm_vec3, hmm_vec4

* Add C versions of equality checks

Also made the C++ tests actually run...😳

* Update documentation
2017-07-16 21:19:34 -07:00
Zak Strange
70ac2b7e5b 1.1.5 (#64)
* Added Width, and Height to hmm_vec2, and fixed SqrtF when compiling without the CRT

* Syntax error

* Test all the vector access methods
2017-06-14 20:49:44 -07:00
Emil Lauridsen
98f535aeec Handle zero-vector normalization. (#63)
* Handle zero-vector normalization.

When normalizing a vectors, we have to check whether vector length is
not zero, to avoid dividing by zero when normalizing zero-vectors.

* Test for normalization of zero vectors
2017-06-13 11:21:55 -05:00
Ben Visness
364569abe9 Fix wrong name for square root function 2017-06-09 10:43:11 -05:00
Ben Visness
a9972e71da Test both with and without SSE 2017-06-09 10:37:38 -05:00
Ben Visness
cf606db217 Test in both C and C++ (#58)
* Switch to custom unit testing that is compatible with C

* Remove Google Test framework

* Attempt to fix missing math functions

* Link against C math library

* Try forcing c99 again

* Include -lm at compile time

* Move -lm argument to the end

* Update README and gitignore
2017-04-07 08:47:54 -05:00
Ben Visness
ad3039186d Initial quaternion implementation (#49)
* Various changes, and started work on Quaternions

* Worked on Quaternions (#46)

* Working on quaternions

* Finished operations, onto slerp

* Working on slerp

* Finished slerp implementation, next is NLerp

* Cleaned HandmadeMath.cpp

* Removed gbmath includes

* fixed minor issue.

* Fixed function names

* Fixed DotQuat call

* Did a style check

* Double Style Check

* Triple Style Check

* Fixed all the bullshit I did wrong

* Fixed more bs

* Added new functions

* Finished function implements

* Fixed some compile errors

* Fixed UTF-8 Error

* Added in most operator overrides

* Changed instances of HMM_PI to HMM_Pi32

* Fixed a warning

* Fixed a major issue with quaternion to matrix function where rotations about the y axis caused strange warping.

* Revert "Fixed a warning"

This reverts commit 043decab0d.

* Revert repo

* Fixed Quaternion to Matrix function.

* Fixed some prevalent issues, and now pulls triganometric funcitions from the std instead of implementing them.

* Fixed tab formatting, added in reverse multiplication function with Quaternions

* Removed error suppression cleanup, as it was causing more warnings. . .

* Added documentation

* Changed ATanf2 to ATan2f

* Fixed some typos and added additional documentation (#48)

* Add tests for quaternions

* Remove (very wrong) quaternion division in favor of multiplying by inverse

* Put back newlines at ends of files

* Make tweaks for PR

* Add assigning arithmetic operators for quaternions

* Add NLerp

Just to make Jonathan Blow happy: http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/

* Rearrange parameters of HMM_Slerp

It now matches HMM_Lerp and HMM_NLerp.

* Update README.md
2017-01-04 16:25:12 -08:00
Ben Visness
eac00c2aa1 Fix tests for vector ops
Tests for vector ops now test all three kinds of vectors (where
applicable), and test both the C and C++ versions of the functions.
2016-09-06 08:54:35 -05:00
Zak Strange
64830b6bbd 0.7 initial commit 2016-09-05 21:04:30 -07:00
Matt Mascarenhas
7e42f3d7c8 Allow HMM_PowerF to try and compute negative bases 2016-08-31 03:16:13 +01:00
Matt Mascarenhas
fcc3052ed4 Make the PowerF() tests more forgiving 2016-08-31 02:37:37 +01:00
Matt Mascarenhas
5e15bfb6b7 Insert the missing closing brace 2016-08-31 02:28:10 +01:00
Matt Mascarenhas
bb03df3fc6 Merge remote-tracking branch 'upstream/master' 2016-08-31 02:16:51 +01:00
Matt Mascarenhas
5b0e0969c2 Add tests for PowerF() 2016-08-31 01:57:20 +01:00
Zak Strange
59db096948 Merge pull request #42 from StrangeZak/lerp
Add header and test for HMM_Lerp
2016-08-30 20:32:07 -04:00
Ben Visness
2d729a3b34 Add header and test for HMM_Lerp 2016-08-30 19:19:04 -05:00
Ben Visness
2ea471b3ce Add HMM_Transpose 2016-08-30 18:53:53 -05:00
Ben Visness
722c48ddf8 Add back tests for HMM_Power and HMM_Clamp 2016-08-30 16:11:43 -05:00
Ben Visness
c7c801c51a Test overloaded versions of HMM_Dot 2016-08-30 15:56:15 -05:00
Zak Strange
fdef0ae0e1 Added missing tests to hmm_test.cpp 2016-08-30 13:43:17 -07:00
Zak Strange
c2dd9f19a7 Fixed more issues in Unit test 2016-08-30 13:33:15 -07:00
Zak Strange
c147a8bd53 Updated Unit Test 2016-08-30 13:30:52 -07:00
Ben Visness
60cde5116e Correct rotation test to be right-handed 2016-08-28 23:11:40 -05:00
Ben Visness
3b0c8befbb Add tests for projection
(Zak should review)
2016-08-28 23:07:59 -05:00
Ben Visness
7f7fc4e0d6 Add tests for transformations 2016-08-28 01:44:05 -05:00