public static void GetNearRightVoxelRef( out NearVoxelRef that, ref NearVoxelRef self ) { that.Sector = self.Sector; that.Offset = self.Offset; if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_X << VoxelSector.ZVOXELBLOCSHIFT_Y ) ) != VoxelSector.ZVOXELBLOCMASK_X << VoxelSector.ZVOXELBLOCSHIFT_Y ) { that.Offset += VoxelSector.ZVOXELBLOCSIZE_Y; } else { that.Sector = self.Sector.near_sectors[(int)VoxelSector.RelativeVoxelOrds.RIGHT - 1]; if( that.Sector != null ) { that.Offset -= VoxelSector.ZVOXELBLOCSIZE_Y * ( VoxelSector.ZVOXELBLOCSIZE_X - 2 ); } } if( that.Sector != null ) { that.Type = self.Sector.VoxelTypeManager.VoxelTable[that.Sector.Data.Data[that.Offset]]; that.VoxelExtension = that.Sector.Data.OtherInfos[that.Offset]; } else { that.Type = null; that.VoxelExtension = null; } }
public static void GetNearVoxelRef( out NearVoxelRef that, ref NearVoxelRef self, VoxelSector.RelativeVoxelOrds direction ) { that.Sector = self.Sector; that.Offset = self.Offset; switch( direction ) { default: throw new NotImplementedException( "Creating voxel ref " + direction + " is not implemented " ); break; case VoxelSector.RelativeVoxelOrds.LEFT: if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_X << VoxelSector.ZVOXELBLOCSHIFT_Y ) ) != 0 ) { that.Offset -= VoxelSector.ZVOXELBLOCSIZE_Y; } else { that.Sector = self.Sector.near_sectors[(int)direction - 1]; if( that.Sector != null ) { that.Offset += VoxelSector.ZVOXELBLOCSIZE_Y * ( VoxelSector.ZVOXELBLOCSIZE_X - 2 ); } } break; case VoxelSector.RelativeVoxelOrds.RIGHT: if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_X << VoxelSector.ZVOXELBLOCSHIFT_Y ) ) != VoxelSector.ZVOXELBLOCMASK_X << VoxelSector.ZVOXELBLOCSHIFT_Y ) { that.Offset += VoxelSector.ZVOXELBLOCSIZE_Y; } else { that.Sector = self.Sector.near_sectors[(int)direction - 1]; if( that.Sector != null ) { that.Offset -= VoxelSector.ZVOXELBLOCSIZE_Y * ( VoxelSector.ZVOXELBLOCSIZE_X - 2 ); } } break; case VoxelSector.RelativeVoxelOrds.BEHIND: if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_Z << ( VoxelSector.ZVOXELBLOCSHIFT_X + VoxelSector.ZVOXELBLOCSHIFT_Y ) ) ) != 0 ) { that.Offset -= VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_X; } else { that.Sector = self.Sector.near_sectors[(int)direction - 1]; if( that.Sector != null ) { that.Offset += ( VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y * ( VoxelSector.ZVOXELBLOCSIZE_Z - 2 ) ); } } break; case VoxelSector.RelativeVoxelOrds.AHEAD: if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_Z << ( VoxelSector.ZVOXELBLOCSHIFT_X + VoxelSector.ZVOXELBLOCSHIFT_Y ) ) ) != ( VoxelSector.ZVOXELBLOCMASK_Z << ( VoxelSector.ZVOXELBLOCSHIFT_X + VoxelSector.ZVOXELBLOCSHIFT_Y ) ) ) { that.Offset += VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_X; } else { that.Sector = self.Sector.near_sectors[(int)direction - 1]; if( that.Sector != null ) { that.Offset -= ( VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y * ( VoxelSector.ZVOXELBLOCSIZE_Z - 2 ) ); } } break; case VoxelSector.RelativeVoxelOrds.BELOW: if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_Y ) ) != 0 ) { that.Offset--; } else { that.Sector = self.Sector.near_sectors[(int)direction - 1]; if( that.Sector != null ) { that.Offset += ( VoxelSector.ZVOXELBLOCSIZE_Y - 2 ); } } break; case VoxelSector.RelativeVoxelOrds.ABOVE: if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_Y ) ) != VoxelSector.ZVOXELBLOCMASK_Y ) { that.Offset++; } else { that.Sector = self.Sector.near_sectors[(int)direction - 1]; if( that.Sector != null ) { that.Offset -= ( VoxelSector.ZVOXELBLOCSIZE_Y - 2 ); } } break; } if( that.Sector != null ) { that.Type = self.Sector.VoxelTypeManager.VoxelTable[that.Sector.Data.Data[that.Offset]]; that.VoxelExtension = that.Sector.Data.OtherInfos[that.Offset]; } else { that.Type = null; that.VoxelExtension = null; } }
public static void GetNearAheadVoxelRef( out NearVoxelRef that, ref VoxelRef self ) { that.Sector = self.Sector; that.Offset = self.Offset; if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_Z << ( VoxelSector.ZVOXELBLOCSHIFT_X + VoxelSector.ZVOXELBLOCSHIFT_Y ) ) ) != ( VoxelSector.ZVOXELBLOCMASK_Z << ( VoxelSector.ZVOXELBLOCSHIFT_X + VoxelSector.ZVOXELBLOCSHIFT_Y ) ) ) that.Offset += VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_X; else { that.Sector = self.Sector.near_sectors[(int)VoxelSector.RelativeVoxelOrds.AHEAD - 1]; if( that.Sector != null ) that.Offset -= ( VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y * ( VoxelSector.ZVOXELBLOCSIZE_Z - 2 ) ); } if( that.Sector != null ) { that.Type = self.VoxelTypeManager.VoxelTable[that.Sector.Data.Data[that.Offset]]; that.VoxelExtension = that.Sector.Data.OtherInfos[that.Offset]; } else { that.Type = null; that.VoxelExtension = null; } }
public static void GetNearBelowVoxelRef( out NearVoxelRef that, ref VoxelRef self ) { that.Sector = self.Sector; that.Offset = self.Offset; if( ( that.Offset & ( VoxelSector.ZVOXELBLOCMASK_Y ) ) != 0 ) that.Offset--; else { that.Sector = self.Sector.near_sectors[(int)VoxelSector.RelativeVoxelOrds.BELOW - 1]; if( that.Sector != null ) that.Offset += ( VoxelSector.ZVOXELBLOCSIZE_Y - 2 ); } if( that.Sector != null ) { that.Type = self.VoxelTypeManager.VoxelTable[that.Sector.Data.Data[that.Offset]]; that.VoxelExtension = that.Sector.Data.OtherInfos[that.Offset]; } else { that.Type = null; that.VoxelExtension = null; } }
public void Swap( ref VoxelRef self, ref NearVoxelRef other, VoxelSector.ModifiedFieldFlags importance ) { ushort selfType = self.Type.properties.Type;// Sector.Data.Data[self.Offset]; VoxelExtension selfOtherInfo = self.VoxelExtension;//Sector.Data.OtherInfos[self.Offset]; ushort otherType = other.Type.properties.Type;//Sector.Data.Data[other.Offset]; VoxelExtension otherOtherInfo = other.VoxelExtension;//.Sector.Data.OtherInfos[other.Offset]; self.Sector.Data.Data[self.Offset] = otherType; self.Sector.Data.OtherInfos[self.Offset] = otherOtherInfo; other.Sector.Data.Data[other.Offset] = selfType; other.Sector.Data.OtherInfos[other.Offset] = selfOtherInfo; self.Sector.Culler.CullSingleVoxel( self.Sector, self.Offset ); other.Sector.Culler.CullSingleVoxel( other.Sector, other.Offset ); self.Sector.Flag_IsModified |= importance; other.Sector.Flag_IsModified |= importance; }