Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/BLI_float3.hh')
-rw-r--r--source/blender/blenlib/BLI_float3.hh18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_float3.hh b/source/blender/blenlib/BLI_float3.hh
index 7e49cc89b52..cbc4d4ed366 100644
--- a/source/blender/blenlib/BLI_float3.hh
+++ b/source/blender/blenlib/BLI_float3.hh
@@ -191,6 +191,24 @@ struct float3 {
return result;
}
+ static float3 refract(const float3 &incident, const float3 &normal, const float eta)
+ {
+ float3 result;
+ float k = 1.0f - eta * eta * (1.0f - dot(normal, incident) * dot(normal, incident));
+ if (k < 0.0f) {
+ result = float3(0.0f);
+ }
+ else {
+ result = eta * incident - (eta * dot(normal, incident) + sqrt(k)) * normal;
+ }
+ return result;
+ }
+
+ static float3 faceforward(const float3 &vector, const float3 &incident, const float3 &reference)
+ {
+ return dot(reference, incident) < 0.0f ? vector : -vector;
+ }
+
static float3 safe_divide(const float3 &a, const float3 &b)
{
float3 result;