ark_api_ffi/ffi/
world_v1.rs

1define_api_id!(0x1df7_daa6_26c6_0ecc, "world-v1");
2
3pub use crate::world_v0::ComponentType;
4pub use crate::world_v0::EntityHandle;
5pub use crate::world_v0::ValueType;
6use bytemuck::CheckedBitPattern;
7use bytemuck::NoUninit;
8use bytemuck::Pod;
9use bytemuck::Zeroable;
10
11pub type DataHandle = u64;
12
13/// Describes what a component parameter is or what it is used for.
14///
15/// Useful for doing ui or serialization of data.
16#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
17#[repr(u32)]
18#[non_exhaustive]
19pub enum ParameterSemantic {
20    Unspecified = 0,
21    EntityHandle = 1,
22    // Deprecated 2021-11-08 in favor of DataHandle
23    //MeshHandle = 2,
24    Position = 3,
25    Scale = 4,
26    Rotation = 5,
27    Color = 6,
28    MeshStyleFlags = 7,
29    DynamicLockFlags = 8,
30    CharacterCollisionFlags = 9,
31    JointType = 10,
32    JointLimitType = 11,
33    NormalizedDirection = 12,
34    Direction = 13,
35    Bitmask = 15,
36    CameraProjectionMode = 16,
37    AngleDegrees = 17,
38    DataHandle = 18,
39    Count = 19,
40}
41
42/// Struct describing a specific parameter of a component.
43#[derive(Debug, Copy, Clone)]
44#[repr(C)]
45pub struct ParameterMetaDataEntry {
46    pub parameter_id: u32,
47    pub name: DataHandle, // Points to string
48    pub value_type: ValueType,
49
50    pub semantic: ParameterSemantic,
51    // Add this here for any future per semantic / type info, such as ranges / enum names. Will usually be invalid.
52    pub size_semantic_data_entry: u32,
53    pub semantic_data: DataHandle,
54}
55
56/// Struct describing a specific component.
57#[derive(Debug, Copy, Clone)]
58#[repr(C)]
59pub struct ComponentMetaDataEntry {
60    pub component_type: ComponentType,
61    pub name: DataHandle,          // Points to string
62    pub size_parameter_entry: u32, // Used for sanity checking "version" and calculate num elements
63    pub parameters: DataHandle,
64}
65
66/// Struct describing all components
67#[derive(Debug, Copy, Clone)]
68#[repr(C)]
69pub struct ComponentsMetaDataEntry {
70    pub size_component_entry: u32, // Used for sanity checking "version" and calculate num elements
71    pub components: DataHandle,
72}
73
74/// Type describing what entities a `WorldEntityQuery` should start with.
75#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, NoUninit, CheckedBitPattern)]
76#[repr(u32)]
77#[non_exhaustive]
78pub enum WorldEntityQueryType {
79    AllEntities = 0,
80    TransformChildren = 1,
81    TransformDescendants = 2,
82    AllEntitiesNoLayerFilter = 3,
83    TransformChildrenNoLayerFilter = 4,
84    TransformDescendantsNoLayerFilter = 5,
85}
86
87/// Struct describing a query for entities in the world.
88///
89/// A query with `layer_mask` = !0u64, `num_include_tags` = 0, `num_exclude_tags` = 0,
90/// will mean all the entities in the world.
91/// Retrieving output of the data will get all the entities the query results in.
92#[derive(Debug, Copy, Clone, NoUninit, CheckedBitPattern)]
93#[repr(C)]
94pub struct WorldEntityQuery {
95    /// What layers to include
96    pub layer_mask: u64,
97
98    /// Number of tags to include
99    pub num_include_tags: u8,
100
101    /// Number of tags to exclude
102    pub num_exclude_tags: u8,
103
104    pub _pad0: [u8; 6],
105
106    // Storage for the tags to include
107    pub include_tags: [u64; 16],
108
109    // Storage for the tags to exclude
110    pub exclude_tags: [u64; 16],
111
112    pub query_type: WorldEntityQueryType,
113
114    pub _pad1: u32,
115
116    pub root_entity: EntityHandle,
117}
118
119#[derive(Debug, Copy, Clone, Pod, Zeroable)]
120#[repr(C)]
121pub struct PhysicsShapeBox {
122    pub center: [f32; 3],
123    pub half_size: [f32; 3],
124    pub rotation: [f32; 4],
125}
126
127#[derive(Debug, Copy, Clone, Pod, Zeroable)]
128#[repr(C)]
129pub struct PhysicsShapeSphere {
130    pub center: [f32; 3],
131    pub radius: f32,
132}
133
134#[derive(Debug, Copy, Clone, Pod, Zeroable)]
135#[repr(C)]
136pub struct PhysicsShapeCapsule {
137    pub pos0: [f32; 3],
138    pub pos1: [f32; 3],
139    pub radius: f32,
140}
141
142#[derive(Debug, Copy, Clone, Pod, Zeroable)]
143#[repr(C)]
144pub struct CompoundPhysicsShape {
145    pub num_boxes: u32,
146    pub boxes_ptr: u32,
147    pub num_spheres: u32,
148    pub spheres_ptr: u32,
149    pub num_capsules: u32,
150    pub capsules_ptr: u32,
151}