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:
authorCharlie Jolly <charlie>2021-10-15 17:27:16 +0300
committerCharlie Jolly <mistajolly@gmail.com>2021-10-15 17:28:20 +0300
commit104887800c0f221fbcffa84bb360dd9ff001d7f1 (patch)
tree743a308c6eda1918e4e97df0d8ba32b7046bedf7 /source/blender/blenlib/BLI_float2.hh
parent6e4ab5b761b03b52177985ecbeb2c2f576159c74 (diff)
Geometry Nodes: Add Voronoi Texture
Port shader Voronoi to GN Reviewed By: JacquesLucke Differential Revision: https://developer.blender.org/D12725
Diffstat (limited to 'source/blender/blenlib/BLI_float2.hh')
-rw-r--r--source/blender/blenlib/BLI_float2.hh25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_float2.hh b/source/blender/blenlib/BLI_float2.hh
index cf6e00ba938..bb4229db86e 100644
--- a/source/blender/blenlib/BLI_float2.hh
+++ b/source/blender/blenlib/BLI_float2.hh
@@ -115,6 +115,11 @@ struct float2 {
return {a.x - b.x, a.y - b.y};
}
+ friend float2 operator-(const float2 &a, const float &b)
+ {
+ return {a.x - b, a.y - b};
+ }
+
friend float2 operator*(const float2 &a, float b)
{
return {a.x * b, a.y * b};
@@ -137,6 +142,26 @@ struct float2 {
return stream;
}
+ static float2 safe_divide(const float2 &a, const float b)
+ {
+ return (b != 0.0f) ? a / b : float2(0.0f);
+ }
+
+ static float2 floor(const float2 &a)
+ {
+ return float2(floorf(a.x), floorf(a.y));
+ }
+
+ /**
+ * Returns a normalized vector. The original vector is not changed.
+ */
+ float2 normalized() const
+ {
+ float2 result;
+ normalize_v2_v2(result, *this);
+ return result;
+ }
+
static float dot(const float2 &a, const float2 &b)
{
return a.x * b.x + a.y * b.y;