From ad32d3d10a4a659507748745a42360d34562637f Mon Sep 17 00:00:00 2001 From: surkeh Date: Fri, 13 Apr 2018 17:22:07 -0700 Subject: [PATCH] Meshes with multiple batches handled --- include/devil1geo.h | 2 +- src/devil1geo.c | 5 ++--- test/main.c | 9 +++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/devil1geo.h b/include/devil1geo.h index e68466f..fbe4db4 100644 --- a/include/devil1geo.h +++ b/include/devil1geo.h @@ -87,7 +87,7 @@ bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const); // ** = 'pass by reference' of a pointer to struct bool getmeshbatch(struct Batch*, - struct MeshHeader*, + unsigned int offset, const char * const); #endif diff --git a/src/devil1geo.c b/src/devil1geo.c index 3edad51..7aa5d7b 100644 --- a/src/devil1geo.c +++ b/src/devil1geo.c @@ -69,13 +69,12 @@ bool getmeshheader(struct MeshHeader **hs, } bool getmeshbatch(struct Batch *b, - struct MeshHeader *h, + unsigned int offset, const char * const filedata) { bool done = false; - if (b == NULL || h == NULL || filedata == NULL) { + if (b == NULL || filedata == NULL) { return done; } - unsigned int offset = h -> offsetBatches; struct BatchData *d1 = NULL; struct VertexData d2; d1 = (struct BatchData*) (filedata + offset); diff --git a/test/main.c b/test/main.c index ca53b4c..94bc145 100644 --- a/test/main.c +++ b/test/main.c @@ -117,14 +117,15 @@ void extractmeshes(const char *filedata, unsigned int i; unsigned int j; bool ok; - //h -> numMesh + //for (i = 0; i < 5; i++) { for (i = 0; i < h -> numMesh; i++) { ok = getmeshheader(&mh, i, filedata); if (ok) { - // for (j = 0; j < mh -> numBatch; j++) { - getmeshbatch(&b, mh, filedata); + for (j = 0; j < mh -> numBatch; j++) { + unsigned int offset = mh->offsetBatches + j * sizeof(struct BatchData); + getmeshbatch(&b, offset, filedata); printmeshbatch(&b); - // } // end for + } // end for } // end if } // end for }