Make internal mesh representation more efficient.
Mokosha opened this issue · 0 comments
Right now, the Mesh data type has the following signature:
data Mesh = Mesh { vertices :: [Vertex],
indices :: [Int16] }
This is fine for prototyping, but any sort of mesh manipulation will need to have more efficient access to the vertex data. Also, loading the mesh up to the GPU should not have the data stored as lists. Ideally, unboxed arrays should provide pretty good performance. For GPU uploading this means that the Vertex
type needs to be an instance of Storable
. This then means that we should probably separate each individual vertex type into its own type rather than rely on type constructors. That way, we can move Vertex
to be a typeclass and each separate type can be an instance of Storable
. Right now, vertices could have normals and texture coordinates, so the size of a Vertex
datatype is unknown and can't be marshalled.
The final consequence of this change would require separate OBJ loading functions for each individual type of mesh. We already kind of do this in the OBJ loader, so this whole amount of work will likely make that functionality more explicit and type safe, which is always a good thing.