From 9cfa40f423a7039675de9292f6298866c3b67073 Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 22 Jan 2025 15:32:50 +0000 Subject: [PATCH] glm__noiseDetail_taylorInvSqrt --- include/cglm/noise.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/cglm/noise.h b/include/cglm/noise.h index c4c79f9..70bee4a 100644 --- a/include/cglm/noise.h +++ b/include/cglm/noise.h @@ -57,11 +57,12 @@ } /* glm__noiseDetail_taylorInvSqrt(vec4 x, vec4 dest) */ -#define glm__noiseDetail_taylorInvSqrt(x, dest) { \ - dest[0] = 1.79284291400159f - 0.85373472095314f * x[0]; \ - dest[1] = 1.79284291400159f - 0.85373472095314f * x[1]; \ - dest[2] = 1.79284291400159f - 0.85373472095314f * x[2]; \ - dest[3] = 1.79284291400159f - 0.85373472095314f * x[3]; \ +#define glm__noiseDetail_taylorInvSqrt(x, dest) { \ + /* dest = 1.79284291400159f - 0.85373472095314f * x */ \ + vec4 temp; \ + glm_vec4_scale(x, 0.85373472095314f, temp); /* temp = 0.853...f * x */ \ + glm_vec4_fill(dest, 1.79284291400159f); /* dest = 1.792...f */ \ + glm_vec4_sub(dest, temp, dest); /* dest = 1.79284291400159f - temp */ \ } /* norm = taylorInvSqrt(vec4(