- 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:
parent
2f96d3c61a
commit
942460ba55
9 changed files with 44 additions and 26 deletions
|
|
@ -306,7 +306,7 @@ void FVoxelModel::Initialize()
|
|||
FVoxelMipLevel *mip = &mVoxel->Mips[0];
|
||||
for (int x = 0; x < mip->SizeX; x++)
|
||||
{
|
||||
uint8_t *slabxoffs = &mip->SlabData[mip->OffsetX[x]];
|
||||
uint8_t *slabxoffs = &mip->GetSlabData(false)[mip->OffsetX[x]];
|
||||
short *xyoffs = &mip->OffsetXY[x * (mip->SizeY + 1)];
|
||||
for (int y = 0; y < mip->SizeY; y++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ struct kvxslab_bgra_t
|
|||
uint32_t col[1/*zleng*/];// color data from top to bottom
|
||||
};
|
||||
|
||||
struct FVoxel;
|
||||
|
||||
struct FVoxelMipLevel
|
||||
{
|
||||
FVoxelMipLevel();
|
||||
|
|
@ -34,17 +36,27 @@ struct FVoxelMipLevel
|
|||
DVector3 Pivot;
|
||||
int *OffsetX;
|
||||
short *OffsetXY;
|
||||
uint8_t *SlabData;
|
||||
private:
|
||||
uint8_t *SlabData;
|
||||
TArray<uint8_t> SlabDataRemapped;
|
||||
public:
|
||||
TArray<uint32_t> SlabDataBgra;
|
||||
|
||||
uint8_t *GetSlabData(bool wantpaletted) const;
|
||||
|
||||
friend FVoxel *R_LoadKVX(int lumpnum);
|
||||
friend struct FVoxel;
|
||||
};
|
||||
|
||||
struct FVoxel
|
||||
{
|
||||
int LumpNum;
|
||||
int NumMips;
|
||||
int VoxelIndex; // Needed by GZDoom
|
||||
int VoxelIndex;
|
||||
uint8_t *Palette;
|
||||
FVoxelMipLevel Mips[MAXVOXMIPS];
|
||||
bool Remapped = false;
|
||||
bool Bgramade = false;
|
||||
|
||||
FVoxel();
|
||||
~FVoxel();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue