mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2025-12-28 15:44:33 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67b84dece7 | ||
|
|
8e188c4b7c | ||
|
|
36fbeaeac4 |
51
CONTRIBUTING.md
Normal file
51
CONTRIBUTING.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Quick style guide
|
||||
|
||||
* Put braces on a new line
|
||||
* Float literals should have digits both before and after the decimal.
|
||||
```cpp
|
||||
// Good
|
||||
0.0f;
|
||||
0.5f;
|
||||
1.0f;
|
||||
3.14159f;
|
||||
|
||||
// Bad
|
||||
1.f
|
||||
.0f
|
||||
```
|
||||
* Put macros and return types on a separate line from the function definition:
|
||||
```cpp
|
||||
HINLINE float
|
||||
HMM_MyFunction()
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
* Explicitly initialize variables to zero:
|
||||
```cpp
|
||||
HINLINE float
|
||||
HMM_MyFunction()
|
||||
{
|
||||
float MyFloat = 0.0f;
|
||||
hmm_vec3 MyVector = {0};
|
||||
}
|
||||
```
|
||||
* Put parentheses around the returned value:
|
||||
```cpp
|
||||
HINLINE float
|
||||
HMM_MyFunction()
|
||||
{
|
||||
return (1.0f);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
# Other notes
|
||||
|
||||
* If a new function is defined with different names for different datatypes, also add C++ overloaded versions of the functions. For example, if you have `HMM_LengthVec2(hmm_vec2)` and `HMM_LengthVec3(hmm_vec3)`, also provide `HMM_Length(hmm_vec2)` and `HMM_Length(hmm_vec3)`.
|
||||
|
||||
It is fine for the overloaded versions to call the C versions.
|
||||
* Only use operator overloading for analogous operators in C. That means `+` for vector addition is fine, but no using `^` for cross product or `|` for dot product.
|
||||
* Try to define functions in the same order as the prototypes.
|
||||
* Don't forget that Handmade Math uses column-major order for matrices!
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
HandmadeMath.h v1.1
|
||||
HandmadeMath.h v1.1.2
|
||||
|
||||
This is a single header file with a bunch of useful functions for
|
||||
basic game math operations.
|
||||
@@ -171,6 +171,8 @@
|
||||
(*) Added HMM_QuaternionFromAxisAngle
|
||||
1.1.1
|
||||
(*) Resolved compiler warnings on gcc and g++
|
||||
1.1.2
|
||||
(*) Fixed invalid HMMDEF's in the function definitions
|
||||
|
||||
LICENSE
|
||||
|
||||
@@ -1544,7 +1546,7 @@ HMM_LookAt(hmm_vec3 Eye, hmm_vec3 Center, hmm_vec3 Up)
|
||||
}
|
||||
|
||||
|
||||
HMMDEF hmm_quaternion
|
||||
HINLINE hmm_quaternion
|
||||
HMM_Quaternion(float X, float Y, float Z, float W)
|
||||
{
|
||||
hmm_quaternion Result = {0};
|
||||
@@ -1775,7 +1777,7 @@ HMM_QuaternionFromAxisAngle(hmm_vec3 Axis, float AngleOfRotation)
|
||||
|
||||
#ifdef HANDMADE_MATH_CPP_MODE
|
||||
|
||||
HMMDEF float
|
||||
HINLINE float
|
||||
HMM_Length(hmm_vec2 A)
|
||||
{
|
||||
float Result = 0.0f;
|
||||
@@ -1785,7 +1787,7 @@ HMM_Length(hmm_vec2 A)
|
||||
return(Result);
|
||||
}
|
||||
|
||||
HMMDEF float
|
||||
HINLINE float
|
||||
HMM_Length(hmm_vec3 A)
|
||||
{
|
||||
float Result = 0.0f;
|
||||
@@ -1795,7 +1797,7 @@ HMM_Length(hmm_vec3 A)
|
||||
return(Result);
|
||||
}
|
||||
|
||||
HMMDEF float
|
||||
HINLINE float
|
||||
HMM_Length(hmm_vec4 A)
|
||||
{
|
||||
float Result = 0.0f;
|
||||
@@ -1933,7 +1935,7 @@ HMM_Add(hmm_vec3 Left, hmm_vec3 Right)
|
||||
return (Result);
|
||||
}
|
||||
|
||||
HMMDEF HINLINE hmm_vec4
|
||||
HINLINE hmm_vec4
|
||||
HMM_Add(hmm_vec4 Left, hmm_vec4 Right)
|
||||
{
|
||||
hmm_vec4 Result = {0};
|
||||
|
||||
@@ -12,6 +12,8 @@ _This library is free and will stay free, but if you would like to support devel
|
||||
|
||||
Version | Changes |
|
||||
----------------|----------------|
|
||||
**1.1.2** | Fixed invalid HMMDEF's in the function definitions
|
||||
**1.1.1** | Resolved compiler warnings on gcc and g++
|
||||
**1.1** | Quaternions! |
|
||||
**1.0** | Lots of testing |
|
||||
**0.7** | Added HMM_Vec2, and HMM_Vec4 versions of HMM_LengthSquared, HMM_Length, and HMM_Normalize. |
|
||||
|
||||
Reference in New Issue
Block a user