More clean up
This commit is contained in:
parent
4306d2d3d8
commit
864925df25
2 changed files with 17 additions and 23 deletions
|
|
@ -1309,34 +1309,29 @@ void DoomLevelSubmesh::PackLightmapAtlas()
|
|||
|
||||
for (LevelMeshSurface* surf : sortedSurfaces)
|
||||
{
|
||||
FinishSurface(LMTextureSize, LMTextureSize, packer, *surf);
|
||||
int sampleWidth = surf->AtlasTile.Width;
|
||||
int sampleHeight = surf->AtlasTile.Height;
|
||||
|
||||
auto result = packer.insert(sampleWidth, sampleHeight);
|
||||
int x = result.pos.x, y = result.pos.y;
|
||||
|
||||
surf->AtlasTile.X = x;
|
||||
surf->AtlasTile.Y = y;
|
||||
surf->AtlasTile.ArrayIndex = (int)result.pageIndex;
|
||||
|
||||
// calculate final texture coordinates
|
||||
for (int i = 0; i < (int)surf->numVerts; i++)
|
||||
{
|
||||
auto& u = LightmapUvs[surf->startUvIndex + i].X;
|
||||
auto& v = LightmapUvs[surf->startUvIndex + i].Y;
|
||||
u = (u + x) / (float)LMTextureSize;
|
||||
v = (v + y) / (float)LMTextureSize;
|
||||
}
|
||||
}
|
||||
|
||||
LMTextureCount = (int)packer.getNumPages();
|
||||
}
|
||||
|
||||
void DoomLevelSubmesh::FinishSurface(int lightmapTextureWidth, int lightmapTextureHeight, RectPacker& packer, LevelMeshSurface& surface)
|
||||
{
|
||||
int sampleWidth = surface.AtlasTile.Width;
|
||||
int sampleHeight = surface.AtlasTile.Height;
|
||||
|
||||
auto result = packer.insert(sampleWidth, sampleHeight);
|
||||
int x = result.pos.x, y = result.pos.y;
|
||||
surface.AtlasTile.ArrayIndex = (int)result.pageIndex;
|
||||
|
||||
// calculate final texture coordinates
|
||||
for (int i = 0; i < (int)surface.numVerts; i++)
|
||||
{
|
||||
auto& u = LightmapUvs[surface.startUvIndex + i].X;
|
||||
auto& v = LightmapUvs[surface.startUvIndex + i].Y;
|
||||
u = (u + x) / (float)lightmapTextureWidth;
|
||||
v = (v + y) / (float)lightmapTextureHeight;
|
||||
}
|
||||
|
||||
surface.AtlasTile.X = x;
|
||||
surface.AtlasTile.Y = y;
|
||||
}
|
||||
|
||||
BBox DoomLevelSubmesh::GetBoundsFromSurface(const LevelMeshSurface& surface) const
|
||||
{
|
||||
constexpr float M_INFINITY = 1e30f; // TODO cleanup
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ private:
|
|||
inline int AllocUvs(int amount) { return LightmapUvs.Reserve(amount); }
|
||||
|
||||
void BuildSurfaceParams(int lightMapTextureWidth, int lightMapTextureHeight, LevelMeshSurface& surface);
|
||||
void FinishSurface(int lightmapTextureWidth, int lightmapTextureHeight, RectPacker& packer, LevelMeshSurface& surface);
|
||||
|
||||
static bool IsDegenerate(const FVector3& v0, const FVector3& v1, const FVector3& v2);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue