Class RegionBoxVoxelVisibility
Namespace: ValveResourceFormat.Blocks
Assembly: ValveResourceFormat.dll
An octree whose leaves list boxes, each tagged with the cluster that owns it, so resolving a query is box overlap. The tree and the visibility rows are packed one after the other in the block payload.
public sealed class RegionBoxVoxelVisibility : IWorldVisibilityInheritance
object ← RegionBoxVoxelVisibility
Implements
Fields
NoCluster
The cluster id of a region no cluster claims. A third of the regions in some maps carry it.
public const ushort NoCluster = 65535Field Value
Properties
BytesPerCluster
Gets the number of bytes in one cluster's visibility row.
public int BytesPerCluster { get; }Property Value
ClusterBitfieldWordCount
Gets how many 32 bit words a cluster bitfield needs.
public int ClusterBitfieldWordCount { get; }Property Value
ClusterCount
Gets the number of clusters, excluding the sky row.
public int ClusterCount { get; }Property Value
ClusterRowOffsets
Gets the byte offset of each cluster's row within .
public int[] ClusterRowOffsets { get; }Property Value
int[]
GridSize
Gets the grid cell size.
public float GridSize { get; }Property Value
HasVisibilityData
Gets whether this holds visibility that can be queried.
public bool HasVisibilityData { get; }Property Value
IsRawPvs
Gets whether the rows are stored uncompressed. Nothing can be read out of them when they are not.
public bool IsRawPvs { get; }Property Value
MaxBounds
Gets the maximum bounds of the octree.
public Vector3 MaxBounds { get; }Property Value
MinBounds
Gets the minimum bounds of the octree.
public Vector3 MinBounds { get; }Property Value
Nodes
Gets the octree nodes.
public RegionBoxVoxelVisibility.Node[] Nodes { get; }Property Value
RegionBoxVoxelVisibility.Node[]
Regions
Gets the region entries.
public RegionBoxVoxelVisibility.Region[] Regions { get; }Property Value
RegionBoxVoxelVisibility.Region[]
SkyRowOffset
Gets the byte offset of the sky row within , or -1 when absent.
public int SkyRowOffset { get; }Property Value
SkyVisibility
Gets the visibility row listing the clusters the sky reaches, empty when there is no sky row.
public ReadOnlyMemory<byte> SkyVisibility { get; }Property Value
SunRowOffset
Gets the byte offset of the sun row within , or -1 when the file carries no sun row.
public int SunRowOffset { get; }Property Value
SunVisibility
Gets the visibility row listing the clusters sunlight reaches, empty when the format has none.
public ReadOnlyMemory<byte> SunVisibility { get; }Property Value
Remarks
Empty when the file carries no sun row, which leaves shadow casters uncullable.
VisBlocks
Gets the raw visibility rows, one per cluster plus the sky row.
public byte[] VisBlocks { get; }Property Value
byte[]
Methods
BuildClusterChildBounds()
Builds the list of boxes making up each cluster, for debug drawing.
public Dictionary<ushort, List<(Vector3 Min, Vector3 Max)>> BuildClusterChildBounds()Returns
Dictionary<ushort, List<(Vector3 Min, Vector3 Max)>>
GetClusterForPosition(Vector3)
Gets the cluster containing the given point, or -1 when it is outside every region.
public int GetClusterForPosition(Vector3 position)Parameters
position Vector3
World-space point.
Returns
GetVisClustersForBox(Vector3, Vector3, Span<uint>)
Fills a bitfield with every cluster the given box overlaps, one bit per cluster id.
public void GetVisClustersForBox(Vector3 min, Vector3 max, Span<uint> clusterBits)Parameters
min Vector3
Minimum corner of the box.
max Vector3
Maximum corner of the box.
Destination bitfield, at least bits long.
GetVisibilityRow(int)
Gets the visibility row for a cluster, or an empty row when it has none.
public ReadOnlyMemory<byte> GetVisibilityRow(int clusterId)Parameters
clusterId int
Cluster to look up.
Returns
GetVisibilityRowForPoint(Vector3)
Gets the visibility row for the cluster at a point, empty when the point resolves to nothing.
public ReadOnlyMemory<byte> GetVisibilityRowForPoint(Vector3 point)Parameters
point Vector3
World-space point.
Returns
Read(KVObject, BinaryReader, long)
Reads the tree and the visibility rows out of the block.
public void Read(KVObject data, BinaryReader reader, long blockOffset)Parameters
data KVObject
The block's KV3 data.
reader BinaryReader
Reader positioned anywhere in the resource.
blockOffset long
Byte offset of the block's payload in the resource.

