Added quaternion dependence

This commit is contained in:
Christophe Riccio 2011-06-05 14:58:55 +01:00
parent a1d172153e
commit 8b4687e6a3

View File

@ -1,14 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /// OpenGL Mathematics (glm.g-truc.net)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///
// Created : 2009-05-06 /// Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
// Updated : 2010-04-30 /// Permission is hereby granted, free of charge, to any person obtaining a copy
// Licence : This source is under MIT License /// of this software and associated documentation files (the "Software"), to deal
// File : glm/gtc/type_ptr.hpp /// in the Software without restriction, including without limitation the rights
/////////////////////////////////////////////////////////////////////////////////////////////////// /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// Dependency: /// copies of the Software, and to permit persons to whom the Software is
// - GLM core /// furnished to do so, subject to the following conditions:
/////////////////////////////////////////////////////////////////////////////////////////////////// ///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtc_type_ptr
/// @file glm/gtc/type_ptr.hpp
/// @date 2009-05-06 / 2011-06-05
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtc_half_float (dependence)
/// @see gtc_quaternion (dependence)
///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_type_ptr #ifndef glm_gtc_type_ptr
#define glm_gtc_type_ptr #define glm_gtc_type_ptr
@ -28,7 +48,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
/// \addtogroup gtc_type_ptr /// \addtogroup gtc_type_ptr
///@{ ///@{
//! Get the const address of the vector content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -39,7 +59,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(vec.x); return &(vec.x);
} }
//! Get the address of the vector content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -50,7 +70,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(vec.x); return &(vec.x);
} }
//! Get the const address of the vector content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -61,7 +81,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(vec.x); return &(vec.x);
} }
//! Get the address of the vector content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -72,7 +92,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(vec.x); return &(vec.x);
} }
//! Get the const address of the vector content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -83,7 +103,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(vec.x); return &(vec.x);
} }
//! Get the address of the vector content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -94,7 +114,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(vec.x); return &(vec.x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -105,7 +125,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -116,7 +136,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -127,7 +147,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -138,7 +158,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -149,7 +169,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -160,7 +180,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -171,7 +191,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -182,7 +202,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -193,7 +213,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -204,7 +224,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -215,7 +235,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -226,7 +246,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -237,7 +257,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -248,7 +268,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -259,7 +279,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr GLM_FUNC_QUALIFIER T * value_ptr
@ -270,7 +290,7 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Get the const address of the matrix content. //! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr GLM_FUNC_QUALIFIER T const * value_ptr
@ -281,6 +301,17 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return &(mat[0].x); return &(mat[0].x);
} }
//! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension.
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tquat<T> const & q
)
{
return &(q[0]);
}
//! Get the address of the matrix content. //! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
@ -379,7 +410,6 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return Result; return Result;
} }
//! Build a matrix from a pointer. //! Build a matrix from a pointer.
//! From GLM_GTC_type_ptr extension. //! From GLM_GTC_type_ptr extension.
template<typename T> template<typename T>
@ -434,8 +464,17 @@ namespace type_ptr ///< GLM_GTC_type_ptr extension: Get access to vectors & matr
return make_mat4x4(ptr); return make_mat4x4(ptr);
} }
///@} //! Build a quaternion from a pointer.
//! From GLM_GTC_type_ptr extension.
template<typename T>
GLM_FUNC_QUALIFIER detail::tquat<T> make_quat(T const * const ptr)
{
detail::tquat<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tquat<T>));
return Result;
}
/// @}
}//namespace type_ptr }//namespace type_ptr
}//namespace gtc }//namespace gtc
}//namespace glm }//namespace glm