nightshade 0.57.0

A cross-platform data-oriented game engine.
Documentation
use std::collections::BTreeMap;

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct SceneNavMesh {
    pub vertices: Vec<[f32; 3]>,
    pub triangles: Vec<SceneNavMeshTriangle>,
    pub edges: Vec<SceneNavMeshEdge>,
    pub adjacency: BTreeMap<usize, Vec<SceneNavMeshConnection>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SceneNavMeshTriangle {
    pub vertex_indices: [usize; 3],
    pub center: [f32; 3],
    pub normal: [f32; 3],
    pub area: f32,
    pub edge_indices: [usize; 3],
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SceneNavMeshEdge {
    pub vertex_indices: [usize; 2],
    pub triangle_indices: [Option<usize>; 2],
    pub midpoint: [f32; 3],
    pub length: f32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SceneNavMeshConnection {
    pub target_triangle: usize,
    pub shared_edge: usize,
    pub cost: f32,
}

impl SceneNavMesh {
    pub fn is_empty(&self) -> bool {
        self.triangles.is_empty()
    }
}

/// What a scene stores about a navigation agent: how it should move, not where
/// it currently is. The path, the waypoint index, and the rest of the runtime
/// state are recomputed on load rather than saved.
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct SceneNavMeshAgent {
    pub movement_speed: f32,
    pub arrival_threshold: f32,
    pub path_recalculation_threshold: f32,
    pub agent_radius: f32,
    pub agent_height: f32,
}