From 670c86cd470aa5f5be9819378a86843b15cc72ba Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Tue, 25 Sep 2018 18:48:00 +0200 Subject: [PATCH] Fix a major oversight that caused UE1 models to use the normals of the first frame for all frames. --- src/r_data/models/models_ue1.cpp | 23 ++++++++++++++--------- src/r_data/models/models_ue1.h | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/r_data/models/models_ue1.cpp b/src/r_data/models/models_ue1.cpp index f4392e54b..838be2af7 100644 --- a/src/r_data/models/models_ue1.cpp +++ b/src/r_data/models/models_ue1.cpp @@ -123,11 +123,14 @@ void FUE1Model::LoadGeometry() // unpack coords 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); - // compute facet normal - FVector3 dir[2]; - dir[0] = verts[Poly.V[1]].Pos-verts[Poly.V[0]].Pos; - dir[1] = verts[Poly.V[2]].Pos-verts[Poly.V[0]].Pos; - Poly.Normal = dir[0]^dir[1]; + // compute facet normals + for ( int j=0; jSet(V.Pos.X,V.Pos.Y,V.Pos.Z,C.X,C.Y); if ( groups[j].type&PT_Curvy ) // use facet normal { - vert->SetNormal(polys[groups[j].P[k]].Normal.X, - polys[groups[j].P[k]].Normal.Y, - polys[groups[j].P[k]].Normal.Z); + vert->SetNormal(polys[groups[j].P[k]].Normals[i].X, + polys[groups[j].P[k]].Normals[i].Y, + polys[groups[j].P[k]].Normals[i].Z); } else vert->SetNormal(V.Normal.X,V.Normal.Y,V.Normal.Z); } diff --git a/src/r_data/models/models_ue1.h b/src/r_data/models/models_ue1.h index fb67758f7..be9f57a10 100644 --- a/src/r_data/models/models_ue1.h +++ b/src/r_data/models/models_ue1.h @@ -89,7 +89,7 @@ private: { int V[3]; FVector2 C[3]; - FVector3 Normal; + TArray Normals; }; struct UE1Group {