| 134 | } |
| 135 | |
| 136 | s32 parse_geometry(Geometry &g, FBXDocument &fbx, const ufbx_mesh *mesh) |
| 137 | { |
| 138 | size_t num_indices = 0; |
| 139 | for (size_t i = 0; i < mesh->material_parts.count; ++i) { |
| 140 | const ufbx_mesh_part *mesh_part = &mesh->material_parts.data[i]; |
| 141 | num_indices += convert_mesh_part(g, fbx, mesh, mesh_part); |
| 142 | } |
| 143 | |
| 144 | array::resize(g._position_indices, (u32)num_indices); |
| 145 | generate_indices(g._position_indices, g._positions, sizeof(f32)*3); |
| 146 | |
| 147 | if (mesh::has_normals(g)) { |
| 148 | array::resize(g._normal_indices, (u32)num_indices); |
| 149 | generate_indices(g._normal_indices, g._normals, sizeof(f32)*3); |
| 150 | } |
| 151 | |
| 152 | if (mesh::has_tangents(g)) { |
| 153 | array::resize(g._tangent_indices, (u32)num_indices); |
| 154 | generate_indices(g._tangent_indices, g._tangents, sizeof(f32)*3); |
| 155 | } |
| 156 | |
| 157 | if (mesh::has_bitangents(g)) { |
| 158 | array::resize(g._bitangent_indices, (u32)num_indices); |
| 159 | generate_indices(g._bitangent_indices, g._bitangents, sizeof(f32)*3); |
| 160 | } |
| 161 | |
| 162 | if (mesh::has_bones(g)) { |
| 163 | array::resize(g._bone_indices, (u32)num_indices); |
| 164 | array::resize(g._weight_indices, (u32)num_indices); |
| 165 | generate_indices(g._bone_indices, g._bones, sizeof(f32)*4); |
| 166 | generate_indices(g._weight_indices, g._weights, sizeof(f32)*4); |
| 167 | } |
| 168 | |
| 169 | if (mesh::has_uvs(g)) { |
| 170 | array::resize(g._uv_indices, (u32)num_indices); |
| 171 | generate_indices(g._uv_indices, g._uvs, sizeof(f32)*2); |
| 172 | } |
| 173 | |
| 174 | return 0; |
| 175 | } |
| 176 | |
| 177 | s32 parse_geometries(Mesh &m, FBXDocument &fbx, const ufbx_mesh_list *meshes, CompileOptions &opts) |
| 178 | { |
no test coverage detected