#define DALI_VECTOR_4_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
struct DALI_CORE_API Vector4
{
-// NOTE
-// xrs, ygt, zbp and waq must be consecutive in memory.
-// No other data must be added before xrs member.
-// No virtual methods must be added to this struct.
+ // NOTE
+ // xrs, ygt, zbp and waq must be consecutive in memory.
+ // No other data must be added before xrs member.
+ // No virtual methods must be added to this struct.
-// Construction
+ // Construction
/**
* @brief Default constructor, initializes the vector to 0.
{
}
-
/**
* @brief Conversion constructor from an array of four floats.
*
* @SINCE_1_0.0
* @param[in] vec2 Vector2 to copy from, z and w are initialized to 0
*/
- explicit Vector4( const Vector2& vec2 );
+ explicit Vector4(const Vector2& vec2);
/**
* @brief Conversion constructor from Vector3.
* @SINCE_1_0.0
* @param[in] vec3 Vector3 to copy from, w is initialized to 0
*/
- explicit Vector4( const Vector3& vec3 );
+ explicit Vector4(const Vector3& vec3);
-// Constants
+ // Constants
static const Vector4 ONE; ///< (1.0f,1.0f,1.0f,1.0f)
static const Vector4 XAXIS; ///< (1.0f,0.0f,0.0f,0.0f)
static const Vector4 YAXIS; ///< (0.0f,1.0f,0.0f,0.0f)
static const Vector4 ZAXIS; ///< (0.0f,0.0f,1.0f,0.0f)
static const Vector4 ZERO; ///< (0.0f, 0.0f, 0.0f, 0.0f)
-// API
+ // API
/**
* @brief Assignment operator.
* @param[in] vec2 A reference to assign from
* @return Itself
*/
- Vector4& operator=(const Vector2& vec2 );
+ Vector4& operator=(const Vector2& vec2);
/**
* @brief Assignment operator.
* @param[in] vec3 A reference to assign from
* @return Itself
*/
- Vector4& operator=(const Vector3& vec3 );
+ Vector4& operator=(const Vector3& vec3);
/**
* @brief Addition operator.
* @param[in] rhs Vector to add
* @return A vector containing the result of the addition
*/
- Vector4 operator+(const Vector4 & rhs) const
+ Vector4 operator+(const Vector4& rhs) const
{
Vector4 temp(*this);
{
Vector4 temp(*this);
- temp-=rhs;
+ temp -= rhs;
return temp;
}
* @param[in] rhs The vector to divide
* @return A vector containing the result of the division
*/
- Vector4 operator/(const Vector4 & rhs) const
+ Vector4 operator/(const Vector4& rhs) const
{
Vector4 temp(*this);
* @param[in] rhs The vector to test against
* @return True if the vectors are equal
*/
- bool operator==(const Vector4 &rhs) const;
+ bool operator==(const Vector4& rhs) const;
/**
* @brief Inequality operator.
* @param[in] rhs The vector to test against
* @return True if the vectors are not equal
*/
- bool operator!=(const Vector4 &rhs) const
+ bool operator!=(const Vector4& rhs) const
{
return !(*this == rhs);
}
*/
const float& operator[](const uint32_t index) const
{
- DALI_ASSERT_ALWAYS( index < 4 && "Vector element index out of bounds" );
+ DALI_ASSERT_ALWAYS(index < 4 && "Vector element index out of bounds");
return AsFloat()[index];
}
*/
float& operator[](const uint32_t index)
{
- DALI_ASSERT_ALWAYS( index < 4 && "Vector element index out of bounds" );
+ DALI_ASSERT_ALWAYS(index < 4 && "Vector element index out of bounds");
return AsFloat()[index];
}
* @param[in] min The minimum vector
* @param[in] max The maximum vector
*/
- void Clamp( const Vector4& min, const Vector4& max );
+ void Clamp(const Vector4& min, const Vector4& max);
/**
* @brief Returns the contents of the vector as an array of 4 floats.
* @return The vector contents as an array of 4 floats
* @note inlined for performance reasons (generates less code than a function call)
*/
- const float* AsFloat() const {return &x;}
+ const float* AsFloat() const
+ {
+ return &x;
+ }
/**
* @brief Returns the contents of the vector as an array of 4 floats.
* @return The vector contents as an array of 4 floats
* @note inlined for performance reasons (generates less code than a function call)
*/
- float* AsFloat() {return &x;}
+ float* AsFloat()
+ {
+ return &x;
+ }
-// Data
+ // Data
// NOTE
// xrs, ygt, zbp and waq must be consecutive in memory.
};
public:
-
- Vector4( const Vector4& ) = default; ///< Default copy constructor
- Vector4( Vector4&& ) = default; ///< Default move constructor
- Vector4& operator=( const Vector4& ) = default; ///< Default copy assignment operator
- Vector4& operator=( Vector4&& ) = default; ///< Default move assignment operator
+ Vector4(const Vector4&) = default; ///< Default copy constructor
+ Vector4(Vector4&&) noexcept = default; ///< Default move constructor
+ Vector4& operator=(const Vector4&) = default; ///< Default copy assignment operator
+ Vector4& operator=(Vector4&&) noexcept = default; ///< Default move assignment operator
};
/**
* @param[in] b A vector
* @return A vector containing the minimum of each component from a and b
*/
-inline Vector4 Min( const Vector4& a, const Vector4& b )
+inline Vector4 Min(const Vector4& a, const Vector4& b)
{
- return Vector4( a.x < b.x ? a.x : b.x,
- a.y < b.y ? a.y : b.y,
- a.z < b.z ? a.z : b.z,
- a.w < b.w ? a.w : b.w );
+ return Vector4(a.x < b.x ? a.x : b.x,
+ a.y < b.y ? a.y : b.y,
+ a.z < b.z ? a.z : b.z,
+ a.w < b.w ? a.w : b.w);
}
/**
* @param[in] b A vector
* @return A vector containing the maximum of each component from a and b
*/
-inline Vector4 Max( const Vector4& a, const Vector4& b )
+inline Vector4 Max(const Vector4& a, const Vector4& b)
{
- return Vector4( a.x > b.x ? a.x : b.x,
- a.y > b.y ? a.y : b.y,
- a.z > b.z ? a.z : b.z,
- a.w > b.w ? a.w : b.w );
+ return Vector4(a.x > b.x ? a.x : b.x,
+ a.y > b.y ? a.y : b.y,
+ a.z > b.z ? a.z : b.z,
+ a.w > b.w ? a.w : b.w);
}
/**
* @param[in] max The maximum value
* @return A vector containing the clamped components of v
*/
-DALI_CORE_API Vector4 Clamp( const Vector4& v, const float& min, const float& max );
+DALI_CORE_API Vector4 Clamp(const Vector4& v, const float& min, const float& max);
// Allow Vector4 to be treated as a POD type
-template <> struct TypeTraits< Vector4 > : public BasicTypes< Vector4 > { enum { IS_TRIVIAL_TYPE = true }; };
+template<>
+struct TypeTraits<Vector4> : public BasicTypes<Vector4>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
/**
* @}