From 36fbeaeac47e1e3521a4e27a6ab979cacc51cd0b Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Tue, 21 Mar 2017 10:49:56 -0700 Subject: [PATCH] Create CONTRIBUTING.md (#54) --- CONTRIBUTING.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..286fec3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Quick style guide + +* Braces on a new line +* 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}; + } + ``` +* 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 operations already built into C. That means 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! +