mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
Fix a major oversight that caused UE1 models to use the normals of the first frame for all frames.
This commit is contained in:
parent
a9b25242cd
commit
670c86cd47
2 changed files with 15 additions and 10 deletions
|
@ -123,11 +123,14 @@ void FUE1Model::LoadGeometry()
|
||||||
// unpack coords
|
// unpack coords
|
||||||
for ( int j=0; j<3; j++ )
|
for ( int j=0; j<3; j++ )
|
||||||
Poly.C[j] = FVector2(dpolys[i].uv[j][0]/255.f,dpolys[i].uv[j][1]/255.f);
|
Poly.C[j] = FVector2(dpolys[i].uv[j][0]/255.f,dpolys[i].uv[j][1]/255.f);
|
||||||
// compute facet normal
|
// compute facet normals
|
||||||
FVector3 dir[2];
|
for ( int j=0; j<numFrames; j++ )
|
||||||
dir[0] = verts[Poly.V[1]].Pos-verts[Poly.V[0]].Pos;
|
{
|
||||||
dir[1] = verts[Poly.V[2]].Pos-verts[Poly.V[0]].Pos;
|
FVector3 dir[2];
|
||||||
Poly.Normal = dir[0]^dir[1];
|
dir[0] = verts[Poly.V[1]+numVerts*j].Pos-verts[Poly.V[0]+numVerts*j].Pos;
|
||||||
|
dir[1] = verts[Poly.V[2]+numVerts*j].Pos-verts[Poly.V[0]+numVerts*j].Pos;
|
||||||
|
Poly.Normals.Push(dir[0]^dir[1]);
|
||||||
|
}
|
||||||
// push
|
// push
|
||||||
polys.Push(Poly);
|
polys.Push(Poly);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +145,7 @@ void FUE1Model::LoadGeometry()
|
||||||
for ( int k=0; k<numPolys; k++ )
|
for ( int k=0; k<numPolys; k++ )
|
||||||
{
|
{
|
||||||
if ( (polys[k].V[0] != j) && (polys[k].V[1] != j) && (polys[k].V[2] != j) ) continue;
|
if ( (polys[k].V[0] != j) && (polys[k].V[1] != j) && (polys[k].V[2] != j) ) continue;
|
||||||
nsum += polys[k].Normal;
|
nsum += polys[k].Normals[i];
|
||||||
}
|
}
|
||||||
verts[j+numVerts*i].Normal = nsum.Unit();
|
verts[j+numVerts*i].Normal = nsum.Unit();
|
||||||
}
|
}
|
||||||
|
@ -198,6 +201,8 @@ void FUE1Model::UnloadGeometry()
|
||||||
numPolys = 0;
|
numPolys = 0;
|
||||||
numGroups = 0;
|
numGroups = 0;
|
||||||
verts.Reset();
|
verts.Reset();
|
||||||
|
for ( int i=0; i<numPolys; i++ )
|
||||||
|
polys[i].Normals.Reset();
|
||||||
polys.Reset();
|
polys.Reset();
|
||||||
for ( int i=0; i<numGroups; i++ )
|
for ( int i=0; i<numGroups; i++ )
|
||||||
groups[i].P.Reset();
|
groups[i].P.Reset();
|
||||||
|
@ -275,9 +280,9 @@ void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
|
||||||
vert->Set(V.Pos.X,V.Pos.Y,V.Pos.Z,C.X,C.Y);
|
vert->Set(V.Pos.X,V.Pos.Y,V.Pos.Z,C.X,C.Y);
|
||||||
if ( groups[j].type&PT_Curvy ) // use facet normal
|
if ( groups[j].type&PT_Curvy ) // use facet normal
|
||||||
{
|
{
|
||||||
vert->SetNormal(polys[groups[j].P[k]].Normal.X,
|
vert->SetNormal(polys[groups[j].P[k]].Normals[i].X,
|
||||||
polys[groups[j].P[k]].Normal.Y,
|
polys[groups[j].P[k]].Normals[i].Y,
|
||||||
polys[groups[j].P[k]].Normal.Z);
|
polys[groups[j].P[k]].Normals[i].Z);
|
||||||
}
|
}
|
||||||
else vert->SetNormal(V.Normal.X,V.Normal.Y,V.Normal.Z);
|
else vert->SetNormal(V.Normal.X,V.Normal.Y,V.Normal.Z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ private:
|
||||||
{
|
{
|
||||||
int V[3];
|
int V[3];
|
||||||
FVector2 C[3];
|
FVector2 C[3];
|
||||||
FVector3 Normal;
|
TArray<FVector3> Normals;
|
||||||
};
|
};
|
||||||
struct UE1Group
|
struct UE1Group
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue