1use crate::IncomingTransition;
6use crate::asset::Asset;
7use crate::atmosphere::{Atmosphere, PostProcessingStatus};
8use crate::clip::{Clip, ClipBinding};
9use crate::clip_effects::ClipEffects;
10use crate::clip_events::ClipEvents;
11use crate::clip_identity::{ClipKey, ClipLength};
12use crate::collider::{Collider, Heightfield};
13use crate::components::{
14 Collision, Instance, Light, MaterialVariants, Mesh, MeshFile, Name, Shadows, Source, Surfaces, Texture,
15 TextureAbsent, TextureFile, Tile, Transform,
16};
17use crate::content::{ContentNote, DisplayName, Record};
18use crate::controller::{Controller, ControllerBinding};
19use crate::convert::{PartScope, PartitionPlan};
20use crate::detail::DetailedMaterial;
21use crate::draw_groups::{DrawGroupDefaults, DrawGroups};
22use crate::draw_order::DrawOrder;
23use crate::environment::{Environment, TimeOfDay};
24use crate::irradiance_volume::IrradianceVolume;
25use crate::layered::LayeredMaterial;
26use crate::light_unit::{DirectionalLightUnit, LightUnit};
27use crate::lod::Lods;
28use crate::lod_switch::{LodSwitch, LodSwitchView};
29use crate::marker::{Curve, Marker};
30use crate::material_parameters::MaterialParameters;
31use crate::material_usage::MaterialUsage;
32use crate::morphs::Morphs;
33use crate::opening::OpeningSuggestions;
34use crate::particles::ParticleSystem;
35use crate::pass::memo::Memo;
36use crate::pbr::PbrMaterial;
37use crate::primitive_keys::PrimitiveKeys;
38use crate::priority::Priority;
39use crate::provenance::Provenance;
40use crate::read_scope::ReadScopes;
41use crate::reflection_probe::ReflectionProbeRegion;
42use crate::render_graph::RenderGraph;
43use crate::rig::{
44 Attachment, JointMap, JointPlacement, MorphWeights, RigInstance, RigPose, SkinInstance, Sockets,
45};
46use crate::shader::{
47 LiftedShader, MaterialPrograms, ProgramFacts, ProgramFrame, Shader, ShaderBinding, ShaderDerivation,
48 ShaderSpecialisations,
49};
50use crate::skeleton::{AssemblyReference, Skeleton};
51use crate::skin::Skin;
52use crate::sky_anchor::SkyAnchor;
53use crate::state::{Condition, PrimitiveCondition, StateAssignment, StateAxis, StateOverride};
54use crate::step_bindings::{StepBindings, StepDraws};
55use crate::texture_forms::TextureForms;
56use crate::texture_layers::TextureLayers;
57use crate::texture_switch::{TextureSwitch, TextureSwitchView};
58use crate::vertex_color::VertexColor;
59use crate::world::{Component, Resource};
60use crate::{LightFalloff, LightTranslucency, SpotFrustum, WaterBody};
61use primase_foundations::parallel::Threads;
62
63#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
65pub enum Declared {
66 Component,
67 Resource,
68}
69
70macro_rules! declared {
71 (components: $($c:ident),* $(,)?; resources: $($r:ident),* $(,)?) => {
72 pub fn names() -> Vec<(&'static str, Declared)> {
74 vec![
75 $((<$c as Component>::NAME, Declared::Component),)*
76 $((<$r as Resource>::NAME, Declared::Resource),)*
77 ]
78 }
79
80 pub const LISTED: &[&str] = &[$(stringify!($c),)* $(stringify!($r),)*];
83 };
84}
85
86declared! {
87 components: Collider, Heightfield, Name, Source, Transform, Instance, Shadows, Mesh, Texture, Light, Collision,
88 TextureFile, TextureAbsent, MeshFile, MaterialVariants, Tile, DrawOrder, LayeredMaterial, Lods, LodSwitch, TextureForms, TextureSwitch, Marker, Curve, MaterialUsage,
89 PbrMaterial, DetailedMaterial, Priority, Provenance, StateAxis, Condition, PrimitiveCondition, StateOverride, VertexColor, Skeleton, AssemblyReference, Skin, Morphs, RigInstance,
90 RigPose, SkinInstance, MorphWeights, Sockets, Attachment, JointMap, JointPlacement, Clip, ClipBinding, Asset, Shader, ShaderBinding, LiftedShader, ShaderSpecialisations, ShaderDerivation,
91 TextureLayers, MaterialPrograms, ProgramFacts, ClipKey, ClipLength, IncomingTransition, ClipEvents, ClipEffects, Controller, ControllerBinding,
92 DrawGroups, DrawGroupDefaults, ContentNote, Record, DisplayName, PrimitiveKeys, MaterialParameters, SkyAnchor,
93 ParticleSystem, IrradianceVolume, ReflectionProbeRegion, StepBindings, StepDraws, LightFalloff, LightTranslucency, SpotFrustum, WaterBody;
94 resources: PartScope, PartitionPlan, Environment, Atmosphere, PostProcessingStatus, StateAssignment, Surfaces, Threads, Memo, RenderGraph,
95 LightUnit, DirectionalLightUnit, TimeOfDay, TextureSwitchView, LodSwitchView, ReadScopes, OpeningSuggestions, ProgramFrame,
96}
97
98#[cfg(test)]
99mod tests {
100 use super::*;
101
102 #[test]
104 fn every_name_once() {
105 let names = names();
106 let set: std::collections::BTreeSet<&str> = names.iter().map(|(n, _)| *n).collect();
107 assert_eq!(set.len(), names.len());
108 assert_eq!(names.len(), LISTED.len());
109 assert!(
110 set.contains("core.mesh") && set.contains("pbr.material") && set.contains("core.environment")
111 );
112 }
113
114 #[test]
115 fn animation_and_content_types_are_listed_with_their_storage_kind() {
116 let names = names();
117 for name in [
118 "core.clip_key",
119 "core.clip_length",
120 "core.incoming_transition",
121 "core.clip_events",
122 "core.controller",
123 "core.controller_binding",
124 "core.draw_groups",
125 "core.draw_group_defaults",
126 "core.content_note",
127 "core.record",
128 "core.display_name",
129 "core.primitive_keys",
130 "core.material_parameters",
131 ] {
132 assert!(names.contains(&(name, Declared::Component)), "{name}");
133 }
134 assert!(!names.iter().any(|(name, _)| *name == "core.clip_catalog"));
135 }
136}