mirror of
https://github.com/g-truc/glm.git
synced 2024-11-23 09:14:34 +00:00
Added assert to row and column functions
This commit is contained in:
parent
1b3d5cd378
commit
6487ed1c34
@ -54,14 +54,14 @@ namespace glm
|
|||||||
template <typename genType>
|
template <typename genType>
|
||||||
typename genType::row_type row(
|
typename genType::row_type row(
|
||||||
genType const & m,
|
genType const & m,
|
||||||
int index);
|
typename genType::size_type const & index);
|
||||||
|
|
||||||
/// Set a specific row to a matrix.
|
/// Set a specific row to a matrix.
|
||||||
/// @see gtc_matrix_access
|
/// @see gtc_matrix_access
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
genType row(
|
genType row(
|
||||||
genType const & m,
|
genType const & m,
|
||||||
int index,
|
typename genType::size_type const & index,
|
||||||
typename genType::row_type const & x);
|
typename genType::row_type const & x);
|
||||||
|
|
||||||
/// Get a specific column of a matrix.
|
/// Get a specific column of a matrix.
|
||||||
@ -69,14 +69,14 @@ namespace glm
|
|||||||
template <typename genType>
|
template <typename genType>
|
||||||
typename genType::col_type column(
|
typename genType::col_type column(
|
||||||
genType const & m,
|
genType const & m,
|
||||||
int index);
|
typename genType::size_type const & index);
|
||||||
|
|
||||||
/// Set a specific column to a matrix.
|
/// Set a specific column to a matrix.
|
||||||
/// @see gtc_matrix_access
|
/// @see gtc_matrix_access
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
genType column(
|
genType column(
|
||||||
genType const & m,
|
genType const & m,
|
||||||
int index,
|
typename genType::size_type const & index,
|
||||||
typename genType::col_type const & x);
|
typename genType::col_type const & x);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
@ -32,10 +32,12 @@ namespace glm
|
|||||||
GLM_FUNC_QUALIFIER genType row
|
GLM_FUNC_QUALIFIER genType row
|
||||||
(
|
(
|
||||||
genType const & m,
|
genType const & m,
|
||||||
int index,
|
typename genType::size_type const & index,
|
||||||
typename genType::row_type const & x
|
typename genType::row_type const & x
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
assert(index < m.col_size());
|
||||||
|
|
||||||
genType Result = m;
|
genType Result = m;
|
||||||
for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
|
for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
|
||||||
Result[i][index] = x[i];
|
Result[i][index] = x[i];
|
||||||
@ -46,9 +48,11 @@ namespace glm
|
|||||||
GLM_FUNC_QUALIFIER typename genType::row_type row
|
GLM_FUNC_QUALIFIER typename genType::row_type row
|
||||||
(
|
(
|
||||||
genType const & m,
|
genType const & m,
|
||||||
int index
|
typename genType::size_type const & index
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
assert(index < m.col_size());
|
||||||
|
|
||||||
typename genType::row_type Result;
|
typename genType::row_type Result;
|
||||||
for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
|
for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
|
||||||
Result[i] = m[i][index];
|
Result[i] = m[i][index];
|
||||||
@ -59,10 +63,12 @@ namespace glm
|
|||||||
GLM_FUNC_QUALIFIER genType column
|
GLM_FUNC_QUALIFIER genType column
|
||||||
(
|
(
|
||||||
genType const & m,
|
genType const & m,
|
||||||
int index,
|
typename genType::size_type const & index,
|
||||||
typename genType::col_type const & x
|
typename genType::col_type const & x
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
assert(index < m.row_size());
|
||||||
|
|
||||||
genType Result = m;
|
genType Result = m;
|
||||||
Result[index] = x;
|
Result[index] = x;
|
||||||
return Result;
|
return Result;
|
||||||
@ -72,9 +78,11 @@ namespace glm
|
|||||||
GLM_FUNC_QUALIFIER typename genType::col_type column
|
GLM_FUNC_QUALIFIER typename genType::col_type column
|
||||||
(
|
(
|
||||||
genType const & m,
|
genType const & m,
|
||||||
int index
|
typename genType::size_type const & index
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
assert(index < m.row_size());
|
||||||
|
|
||||||
return m[index];
|
return m[index];
|
||||||
}
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
Loading…
Reference in New Issue
Block a user