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:
authorJulian Eisel <julian@blender.org>2020-08-07 14:04:31 +0300
committerJulian Eisel <julian@blender.org>2020-08-07 14:04:31 +0300
commit0d2d4a6d4a75ac38c41f872c88255eab70e88ab7 (patch)
treeb7a7518af86dddba48e05a98b3c2be55e8804721 /extern/mantaflow/helper/util/vectorbase.h
parent9b416c66fb714bdfd15a481489dbf650d0f389ea (diff)
parentcfc6f9eb18e701f5be601b95c45004e8cf7fbc81 (diff)
Merge branch 'master' into temp-ui-button-type-refactortemp-ui-button-type-refactor
Diffstat (limited to 'extern/mantaflow/helper/util/vectorbase.h')
-rw-r--r--extern/mantaflow/helper/util/vectorbase.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/extern/mantaflow/helper/util/vectorbase.h b/extern/mantaflow/helper/util/vectorbase.h
index 41584663a0f..9b4d9c83f0b 100644
--- a/extern/mantaflow/helper/util/vectorbase.h
+++ b/extern/mantaflow/helper/util/vectorbase.h
@@ -248,12 +248,14 @@ template<class S> class Vector3D {
protected:
};
-//! helper to check whether float/double value is non-zero
-inline bool notZero(Real f)
+//! helper to check whether value is non-zero
+template<class S> inline bool notZero(S v)
{
- if (std::abs(f) > VECTOR_EPSILON)
- return true;
- return false;
+ return (std::abs(v) > VECTOR_EPSILON);
+}
+template<class S> inline bool notZero(Vector3D<S> v)
+{
+ return (std::abs(norm(v)) > VECTOR_EPSILON);
}
//************************************************************************
@@ -437,6 +439,36 @@ inline Real normSquare(const int v)
return square(v);
}
+//! Compute sum of all components, allow use of int, Real too
+template<class S> inline S sum(const S v)
+{
+ return v;
+}
+template<class S> inline S sum(const Vector3D<S> &v)
+{
+ return v.x + v.y + v.z;
+}
+
+//! Get absolute representation of vector, allow use of int, Real too
+inline Real abs(const Real v)
+{
+ return std::fabs(v);
+}
+inline int abs(const int v)
+{
+ return std::abs(v);
+}
+
+template<class S> inline Vector3D<S> abs(const Vector3D<S> &v)
+{
+ Vector3D<S> cp(v.x, v.y, v.z);
+ for (int i = 0; i < 3; ++i) {
+ if (cp[i] < 0)
+ cp[i] *= (-1.0);
+ }
+ return cp;
+}
+
//! Returns a normalized vector
template<class S> inline Vector3D<S> getNormalized(const Vector3D<S> &v)
{