projects
/
platform
/
core
/
uifw
/
dali-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git]
/
dali
/
public-api
/
math
/
vector4.h
diff --git
a/dali/public-api/math/vector4.h
b/dali/public-api/math/vector4.h
index
3d40bf9
..
a42c55a
100644
(file)
--- a/
dali/public-api/math/vector4.h
+++ b/
dali/public-api/math/vector4.h
@@
-2,7
+2,7
@@
#define __DALI_VECTOR_4_H__
/*
#define __DALI_VECTOR_4_H__
/*
- * Copyright (c) 201
5
Samsung Electronics Co., Ltd.
+ * Copyright (c) 201
8
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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-19,6
+19,7
@@
*/
// EXTERNAL INCLUDES
*/
// EXTERNAL INCLUDES
+#include <cstdint> // uint32_t
#include <iosfwd>
// INTERNAL INCLUDES
#include <iosfwd>
// INTERNAL INCLUDES
@@
-38,10
+39,10
@@
struct Vector3;
/**
* @brief A four dimensional vector.
*
/**
* @brief A four dimensional vector.
*
- * Components can be used as position or offset (x,y,z,w); color (r,g,b,a) or texture coords(s,t,p,q)
+ * Components can be used as position or offset (x,y,z,w); color (r,g,b,a) or texture coords(s,t,p,q)
.
* @SINCE_1_0.0
*/
* @SINCE_1_0.0
*/
-struct DALI_
IMPORT
_API Vector4
+struct DALI_
CORE
_API Vector4
{
// NOTE
// xrs, ygt, zbp and waq must be consecutive in memory.
{
// NOTE
// xrs, ygt, zbp and waq must be consecutive in memory.
@@
-66,10
+67,10
@@
struct DALI_IMPORT_API Vector4
* @brief Conversion constructor from four floats.
*
* @SINCE_1_0.0
* @brief Conversion constructor from four floats.
*
* @SINCE_1_0.0
- * @param
[in]
x (or r/s) component
- * @param
[in]
y (or g/t) component
- * @param
[in]
z (or b/p) component
- * @param
[in]
w (or a/q) component
+ * @param
[in] x
x (or r/s) component
+ * @param
[in] y
y (or g/t) component
+ * @param
[in] z
z (or b/p) component
+ * @param
[in] w
w (or a/q) component
*/
explicit Vector4(float x, float y, float z, float w)
: x(x),
*/
explicit Vector4(float x, float y, float z, float w)
: x(x),
@@
-84,7
+85,7
@@
struct DALI_IMPORT_API Vector4
* @brief Conversion constructor from an array of four floats.
*
* @SINCE_1_0.0
* @brief Conversion constructor from an array of four floats.
*
* @SINCE_1_0.0
- * @param
[in] array Array of either xyzw/rgba/stpq
+ * @param[in] array Array of either xyzw/rgba/stpq
*/
explicit Vector4(const float* array)
: x(array[0]),
*/
explicit Vector4(const float* array)
: x(array[0]),
@@
-98,7
+99,7
@@
struct DALI_IMPORT_API Vector4
* @brief Conversion constructor from Vector2.
*
* @SINCE_1_0.0
* @brief Conversion constructor from Vector2.
*
* @SINCE_1_0.0
- * @param
[in] vec2 Vector2 to copy from, z and w are initialized to 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 );
@@
-106,7
+107,7
@@
struct DALI_IMPORT_API Vector4
* @brief Conversion constructor from Vector3.
*
* @SINCE_1_0.0
* @brief Conversion constructor from Vector3.
*
* @SINCE_1_0.0
- * @param
[in] vec3 Vector3 to copy from, w is initialized to 0
+ * @param[in] vec3 Vector3 to copy from, w is initialized to 0
*/
explicit Vector4( const Vector3& vec3 );
*/
explicit Vector4( const Vector3& vec3 );
@@
-123,8
+124,8
@@
struct DALI_IMPORT_API Vector4
* @brief Assignment operator.
*
* @SINCE_1_0.0
* @brief Assignment operator.
*
* @SINCE_1_0.0
- * @param
[in] array Array of floats
- * @return
i
tself
+ * @param[in] array Array of floats
+ * @return
I
tself
*/
Vector4& operator=(const float* array)
{
*/
Vector4& operator=(const float* array)
{
@@
-139,20
+140,20
@@
struct DALI_IMPORT_API Vector4
/**
* @brief Assignment operator.
*
/**
* @brief Assignment operator.
*
- * Only sets x and y. z and w are left as they were
+ * Only sets x and y. z and w are left as they were
.
* @SINCE_1_0.0
* @SINCE_1_0.0
- * @param
[in] vec2 A reference to assign from.
- * @return
i
tself
+ * @param
[in] vec2 A reference to assign from
+ * @return
I
tself
*/
Vector4& operator=(const Vector2& vec2 );
/**
* @brief Assignment operator.
*
*/
Vector4& operator=(const Vector2& vec2 );
/**
* @brief Assignment operator.
*
- * Only sets x and y and z. w is left as it was
+ * Only sets x and y and z. w is left as it was
.
* @SINCE_1_0.0
* @SINCE_1_0.0
- * @param
[in] vec3 A reference to assign from
- * @return
i
tself
+ * @param[in] vec3 A reference to assign from
+ * @return
I
tself
*/
Vector4& operator=(const Vector3& vec3 );
*/
Vector4& operator=(const Vector3& vec3 );
@@
-160,7
+161,7
@@
struct DALI_IMPORT_API Vector4
* @brief Addition operator.
*
* @SINCE_1_0.0
* @brief Addition operator.
*
* @SINCE_1_0.0
- * @param[in] rhs Vector to add
.
+ * @param[in] rhs Vector to add
* @return A vector containing the result of the addition
*/
Vector4 operator+(const Vector4 & rhs) const
* @return A vector containing the result of the addition
*/
Vector4 operator+(const Vector4 & rhs) const
@@
-174,8
+175,8
@@
struct DALI_IMPORT_API Vector4
* @brief Addition assignment operator.
*
* @SINCE_1_0.0
* @brief Addition assignment operator.
*
* @SINCE_1_0.0
- * @param[in] rhs Vector to add
.
- * @return
i
tself
+ * @param[in] rhs Vector to add
+ * @return
I
tself
*/
Vector4& operator+=(const Vector4& rhs)
{
*/
Vector4& operator+=(const Vector4& rhs)
{
@@
-191,7
+192,7
@@
struct DALI_IMPORT_API Vector4
* @brief Subtraction operator.
*
* @SINCE_1_0.0
* @brief Subtraction operator.
*
* @SINCE_1_0.0
- * @param[in] rhs
The vector to subtract
+ * @param[in] rhs The vector to subtract
* @return A vector containing the result of the subtraction
*/
Vector4 operator-(const Vector4& rhs) const
* @return A vector containing the result of the subtraction
*/
Vector4 operator-(const Vector4& rhs) const
@@
-208,7
+209,7
@@
struct DALI_IMPORT_API Vector4
*
* @SINCE_1_0.0
* @param[in] rhs The vector to subtract
*
* @SINCE_1_0.0
* @param[in] rhs The vector to subtract
- * @return
i
tself
+ * @return
I
tself
*/
Vector4& operator-=(const Vector4& rhs)
{
*/
Vector4& operator-=(const Vector4& rhs)
{
@@
-251,7
+252,7
@@
struct DALI_IMPORT_API Vector4
*
* @SINCE_1_0.0
* @param[in] rhs The vector to multiply
*
* @SINCE_1_0.0
* @param[in] rhs The vector to multiply
- * @return
i
tself
+ * @return
I
tself
*/
Vector4& operator*=(const Vector4& rhs)
{
*/
Vector4& operator*=(const Vector4& rhs)
{
@@
-268,7
+269,7
@@
struct DALI_IMPORT_API Vector4
*
* @SINCE_1_0.0
* @param[in] rhs The float value to scale the vector
*
* @SINCE_1_0.0
* @param[in] rhs The float value to scale the vector
- * @return
i
tself
+ * @return
I
tself
*/
Vector4& operator*=(float rhs)
{
*/
Vector4& operator*=(float rhs)
{
@@
-312,7
+313,7
@@
struct DALI_IMPORT_API Vector4
*
* @SINCE_1_0.0
* @param[in] rhs The vector to divide
*
* @SINCE_1_0.0
* @param[in] rhs The vector to divide
- * @return
i
tself
+ * @return
I
tself
*/
Vector4& operator/=(const Vector4& rhs)
{
*/
Vector4& operator/=(const Vector4& rhs)
{
@@
-329,7
+330,7
@@
struct DALI_IMPORT_API Vector4
*
* @SINCE_1_0.0
* @param[in] rhs The float value to scale the vector by
*
* @SINCE_1_0.0
* @param[in] rhs The float value to scale the vector by
- * @return
i
tself
+ * @return
I
tself
*/
Vector4& operator/=(float rhs)
{
*/
Vector4& operator/=(float rhs)
{
@@
-346,7
+347,7
@@
struct DALI_IMPORT_API Vector4
* @brief Unary negation operator.
*
* @SINCE_1_0.0
* @brief Unary negation operator.
*
* @SINCE_1_0.0
- * @return
t
he negative value
+ * @return
T
he negative value
*/
Vector4 operator-() const
{
*/
Vector4 operator-() const
{
@@
-358,22
+359,22
@@
struct DALI_IMPORT_API Vector4
/**
* @brief Equality operator.
*
/**
* @brief Equality operator.
*
- * Utili
s
es appropriate machine epsilon values.
+ * Utili
z
es appropriate machine epsilon values.
*
* @SINCE_1_0.0
* @param[in] rhs The vector to test against
*
* @SINCE_1_0.0
* @param[in] rhs The vector to test against
- * @return
t
rue if the vectors are equal
+ * @return
T
rue if the vectors are equal
*/
bool operator==(const Vector4 &rhs) const;
/**
* @brief Inequality operator.
*
*/
bool operator==(const Vector4 &rhs) const;
/**
* @brief Inequality operator.
*
- * Utili
s
es appropriate machine epsilon values.
+ * Utili
z
es appropriate machine epsilon values.
*
* @SINCE_1_0.0
* @param[in] rhs The vector to test against
*
* @SINCE_1_0.0
* @param[in] rhs The vector to test against
- * @return
t
rue if the vectors are not equal
+ * @return
T
rue if the vectors are not equal
*/
bool operator!=(const Vector4 &rhs) const
{
*/
bool operator!=(const Vector4 &rhs) const
{
@@
-383,12
+384,12
@@
struct DALI_IMPORT_API Vector4
/**
* @brief Const array subscript operator overload.
*
/**
* @brief Const array subscript operator overload.
*
- * Asserts if index is out of range. Should be 0, 1, 2 or 3
+ * Asserts if index is out of range. Should be 0, 1, 2 or 3
.
* @SINCE_1_0.0
* @param[in] index Subscript index
* @SINCE_1_0.0
* @param[in] index Subscript index
- * @return
The float at the given index
+ * @return The float at the given index
*/
*/
- const float& operator[](const u
nsigned in
t index) const
+ const float& operator[](const u
int32_
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" );
@@
-398,12
+399,12
@@
struct DALI_IMPORT_API Vector4
/**
* @brief Mutable array subscript operator overload.
*
/**
* @brief Mutable array subscript operator overload.
*
- * Asserts if index is out of range. Should be 0, 1, 2 or 3
+ * Asserts if index is out of range. Should be 0, 1, 2 or 3
.
* @SINCE_1_0.0
* @param[in] index Subscript index
* @SINCE_1_0.0
* @param[in] index Subscript index
- * @return
The float at the given index
+ * @return The float at the given index
*/
*/
- float& operator[](const u
nsigned in
t index)
+ float& operator[](const u
int32_
t index)
{
DALI_ASSERT_ALWAYS( index < 4 && "Vector element index out of bounds" );
{
DALI_ASSERT_ALWAYS( index < 4 && "Vector element index out of bounds" );
@@
-417,8
+418,8
@@
struct DALI_IMPORT_API Vector4
* This is great for lighting, threshold testing the angle between two unit vectors,
* calculating the distance between two points in a particular direction.
* @SINCE_1_0.0
* This is great for lighting, threshold testing the angle between two unit vectors,
* calculating the distance between two points in a particular direction.
* @SINCE_1_0.0
- * @param
[in] other
The other vector
- * @return
t
he dot product
+ * @param
[in] other
The other vector
+ * @return
T
he dot product
*/
float Dot(const Vector3& other) const;
*/
float Dot(const Vector3& other) const;
@@
-429,8
+430,8
@@
struct DALI_IMPORT_API Vector4
* This is great for lighting, threshold testing the angle between two unit vectors,
* calculating the distance between two points in a particular direction.
* @SINCE_1_0.0
* This is great for lighting, threshold testing the angle between two unit vectors,
* calculating the distance between two points in a particular direction.
* @SINCE_1_0.0
- * @param
[in] other
The other vector
- * @return
t
he dot product
+ * @param
[in] other
The other vector
+ * @return
T
he dot product
*/
float Dot(const Vector4& other) const;
*/
float Dot(const Vector4& other) const;
@@
-438,8
+439,8
@@
struct DALI_IMPORT_API Vector4
* @brief Returns the 4d dot product of this vector and another vector.
*
* @SINCE_1_0.0
* @brief Returns the 4d dot product of this vector and another vector.
*
* @SINCE_1_0.0
- * @param
[in] other
The other vector
- * @return
t
he dot product
+ * @param
[in] other
The other vector
+ * @return
T
he dot product
*/
float Dot4(const Vector4& other) const;
*/
float Dot4(const Vector4& other) const;
@@
-450,7
+451,7
@@
struct DALI_IMPORT_API Vector4
* two vectors. This is great for calculating normals and making matrices orthogonal.
*
* @SINCE_1_0.0
* two vectors. This is great for calculating normals and making matrices orthogonal.
*
* @SINCE_1_0.0
- * @param
[in] other
The other vector
+ * @param
[in] other
The other vector
* @return A vector containing the cross product
*/
Vector4 Cross(const Vector4& other) const;
* @return A vector containing the cross product
*/
Vector4 Cross(const Vector4& other) const;
@@
-459,7
+460,7
@@
struct DALI_IMPORT_API Vector4
* @brief Returns the length of the vector.
*
* @SINCE_1_0.0
* @brief Returns the length of the vector.
*
* @SINCE_1_0.0
- * @return
the length.
+ * @return
The length
*/
float Length() const;
*/
float Length() const;
@@
-469,7
+470,7
@@
struct DALI_IMPORT_API Vector4
* This is faster than using Length() when performing
* threshold checks as it avoids use of the square root.
* @SINCE_1_0.0
* This is faster than using Length() when performing
* threshold checks as it avoids use of the square root.
* @SINCE_1_0.0
- * @return
the length of the vector squared.
+ * @return
The length of the vector squared
*/
float LengthSquared() const;
*/
float LengthSquared() const;
@@
-485,8
+486,8
@@
struct DALI_IMPORT_API Vector4
* @brief Clamps the vector between minimum and maximum vectors.
*
* @SINCE_1_0.0
* @brief Clamps the vector between minimum and maximum vectors.
*
* @SINCE_1_0.0
- * @param
[in] min The minimum vector
- * @param
[in] max The maximum vector
+ * @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 );
@@
-504,7
+505,7
@@
struct DALI_IMPORT_API Vector4
* @endcode
*
* @SINCE_1_0.0
* @endcode
*
* @SINCE_1_0.0
- * @return
the vector contents 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;}
* @note inlined for performance reasons (generates less code than a function call)
*/
const float* AsFloat() const {return &x;}
@@
-523,7
+524,7
@@
struct DALI_IMPORT_API Vector4
* @endcode
*
* @SINCE_1_0.0
* @endcode
*
* @SINCE_1_0.0
- * @return
the vector contents 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;}
* @note inlined for performance reasons (generates less code than a function call)
*/
float* AsFloat() {return &x;}
@@
-565,20
+566,20
@@
struct DALI_IMPORT_API Vector4
* @brief Print a Vector4.
*
* @SINCE_1_0.0
* @brief Print a Vector4.
*
* @SINCE_1_0.0
- * @param
[in] o The output stream operator.
- * @param
[in] vector The vector to print.
- * @return The output stream operator
.
+ * @param
[in] o The output stream operator
+ * @param
[in] vector The vector to print
+ * @return The output stream operator
*/
*/
-DALI_
IMPORT
_API std::ostream& operator<<(std::ostream& o, const Vector4& vector);
+DALI_
CORE
_API std::ostream& operator<<(std::ostream& o, const Vector4& vector);
/**
* @brief Returns a vector with components set to the minimum of the corresponding component in a and b.
*
/**
* @brief Returns a vector with components set to the minimum of the corresponding component in a and b.
*
- * If a=0,1,2,3 and b=4,0,1,2
returns a vector of 0,0,1,2
+ * If a=0,1,2,3 and b=4,0,1,2
returns a vector of 0,0,1,2.
* @SINCE_1_0.0
* @SINCE_1_0.0
- * @param
[in] a
A vector
- * @param
[in] b
A vector
- * @return
a
vector containing the minimum of each component from a and b
+ * @param
[in] a
A vector
+ * @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 )
{
@@
-591,11
+592,11
@@
inline Vector4 Min( const Vector4& a, const Vector4& b )
/**
* @brief Returns a vector with components set to the maximum of the corresponding component in a and b.
*
/**
* @brief Returns a vector with components set to the maximum of the corresponding component in a and b.
*
- * If a=0,1,2,3 and b=4,0,1,2
returns a vector of 4,1,2,3
+ * If a=0,1,2,3 and b=4,0,1,2
returns a vector of 4,1,2,3.
* @SINCE_1_0.0
* @SINCE_1_0.0
- * @param
[in] a
A vector
- * @param
[in] b
A vector
- * @return
a
vector containing the maximum of each component from a and b
+ * @param
[in] a
A vector
+ * @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 )
{
@@
-609,12
+610,12
@@
inline Vector4 Max( const Vector4& a, const Vector4& b )
* @brief Clamps each of vector v's components between minimum and maximum values.
*
* @SINCE_1_0.0
* @brief Clamps each of vector v's components between minimum and maximum values.
*
* @SINCE_1_0.0
- * @param
[in] v
A vector
- * @param
[in] min The minimum value
- * @param
[in] max The maximum value
- * @return
a
vector containing the clamped components of v
+ * @param
[in] v
A vector
+ * @param[in] min The minimum value
+ * @param[in] max The maximum value
+ * @return
A
vector containing the clamped components of v
*/
*/
-DALI_
IMPORT
_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 }; };
// Allow Vector4 to be treated as a POD type
template <> struct TypeTraits< Vector4 > : public BasicTypes< Vector4 > { enum { IS_TRIVIAL_TYPE = true }; };