mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2025-05-31 14:11:42 +05:30
Merged a/iosanitycheck into master
This commit is contained in:
@@ -45,6 +45,7 @@ void write(const char *filename,
|
||||
fclose(out);
|
||||
if (written == 0) {
|
||||
perror("write error");
|
||||
exit(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +62,7 @@ void append(const char *filename, const char *t, unsigned size) {
|
||||
fclose(out);
|
||||
if (written == 0) {
|
||||
perror("write error");
|
||||
exit(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,22 +25,22 @@ void writemesh(const struct MeshHeader *mh,
|
||||
|
||||
// batch data the same treatment.
|
||||
struct BatchData * newBatches = malloc(newmh.numBatch * sizeof(struct BatchData));
|
||||
uint64_t previousBatch = 0;
|
||||
uint64_t endOfPrevious = 0;
|
||||
for (int i = 0; i < newmh.numBatch; i++) {
|
||||
newBatches[i] = (m -> b) -> bd[i];
|
||||
unsigned int nVertices = m -> b -> bd[i].numVertex;
|
||||
if (previousBatch == 0) {
|
||||
if (endOfPrevious == 0) {
|
||||
newBatches[i].offsetPositions = newmh.offsetBatches + ( newmh.numBatch * sizeof(struct BatchData));
|
||||
}
|
||||
else {
|
||||
newBatches[i].offsetPositions = previousBatch;
|
||||
newBatches[i].offsetPositions = endOfPrevious;
|
||||
}
|
||||
newBatches[i].offsetNormals = newBatches[i].offsetPositions + (sizeof(struct Coordinate) * nVertices);
|
||||
newBatches[i].offsetUVs = newBatches[i].offsetNormals + (sizeof(struct Coordinate) * nVertices);
|
||||
newBatches[i].offsetBoneIndexes = newBatches[i].offsetUVs + (sizeof(struct UVs) * nVertices);
|
||||
newBatches[i].offsetBoneWeights = newBatches[i].offsetBoneIndexes + (sizeof(struct BoneIndexes) * nVertices);
|
||||
append(fn, (char*)(&newBatches[i]), sizeof(struct BatchData));
|
||||
previousBatch = newBatches[i].offsetBoneWeights + (sizeof(struct BoneWeights) * nVertices);;
|
||||
endOfPrevious = newBatches[i].offsetBoneWeights + (sizeof(struct BoneWeights) * nVertices);;
|
||||
}
|
||||
|
||||
for (int i = 0; i < newmh.numBatch; i++) {
|
||||
@@ -57,8 +57,8 @@ void writemesh(const struct MeshHeader *mh,
|
||||
}
|
||||
|
||||
void extractmeshes(const char *filedata,
|
||||
unsigned int filesize,
|
||||
const char *filename) {
|
||||
const char *filename,
|
||||
unsigned int filesize) {
|
||||
if (filedata == NULL || filesize <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ void extractmeshes(const char *filedata,
|
||||
DEVIL1GEO.getmeshheader(&mh, i, filedata);
|
||||
m.b = (struct Batch*)malloc(sizeof(struct Batch) * (mh -> numBatch));
|
||||
if (m.b != NULL) {
|
||||
DEVIL1GEO.getmesh(&m, i, filedata);
|
||||
DEVIL1GEO.getmesh(&m, i, filedata, filesize);
|
||||
writemesh(mh, &m, filename, i);
|
||||
free(m.b);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ int main(int argc, char ** argv) {
|
||||
char *f = argv[1];
|
||||
unsigned int bufsize = 0;
|
||||
char *buffer = loadfile(f, &bufsize);
|
||||
extractmeshes(buffer, bufsize, f);
|
||||
extractmeshes(buffer, f, bufsize);
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user