Good Afternoon,
I have a quick question about an efficient way of storing world transformation vertices.
So far, I do something like this
class GeometryObject{
public:
const std::vector<Vec2f> & GetTransformed()const{
return m_transformed;
}
void Transform(const Mat3& l_matrix){
for(all verts in model){
m_transformed[i] = l_matrix * m_local[i];
}
}
private:
std::vector<Vec2> m_local; //local verts not affected by translation, rotation etc.
std::vector<Vec2> m_transformed; //transformed verts affected by translate, rotation etc.
};
This has always felt like a huge waste of memory because I am doubleing the amount of vert data stored in an object.
The reference keeps me from making a copy however so it should be faster than simply returning a new copy of std::vector<Vec2> every time I need world data.
So my question is: Is there a more efficient way to transform data? I would also like to make this extensible to 3d where a mesh might have thounsands of triangles.
Thanks so much for the help.
Mike