From 302c11982f22a5ba35df35c633b4acd9edae719e Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Fri, 24 Jan 2025 21:17:04 +0100 Subject: [PATCH] [orx-mesh-noise] Fix barycentric weighting --- orx-mesh-noise/src/commonMain/kotlin/MeshNoise.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/orx-mesh-noise/src/commonMain/kotlin/MeshNoise.kt b/orx-mesh-noise/src/commonMain/kotlin/MeshNoise.kt index af596105..af9f08f0 100644 --- a/orx-mesh-noise/src/commonMain/kotlin/MeshNoise.kt +++ b/orx-mesh-noise/src/commonMain/kotlin/MeshNoise.kt @@ -32,6 +32,10 @@ fun nonUniformBarycentric(weight0: Double, weight1: Double, weight2: Double, ran var b0 = b.x / weight0 var b1 = b.y / weight1 var b2 = b.z / weight2 + val b = uniformBarycentric(random) + var b0 = b.x * weight0 + var b1 = b.y * weight1 + var b2 = b.z * weight2 val totalWeight = b0 + b1 + b2 b0 /= totalWeight b1 /= totalWeight