Skip to content

Commit

Permalink
Convert everything to new inline scheme (#57) (#72)
Browse files Browse the repository at this point in the history
* Convert everything to new inline scheme

* Add both extern and inline for some SSE vs. non-SSE functions

Some functions had nice, compact SSE implementations but bulky non-SSE
implementations, so this commit inlines just the implementations that make
sense. Also updated documentation.

* Convert HINLINE and HEXTERN to HMM_INLINE and HMM_EXTERN
  • Loading branch information
bvisness committed Oct 31, 2017
1 parent 5f173e0 commit 4981d5a
Show file tree
Hide file tree
Showing 3 changed files with 940 additions and 1,520 deletions.
23 changes: 6 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Understanding the structure of Handmade Math

Most of the functions in Handmade Math are very short, and are the kind of functions you want to have inlined. Because of this, most functions in Handmade Math are defined with `HINLINE`, which is defined as `static inline`.

The exceptions are functions like `HMM_Rotate`, which are long enough that it doesn't make sense to inline them. These functions are defined with an `HEXTERN` prototype, and implemented in the `#ifdef HANDMADE_MATH_IMPLEMENTATION` block.

# Quick style guide

* Put braces on a new line
Expand All @@ -13,23 +19,6 @@
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
Expand Down
Loading

0 comments on commit 4981d5a

Please sign in to comment.