pub struct ParameterList<T> {
values: Vec<(ParameterPoint, T)>,
param_spaces: Vec<[Parameter; 7]>,
nodes: Vec<FlatNode>,
}Expand description
A list of biome parameter points with their associated values.
Uses an R-Tree for lookup matching vanilla’s Climate.ParameterList.
Fields§
§values: Vec<(ParameterPoint, T)>The biome entries (parameter point, value pairs)
param_spaces: Vec<[Parameter; 7]>Cached parameter spaces for each value (for distance computation in lastResult)
nodes: Vec<FlatNode>Flat R-Tree nodes in BFS order. Root is at index 0.
Implementations§
Source§impl<T> ParameterList<T>
impl<T> ParameterList<T>
Sourcepub fn new(values: Vec<(ParameterPoint, T)>) -> Self
pub fn new(values: Vec<(ParameterPoint, T)>) -> Self
Create a new parameter list from values, building an R-Tree index.
§Panics
Panics if values is empty.
Sourcepub fn values(&self) -> &[(ParameterPoint, T)]
pub fn values(&self) -> &[(ParameterPoint, T)]
Get the underlying values.
Sourcepub fn find_value(&self, target: &TargetPoint) -> &T
pub fn find_value(&self, target: &TargetPoint) -> &T
Find the best matching value for a target point (no caching).
Uses R-Tree search matching vanilla’s Climate.ParameterList.findValue().
Note: Vanilla warm-starts with lastResult via ThreadLocal, which can
affect tie-breaking on equal-distance candidates. This version starts
from i64::MAX (no warm-start). Use find_value_cached for the hot
path to match vanilla’s tie-breaking behavior.
§Panics
Panics if the R-Tree search fails to find any matching value.
Sourcepub fn find_value_cached(
&self,
target: &TargetPoint,
cache: &mut Option<usize>,
) -> &T
pub fn find_value_cached( &self, target: &TargetPoint, cache: &mut Option<usize>, ) -> &T
Find the best matching value with lastResult caching.
Matches vanilla’s Climate.ParameterList.findValue() with ThreadLocal
lastNode warm-starting. The cache stores the index of the last result,
which is used as the initial candidate for the next search, improving
both performance and tie-breaking behavior.
§Panics
Panics if the R-Tree search fails to find any matching value.