enginerenderer 0.0.1

A zero-dependency offline rendering engine in pure Rust — CPU path tracing, BVH acceleration, 16-band spectral rendering, PBR materials, animation & video export.
Documentation
use crate::core::engine::scene::graph::SceneGraph;

fn detail_score(scene_radius: f64, node_count: usize, luminous_nodes: usize) -> f64 {
    let base = (node_count as f64).ln().max(1.0);
    let luminous_ratio = luminous_nodes as f64 / node_count.max(1) as f64;
    let radius_factor = (scene_radius / 10.0).clamp(0.5, 3.0);
    (base * (1.0 + luminous_ratio) * radius_factor).clamp(0.1, 5.0)
}

fn camera_distance_scale(detail: f64) -> f64 {
    (1.0 + detail * 0.15).clamp(0.8, 2.0)
}

#[derive(Debug, Clone, Copy)]
/// Runtime guidance computed from scene complexity analysis.
pub struct AiDirective {
    /// Scalar applied to rendering quality heuristics.
    pub quality_bias: f64,
    /// Scalar applied to camera distance from scene focus.
    pub camera_distance_scale: f64,
    /// Exposure adjustment suggested by scene analysis.
    pub exposure_bias: f64,
}

#[derive(Debug, Clone, Copy)]
/// Lightweight AI heuristic manager used by runtime systems.
pub struct AiManager {
    aggressiveness: f64,
}

impl AiManager {
    /// Creates a manager with a bounded aggressiveness factor.
    pub fn new(aggressiveness: f64) -> Self {
        Self {
            aggressiveness: aggressiveness.clamp(0.25, 2.0),
        }
    }

    /// Analyzes scene graph characteristics and returns runtime directives.
    pub fn analyze(&self, graph: &SceneGraph, detail_scale: f64) -> AiDirective {
        let detail = detail_score(
            graph.scene_radius(),
            graph.node_count(),
            graph.luminous_node_count(),
        ) * detail_scale.clamp(0.75, 2.5);

        AiDirective {
            quality_bias: (0.82 + detail * 0.22 * self.aggressiveness).clamp(0.7, 1.25),
            camera_distance_scale: camera_distance_scale(detail),
            exposure_bias: (1.0 + detail * 0.12).clamp(0.95, 1.18),
        }
    }
}