mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-19 22:53:47 +00:00
closest
backup closest working example, no errors or warnings from compile, matrices arent correct though yet.
This commit is contained in:
parent
888332a85c
commit
c61d36b799
2 changed files with 67 additions and 10 deletions
|
|
@ -796,15 +796,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void invertTo(Matrix<DATA_TYPE, cols, rows>* matrix) {
|
||||
Matrix<DATA_TYPE, rows, cols> invMatrix = this->inverse();
|
||||
|
||||
for (U32 i = 0; i < rows; ++i) {
|
||||
for (U32 j = 0; j < cols; ++j) {
|
||||
(*matrix)(j, i) = invMatrix(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
void invertTo(Matrix<DATA_TYPE, cols, rows>* matrix) const;
|
||||
void invertTo(Matrix<DATA_TYPE, cols, rows>* matrix);
|
||||
|
||||
void dumpMatrix(const char* caption = NULL) const;
|
||||
// Static identity matrix
|
||||
|
|
@ -1157,6 +1150,47 @@ inline VectorF Matrix<DATA_TYPE, rows, cols>::getUpVector() const
|
|||
return vec;
|
||||
}
|
||||
|
||||
template<typename DATA_TYPE, U32 rows, U32 cols>
|
||||
inline void Matrix<DATA_TYPE, rows, cols>::invertTo(Matrix<DATA_TYPE, cols, rows>* matrix) const
|
||||
{
|
||||
Matrix<DATA_TYPE, rows, cols> invMatrix;
|
||||
for (U32 i = 0; i < rows; ++i) {
|
||||
for (U32 j = 0; j < cols; ++j) {
|
||||
invMatrix(i, j) = (*this)(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
invMatrix.inverse();
|
||||
|
||||
for (U32 i = 0; i < rows; ++i) {
|
||||
for (U32 j = 0; j < cols; ++j) {
|
||||
(*matrix)(j, i) = invMatrix(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
(*matrix)(3, 0) = (*this)(3, 0);
|
||||
(*matrix)(3, 1) = (*this)(3, 1);
|
||||
(*matrix)(3, 2) = (*this)(3, 2);
|
||||
(*matrix)(3, 3) = (*this)(3, 3);
|
||||
}
|
||||
|
||||
template<typename DATA_TYPE, U32 rows, U32 cols>
|
||||
inline void Matrix<DATA_TYPE, rows, cols>::invertTo(Matrix<DATA_TYPE, cols, rows>* matrix)
|
||||
{
|
||||
Matrix<DATA_TYPE, rows, cols> invMatrix = this->inverse();
|
||||
|
||||
for (U32 i = 0; i < rows; ++i) {
|
||||
for (U32 j = 0; j < cols; ++j) {
|
||||
(*matrix)(i, j) = invMatrix(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
(*matrix)(3, 0) = (*this)(3, 0);
|
||||
(*matrix)(3, 1) = (*this)(3, 1);
|
||||
(*matrix)(3, 2) = (*this)(3, 2);
|
||||
(*matrix)(3, 3) = (*this)(3, 3);
|
||||
}
|
||||
|
||||
template<typename DATA_TYPE, U32 rows, U32 cols>
|
||||
inline void Matrix<DATA_TYPE, rows, cols>::setRow(S32 row, const Point4F& cptr) {
|
||||
if(cols >= 2)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef _MATRIXSETDELEGATES_H_
|
||||
#define _MATRIXSETDELEGATES_H_
|
||||
|
||||
// Access to the direct value
|
||||
#ifndef USE_TEMPLATE_MATRIX
|
||||
#define MATRIX_SET_GET_VALUE_FN(xfm) _transform_##xfm
|
||||
#define MATRIX_SET_GET_VALUE(xfm) inline const MatrixF &MATRIX_SET_GET_VALUE_FN(xfm)() { return mTransform[xfm]; }
|
||||
#define MATRIX_SET_BIND_VALUE(xfm) mEvalDelegate[xfm].bind(this, &MatrixSet::MATRIX_SET_GET_VALUE_FN(xfm))
|
||||
|
|
@ -44,5 +44,28 @@
|
|||
return mTransform[matC]; \
|
||||
}
|
||||
|
||||
#else
|
||||
// Access to the direct value
|
||||
#define MATRIX_SET_GET_VALUE_FN(xfm) _transform_##xfm
|
||||
#define MATRIX_SET_GET_VALUE(xfm) inline const MatrixF &MATRIX_SET_GET_VALUE_FN(xfm)() { return mTransform[xfm]; }
|
||||
#define MATRIX_SET_BIND_VALUE(xfm) mEvalDelegate[xfm].bind(this, &MatrixSet::MATRIX_SET_GET_VALUE_FN(xfm))
|
||||
|
||||
#define MATRIX_SET_IS_INVERSE_OF_FN(inv_xfm, src_xfm) _##inv_xfm##_is_inverse_of_##src_xfm
|
||||
#define MATRIX_SET_IS_INVERSE_OF(inv_xfm, src_xfm) inline const MatrixF &MATRIX_SET_IS_INVERSE_OF_FN(inv_xfm, src_xfm)() \
|
||||
{ \
|
||||
mEvalDelegate[src_xfm]().invertTo(&mTransform[inv_xfm]); \
|
||||
MATRIX_SET_BIND_VALUE(inv_xfm); \
|
||||
return mTransform[inv_xfm]; \
|
||||
}
|
||||
|
||||
|
||||
#define MATRIX_SET_MULT_ASSIGN_FN(matA, matB, matC) _##matC##_is_##matA##_x_##matB
|
||||
#define MATRIX_SET_MULT_ASSIGN(matA, matB, matC) inline const MatrixF &MATRIX_SET_MULT_ASSIGN_FN(matA, matB, matC)() \
|
||||
{ \
|
||||
mTransform[matC].mul(mEvalDelegate[matA](),mEvalDelegate[matB]()); \
|
||||
MATRIX_SET_BIND_VALUE(matC); \
|
||||
return mTransform[matC]; \
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // _MATRIXSETDELEGATES_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue