mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-16 17:21:10 +00:00
Remove awful hardcoded byte offset hack
This commit is contained in:
parent
834480995c
commit
73f3d9166f
7 changed files with 10 additions and 10 deletions
|
@ -187,6 +187,7 @@ public:
|
|||
std::unique_ptr<TriangleMeshShape> Collision;
|
||||
|
||||
virtual LevelMeshSurface* GetSurface(int index) { return nullptr; }
|
||||
virtual unsigned GetSurfaceIndex(const LevelMeshSurface* surface) const { return unsigned(-1); }
|
||||
virtual int GetSurfaceCount() { return 0; }
|
||||
|
||||
virtual void UpdateLightLists() { }
|
||||
|
|
|
@ -739,11 +739,11 @@ public:
|
|||
return SetViewpoint(matrices);
|
||||
}
|
||||
|
||||
inline void PushVisibleSurface(int surfaceIndex, LevelMeshSurface* surface)
|
||||
inline void PushVisibleSurface(LevelMeshSurface* surface)
|
||||
{
|
||||
if (surface->needsUpdate) // TODO atomic?
|
||||
{
|
||||
int index = mActiveLightmapSurfaceBufferIndex.fetch_add(1);
|
||||
auto index = mActiveLightmapSurfaceBufferIndex.fetch_add(1);
|
||||
if (index < mActiveLightmapSurfacesBuffer.Size())
|
||||
{
|
||||
mActiveLightmapSurfacesBuffer[index] = surface;
|
||||
|
|
|
@ -231,7 +231,7 @@ void VkLightmap::RenderAtlasImage(size_t pageIndex, const TArray<LevelMeshSurfac
|
|||
LightmapPushConstants pc;
|
||||
pc.LightStart = firstLight;
|
||||
pc.LightEnd = firstLight + lightCount;
|
||||
pc.SurfaceIndex = (int32_t)std::distance((char*)mesh->GetSurface(0), (char*)targetSurface) / 288;
|
||||
pc.SurfaceIndex = mesh->GetSurfaceIndex(targetSurface);
|
||||
pc.LightmapOrigin = targetSurface->worldOrigin - targetSurface->worldStepX - targetSurface->worldStepY;
|
||||
pc.LightmapStepX = targetSurface->worldStepX * viewport.width;
|
||||
pc.LightmapStepY = targetSurface->worldStepY * viewport.height;
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
void UpdateLightLists() override;
|
||||
|
||||
LevelMeshSurface* GetSurface(int index) override { return &Surfaces[index]; }
|
||||
unsigned GetSurfaceIndex(const LevelMeshSurface* surface) const { return std::distance(reinterpret_cast<const DoomLevelMeshSurface*>(&Surfaces[0]), reinterpret_cast<const DoomLevelMeshSurface*>(surface)); }
|
||||
int GetSurfaceCount() override { return Surfaces.Size(); }
|
||||
|
||||
|
||||
|
|
|
@ -865,7 +865,7 @@ void UpdateLightmaps(DFrameBuffer* screen, FRenderState& RenderState)
|
|||
|
||||
list.Resize(min(list.Size(), unsigned(size)));
|
||||
|
||||
if (size < lm_background_updates)
|
||||
if (size < unsigned(lm_background_updates))
|
||||
{
|
||||
for (auto& e : level.levelMesh->Surfaces)
|
||||
{
|
||||
|
@ -873,7 +873,7 @@ void UpdateLightmaps(DFrameBuffer* screen, FRenderState& RenderState)
|
|||
{
|
||||
list.Push(&e);
|
||||
|
||||
if (list.Size() >= lm_background_updates)
|
||||
if (list.Size() >= unsigned(lm_background_updates))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -505,15 +505,13 @@ void HWFlat::ProcessSector(HWDrawInfo *di, FRenderState& state, sector_t * front
|
|||
// Lightmaps
|
||||
//
|
||||
|
||||
const auto* lm = §or->Level->levelMesh->Surfaces[0]; // temporay hack on top of a temporary hack
|
||||
|
||||
for (int i = 0, count = sector->subsectorcount; i < count; ++i)
|
||||
{
|
||||
for (int plane = 0; plane < 2; ++plane)
|
||||
{
|
||||
if (auto lightmap = sector->subsectors[i]->lightmap[plane][0])
|
||||
{
|
||||
state.PushVisibleSurface(lightmap - lm, lightmap);
|
||||
state.PushVisibleSurface(lightmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -524,7 +522,7 @@ void HWFlat::ProcessSector(HWDrawInfo *di, FRenderState& state, sector_t * front
|
|||
{
|
||||
if (surface)
|
||||
{
|
||||
state.PushVisibleSurface(surface - lm, surface);
|
||||
state.PushVisibleSurface(surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1267,7 +1267,7 @@ void HWWall::DoTexture(HWDrawInfo *di, FRenderState& state, int _type,seg_t * se
|
|||
lightmap = seg->sidedef->lightmap[type - RENDERWALL_TOP];
|
||||
if (lightmap)
|
||||
{
|
||||
state.PushVisibleSurface(lightmap - &seg->Subsector->sector->Level->levelMesh->Surfaces[0], lightmap);
|
||||
state.PushVisibleSurface(lightmap);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue