- changed voxel remapping to make a copy instead of destroying the original.

With live renderer switching both sets of data are needed.
This commit is contained in:
Christoph Oelckers 2018-04-03 00:30:02 +02:00
commit 942460ba55
9 changed files with 44 additions and 26 deletions

View file

@ -386,6 +386,18 @@ FVoxelMipLevel::~FVoxelMipLevel()
}
}
//==========================================================================
//
// FVoxelMipLevel :: GetSlabData
//
//==========================================================================
uint8_t *FVoxelMipLevel::GetSlabData(bool wantremapped) const
{
if (wantremapped && SlabDataRemapped.Size() > 0) return &SlabDataRemapped[0];
return SlabData;
}
//==========================================================================
//
// FVoxel Constructor
@ -410,6 +422,8 @@ FVoxel::~FVoxel()
void FVoxel::CreateBgraSlabData()
{
if (Bgramade) return;
Bgramade = true;
for (int i = 0; i < NumMips; ++i)
{
int size = Mips[i].OffsetX[Mips[i].SizeX];
@ -464,14 +478,20 @@ void FVoxel::CreateBgraSlabData()
void FVoxel::Remap()
{
if (Remapped) return;
Remapped = true;
if (Palette != NULL)
{
uint8_t *remap = GetVoxelRemap(Palette);
for (int i = 0; i < NumMips; ++i)
{
RemapVoxelSlabs((kvxslab_t *)Mips[i].SlabData, Mips[i].OffsetX[Mips[i].SizeX], remap);
int size = Mips[i].OffsetX[Mips[i].SizeX];
if (size <= 0) continue;
Mips[i].SlabDataRemapped.Resize(size);
memcpy(&Mips[i].SlabDataRemapped [0], Mips[i].SlabData, size);
RemapVoxelSlabs((kvxslab_t *)&Mips[i].SlabDataRemapped[0], Mips[i].OffsetX[Mips[i].SizeX], remap);
}
RemovePalette();
}
}