-
Notifications
You must be signed in to change notification settings - Fork 105
Make naming more consistent and concise #146
Copy link
Copy link
Closed
Description
Handmade Math is too verbose right now. We want our names to be distinct and not conflict with other libraries, but nobody wants to read math expressions full of HMM_MultiplyMat4ByVec4. We should follow a more terse naming scheme.
Additionally, every part of Handmade Math's API should be prefixed with HMM_. Nothing will be hmm_ and nothing will be bare. HMM_ is our namespace and we must stick to it.
- Types will be CamelCased for consistency:
- Vectors:
HMM_Vec2,HMM_Vec3,HMM_Vec4 - Matrices:
HMM_Mat2,HMM_Mat3,HMM_Mat4 - Quaternions:
HMM_Quat(four letter gang)
- Vectors:
- All references to data types in in function names must use single-letter forms:
- Vectors:
V2,V3,V4 - Matrices:
M2,M3,M4 - Quaternions:
Q - Floats:
F - Ints:
I
- Vectors:
- Common operations used in expressions should use short names:
- Arithmetic:
Add,Sub,Mul,Div - Comparison:
Eq - Vector operations:
Len,Norm.DotandCrosscan stay the same. (NormI think is debatable, since "norm" already has a different meaning, but I really hate reading expressions full of "normalize" or "normalized".) - Any inverse:
Inv - Square root & inverse square root:
Sqrt,InvSqrt
- Arithmetic:
- Major transformations and projections can keep their full names:
Translate,Rotate,Scale,Orthographic,Perspective, etc. These are not used commonly enough in dense expressions to be worth a terse name.
Examples:
HMM_MultiplyMat4ByVec4->HMM_MulM4V4HMM_MultiplyVec3f->HMM_MulV3FHMM_EqualsVec4->HMM_EqV4HMM_LengthVec3->HMM_LenV3HMM_NormalizeVec3->HMM_NormV3(In my opinion, calling it "NormV3" instead of "V3Norm" dodges the issue of "norm" meaning "length".)
Renaming the types will be moderately more annoying for those who want to upgrade due to the conflict with existing "constructor" functions like HMM_Vec3. However, they can first find and replace HMM_Vec3 with HMM_V3 before finding and replacing hmm_vec3 with HMM_Vec3. Not the end of the world; the process can still be automated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels