mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-22 13:53:02 +05:30
Initialized pointers for arrays in struct Batch
This commit is contained in:
parent
fb962d2ffe
commit
ad357afc36
@ -76,6 +76,8 @@ void printmeshbatch(struct Batch*);
|
||||
|
||||
void printpositions(struct Positions*, unsigned int);
|
||||
|
||||
void printnormals(struct Normals*, unsigned int);
|
||||
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const);
|
||||
|
||||
|
@ -49,6 +49,16 @@ void printpositions(struct Positions *p, unsigned int count) {
|
||||
}
|
||||
}
|
||||
|
||||
void printnormals(struct Normals *n, unsigned int count) {
|
||||
if (n == NULL) {
|
||||
return;
|
||||
}
|
||||
unsigned int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
printf("(%f, %f, %f)\n", (n[i]).x, (n[i]).y, (n[i]).z);
|
||||
}
|
||||
}
|
||||
|
||||
bool getmeshheader(struct MeshHeader **hs,
|
||||
unsigned int i,
|
||||
const char * const filedata) {
|
||||
@ -75,13 +85,11 @@ bool getmeshbatch(struct Batch **b,
|
||||
}
|
||||
unsigned int offset = h -> offsetBatches;
|
||||
*b = (struct Batch*)(filedata + offset);
|
||||
(*b) -> p = (struct Positions*)(filedata + ((*b) -> offsetPositions));
|
||||
printf("p = %x\n", (*b) -> offsetPositions);
|
||||
printpositions((*b) -> p, 3);
|
||||
(*b) -> n = NULL;
|
||||
(*b) -> u = NULL;
|
||||
(*b) -> bi = NULL;
|
||||
(*b) -> bw = NULL;
|
||||
(*b) -> p = (struct Positions*)(filedata + ((*b) -> offsetPositions));
|
||||
(*b) -> n = (struct Normals*)(filedata + ((*b) -> offsetNormals));
|
||||
(*b) -> u = (struct UVs*)(filedata + ((*b) -> offsetUVs));
|
||||
(*b) -> bi = (struct BoneIndexes*)(filedata + ((*b) -> offsetBoneIndexes));
|
||||
(*b) -> bw = (struct BoneWeights*)(filedata + ((*b) -> offsetBoneWeights));
|
||||
done = true;
|
||||
return done;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void extractmeshes(const char *filedata,
|
||||
unsigned int i;
|
||||
bool ok;
|
||||
//h -> numMesh
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (i = 1; i < 2; i++) {
|
||||
ok = getmeshheader(&mh, i, filedata);
|
||||
if (ok) {
|
||||
getmeshbatch(&b, mh, filedata);
|
||||
|
Loading…
Reference in New Issue
Block a user