From 8e188c4b7c4c4f5d270af38656dd758b393d73f3 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Tue, 21 Mar 2017 18:14:57 -0500 Subject: [PATCH] Update CONTRIBUTING.md --- CONTRIBUTING.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 286fec3..dbc7821 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,19 @@ # Quick style guide -* Braces on a new line -* Macros and return types on a separate line from the function definition: +* 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() @@ -18,7 +30,7 @@ hmm_vec3 MyVector = {0}; } ``` -* Parentheses around the returned value: +* Put parentheses around the returned value: ```cpp HINLINE float HMM_MyFunction() @@ -33,7 +45,7 @@ * 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. +* 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!