mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2025-12-30 08:24:33 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67b84dece7 | ||
|
|
8e188c4b7c | ||
|
|
36fbeaeac4 | ||
|
|
666f7e3325 |
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
|
This is a single header file with a bunch of useful functions for
|
||||||
basic game math operations.
|
basic game math operations.
|
||||||
@@ -153,7 +153,6 @@
|
|||||||
(*) Added HMM_NormalizeVec4
|
(*) Added HMM_NormalizeVec4
|
||||||
1.0
|
1.0
|
||||||
(*) Lots of testing!
|
(*) Lots of testing!
|
||||||
|
|
||||||
1.1
|
1.1
|
||||||
(*) Quaternion support
|
(*) Quaternion support
|
||||||
(*) Added type hmm_quaternion
|
(*) Added type hmm_quaternion
|
||||||
@@ -170,6 +169,10 @@
|
|||||||
(*) Added HMM_Slerp
|
(*) Added HMM_Slerp
|
||||||
(*) Added HMM_QuaternionToMat4
|
(*) Added HMM_QuaternionToMat4
|
||||||
(*) Added HMM_QuaternionFromAxisAngle
|
(*) 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
|
LICENSE
|
||||||
|
|
||||||
@@ -206,7 +209,8 @@
|
|||||||
#pragma warning(disable:4201)
|
#pragma warning(disable:4201)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __clang__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wgnu-anonymous-struct"
|
#pragma GCC diagnostic ignored "-Wgnu-anonymous-struct"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -657,6 +661,10 @@ HMMDEF hmm_quaternion &operator/=(hmm_quaternion &Left, float Right);
|
|||||||
|
|
||||||
#endif /* HANDMADE_MATH_CPP */
|
#endif /* HANDMADE_MATH_CPP */
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* HANDMADE_MATH_H */
|
#endif /* HANDMADE_MATH_H */
|
||||||
|
|
||||||
#ifdef HANDMADE_MATH_IMPLEMENTATION
|
#ifdef HANDMADE_MATH_IMPLEMENTATION
|
||||||
@@ -1538,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(float X, float Y, float Z, float W)
|
||||||
{
|
{
|
||||||
hmm_quaternion Result = {0};
|
hmm_quaternion Result = {0};
|
||||||
@@ -1769,7 +1777,7 @@ HMM_QuaternionFromAxisAngle(hmm_vec3 Axis, float AngleOfRotation)
|
|||||||
|
|
||||||
#ifdef HANDMADE_MATH_CPP_MODE
|
#ifdef HANDMADE_MATH_CPP_MODE
|
||||||
|
|
||||||
HMMDEF float
|
HINLINE float
|
||||||
HMM_Length(hmm_vec2 A)
|
HMM_Length(hmm_vec2 A)
|
||||||
{
|
{
|
||||||
float Result = 0.0f;
|
float Result = 0.0f;
|
||||||
@@ -1779,7 +1787,7 @@ HMM_Length(hmm_vec2 A)
|
|||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
HMMDEF float
|
HINLINE float
|
||||||
HMM_Length(hmm_vec3 A)
|
HMM_Length(hmm_vec3 A)
|
||||||
{
|
{
|
||||||
float Result = 0.0f;
|
float Result = 0.0f;
|
||||||
@@ -1789,7 +1797,7 @@ HMM_Length(hmm_vec3 A)
|
|||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
HMMDEF float
|
HINLINE float
|
||||||
HMM_Length(hmm_vec4 A)
|
HMM_Length(hmm_vec4 A)
|
||||||
{
|
{
|
||||||
float Result = 0.0f;
|
float Result = 0.0f;
|
||||||
@@ -1927,7 +1935,7 @@ HMM_Add(hmm_vec3 Left, hmm_vec3 Right)
|
|||||||
return (Result);
|
return (Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
HMMDEF HINLINE hmm_vec4
|
HINLINE hmm_vec4
|
||||||
HMM_Add(hmm_vec4 Left, hmm_vec4 Right)
|
HMM_Add(hmm_vec4 Left, hmm_vec4 Right)
|
||||||
{
|
{
|
||||||
hmm_vec4 Result = {0};
|
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 |
|
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.1** | Quaternions! |
|
||||||
**1.0** | Lots of testing |
|
**1.0** | Lots of testing |
|
||||||
**0.7** | Added HMM_Vec2, and HMM_Vec4 versions of HMM_LengthSquared, HMM_Length, and HMM_Normalize. |
|
**0.7** | Added HMM_Vec2, and HMM_Vec4 versions of HMM_LengthSquared, HMM_Length, and HMM_Normalize. |
|
||||||
|
|||||||
Reference in New Issue
Block a user