pub struct LOD<S>where
    S: State,
{ /* private fields */ }
Expand description

Object that represents space level of details. This gives you the ability to sample space area states at different zoom levels (LOD mechanism).

Implementations

Creates new LOD information universe.

Arguments
  • dimensions - Number of dimensions which space contains.
  • count - Number of levels.
  • root_state - State of root level.
Examples
use quantized_density_fields::LOD;

// Create 2D space with 1 level of details and `16` as root space.
let lod = LOD::new(2, 1, 16);
assert_eq!(*lod.state(), 16);
// LOD has 4 children level objects.
assert_eq!(lod.level(lod.root()).sublevels().len(), 4);
// sampled state at level 1 equals to `4` (`16 / 4`).
assert_eq!(*lod.level(lod.level(lod.root()).sublevels()[0]).state(), 4);

Gets LOD id.

Gets LOD root level node id.

Gets LOD dimensions number.

Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
assert_eq!(lod.dimensions(), 2);

Gets LOD zoom levels number.

Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
assert_eq!(lod.levels_count(), 1);

Gets LOD root level state.

Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
assert_eq!(*lod.state(), 16);

Tells if space level with given id exists in LOD.

Arguments
  • id - level id.
Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
assert!(lod.level_exists(lod.root()));

Try to get reference to given space level.

Arguments
  • id - level id.
Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
if let Some(level) = lod.try_get_level(lod.root()) {
    assert_eq!(*level.state(), 16);
}

Gets reference to given space level and throws error if level does not exists.

Arguments
  • id - level id.
Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
if let Ok(level) = lod.get_level(lod.root()) {
    assert_eq!(*level.state(), 16);
}

Gets reference to given space level and panics if level does not exists.

Arguments
  • id - level id.
Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
assert_eq!(*lod.level(lod.root()).state(), 16);

Try to set given level state.

Arguments
  • id - level id.
  • state - state.
Examples
use quantized_density_fields::LOD;

let mut lod = LOD::new(2, 1, 9);
let id = lod.root();
assert!(lod.try_set_level_state(id, 3));

Set given level state or throw error if level does not exists.

Arguments
  • id - level id.
  • state - state.
Examples
use quantized_density_fields::LOD;

let mut lod = LOD::new(2, 1, 9);
let id = lod.root();
assert!(lod.set_level_state(id, 3).is_ok());

Gets list of space level neighbors IDs or throws error if level does not exists.

Arguments
  • id - Level id.
Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
let subs = lod.level(lod.root()).sublevels();
assert_eq!(lod.find_level_neighbors(subs[0]).unwrap(), vec![subs[1], subs[2], subs[3]]);

Gets list of space level IDs that defines shortest path between two space levels, or throws error if level does not exists. Levels must lay on the same zoom level!

Arguments
  • from - source level id.
  • to - target level id.
Examples
use quantized_density_fields::LOD;

let lod = LOD::new(2, 1, 16);
let subs = lod.level(lod.root()).sublevels();
assert_eq!(lod.find_path(subs[1], subs[3]).unwrap(), vec![subs[1], subs[0], subs[3]]);

Performs simulation step (go through all platonic spaces and modifies its states based on neighbor states). Actual state simulation is performed by your struct that implements Simulation trait.

Does the same as simulation_step() but in parallel manner (it may or may not increase simulation performance if simulation is very complex).

Performs simulation on LOD like simulation_step() but instead of applying results to LOD, it returns simulated platonic level states along with their level ID.

Performs simulation on LOD like simulation_step_parallel() but instead of applying results to LOD, it returns simulated platonic level states along with their level ID.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.