use serde::{Deserialize, Serialize};
use super::{NodeGraphPaintCachePruneTuning, NodeGraphSpatialIndexTuning};
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct NodeGraphRuntimeTuning {
#[serde(default = "default_spatial_index_tuning")]
pub spatial_index: NodeGraphSpatialIndexTuning,
#[serde(default = "default_only_render_visible_elements")]
pub only_render_visible_elements: bool,
#[serde(default = "default_paint_cache_prune_tuning")]
pub paint_cache_prune: NodeGraphPaintCachePruneTuning,
}
impl NodeGraphRuntimeTuning {
pub fn is_default(this: &Self) -> bool {
this == &Self::default()
}
pub fn with_spatial_index_enabled(mut self, enabled: bool) -> Self {
self.spatial_index.enabled = enabled;
self
}
pub fn with_only_render_visible_elements(mut self, enabled: bool) -> Self {
self.only_render_visible_elements = enabled;
self
}
}
impl Default for NodeGraphRuntimeTuning {
fn default() -> Self {
Self {
spatial_index: default_spatial_index_tuning(),
only_render_visible_elements: default_only_render_visible_elements(),
paint_cache_prune: default_paint_cache_prune_tuning(),
}
}
}
fn default_spatial_index_tuning() -> NodeGraphSpatialIndexTuning {
NodeGraphSpatialIndexTuning::default()
}
fn default_paint_cache_prune_tuning() -> NodeGraphPaintCachePruneTuning {
NodeGraphPaintCachePruneTuning::default()
}
pub(crate) fn default_only_render_visible_elements() -> bool {
true
}