mirror of
https://github.com/thepigeongenerator/sdl_template.git
synced 2025-12-17 05:55:47 +01:00
small optimisation to normalisation function
This commit is contained in:
@@ -45,8 +45,8 @@ static inline float float2_mag(float2 v) {
|
||||
|
||||
// normalizes the float2
|
||||
static inline float2 float2_norm(float2 v) {
|
||||
float len = float2_mag(v);
|
||||
return float2_div(v, len);
|
||||
float s = 1.0F / float2_mag(v); // get the scaling factor
|
||||
return float2_scale(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
}
|
||||
|
||||
// gets the dot product of two float2s
|
||||
|
||||
@@ -46,8 +46,8 @@ static inline float float3_mag(float3 v) {
|
||||
|
||||
// normalizes the float3
|
||||
static inline float3 float3_norm(float3 v) {
|
||||
float len = float3_mag(v);
|
||||
return float3_div(v, len);
|
||||
float s = 1.0F / float3_mag(v); // get the scaling factor
|
||||
return float3_scale(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
}
|
||||
|
||||
// gets the dot product of two float3s
|
||||
|
||||
@@ -47,8 +47,8 @@ static inline float float4_mag(float4 v) {
|
||||
|
||||
// normalizes the float4
|
||||
static inline float4 float4_norm(float4 v) {
|
||||
float len = float4_mag(v);
|
||||
return float4_div(v, len);
|
||||
float s = 1.0F / float4_mag(v); // get the scaling factor
|
||||
return float4_scale(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
}
|
||||
|
||||
// gets the dot product of two float4s
|
||||
|
||||
Reference in New Issue
Block a user