Skip to content

Commit 6e64ac8

Browse files
committed
fix more issues with fbx import, still need to figure out why batch wont render properly
1 parent 16f5042 commit 6e64ac8

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/io/BinIO.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ namespace BIN {
10851085

10861086
ufbx_load_opts opts = {};
10871087
opts.target_axes = ufbx_axes_right_handed_y_up;
1088-
opts.target_unit_meters = 1.0f;
1088+
opts.target_unit_meters = 0.01f;
10891089
ufbx_scene* scene = ufbx_load_file(path.c_str(), &opts, nullptr);
10901090

10911091
// set up resources per node
@@ -1132,10 +1132,12 @@ namespace BIN {
11321132
std::map<std::pair<uint32_t, uint32_t>, uint16_t> meshIdxRemap;
11331133
uint16_t batchIdx = 0;
11341134
for(ufbx_mesh* mesh : scene->meshes){
1135+
std::cout << "Adding Mesh " << mesh->name.data << std::endl;
11351136
for(ufbx_mesh_part part : mesh->material_parts){
11361137
meshIdxRemap[{mesh->typed_id, part.index}] = batchIdx;
1137-
mdl.mBatches[batchIdx++] = {};
1138-
1138+
mdl.mBatches[batchIdx] = {};
1139+
std::cout << "Batch IDX " << batchIdx << " remap[" << mesh->typed_id << ", " << part.index << "]" << std::endl;
1140+
11391141
std::vector<Vertex> vertices;
11401142
std::vector<uint32_t> triIndices;
11411143
triIndices.resize(mesh->max_face_triangles * 3);
@@ -1174,18 +1176,17 @@ namespace BIN {
11741176
triangle_stripper::primitive_vector primitives;
11751177
stripify.SetBackwardSearch(false);
11761178
stripify.Strip(&primitives);
1177-
1178-
int indexCount = 0;
1179+
11791180
for(auto p : primitives){
11801181
BIN::Primitive primitive;
11811182
primitive.Opcode = (p.Type == triangle_stripper::TRIANGLE_STRIP ? GXPrimitiveType::TriangleStrip : GXPrimitiveType::Triangles);
11821183
for(int i = 0; i < p.Indices.size(); i++){
11831184
primitive.Vertices.push_back(vertices[p.Indices[i]]);
11841185
}
1185-
indexCount += p.Indices.size();
1186-
mdl.mBatches[mesh->typed_id+part.index].Primitives.push_back(primitive);
1186+
mdl.mBatches[batchIdx].Primitives.push_back(primitive);
11871187
}
1188-
1188+
std::cout << "Primitives Size " << mdl.mBatches[batchIdx].Primitives.size() << std::endl;
1189+
batchIdx++;
11891190
}
11901191
}
11911192

0 commit comments

Comments
 (0)