Fix normals in wall surfaces that are squished into triangles
This commit is contained in:
parent
d212147a3c
commit
6078e339fc
2 changed files with 20 additions and 6 deletions
|
|
@ -470,7 +470,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2], verts[3]);
|
||||
Surfaces.Push(surf);
|
||||
return;
|
||||
}
|
||||
|
|
@ -501,7 +501,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2], verts[3]);
|
||||
Surfaces.Push(surf);
|
||||
return;
|
||||
}
|
||||
|
|
@ -549,7 +549,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2], verts[3]);
|
||||
Surfaces.Push(surf);
|
||||
}
|
||||
|
||||
|
|
@ -587,7 +587,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2], verts[3]);
|
||||
surf.Type = ST_LOWERSIDE;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.bSky = false;
|
||||
|
|
@ -626,7 +626,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2], verts[3]);
|
||||
surf.Type = ST_UPPERSIDE;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.bSky = bSky;
|
||||
|
|
@ -665,7 +665,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2], verts[3]);
|
||||
surf.Type = ST_MIDDLESIDE;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,20 @@ private:
|
|||
return FVector4(n.X, n.Y, n.Z, d);
|
||||
}
|
||||
|
||||
static FVector4 ToPlane(const FVector3& pt1, const FVector3& pt2, const FVector3& pt3, const FVector3& pt4)
|
||||
{
|
||||
if (pt1.ApproximatelyEquals(pt3))
|
||||
{
|
||||
return ToPlane(pt1, pt2, pt4);
|
||||
}
|
||||
else if(pt1.ApproximatelyEquals(pt2) || pt2.ApproximatelyEquals(pt3))
|
||||
{
|
||||
return ToPlane(pt1, pt3, pt4);
|
||||
}
|
||||
|
||||
return ToPlane(pt1, pt2, pt3);
|
||||
}
|
||||
|
||||
static FVector2 ToFVector2(const DVector2& v) { return FVector2((float)v.X, (float)v.Y); }
|
||||
static FVector3 ToFVector3(const DVector3& v) { return FVector3((float)v.X, (float)v.Y, (float)v.Z); }
|
||||
static FVector4 ToFVector4(const DVector4& v) { return FVector4((float)v.X, (float)v.Y, (float)v.Z, (float)v.W); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue