WiP for proper support of ECS - figuring out how to use transformations in a ECS

This commit is contained in:
Hartmut Seichter 2020-12-17 23:23:08 +01:00
parent 1c5b74454f
commit a4f9308aa7
10 changed files with 107 additions and 60 deletions

View file

@ -75,6 +75,7 @@ public:
stream& operator << (const void *value); ///! pointer
protected:
debug* _log;

View file

@ -70,9 +70,6 @@ struct matrix_ : matrixbase_<T, matrix_<R, C, T>>
return *this;
}
// //! get cell count
// inline std::size_t coefficients() const { return this->size(); }
inline size_t offset(size_t r,size_t c) const {
return (RowMajor) ? r * C + c : c * R + r;
}
@ -85,7 +82,7 @@ struct matrix_ : matrixbase_<T, matrix_<R, C, T>>
return data[offset(r,c)];
}
inline const T* ptr() const { return &data[0]; }
inline const T *ptr() const { return &data[0]; }
//! set identity
inline matrix_& set_identity()
@ -201,6 +198,14 @@ struct matrix_ : matrixbase_<T, matrix_<R, C, T>>
for (size_t i = 0; i < rows; i++) c[i] = (*this)(i,col_);
return c;
}
static constexpr auto identity() {
matrix_ res;
for (std::size_t r = 0;r < rows; r++)
for (std::size_t c = 0; c < cols; c++)
res(r,c) = (c == r) ? T(1) : T(0);
return res;
}
};
template <> inline

View file

@ -39,7 +39,7 @@ namespace pw {
template <typename T, typename Derived>
struct matrixbase_ {
typedef T value_type;
using value_type = T;
Derived& derived() { return static_cast<Derived&>(*this); }
const Derived& derived() const { return static_cast<const Derived&>(*this); }