mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- fixed: DMD models didn't load their triangle data.
- fixed: MD2 models didn't handle the triangles' byte order.
This commit is contained in:
parent
f8016bef86
commit
5a91fd0ad4
1 changed files with 23 additions and 4 deletions
|
@ -115,7 +115,6 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length)
|
|||
char *temp;
|
||||
ModelFrame *frame;
|
||||
int i, k, c;
|
||||
FTriangle *triangles[MAX_LODS];
|
||||
int axis[3] = { VX, VY, VZ };
|
||||
|
||||
int fileoffset=12+sizeof(dmd_chunk_t);
|
||||
|
@ -197,8 +196,19 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length)
|
|||
{
|
||||
lodInfo[i].numTriangles = LittleLong(lodInfo[i].numTriangles);
|
||||
lodInfo[i].offsetTriangles = LittleLong(lodInfo[i].offsetTriangles);
|
||||
|
||||
lods[i].triangles = triangles[i] = (FTriangle*)(buffer + lodInfo[i].offsetTriangles);
|
||||
if (lodInfo[i].numTriangles > 0)
|
||||
{
|
||||
lods[i].triangles = new FTriangle[lodInfo[i].numTriangles];
|
||||
memcpy(lods[i].triangles, buffer + lodInfo[i].offsetTriangles, lodInfo[i].numTriangles * sizeof(FTriangle));
|
||||
for (int j = 0; j < lodInfo[i].numTriangles; j++)
|
||||
{
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
lods[i].triangles[j].textureIndices[k] = LittleShort(lods[i].triangles[j].textureIndices[k]);
|
||||
lods[i].triangles[j].vertexIndices[k] = LittleShort(lods[i].triangles[j].vertexIndices[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loaded=true;
|
||||
|
@ -465,7 +475,16 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length)
|
|||
|
||||
lods[0].triangles = new FTriangle[lodInfo[0].numTriangles];
|
||||
|
||||
memcpy(lods[0].triangles, buffer + lodInfo[0].offsetTriangles, sizeof(FTriangle) * lodInfo[0].numTriangles);
|
||||
int cnt = lodInfo[0].numTriangles;
|
||||
memcpy(lods[0].triangles, buffer + lodInfo[0].offsetTriangles, sizeof(FTriangle) * cnt);
|
||||
for (int j = 0; j < cnt; j++)
|
||||
{
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
lods[0].triangles[j].textureIndices[k] = LittleShort(lods[0].triangles[j].textureIndices[k]);
|
||||
lods[0].triangles[j].vertexIndices[k] = LittleShort(lods[0].triangles[j].vertexIndices[k]);
|
||||
}
|
||||
}
|
||||
|
||||
skins = new FTexture *[info.numSkins];
|
||||
|
||||
|
|
Loading…
Reference in a new issue