|
|
|
|
@ -119,7 +119,7 @@ copyDiffuseTexture(texture_assets* textures,
|
|
|
|
|
dtex->bits_per_channel = t_img.bits; |
|
|
|
|
dtex->num_channels = t_img.component; |
|
|
|
|
dtex->data_len = t_img.image.size(); |
|
|
|
|
dtex->pixels = (u8*) arenaAllocateBlock(arena, dtex->data_len); |
|
|
|
|
dtex->pixels = ARENA_ALLOC(arena, u8, dtex->data_len); |
|
|
|
|
// FIXME: overwriting memory here... also fix in libTangerine
|
|
|
|
|
std::strncpy(dtex->file_path, t_img.uri.c_str(), t_img.uri.size()); |
|
|
|
|
dtex->filepath_hash = utilFNV64a_str(t_img.uri.c_str()); |
|
|
|
|
@ -203,7 +203,7 @@ initModel(Assets* assets,
|
|
|
|
|
assets->num_models++; |
|
|
|
|
|
|
|
|
|
uint buf_count = t_mdl.bufferViews.size(); |
|
|
|
|
mdl->meshes = (mesh*) arenaAllocateBlock(arena, buf_count * sizeof(mesh)); |
|
|
|
|
mdl->meshes = ARENA_ALLOC(arena, mesh, buf_count); |
|
|
|
|
mdl->num_meshes = t_mdl.meshes.size(); |
|
|
|
|
mdl->filepath = arenaCopyCStr(arena, filename, MAX_PATH_SIZE); |
|
|
|
|
mdl->filepath_hash = utilFNV64a_str(mdl->filepath); |
|
|
|
|
@ -235,7 +235,7 @@ copyBuffer(uint8_t*& buffer_ref,
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
assert(bv.byteStride == 0); |
|
|
|
|
buffer_ref = (uint8_t*) arenaAllocateBlock(arena, bv.byteLength); |
|
|
|
|
buffer_ref = ARENA_ALLOC(arena, u8, bv.byteLength); |
|
|
|
|
std::memcpy(buffer_ref, &t_buf.data[bv.byteOffset], bv.byteLength); |
|
|
|
|
|
|
|
|
|
return buffer_ref != nullptr; |
|
|
|
|
@ -249,8 +249,7 @@ parseNodeTransform(memory_arena* arena, const tinygltf::Node* node)
|
|
|
|
|
&& node->scale.size() == 3 |
|
|
|
|
&& node->translation.size() == 3) |
|
|
|
|
{ |
|
|
|
|
glm::mat4* xform = |
|
|
|
|
(glm::mat4*) arenaAllocateBlock(arena, sizeof(glm::mat4)); |
|
|
|
|
glm::mat4* xform = ARENA_ALLOC(arena, glm::mat4, 1); |
|
|
|
|
*xform = glm::mat4(1.0f); |
|
|
|
|
*xform = glm::rotate(*xform, (float) node->rotation[3], |
|
|
|
|
glm::vec3((float) node->rotation[0], |
|
|
|
|
@ -301,7 +300,7 @@ parseMeshNode(mesh* m,
|
|
|
|
|
m->usage = GL_STATIC_DRAW; // TODO: logic for updating dynamic meshes
|
|
|
|
|
// FIXME: the node transforms from blender only work as part of a node tree
|
|
|
|
|
#if 1 |
|
|
|
|
m->xform = (glm::mat4*) arenaAllocateBlock(arena, sizeof(glm::mat4)); |
|
|
|
|
m->xform = ARENA_ALLOC(arena, glm::mat4, 1); |
|
|
|
|
*m->xform = glm::mat4(1.0f); |
|
|
|
|
#else |
|
|
|
|
m->xform = parseNodeTransform(arena, &node); |
|
|
|
|
|