Remove old wall surface creation code
This commit is contained in:
parent
9ca058ccc9
commit
2cda07245c
2 changed files with 2 additions and 624 deletions
|
|
@ -179,6 +179,7 @@ void DoomLevelSubmesh::CreateStaticSurfaces(FLevelLocals& doomMap)
|
|||
|
||||
void DoomLevelSubmesh::CreateDynamicSurfaces(FLevelLocals& doomMap)
|
||||
{
|
||||
#if 0
|
||||
// Look for polyobjects
|
||||
for (unsigned int i = 0; i < doomMap.lines.Size(); i++)
|
||||
{
|
||||
|
|
@ -198,6 +199,7 @@ void DoomLevelSubmesh::CreateDynamicSurfaces(FLevelLocals& doomMap)
|
|||
|
||||
CreateSideSurfaces(doomMap, side);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateIndexes()
|
||||
|
|
@ -492,601 +494,6 @@ void DoomLevelSubmesh::SetSideLightmap(DoomLevelMeshSurface* surface)
|
|||
}
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateLinePortalSurface(FLevelLocals& doomMap, side_t* side)
|
||||
{
|
||||
sector_t* front = side->sector;
|
||||
|
||||
FVector2 v1 = ToFVector2(side->V1()->fPos());
|
||||
FVector2 v2 = ToFVector2(side->V2()->fPos());
|
||||
|
||||
float v1Top = (float)front->ceilingplane.ZatPoint(v1);
|
||||
float v1Bottom = (float)front->floorplane.ZatPoint(v1);
|
||||
float v2Top = (float)front->ceilingplane.ZatPoint(v2);
|
||||
float v2Bottom = (float)front->floorplane.ZatPoint(v2);
|
||||
|
||||
FFlatVertex verts[4];
|
||||
verts[0].x = verts[2].x = v1.X;
|
||||
verts[0].y = verts[2].y = v1.Y;
|
||||
verts[1].x = verts[3].x = v2.X;
|
||||
verts[1].y = verts[3].y = v2.Y;
|
||||
verts[0].z = v1Bottom;
|
||||
verts[1].z = v2Bottom;
|
||||
verts[2].z = v1Top;
|
||||
verts[3].z = v2Top;
|
||||
|
||||
DoomLevelMeshSurface surf;
|
||||
surf.Submesh = this;
|
||||
surf.Type = ST_MIDDLESIDE;
|
||||
surf.TypeIndex = side->Index();
|
||||
surf.bSky = front->GetTexture(sector_t::floor) == skyflatnum || front->GetTexture(sector_t::ceiling) == skyflatnum;
|
||||
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||
surf.startVertIndex = MeshVertices.Size();
|
||||
surf.numVerts = 4;
|
||||
surf.Side = side;
|
||||
|
||||
MeshVertices.Push(verts[0]);
|
||||
MeshVertices.Push(verts[1]);
|
||||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
|
||||
int uniformsIndex = MeshSurfaceUniforms.Size();
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
|
||||
surf.plane = ToPlane(verts[0].fPos(), verts[1].fPos(), verts[2].fPos(), verts[3].fPos());
|
||||
surf.sectorGroup = sectorGroup[front->Index()];
|
||||
surf.AlwaysUpdate = !!(front->Flags & SECF_LM_DYNAMIC);
|
||||
|
||||
SurfaceUniforms uniforms = DefaultUniforms();
|
||||
uniforms.uLightLevel = front->lightlevel * (1.0f / 255.0f);
|
||||
|
||||
FMaterialState material;
|
||||
|
||||
SetSideTextureUVs(surf, side, side_t::top, v1Top, v1Bottom, v2Top, v2Bottom);
|
||||
|
||||
MeshSurfaceUniforms.Push(uniforms);
|
||||
MeshSurfaceMaterials.Push(material);
|
||||
Surfaces.Push(surf);
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateSideSurfaces(FLevelLocals& doomMap, side_t* side)
|
||||
{
|
||||
sector_t* front = side->sector;
|
||||
sector_t* back = (side->linedef->frontsector == front) ? side->linedef->backsector : side->linedef->frontsector;
|
||||
|
||||
FVector2 v1 = ToFVector2(side->V1()->fPos());
|
||||
FVector2 v2 = ToFVector2(side->V2()->fPos());
|
||||
|
||||
float v1Top = (float)front->ceilingplane.ZatPoint(v1);
|
||||
float v1Bottom = (float)front->floorplane.ZatPoint(v1);
|
||||
float v2Top = (float)front->ceilingplane.ZatPoint(v2);
|
||||
float v2Bottom = (float)front->floorplane.ZatPoint(v2);
|
||||
|
||||
if (side->linedef->getPortal() && side->linedef->frontsector == front)
|
||||
{
|
||||
CreateLinePortalSurface(doomMap, side);
|
||||
}
|
||||
else if (side->linedef->special == Line_Horizon && front != back)
|
||||
{
|
||||
CreateLineHorizonSurface(doomMap, side);
|
||||
}
|
||||
else if (!back)
|
||||
{
|
||||
CreateFrontWallSurface(doomMap, side);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (side->textures[side_t::mid].texture.isValid())
|
||||
{
|
||||
CreateMidWallSurface(doomMap, side);
|
||||
}
|
||||
|
||||
Create3DFloorWallSurfaces(doomMap, side);
|
||||
|
||||
float v1TopBack = (float)back->ceilingplane.ZatPoint(v1);
|
||||
float v1BottomBack = (float)back->floorplane.ZatPoint(v1);
|
||||
float v2TopBack = (float)back->ceilingplane.ZatPoint(v2);
|
||||
float v2BottomBack = (float)back->floorplane.ZatPoint(v2);
|
||||
|
||||
if (v1Bottom < v1BottomBack || v2Bottom < v2BottomBack)
|
||||
{
|
||||
CreateBottomWallSurface(doomMap, side);
|
||||
}
|
||||
|
||||
if (v1Top > v1TopBack || v2Top > v2TopBack)
|
||||
{
|
||||
CreateTopWallSurface(doomMap, side);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateLineHorizonSurface(FLevelLocals& doomMap, side_t* side)
|
||||
{
|
||||
sector_t* front = side->sector;
|
||||
|
||||
FVector2 v1 = ToFVector2(side->V1()->fPos());
|
||||
FVector2 v2 = ToFVector2(side->V2()->fPos());
|
||||
|
||||
float v1Top = (float)front->ceilingplane.ZatPoint(v1);
|
||||
float v1Bottom = (float)front->floorplane.ZatPoint(v1);
|
||||
float v2Top = (float)front->ceilingplane.ZatPoint(v2);
|
||||
float v2Bottom = (float)front->floorplane.ZatPoint(v2);
|
||||
|
||||
DoomLevelMeshSurface surf;
|
||||
surf.Submesh = this;
|
||||
surf.Type = ST_MIDDLESIDE;
|
||||
surf.TypeIndex = side->Index();
|
||||
surf.bSky = front->GetTexture(sector_t::floor) == skyflatnum || front->GetTexture(sector_t::ceiling) == skyflatnum;
|
||||
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||
surf.Side = side;
|
||||
|
||||
FFlatVertex verts[4];
|
||||
verts[0].x = verts[2].x = v1.X;
|
||||
verts[0].y = verts[2].y = v1.Y;
|
||||
verts[1].x = verts[3].x = v2.X;
|
||||
verts[1].y = verts[3].y = v2.Y;
|
||||
verts[0].z = v1Bottom;
|
||||
verts[1].z = v2Bottom;
|
||||
verts[2].z = v1Top;
|
||||
verts[3].z = v2Top;
|
||||
|
||||
surf.startVertIndex = MeshVertices.Size();
|
||||
surf.numVerts = 4;
|
||||
MeshVertices.Push(verts[0]);
|
||||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
MeshVertices.Push(verts[1]);
|
||||
|
||||
int uniformsIndex = MeshSurfaceUniforms.Size();
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
|
||||
surf.plane = ToPlane(verts[0].fPos(), verts[1].fPos(), verts[2].fPos(), verts[3].fPos());
|
||||
surf.sectorGroup = sectorGroup[front->Index()];
|
||||
surf.AlwaysUpdate = !!(front->Flags & SECF_LM_DYNAMIC);
|
||||
|
||||
SurfaceUniforms uniforms = DefaultUniforms();
|
||||
uniforms.uLightLevel = front->lightlevel * (1.0f / 255.0f);
|
||||
|
||||
FMaterialState material;
|
||||
|
||||
SetSideTextureUVs(surf, side, side_t::top, v1Top, v1Bottom, v2Top, v2Bottom);
|
||||
|
||||
MeshSurfaceUniforms.Push(uniforms);
|
||||
MeshSurfaceMaterials.Push(material);
|
||||
Surfaces.Push(surf);
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateFrontWallSurface(FLevelLocals& doomMap, side_t* side)
|
||||
{
|
||||
sector_t* front = side->sector;
|
||||
/*
|
||||
bool isPolyLine = !!(side->Flags & WALLF_POLYOBJ);
|
||||
if (isPolyLine)
|
||||
{
|
||||
subsector_t* subsector = level.PointInRenderSubsector((side->V1()->fPos() + side->V2()->fPos()) * 0.5);
|
||||
front = subsector->sector;
|
||||
}
|
||||
*/
|
||||
FVector2 v1 = ToFVector2(side->V1()->fPos());
|
||||
FVector2 v2 = ToFVector2(side->V2()->fPos());
|
||||
|
||||
float v1Top = (float)front->ceilingplane.ZatPoint(v1);
|
||||
float v1Bottom = (float)front->floorplane.ZatPoint(v1);
|
||||
float v2Top = (float)front->ceilingplane.ZatPoint(v2);
|
||||
float v2Bottom = (float)front->floorplane.ZatPoint(v2);
|
||||
|
||||
FFlatVertex verts[4];
|
||||
verts[0].x = verts[2].x = v1.X;
|
||||
verts[0].y = verts[2].y = v1.Y;
|
||||
verts[1].x = verts[3].x = v2.X;
|
||||
verts[1].y = verts[3].y = v2.Y;
|
||||
verts[0].z = v1Bottom;
|
||||
verts[1].z = v2Bottom;
|
||||
verts[2].z = v1Top;
|
||||
verts[3].z = v2Top;
|
||||
|
||||
DoomLevelMeshSurface surf;
|
||||
surf.Submesh = this;
|
||||
surf.bSky = false;
|
||||
surf.startVertIndex = MeshVertices.Size();
|
||||
surf.numVerts = 4;
|
||||
surf.bSky = false;
|
||||
MeshVertices.Push(verts[0]);
|
||||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
MeshVertices.Push(verts[1]);
|
||||
|
||||
int uniformsIndex = MeshSurfaceUniforms.Size();
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
|
||||
surf.plane = ToPlane(verts[0].fPos(), verts[1].fPos(), verts[2].fPos(), verts[3].fPos());
|
||||
surf.Type = ST_MIDDLESIDE;
|
||||
surf.TypeIndex = side->Index();
|
||||
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||
surf.ControlSector = nullptr;
|
||||
surf.sectorGroup = sectorGroup[front->Index()];
|
||||
surf.texture = TexMan.GetGameTexture(side->textures[side_t::mid].texture);
|
||||
surf.AlwaysUpdate = !!(front->Flags & SECF_LM_DYNAMIC);
|
||||
surf.Side = side;
|
||||
|
||||
SurfaceUniforms uniforms = DefaultUniforms();
|
||||
uniforms.uLightLevel = front->lightlevel * (1.0f / 255.0f);
|
||||
|
||||
FMaterialState material;
|
||||
|
||||
SetSideTextureUVs(surf, side, side_t::top, v1Top, v1Bottom, v2Top, v2Bottom);
|
||||
|
||||
MeshSurfaceUniforms.Push(uniforms);
|
||||
MeshSurfaceMaterials.Push(material);
|
||||
Surfaces.Push(surf);
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateMidWallSurface(FLevelLocals& doomMap, side_t* side)
|
||||
{
|
||||
sector_t* front = side->sector;
|
||||
|
||||
FVector2 v1 = ToFVector2(side->V1()->fPos());
|
||||
FVector2 v2 = ToFVector2(side->V2()->fPos());
|
||||
|
||||
float v1Top = (float)front->ceilingplane.ZatPoint(v1);
|
||||
float v1Bottom = (float)front->floorplane.ZatPoint(v1);
|
||||
float v2Top = (float)front->ceilingplane.ZatPoint(v2);
|
||||
float v2Bottom = (float)front->floorplane.ZatPoint(v2);
|
||||
|
||||
FFlatVertex verts[4];
|
||||
verts[0].x = verts[2].x = v1.X;
|
||||
verts[0].y = verts[2].y = v1.Y;
|
||||
verts[1].x = verts[3].x = v2.X;
|
||||
verts[1].y = verts[3].y = v2.Y;
|
||||
|
||||
const auto& texture = side->textures[side_t::mid].texture;
|
||||
|
||||
if ((side->Flags & WALLF_WRAP_MIDTEX) || (side->linedef->flags & WALLF_WRAP_MIDTEX))
|
||||
{
|
||||
verts[0].z = v1Bottom;
|
||||
verts[1].z = v2Bottom;
|
||||
verts[2].z = v1Top;
|
||||
verts[3].z = v2Top;
|
||||
}
|
||||
else
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
auto gameTexture = TexMan.GetGameTexture(texture);
|
||||
|
||||
float mid1Top = (float)(gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale);
|
||||
float mid2Top = (float)(gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale);
|
||||
float mid1Bottom = 0;
|
||||
float mid2Bottom = 0;
|
||||
|
||||
float yTextureOffset = (float)(side->textures[side_t::mid].yOffset / gameTexture->GetScaleY());
|
||||
|
||||
if (side->linedef->flags & ML_DONTPEGBOTTOM)
|
||||
{
|
||||
yTextureOffset += (float)side->sector->planes[sector_t::floor].TexZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
yTextureOffset += (float)(side->sector->planes[sector_t::ceiling].TexZ - gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale);
|
||||
}
|
||||
|
||||
verts[0].z = min(max(yTextureOffset + mid1Bottom, v1Bottom), v1Top);
|
||||
verts[1].z = min(max(yTextureOffset + mid2Bottom, v2Bottom), v2Top);
|
||||
verts[2].z = max(min(yTextureOffset + mid1Top, v1Top), v1Bottom);
|
||||
verts[3].z = max(min(yTextureOffset + mid2Top, v2Top), v2Bottom);
|
||||
}
|
||||
|
||||
// mid texture
|
||||
DoomLevelMeshSurface surf;
|
||||
surf.Submesh = this;
|
||||
surf.bSky = false;
|
||||
surf.startVertIndex = MeshVertices.Size();
|
||||
surf.numVerts = 4;
|
||||
surf.bSky = false;
|
||||
surf.plane = ToPlane(verts[0].fPos(), verts[1].fPos(), verts[2].fPos(), verts[3].fPos());
|
||||
|
||||
if (side->linedef->sidedef[0] != side)
|
||||
{
|
||||
surf.plane = -surf.plane;
|
||||
surf.plane.W = -surf.plane.W;
|
||||
}
|
||||
|
||||
MeshVertices.Push(verts[0]);
|
||||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
MeshVertices.Push(verts[1]);
|
||||
|
||||
int uniformsIndex = MeshSurfaceUniforms.Size();
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
|
||||
surf.Type = ST_MIDDLESIDE;
|
||||
surf.TypeIndex = side->Index();
|
||||
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||
surf.ControlSector = nullptr;
|
||||
surf.sectorGroup = sectorGroup[front->Index()];
|
||||
surf.texture = TexMan.GetGameTexture(texture);
|
||||
surf.alpha = float(side->linedef->alpha);
|
||||
surf.AlwaysUpdate = !!(front->Flags & SECF_LM_DYNAMIC);
|
||||
surf.Side = side;
|
||||
|
||||
SurfaceUniforms uniforms = DefaultUniforms();
|
||||
uniforms.uLightLevel = front->lightlevel * (1.0f / 255.0f);
|
||||
|
||||
FMaterialState material;
|
||||
|
||||
SetSideTextureUVs(surf, side, side_t::top, verts[2].z, verts[0].z, verts[3].z, verts[1].z);
|
||||
|
||||
MeshSurfaceUniforms.Push(uniforms);
|
||||
MeshSurfaceMaterials.Push(material);
|
||||
Surfaces.Push(surf);
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::Create3DFloorWallSurfaces(FLevelLocals& doomMap, side_t* side)
|
||||
{
|
||||
sector_t* front = side->sector;
|
||||
sector_t* back = (side->linedef->frontsector == front) ? side->linedef->backsector : side->linedef->frontsector;
|
||||
|
||||
FVector2 v1 = ToFVector2(side->V1()->fPos());
|
||||
FVector2 v2 = ToFVector2(side->V2()->fPos());
|
||||
|
||||
float v1Top = (float)front->ceilingplane.ZatPoint(v1);
|
||||
float v1Bottom = (float)front->floorplane.ZatPoint(v1);
|
||||
float v2Top = (float)front->ceilingplane.ZatPoint(v2);
|
||||
float v2Bottom = (float)front->floorplane.ZatPoint(v2);
|
||||
|
||||
for (unsigned int j = 0; j < front->e->XFloor.ffloors.Size(); j++)
|
||||
{
|
||||
F3DFloor* xfloor = front->e->XFloor.ffloors[j];
|
||||
|
||||
// Don't create a line when both sectors have the same 3d floor
|
||||
bool bothSides = false;
|
||||
for (unsigned int k = 0; k < back->e->XFloor.ffloors.Size(); k++)
|
||||
{
|
||||
if (back->e->XFloor.ffloors[k] == xfloor)
|
||||
{
|
||||
bothSides = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bothSides)
|
||||
continue;
|
||||
|
||||
DoomLevelMeshSurface surf;
|
||||
surf.Submesh = this;
|
||||
surf.Type = ST_MIDDLESIDE;
|
||||
surf.TypeIndex = side->Index();
|
||||
surf.ControlSector = xfloor->model;
|
||||
surf.bSky = false;
|
||||
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||
surf.Side = side;
|
||||
|
||||
float blZ = (float)xfloor->model->floorplane.ZatPoint(v1);
|
||||
float brZ = (float)xfloor->model->floorplane.ZatPoint(v2);
|
||||
float tlZ = (float)xfloor->model->ceilingplane.ZatPoint(v1);
|
||||
float trZ = (float)xfloor->model->ceilingplane.ZatPoint(v2);
|
||||
|
||||
FFlatVertex verts[4];
|
||||
verts[0].x = verts[2].x = v2.X;
|
||||
verts[0].y = verts[2].y = v2.Y;
|
||||
verts[1].x = verts[3].x = v1.X;
|
||||
verts[1].y = verts[3].y = v1.Y;
|
||||
verts[0].z = brZ;
|
||||
verts[1].z = blZ;
|
||||
verts[2].z = trZ;
|
||||
verts[3].z = tlZ;
|
||||
|
||||
surf.startVertIndex = MeshVertices.Size();
|
||||
surf.numVerts = 4;
|
||||
MeshVertices.Push(verts[0]);
|
||||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
MeshVertices.Push(verts[1]);
|
||||
|
||||
int uniformsIndex = MeshSurfaceUniforms.Size();
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
|
||||
surf.plane = ToPlane(verts[0].fPos(), verts[1].fPos(), verts[2].fPos(), verts[3].fPos());
|
||||
surf.sectorGroup = sectorGroup[front->Index()];
|
||||
surf.texture = TexMan.GetGameTexture(side->textures[side_t::mid].texture);
|
||||
surf.AlwaysUpdate = !!(front->Flags & SECF_LM_DYNAMIC);
|
||||
|
||||
SurfaceUniforms uniforms = DefaultUniforms();
|
||||
uniforms.uLightLevel = front->lightlevel * (1.0f / 255.0f);
|
||||
|
||||
FMaterialState material;
|
||||
|
||||
SetSideTextureUVs(surf, side, side_t::top, tlZ, blZ, trZ, brZ);
|
||||
|
||||
MeshSurfaceUniforms.Push(uniforms);
|
||||
MeshSurfaceMaterials.Push(material);
|
||||
Surfaces.Push(surf);
|
||||
}
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateTopWallSurface(FLevelLocals& doomMap, side_t* side)
|
||||
{
|
||||
sector_t* front = side->sector;
|
||||
sector_t* back = (side->linedef->frontsector == front) ? side->linedef->backsector : side->linedef->frontsector;
|
||||
|
||||
FVector2 v1 = ToFVector2(side->V1()->fPos());
|
||||
FVector2 v2 = ToFVector2(side->V2()->fPos());
|
||||
|
||||
float v1Top = (float)front->ceilingplane.ZatPoint(v1);
|
||||
float v2Top = (float)front->ceilingplane.ZatPoint(v2);
|
||||
float v1TopBack = (float)back->ceilingplane.ZatPoint(v1);
|
||||
float v2TopBack = (float)back->ceilingplane.ZatPoint(v2);
|
||||
|
||||
bool bSky = IsTopSideSky(front, back, side);
|
||||
if (!bSky && !IsTopSideVisible(side))
|
||||
return;
|
||||
|
||||
FFlatVertex verts[4];
|
||||
verts[0].x = verts[2].x = v1.X;
|
||||
verts[0].y = verts[2].y = v1.Y;
|
||||
verts[1].x = verts[3].x = v2.X;
|
||||
verts[1].y = verts[3].y = v2.Y;
|
||||
verts[0].z = v1TopBack;
|
||||
verts[1].z = v2TopBack;
|
||||
verts[2].z = v1Top;
|
||||
verts[3].z = v2Top;
|
||||
|
||||
DoomLevelMeshSurface surf;
|
||||
surf.Submesh = this;
|
||||
surf.startVertIndex = MeshVertices.Size();
|
||||
surf.numVerts = 4;
|
||||
MeshVertices.Push(verts[0]);
|
||||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
MeshVertices.Push(verts[1]);
|
||||
|
||||
int uniformsIndex = MeshSurfaceUniforms.Size();
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
|
||||
surf.plane = ToPlane(verts[0].fPos(), verts[1].fPos(), verts[2].fPos(), verts[3].fPos());
|
||||
surf.Type = ST_UPPERSIDE;
|
||||
surf.TypeIndex = side->Index();
|
||||
surf.bSky = bSky;
|
||||
surf.sampleDimension = side->textures[side_t::top].LightmapSampleDistance;
|
||||
surf.ControlSector = nullptr;
|
||||
surf.sectorGroup = sectorGroup[front->Index()];
|
||||
surf.texture = TexMan.GetGameTexture(side->textures[side_t::top].texture);
|
||||
surf.AlwaysUpdate = !!(front->Flags & SECF_LM_DYNAMIC);
|
||||
surf.Side = side;
|
||||
|
||||
SurfaceUniforms uniforms = DefaultUniforms();
|
||||
uniforms.uLightLevel = front->lightlevel * (1.0f / 255.0f);
|
||||
|
||||
FMaterialState material;
|
||||
|
||||
SetSideTextureUVs(surf, side, side_t::top, v1Top, v1TopBack, v2Top, v2TopBack);
|
||||
|
||||
MeshSurfaceUniforms.Push(uniforms);
|
||||
MeshSurfaceMaterials.Push(material);
|
||||
Surfaces.Push(surf);
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateBottomWallSurface(FLevelLocals& doomMap, side_t* side)
|
||||
{
|
||||
if (!IsBottomSideVisible(side))
|
||||
return;
|
||||
|
||||
sector_t* front = side->sector;
|
||||
sector_t* back = (side->linedef->frontsector == front) ? side->linedef->backsector : side->linedef->frontsector;
|
||||
|
||||
FVector2 v1 = ToFVector2(side->V1()->fPos());
|
||||
FVector2 v2 = ToFVector2(side->V2()->fPos());
|
||||
|
||||
float v1Bottom = (float)front->floorplane.ZatPoint(v1);
|
||||
float v2Bottom = (float)front->floorplane.ZatPoint(v2);
|
||||
float v1BottomBack = (float)back->floorplane.ZatPoint(v1);
|
||||
float v2BottomBack = (float)back->floorplane.ZatPoint(v2);
|
||||
|
||||
FFlatVertex verts[4];
|
||||
verts[0].x = verts[2].x = v1.X;
|
||||
verts[0].y = verts[2].y = v1.Y;
|
||||
verts[1].x = verts[3].x = v2.X;
|
||||
verts[1].y = verts[3].y = v2.Y;
|
||||
verts[0].z = v1Bottom;
|
||||
verts[1].z = v2Bottom;
|
||||
verts[2].z = v1BottomBack;
|
||||
verts[3].z = v2BottomBack;
|
||||
|
||||
DoomLevelMeshSurface surf;
|
||||
surf.Submesh = this;
|
||||
surf.startVertIndex = MeshVertices.Size();
|
||||
surf.numVerts = 4;
|
||||
MeshVertices.Push(verts[0]);
|
||||
MeshVertices.Push(verts[2]);
|
||||
MeshVertices.Push(verts[3]);
|
||||
MeshVertices.Push(verts[1]);
|
||||
|
||||
int uniformsIndex = MeshSurfaceUniforms.Size();
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
MeshUniformIndexes.Push(uniformsIndex);
|
||||
|
||||
surf.plane = ToPlane(verts[0].fPos(), verts[1].fPos(), verts[2].fPos(), verts[3].fPos());
|
||||
surf.Type = ST_LOWERSIDE;
|
||||
surf.TypeIndex = side->Index();
|
||||
surf.bSky = false;
|
||||
surf.sampleDimension = side->textures[side_t::bottom].LightmapSampleDistance;
|
||||
surf.ControlSector = nullptr;
|
||||
surf.sectorGroup = sectorGroup[front->Index()];
|
||||
surf.texture = TexMan.GetGameTexture(side->textures[side_t::bottom].texture);
|
||||
surf.AlwaysUpdate = !!(front->Flags & SECF_LM_DYNAMIC);
|
||||
surf.Side = side;
|
||||
|
||||
SurfaceUniforms uniforms = DefaultUniforms();
|
||||
uniforms.uLightLevel = front->lightlevel * (1.0f / 255.0f);
|
||||
|
||||
FMaterialState material;
|
||||
|
||||
SetSideTextureUVs(surf, side, side_t::bottom, v1BottomBack, v1Bottom, v2BottomBack, v2Bottom);
|
||||
|
||||
MeshSurfaceUniforms.Push(uniforms);
|
||||
MeshSurfaceMaterials.Push(material);
|
||||
Surfaces.Push(surf);
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::SetSideTextureUVs(DoomLevelMeshSurface& surface, side_t* side, side_t::ETexpart texpart, float v1TopZ, float v1BottomZ, float v2TopZ, float v2BottomZ)
|
||||
{
|
||||
FFlatVertex* uvs = &MeshVertices[surface.startVertIndex];
|
||||
|
||||
if (surface.texture)
|
||||
{
|
||||
const auto gtxt = surface.texture;
|
||||
|
||||
FTexCoordInfo tci;
|
||||
GetTexCoordInfo(gtxt, &tci, side, texpart);
|
||||
|
||||
float startU = tci.FloatToTexU(tci.TextureOffset((float)side->GetTextureXOffset(texpart)) + tci.TextureOffset((float)side->GetTextureXOffset(texpart)));
|
||||
float endU = startU + tci.FloatToTexU(side->TexelLength);
|
||||
|
||||
uvs[0].u = startU;
|
||||
uvs[1].u = endU;
|
||||
uvs[3].u = startU;
|
||||
uvs[2].u = endU;
|
||||
|
||||
// To do: the ceiling version is apparently used in some situation related to 3d floors (rover->top.isceiling)
|
||||
//float offset = tci.RowOffset((float)side->GetTextureYOffset(texpart)) + tci.RowOffset((float)side->GetTextureYOffset(texpart)) + (float)side->sector->GetPlaneTexZ(sector_t::ceiling);
|
||||
float offset = tci.RowOffset((float)side->GetTextureYOffset(texpart)) + tci.RowOffset((float)side->GetTextureYOffset(texpart)) + (float)side->sector->GetPlaneTexZ(sector_t::floor);
|
||||
|
||||
uvs[0].v = tci.FloatToTexV(offset - v1BottomZ);
|
||||
uvs[1].v = tci.FloatToTexV(offset - v2BottomZ);
|
||||
uvs[3].v = tci.FloatToTexV(offset - v1TopZ);
|
||||
uvs[2].v = tci.FloatToTexV(offset - v2TopZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
uvs[0].u = 0.0f;
|
||||
uvs[0].v = 0.0f;
|
||||
uvs[1].u = 0.0f;
|
||||
uvs[1].v = 0.0f;
|
||||
uvs[2].u = 0.0f;
|
||||
uvs[2].v = 0.0f;
|
||||
uvs[3].u = 0.0f;
|
||||
uvs[3].v = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::CreateFloorSurface(FLevelLocals &doomMap, subsector_t *sub, sector_t *sector, sector_t *controlSector, int typeIndex)
|
||||
{
|
||||
DoomLevelMeshSurface surf;
|
||||
|
|
@ -1267,23 +674,6 @@ void DoomLevelSubmesh::CreateSubsectorSurfaces(FLevelLocals &doomMap)
|
|||
}
|
||||
}
|
||||
|
||||
bool DoomLevelSubmesh::IsTopSideSky(sector_t* frontsector, sector_t* backsector, side_t* side)
|
||||
{
|
||||
return IsSkySector(frontsector, sector_t::ceiling) && IsSkySector(backsector, sector_t::ceiling);
|
||||
}
|
||||
|
||||
bool DoomLevelSubmesh::IsTopSideVisible(side_t* side)
|
||||
{
|
||||
auto tex = TexMan.GetGameTexture(side->GetTexture(side_t::top), true);
|
||||
return tex && tex->isValid();
|
||||
}
|
||||
|
||||
bool DoomLevelSubmesh::IsBottomSideVisible(side_t* side)
|
||||
{
|
||||
auto tex = TexMan.GetGameTexture(side->GetTexture(side_t::bottom), true);
|
||||
return tex && tex->isValid();
|
||||
}
|
||||
|
||||
bool DoomLevelSubmesh::IsSkySector(sector_t* sector, int plane)
|
||||
{
|
||||
// plane is either sector_t::ceiling or sector_t::floor
|
||||
|
|
|
|||
|
|
@ -67,15 +67,6 @@ private:
|
|||
void CreateSubsectorSurfaces(FLevelLocals& doomMap);
|
||||
void CreateCeilingSurface(FLevelLocals& doomMap, subsector_t* sub, sector_t* sector, sector_t* controlSector, int typeIndex);
|
||||
void CreateFloorSurface(FLevelLocals& doomMap, subsector_t* sub, sector_t* sector, sector_t* controlSector, int typeIndex);
|
||||
void CreateSideSurfaces(FLevelLocals& doomMap, side_t* side);
|
||||
void CreateLinePortalSurface(FLevelLocals& doomMap, side_t* side);
|
||||
void CreateLineHorizonSurface(FLevelLocals& doomMap, side_t* side);
|
||||
void CreateFrontWallSurface(FLevelLocals& doomMap, side_t* side);
|
||||
void CreateTopWallSurface(FLevelLocals& doomMap, side_t* side);
|
||||
void CreateMidWallSurface(FLevelLocals& doomMap, side_t* side);
|
||||
void CreateBottomWallSurface(FLevelLocals& doomMap, side_t* side);
|
||||
void Create3DFloorWallSurfaces(FLevelLocals& doomMap, side_t* side);
|
||||
void SetSideTextureUVs(DoomLevelMeshSurface& surface, side_t* side, side_t::ETexpart texpart, float v1TopZ, float v1BottomZ, float v2TopZ, float v2BottomZ);
|
||||
|
||||
void SetSubsectorLightmap(DoomLevelMeshSurface* surface);
|
||||
void SetSideLightmap(DoomLevelMeshSurface* surface);
|
||||
|
|
@ -84,9 +75,6 @@ private:
|
|||
|
||||
void CreateIndexes();
|
||||
|
||||
static bool IsTopSideSky(sector_t* frontsector, sector_t* backsector, side_t* side);
|
||||
static bool IsTopSideVisible(side_t* side);
|
||||
static bool IsBottomSideVisible(side_t* side);
|
||||
static bool IsSkySector(sector_t* sector, int plane);
|
||||
|
||||
static FVector4 ToPlane(const FVector3& pt1, const FVector3& pt2, const FVector3& pt3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue