[Bf-blender-cvs] [2c519ceb634] functions: simple Vec3 type

Jacques Lucke noreply at git.blender.org
Fri Jun 7 17:18:49 CEST 2019


Commit: 2c519ceb6342001cc135f8b2995f34b15721a177
Author: Jacques Lucke
Date:   Fri Jun 7 15:53:12 2019 +0200
Branches: functions
https://developer.blender.org/rB2c519ceb6342001cc135f8b2995f34b15721a177

simple Vec3 type

===================================================================

A	source/blender/blenlib/BLI_math.hpp

===================================================================

diff --git a/source/blender/blenlib/BLI_math.hpp b/source/blender/blenlib/BLI_math.hpp
new file mode 100644
index 00000000000..c2f5741b11c
--- /dev/null
+++ b/source/blender/blenlib/BLI_math.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+namespace BLI {
+
+struct Vec3 {
+  float x, y, z;
+
+  friend Vec3 operator+(Vec3 a, Vec3 b)
+  {
+    return {a.x + b.x, a.y + b.y, a.z + b.z};
+  }
+
+  void operator+=(Vec3 b)
+  {
+    this->x += b.x;
+    this->y += b.y;
+    this->z += b.z;
+  }
+
+  friend Vec3 operator*(Vec3 a, Vec3 b)
+  {
+    return {a.x * b.x, a.y * b.y, a.z * b.z};
+  }
+
+  friend Vec3 operator*(Vec3 a, float b)
+  {
+    return {a.x * b, a.y * b, a.z * b};
+  }
+};
+
+}  // namespace BLI



More information about the Bf-blender-cvs mailing list