Skip to content

Commit

Permalink
New functions for Voxel Sectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackvoxel committed Aug 5, 2021
1 parent 24d5721 commit 5c66d6c
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/ZVoxelSector.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class ZVoxelSector : public ZObject
Flag_NotStandardSize = NotStandardSize;
}

inline ULong GetOffset(Long x, Long y, Long z)
{
return(y + (x + z * Size_x) * Size_y);
}

inline void SetCube(Long x, Long y, Long z, UShort CubeValue)
{
Long Offset;
Expand All @@ -210,20 +215,36 @@ class ZVoxelSector : public ZObject
OtherInfos[Offset]=0;
}

inline void SetCube_Transfert(Long x,Long y, Long z, ZVoxelLocation * SrcLoc)
// Non standard sector size
inline void SetCube_Transfert_NSS(Long x,Long y, Long z, ZVoxelLocation * SrcLoc)
{
Long Offset;

Offset = (y & ZVOXELBLOCMASK_Y)
+ ((x & ZVOXELBLOCMASK_X) << ZVOXELBLOCSHIFT_Y )
+ ((z & ZVOXELBLOCMASK_Z) << (ZVOXELBLOCSHIFT_Y + ZVOXELBLOCSHIFT_X));
Offset = y
+ x * Size_y
+ z * Size_y * Size_x;

Data[Offset] = SrcLoc->Sector->Data[SrcLoc->Offset];
OtherInfos[Offset] = SrcLoc->Sector->OtherInfos[SrcLoc->Offset];
SrcLoc->Sector->Data[SrcLoc->Offset] = 0;
SrcLoc->Sector->OtherInfos[SrcLoc->Offset]=0;
}

inline void SetCube_TransfertTo_NSS(Long x,Long y, Long z, ZVoxelLocation * SrcLoc)
{
Long Offset;

Offset = y
+ x * Size_y
+ z * Size_y * Size_x;


SrcLoc->Sector->Data[SrcLoc->Offset] = Data[Offset];
SrcLoc->Sector->OtherInfos[SrcLoc->Offset] = OtherInfos[Offset];
Data[Offset] = 0;
OtherInfos[Offset] = 0;
}

inline void SetCube_WithExtension(Long x, Long y, Long z, UShort CubeValue, ZMemSize Extension)
{
Long Offset;
Expand All @@ -241,6 +262,11 @@ class ZVoxelSector : public ZObject
return(Data[Offset]);
}

inline UShort GetCube(ULong Offset)
{
return(Data[Offset]);
}

void MakeSector()
{
Long x,y,z;
Expand All @@ -261,13 +287,15 @@ class ZVoxelSector : public ZObject
}
}

// Don't use with voxels using extensions.
void Fill(UShort VoxelType)
{
ZMemSize i;

for ( i=0 ; i<DataSize ; i++ )
{
Data[i] = VoxelType;
OtherInfos[i]=0;
FaceCulling[i] = 255;
}
}
Expand Down

0 comments on commit 5c66d6c

Please sign in to comment.