Class ModelLodInfo
Namespace: ValveResourceFormat.ResourceTypes
Assembly: ValveResourceFormat.dll
Describes a model's level-of-detail (LOD) structure: which meshes belong to which LOD level and the per-level switch values. Built once from the compiled model's m_refLODGroupMasks (bit N set => mesh is in LOD level N) and m_lodGroupSwitchDistances.
public sealed class ModelLodInfoInheritance
Constructors
ModelLodInfo(long[], float[])
Initializes LOD info from a model's mesh LOD masks (m_refLODGroupMasks) and switch distances (m_lodGroupSwitchDistances).
public ModelLodInfo(long[] meshLodMasks, float[] switchDistances)Parameters
meshLodMasks long[]
switchDistances float[]
Properties
AvailableLevels
Gets the sorted distinct LOD levels present across all meshes, e.g. [0, 1, 2].
public IReadOnlyList<int> AvailableLevels { get; }Property Value
CombinedMask
Gets the bitwise OR of every mesh's LOD mask.
public long CombinedMask { get; }Property Value
HasDistinctLevels
Gets whether switching LOD level actually changes what's rendered, which is what decides whether a selector is worth showing. Real LODs have some mesh in one level but not another. A mesh that's in (or out of) every level, like a lone mask-0xFF mesh with no switch distances, looks the same everywhere and is just the compiler's "always shown" flag. An empty level still counts as a distinct state, so a populated level next to an empty one (such as an empty LOD0) is a real LOD.
public bool HasDistinctLevels { get; }Property Value
LevelCount
Gets the total number of LOD levels the model declares, including empty levels (e.g. a misconfigured empty LOD0).
public int LevelCount { get; }Property Value
LowestLevel
Gets the lowest LOD level that actually contains meshes. Normally 0, but models that leave LOD0 empty return the next populated level. Returns 0 when no LOD bits are set.
public int LowestLevel { get; }Property Value
Remarks
A lower level represents higher mesh detail.
SwitchDistances
Gets the per-level switch values. Index N is the value at which LOD level N becomes active. These are a screen-size metric (100 / on-screen size of a unit sphere), not world units. Empty for models without LOD switch data.
public IReadOnlyList<float> SwitchDistances { get; }Property Value
Methods
GetMetricRange(int)
Gets the screen-size metric range LOD level is active over: from its own switch value (inclusive) up to the next populated level's (exclusive). The top level is open-ended (null Max). Jumping to the next populated level skips over any empty level in between, matching .
public (float Min, float? Max) GetMetricRange(int level)Parameters
level int
Returns
IsMeshInAllLevels(int)
Determines whether the mesh at meshIndex shows up in every populated LOD level. Those meshes render at all levels and are authored as a single LODGroupAll entry rather than added to each group. Only meaningful when more than one level is populated.
public bool IsMeshInAllLevels(int meshIndex)Parameters
meshIndex int
Returns
IsMeshInLevel(int, int)
Determines whether the mesh at meshIndex is present in LOD level level. Meshes without a mask entry are treated as always present.
public bool IsMeshInLevel(int meshIndex, int level)Parameters
meshIndex int
level int
Returns
LowestSetLevel(long)
Returns the index of the lowest set bit in combinedMask, or 0 if none.
public static int LowestSetLevel(long combinedMask)Parameters
combinedMask long
Returns
SelectLevel(float)
Selects the LOD level for a given screen-size metric: the highest available level whose switch value the metric has reached, never below .
public int SelectLevel(float metric)Parameters
metric float

