Skip to content

Commit 56ac9f3

Browse files
committed
Bugfixes
1 parent e3ffc0b commit 56ac9f3

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/main/fmt/obj/Compressor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ namespace lsp
683683
if ((res == STATUS_OK) && (has_normals))
684684
{
685685
if (equal_normals)
686-
res = write_varint_icount(n); // Write the fill index
686+
res = write_varint_icount(vn[0]); // Write the fill index
687687
else
688688
res = write_indices(vn, n);
689689
}

src/main/fmt/obj/Decompressor.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,14 @@ namespace lsp
490490
return STATUS_NO_MEM;
491491

492492
index_t *vv = data.array();
493+
index_t *vt = &vv[count];
494+
index_t *vn = &vt[count];
495+
493496
if ((res = read_indices(vv, count, true)) != STATUS_OK)
494497
return res;
495-
if ((res = read_indices(&vv[count], count, texcoords)) != STATUS_OK)
498+
if ((res = read_indices(vt, count, texcoords)) != STATUS_OK)
496499
return res;
497500

498-
index_t *vn = &vv[count << 1];
499501
if (fill)
500502
{
501503
size_t index = 0;
@@ -511,7 +513,7 @@ namespace lsp
511513
}
512514

513515

514-
return handler->add_face(vv, &vv[count], vn, count);
516+
return handler->add_face(vv, vn, vt, count);
515517
}
516518

517519
status_t Decompressor::parse_line(IObjHandler *handler, bool texcoords)
@@ -526,12 +528,13 @@ namespace lsp
526528
return STATUS_NO_MEM;
527529

528530
index_t *vv = data.array();
531+
index_t *vt = &vv[count];
529532
if ((res = read_indices(vv, count, true)) != STATUS_OK)
530533
return res;
531-
if ((res = read_indices(&vv[count], count, texcoords)) != STATUS_OK)
534+
if ((res = read_indices(vt, count, texcoords)) != STATUS_OK)
532535
return res;
533536

534-
return handler->add_line(vv, &vv[count], count);
537+
return handler->add_line(vv, vt, count);
535538
}
536539

537540
status_t Decompressor::parse_points(IObjHandler *handler)

src/test/utest/fmt/obj/compressor.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ namespace lsp
217217
memcpy(call->indices.t, vt, n * sizeof(obj::index_t));
218218
memcpy(call->indices.n, vn, n * sizeof(obj::index_t));
219219

220+
printf("#%04d: f ", int(vCalls.size() - 1));
221+
for (size_t i=0; i<n; ++i)
222+
{
223+
printf("%d/%d/%d ", int(vv[i]), int(vt[i]), int(vn[i]));
224+
}
225+
printf("\n");
226+
220227
return STATUS_OK;
221228
}
222229

@@ -370,7 +377,7 @@ UTEST_BEGIN("runtime.fmt.obj", compressor)
370377
int(i), int(ca->indices.count), int(cb->indices.count));
371378
return i;
372379
}
373-
for (size_t j=0; i<ca->indices.count; ++i)
380+
for (size_t j=0; j<ca->indices.count; ++j)
374381
{
375382
if (ca->indices.v[j] != cb->indices.v[j])
376383
{
@@ -379,7 +386,7 @@ UTEST_BEGIN("runtime.fmt.obj", compressor)
379386
return i;
380387
}
381388
}
382-
for (size_t j=0; i<ca->indices.count; ++i)
389+
for (size_t j=0; j<ca->indices.count; ++j)
383390
{
384391
if (ca->indices.t[j] != cb->indices.t[j])
385392
{
@@ -388,7 +395,7 @@ UTEST_BEGIN("runtime.fmt.obj", compressor)
388395
return i;
389396
}
390397
}
391-
for (size_t j=0; i<ca->indices.count; ++i)
398+
for (size_t j=0; j<ca->indices.count; ++j)
392399
{
393400
if (ca->indices.n[j] != cb->indices.n[j])
394401
{
@@ -406,7 +413,7 @@ UTEST_BEGIN("runtime.fmt.obj", compressor)
406413
int(i), int(ca->indices.count), int(cb->indices.count));
407414
return i;
408415
}
409-
for (size_t j=0; i<ca->indices.count; ++i)
416+
for (size_t j=0; j<ca->indices.count; ++j)
410417
{
411418
if (ca->indices.v[j] != cb->indices.v[j])
412419
{
@@ -425,7 +432,7 @@ UTEST_BEGIN("runtime.fmt.obj", compressor)
425432
return i;
426433
}
427434

428-
for (size_t j=0; i<ca->indices.count; ++i)
435+
for (size_t j=0; j<ca->indices.count; ++j)
429436
{
430437
if (ca->indices.v[j] != cb->indices.v[j])
431438
{
@@ -434,7 +441,7 @@ UTEST_BEGIN("runtime.fmt.obj", compressor)
434441
return i;
435442
}
436443
}
437-
for (size_t j=0; i<ca->indices.count; ++i)
444+
for (size_t j=0; j<ca->indices.count; ++j)
438445
{
439446
if (ca->indices.t[j] != cb->indices.t[j])
440447
{
@@ -494,14 +501,12 @@ UTEST_BEGIN("runtime.fmt.obj", compressor)
494501

495502
UTEST_MAIN
496503
{
497-
printf("Testing compression of complicated OBJ file...\n");
504+
printf("Testing compression of complicated OBJ files...\n");
498505
test_compress_obj_file("fmt/obj/parking.obj", "parking");
499-
printf("Testing compression of complicated OBJ file...\n");
500506
test_compress_obj_file("fmt/obj/coliseum.obj", "coliseum");
501-
printf("Testing compression of complicated OBJ file...\n");
502507
test_compress_obj_file("fmt/obj/forest.obj", "forest");
503-
printf("Testing compression of complicated OBJ file...\n");
504508
test_compress_obj_file("fmt/obj/cooling-tower.obj", "cooling-tower");
509+
test_compress_obj_file("fmt/obj/church.obj", "church");
505510
}
506511

507512
UTEST_END

0 commit comments

Comments
 (0)