Load animation data into model
This commit is contained in:
1 parent
f24a920e66
commit
ffa0beb55a
3 files changed
+85
-4
No files matched your search
@@ -6,9 +6,9 @@
|
||||
model_t model_init(size_t vertex_count, size_t index_count)
|
||||
{
|
||||
model_t model = {
|
||||
.indices = calloc(index_count, sizeof(index_t)),
|
||||
.indices = malloc(index_count * sizeof(index_t)),
|
||||
.index_count = index_count,
|
||||
.vertices = calloc(vertex_count, sizeof(vertex_t)),
|
||||
.vertices = malloc(vertex_count * sizeof(vertex_t)),
|
||||
.vertex_count = vertex_count,
|
||||
};
|
||||
return model;
|
||||
@@ -34,5 +34,19 @@ void model_cleanup(model_t *m)
|
||||
free(m->inverse_bind_matrices);
|
||||
m->inverse_bind_matrices = nullptr;
|
||||
}
|
||||
m->vertex_count = m->index_count = m->bone_count = 0;
|
||||
if (m->animation.times != nullptr) {
|
||||
free(m->animation.times);
|
||||
m->animation.times = nullptr;
|
||||
}
|
||||
if (m->animation.bones != nullptr) {
|
||||
for (unsigned i = 0; i < m->bone_count; ++i) {
|
||||
free(m->animation.bones[i].translations);
|
||||
free(m->animation.bones[i].rotations);
|
||||
free(m->animation.bones[i].scales);
|
||||
}
|
||||
free(m->animation.bones);
|
||||
m->animation.bones = nullptr;
|
||||
}
|
||||
m->vertex_count = m->index_count = m->bone_count
|
||||
= m->animation.keyframe_count = 0;
|
||||
}
|
||||
Reference in new issue
Block a user