change raw pointer to vector

This commit is contained in:
Michael Kirsch 2019-02-26 20:37:06 +01:00 committed by Joseph Lenox
parent 402358f346
commit a023cff882
3 changed files with 18 additions and 7 deletions

View File

@ -61,12 +61,22 @@ void TransformationMatrix::swap(TransformationMatrix &other)
std::swap(this->m33, other.m33); std::swap(this->m34, other.m34); std::swap(this->m33, other.m33); std::swap(this->m34, other.m34);
} }
float* TransformationMatrix::matrix3x4f() const std::vector<float> TransformationMatrix::matrix3x4f() const
{ {
float out_arr[12]; std::vector<float> out_arr(0);
out_arr[0] = this->m11; out_arr[1] = this->m12; out_arr[2] = this->m13; out_arr[3] = this->m14; out_arr.reserve(12);
out_arr[4] = this->m21; out_arr[5] = this->m22; out_arr[6] = this->m23; out_arr[7] = this->m24; out_arr.push_back(this->m11);
out_arr[8] = this->m31; out_arr[9] = this->m32; out_arr[10] = this->m33; out_arr[11] = this->m34; out_arr.push_back(this->m12);
out_arr.push_back(this->m13);
out_arr.push_back(this->m14);
out_arr.push_back(this->m21);
out_arr.push_back(this->m22);
out_arr.push_back(this->m23);
out_arr.push_back(this->m24);
out_arr.push_back(this->m31);
out_arr.push_back(this->m32);
out_arr.push_back(this->m33);
out_arr.push_back(this->m34);
return out_arr; return out_arr;
} }

View File

@ -27,7 +27,7 @@ public:
/// Return the row-major form of the represented transformation matrix /// Return the row-major form of the represented transformation matrix
/// for admesh transform /// for admesh transform
float * matrix3x4f() const; std::vector<float> matrix3x4f() const;
/// Return the determinante of the matrix /// Return the determinante of the matrix
double determinante() const; double determinante() const;

View File

@ -282,7 +282,8 @@ TriangleMesh::WriteOBJFile(const std::string &output_file) const {
void TriangleMesh::transform(const TransformationMatrix &trafo) void TriangleMesh::transform(const TransformationMatrix &trafo)
{ {
stl_transform(&this->stl, trafo.matrix3x4f); std::vector<float> trafo_arr = trafo.matrix3x4f;
stl_transform(&this->stl, &(trafo_arr.at(0)));
stl_invalidate_shared_vertices(&this->stl); stl_invalidate_shared_vertices(&this->stl);
} }