mirror of
https://github.com/ZDoom/ZDRay.git
synced 2025-02-09 07:41:03 +00:00
- add 3d floor ceiling and floor surfaces
This commit is contained in:
parent
0f6da0df5d
commit
5ea89ac1b6
3 changed files with 68 additions and 49 deletions
|
@ -613,7 +613,7 @@ void kexLightmapBuilder::AddLightmapLump(FWadWriter &wadFile)
|
||||||
|
|
||||||
lumpFile.Write32(surfaces[i]->type);
|
lumpFile.Write32(surfaces[i]->type);
|
||||||
lumpFile.Write32(surfaces[i]->typeIndex);
|
lumpFile.Write32(surfaces[i]->typeIndex);
|
||||||
lumpFile.Write32(0xffffffff/*surfaces[i]->controlSector*/);
|
lumpFile.Write32(surfaces[i]->controlSector ? (uint32_t)(surfaces[i]->controlSector - &map->Sectors[0]) : 0xffffffff);
|
||||||
lumpFile.Write32(surfaces[i]->lightmapNum);
|
lumpFile.Write32(surfaces[i]->lightmapNum);
|
||||||
lumpFile.Write32(coordOffsets);
|
lumpFile.Write32(coordOffsets);
|
||||||
coordOffsets += surfaces[i]->numVerts;
|
coordOffsets += surfaces[i]->numVerts;
|
||||||
|
|
|
@ -99,6 +99,7 @@ static void CreateSideSurfaces(FLevel &doomMap, IntSideDef *side)
|
||||||
surf->plane.SetDistance(surf->verts[0]);
|
surf->plane.SetDistance(surf->verts[0]);
|
||||||
surf->type = ST_LOWERSIDE;
|
surf->type = ST_LOWERSIDE;
|
||||||
surf->typeIndex = side - &doomMap.Sides[0];
|
surf->typeIndex = side - &doomMap.Sides[0];
|
||||||
|
surf->controlSector = nullptr;
|
||||||
|
|
||||||
surfaces.push_back(std::move(surf));
|
surfaces.push_back(std::move(surf));
|
||||||
}
|
}
|
||||||
|
@ -142,6 +143,7 @@ static void CreateSideSurfaces(FLevel &doomMap, IntSideDef *side)
|
||||||
surf->type = ST_UPPERSIDE;
|
surf->type = ST_UPPERSIDE;
|
||||||
surf->typeIndex = side - &doomMap.Sides[0];
|
surf->typeIndex = side - &doomMap.Sides[0];
|
||||||
surf->bSky = bSky;
|
surf->bSky = bSky;
|
||||||
|
surf->controlSector = nullptr;
|
||||||
|
|
||||||
surfaces.push_back(std::move(surf));
|
surfaces.push_back(std::move(surf));
|
||||||
}
|
}
|
||||||
|
@ -171,11 +173,67 @@ static void CreateSideSurfaces(FLevel &doomMap, IntSideDef *side)
|
||||||
surf->plane.SetDistance(surf->verts[0]);
|
surf->plane.SetDistance(surf->verts[0]);
|
||||||
surf->type = ST_MIDDLESIDE;
|
surf->type = ST_MIDDLESIDE;
|
||||||
surf->typeIndex = side - &doomMap.Sides[0];
|
surf->typeIndex = side - &doomMap.Sides[0];
|
||||||
|
surf->controlSector = nullptr;
|
||||||
|
|
||||||
surfaces.push_back(std::move(surf));
|
surfaces.push_back(std::move(surf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CreateFloorSurface(FLevel &doomMap, MapSubsectorEx *sub, IntSector *sector, int typeIndex, bool is3DFloor)
|
||||||
|
{
|
||||||
|
auto surf = std::make_unique<surface_t>();
|
||||||
|
surf->numVerts = sub->numlines;
|
||||||
|
surf->verts.resize(surf->numVerts);
|
||||||
|
|
||||||
|
// floor verts
|
||||||
|
for (int j = 0; j < surf->numVerts; j++)
|
||||||
|
{
|
||||||
|
MapSegGLEx *seg = &doomMap.GLSegs[sub->firstline + (surf->numVerts - 1) - j];
|
||||||
|
FloatVertex v1 = doomMap.GetSegVertex(seg->v1);
|
||||||
|
|
||||||
|
surf->verts[j].x = v1.x;
|
||||||
|
surf->verts[j].y = v1.y;
|
||||||
|
surf->verts[j].z = sector->floorplane.zAt(surf->verts[j].x, surf->verts[j].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
surf->plane = sector->floorplane;
|
||||||
|
surf->type = ST_FLOOR;
|
||||||
|
surf->typeIndex = typeIndex;
|
||||||
|
surf->controlSector = is3DFloor ? sector : nullptr;
|
||||||
|
|
||||||
|
surfaces.push_back(std::move(surf));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CreateCeilingSurface(FLevel &doomMap, MapSubsectorEx *sub, IntSector *sector, int typeIndex, bool is3DFloor)
|
||||||
|
{
|
||||||
|
auto surf = std::make_unique<surface_t>();
|
||||||
|
surf->numVerts = sub->numlines;
|
||||||
|
surf->verts.resize(surf->numVerts);
|
||||||
|
|
||||||
|
if (doomMap.bSkySectors[sector - &doomMap.Sectors[0]])
|
||||||
|
{
|
||||||
|
surf->bSky = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ceiling verts
|
||||||
|
for (int j = 0; j < surf->numVerts; j++)
|
||||||
|
{
|
||||||
|
MapSegGLEx *seg = &doomMap.GLSegs[sub->firstline + j];
|
||||||
|
FloatVertex v1 = doomMap.GetSegVertex(seg->v1);
|
||||||
|
|
||||||
|
surf->verts[j].x = v1.x;
|
||||||
|
surf->verts[j].y = v1.y;
|
||||||
|
surf->verts[j].z = sector->ceilingplane.zAt(surf->verts[j].x, surf->verts[j].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
surf->plane = sector->ceilingplane;
|
||||||
|
surf->type = ST_CEILING;
|
||||||
|
surf->typeIndex = typeIndex;
|
||||||
|
surf->controlSector = is3DFloor ? sector : nullptr;
|
||||||
|
|
||||||
|
surfaces.push_back(std::move(surf));
|
||||||
|
}
|
||||||
|
|
||||||
static void CreateSubsectorSurfaces(FLevel &doomMap)
|
static void CreateSubsectorSurfaces(FLevel &doomMap)
|
||||||
{
|
{
|
||||||
printf("------------- Building subsector surfaces -------------\n");
|
printf("------------- Building subsector surfaces -------------\n");
|
||||||
|
@ -192,59 +250,17 @@ static void CreateSubsectorSurfaces(FLevel &doomMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
IntSector *sector = doomMap.GetSectorFromSubSector(sub);
|
IntSector *sector = doomMap.GetSectorFromSubSector(sub);
|
||||||
|
if (!sector || sector->controlsector)
|
||||||
if (!sector)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sector->controlsector)
|
CreateFloorSurface(doomMap, sub, sector, i, false);
|
||||||
continue;
|
CreateCeilingSurface(doomMap, sub, sector, i, false);
|
||||||
|
|
||||||
auto surf = std::make_unique<surface_t>();
|
for (unsigned int j = 0; j < sector->x3dfloors.Size(); j++)
|
||||||
surf->numVerts = sub->numlines;
|
|
||||||
surf->verts.resize(surf->numVerts);
|
|
||||||
|
|
||||||
// floor verts
|
|
||||||
for (int j = 0; j < surf->numVerts; j++)
|
|
||||||
{
|
{
|
||||||
MapSegGLEx *seg = &doomMap.GLSegs[sub->firstline + (surf->numVerts - 1) - j];
|
CreateFloorSurface(doomMap, sub, sector->x3dfloors[j], i, true);
|
||||||
FloatVertex v1 = doomMap.GetSegVertex(seg->v1);
|
CreateCeilingSurface(doomMap, sub, sector->x3dfloors[j], i, false);
|
||||||
|
|
||||||
surf->verts[j].x = v1.x;
|
|
||||||
surf->verts[j].y = v1.y;
|
|
||||||
surf->verts[j].z = sector->floorplane.zAt(surf->verts[j].x, surf->verts[j].y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
surf->plane = sector->floorplane;
|
|
||||||
surf->type = ST_FLOOR;
|
|
||||||
surf->typeIndex = i;
|
|
||||||
|
|
||||||
surfaces.push_back(std::move(surf));
|
|
||||||
|
|
||||||
surf = std::make_unique<surface_t>();
|
|
||||||
surf->numVerts = sub->numlines;
|
|
||||||
surf->verts.resize(surf->numVerts);
|
|
||||||
|
|
||||||
if (doomMap.bSkySectors[sector - &doomMap.Sectors[0]])
|
|
||||||
{
|
|
||||||
surf->bSky = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ceiling verts
|
|
||||||
for (int j = 0; j < surf->numVerts; j++)
|
|
||||||
{
|
|
||||||
MapSegGLEx *seg = &doomMap.GLSegs[sub->firstline + j];
|
|
||||||
FloatVertex v1 = doomMap.GetSegVertex(seg->v1);
|
|
||||||
|
|
||||||
surf->verts[j].x = v1.x;
|
|
||||||
surf->verts[j].y = v1.y;
|
|
||||||
surf->verts[j].z = sector->ceilingplane.zAt(surf->verts[j].x, surf->verts[j].y);
|
|
||||||
}
|
|
||||||
|
|
||||||
surf->plane = sector->ceilingplane;
|
|
||||||
surf->type = ST_CEILING;
|
|
||||||
surf->typeIndex = i;
|
|
||||||
|
|
||||||
surfaces.push_back(std::move(surf));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nLeaf surfaces: %i\n", (int)surfaces.size() - doomMap.NumGLSubsectors);
|
printf("\nLeaf surfaces: %i\n", (int)surfaces.size() - doomMap.NumGLSubsectors);
|
||||||
|
|
|
@ -45,6 +45,8 @@ enum surfaceType_t
|
||||||
// convert from fixed point(FRACUNIT) to floating point
|
// convert from fixed point(FRACUNIT) to floating point
|
||||||
#define F(x) (((float)(x))/65536.0f)
|
#define F(x) (((float)(x))/65536.0f)
|
||||||
|
|
||||||
|
struct IntSector;
|
||||||
|
|
||||||
struct surface_t
|
struct surface_t
|
||||||
{
|
{
|
||||||
kexPlane plane;
|
kexPlane plane;
|
||||||
|
@ -60,6 +62,7 @@ struct surface_t
|
||||||
std::vector<float> lightmapCoords;
|
std::vector<float> lightmapCoords;
|
||||||
surfaceType_t type;
|
surfaceType_t type;
|
||||||
int typeIndex;
|
int typeIndex;
|
||||||
|
IntSector *controlSector;
|
||||||
bool bSky;
|
bool bSky;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue