From 6259f1b47ffce577ce6105612604152868bec035 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 20 Aug 2016 19:33:36 -0500 Subject: [PATCH] Add ability to construct vec4 from vec3 and float This is very useful for applications using homogeneous coordinates, since I can take a vec3 representing a position or normal, and construct the appropriate vec4 in homogeneous coordinates. --- HandmadeMath.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/HandmadeMath.h b/HandmadeMath.h index 8b04942..713f5fd 100644 --- a/HandmadeMath.h +++ b/HandmadeMath.h @@ -295,6 +295,7 @@ HMMDEF hmm_vec3 HMM_Vec3(float X, float Y, float Z); HMMDEF hmm_vec3 HMM_Vec3i(int X, int Y, int Z); HMMDEF hmm_vec4 HMM_Vec4(float X, float Y, float Z, float W); HMMDEF hmm_vec4 HMM_Vec4i(int X, int Y, int Z, int W); +HMMDEF hmm_vec4 HMM_Vec4v(hmm_vec3 Vector, float W); HMMDEF hmm_vec2 HMM_AddVec2(hmm_vec2 Left, hmm_vec2 Right); HMMDEF hmm_vec3 HMM_AddVec3(hmm_vec3 Left, hmm_vec3 Right); @@ -621,6 +622,17 @@ HMM_Vec4i(int X, int Y, int Z, int W) return (Result); } +HINLINE hmm_vec4 +HMM_Vec4v(hmm_vec3 Vector, float W) +{ + hmm_vec4 Result; + + Result.XYZ = Vector; + Result.W = W; + + return (Result); +} + HINLINE hmm_vec2 HMM_AddVec2(hmm_vec2 Left, hmm_vec2 Right) {