1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
define_api_id!(0x1d69_ec55_ed04_461c, "world-v2");

pub use crate::world_v0::EntityHandle;
pub use crate::world_v0::MeshHandle;
pub use crate::world_v0::MeshProperties;
pub use crate::world_v0::Message;
pub use crate::world_v0::Ray;
pub use crate::world_v0::Value;
pub use crate::world_v1::DataHandle;
use crate::FFIResult;
use bytemuck::CheckedBitPattern;
use bytemuck::NoUninit;
use bytemuck::Pod;
use bytemuck::Zeroable;

/// A raw handle to a unique resource
///
/// This handle can be retrieved through the Resource Ark API
pub type ResourceHandleRepr = u32;

pub const INVALID_RESOURCE_HANDLE: u32 = !0u32;

/// Mesh semantic to describe what a stream contains
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, NoUninit, CheckedBitPattern)]
#[repr(u32)]
pub enum MeshStreamSemantic {
    Indices = 0,
    Positions = 1,
    Normals = 2,
    Colors = 3,
    TexCoords = 4,
    BoneIndicesWeights = 5, // two streams in one as they are always together.
}

/// Mesh component format for a stream
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, NoUninit, CheckedBitPattern)]
#[repr(u32)]
pub enum MeshComponentFormat {
    /// 16-bit floating point
    Float16 = 0,
    /// 32-bit floating point
    Float32 = 1,

    /// 8-bit unsigned integer
    UInt8 = 2,
    /// 8-bit signed integer
    SInt8 = 3,

    /// 16-bit unsigned integer
    UInt16 = 4,
    /// 16-bit signed integer
    SInt16 = 5,

    /// 32-bit unsigned integer
    UInt32 = 6,
    /// 32-bit signed integer
    SInt32 = 7,
}

// Mesh stream layout
#[derive(Debug, Copy, Clone, PartialEq, Eq, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct MeshStreamLayout {
    pub semantic: MeshStreamSemantic,
    pub component_format: MeshComponentFormat,
    pub component_count: u32,
    pub buffer_ptr: u32,
    pub buffer_size: u32,
}

bitflags::bitflags! {
    #[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
    #[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
    #[repr(C)]
    #[derive(Pod, Zeroable)]
    pub struct MeshStyleFlags : u32 {

        /// Enables lighting.
        const LIGHTING = 0b0000_0001;

        /// Does nothing, kept only for compatibility. Whether alpha blending is enabled depends on
        /// the diffuse_tint's alpha value, and the mesh's vertex alpha values.
        const ALPHA_BLENDING = 0b0000_0010;

        /// Enables lighting based on triangle face normals rather than vertex normals.
        const FLAT_SHADING = 0b0000_0100;

        // used to be HSV_TRANSFORM
        /// Do not use.
        const _LEGACY = 0b0000_1000;

        /// Enables premultiplied alpha. An alpha of zero, either through the mesh or diffuse tint, then means additive blending.
        const PREMULTIPLIED_ALPHA = 0b0001_0000;

        /// Will make the mesh face the camera at all times, can be handy for things like particles or ui.
        const BILLBOARD = 0b0010_0000;

        /// Two sided - effectively turns off backface culling.
        const TWO_SIDED = 0b0100_0000;

        /// Outline - adds a thin outline.
        const OUTLINE = 0b1000_0000;

        /// Overlay - Rendered after all post processing.
        /// This can be usefull for rendering HUD elements and other visual overlays.
        /// Shadows, reflections and global illumination will be disabled on the object if this flag is enabled.
        const OVERLAY = 0b0001_0000_0000;
    }
}

impl Default for MeshStyleFlags {
    fn default() -> Self {
        Self::LIGHTING | Self::ALPHA_BLENDING
    }
}

bitflags::bitflags! {
    #[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
    #[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
    #[repr(C)]
    #[derive(Pod, Zeroable)]
    pub struct MeshVisibilityFlags : u8 {
        const REFLECTIONS = 0b0000_0001; // Mesh affects reflections
        const SHADOWS = 0b0000_0010; // Mesh affects shadows
        const GLOBAL_ILLUMINATION = 0b0000_0100; // Mesh affects global illumination
        const PRIMARY = 0b0000_1000; // Mesh affects the primary ray/gbuffer.
    }
}

impl Default for MeshVisibilityFlags {
    fn default() -> Self {
        Self::REFLECTIONS | Self::SHADOWS | Self::GLOBAL_ILLUMINATION | Self::PRIMARY
    }
}

#[allow(clippy::too_many_arguments)]
#[ark_api_macros::ark_bindgen(imports = "ark-world-v2")]
mod world {
    use super::*;

    #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
    #[repr(u32)]
    pub enum EntityTemplate {
        Empty = 0,
        PhysicsObject = 1,
        Environment = 2,
        MeshStyle = 3,
        Camera = 4,
        NonPhysicsObject = 5,
    }

    #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
    #[repr(u64)]
    #[non_exhaustive]
    pub enum ComponentType {
        Invalid = 0,
        Transform = 1,
        Render = 2,
        Physics = 3,
        Environment = 4,
        MeshStyle = 5,
        Camera = 6,
        // 7 used to be Joint
        //Velocity = 8, // Deprecated, here to reserve the value for binary compatibility. To be deleted.
        Bounds = 9,
        Tag = 10,
        Layer = 11,
        // 12 used to be PhysicsCharacter
        EntityInfo = 13,
        D6Joint = 14,
        //Articulation = 15, // Deprecated, here to reserve the value for binary compatibility. To be deleted.
        //ArticulationLink = 16, // Deprecated, here to reserve the value for binary compatibility. To be deleted.
        SdfModel = 17,
        //SkinnedSdfModel = 18, // Deprecated, here to reserve the value for binary compatibility. To be deleted.
        AudioSource = 19,
    }

    /// Struct for providing information about an audio clip.
    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct AudioClipInfo {
        pub num_samples: u64,
        pub num_channels: u32,
        pub sample_rate: u32,
    }

    impl AudioClipInfo {
        pub fn length_in_seconds(&self) -> f32 {
            (self.num_samples as f32) / (self.sample_rate as f32)
        }
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct SdfSkinInfo {
        pub replacement_mesh: DataHandle,
    }

    /// Type describing what data to retrieve with `world__retrieve_data`
    #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
    #[repr(u32)]
    #[non_exhaustive]
    pub enum RetrieveDataType {
        // Deprecated
        // Input = 0,
        /// Can be used to currently retrieve strings and binary data (entity names and reflection).
        Output = 1,
        // Deprecated
        //Type = 2,
        /// Returns data type specific information (for instance `AudioClipInfo` for `CreateDataType::AudioClipOgg` and `CreateDataType::AudioClipWav`)
        Info = 3,

        WorldDataType = 4,
    }

    /// Type used to describe a data object created using either `world__create_data` or by the host.
    #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
    #[repr(u64)]
    #[non_exhaustive]
    pub enum CreateDataType {
        //Invalid = 0,
        String = 1, // data_len passed to create_data can be without null-terminator,
        Binary = 2,
        ComponentsMetaData = 3, // Needs no input-data when created but can be used to get information about all components available.
        WorldEntityQuery = 4,
        CompoundPhysicsShape = 5,
        SdfProgram = 6,
        #[deprecated(note = "Use `SdfSkin2`")]
        SdfSkin = 7,
        AudioClipOgg = 8,
        AudioClipWav = 9,
        MorphTargetData = 10,
        #[deprecated(note = "Use `MeshRawWithName`")] // 2021-08-27
        MeshRaw = 11,
        MeshGltf = 12,
        PlayerIdSet = 13,
        #[deprecated(note = "Use `MeshRawWithMaterialAndName`")] // 2021-08-27
        MeshRawWithMaterial = 14,
        WorldMaterial = 15,
        SdfSkin2 = 16,
        WorldMaterials = 17,
        MeshGltfNamed = 18,
        /// Simplifies an existing mesh
        MeshSimplified = 19,
        MeshRawWithName = 20,
        MeshRawWithMaterialAndName = 21,
        FormattedText = 22,
        /// Data for client-side render modules.
        RenderModule = 23,
        MeshGltfResource = 24,
        AudioClipOggResource = 25,
        AudioClipWavResource = 26,
        // Data for client-side audio modules.
        AudioModule = 27,
    }

    impl CreateDataType {
        pub fn name(self) -> &'static str {
            match self {
                Self::String => "String",
                Self::Binary => "Binary",
                Self::ComponentsMetaData => "ComponentsMetaData",
                Self::WorldEntityQuery => "WorldEntityQuery",
                Self::CompoundPhysicsShape => "CompoundPhysicsShape",
                Self::SdfProgram => "SdfProgram",
                Self::SdfSkin => "SdfSkin",
                Self::AudioClipOgg => "AudioClipOgg",
                Self::AudioClipWav => "AudioClipWav",
                Self::MorphTargetData => "MorphTargetData",
                Self::MeshRaw => "MeshRaw",
                Self::MeshGltf => "MeshGltf",
                Self::PlayerIdSet => "PlayerIdSet",
                Self::MeshRawWithMaterial => "MeshRawWithMaterial",
                Self::WorldMaterial => "WorldMaterial",
                Self::SdfSkin2 => "SdfSkin2",
                Self::WorldMaterials => "WorldMaterials",
                Self::MeshGltfNamed => "MeshGltfNamed",
                Self::MeshSimplified => "MeshSimplified",
                Self::MeshRawWithName => "MeshRawWithName",
                Self::MeshRawWithMaterialAndName => "MeshRawWithMaterialAndName",
                Self::FormattedText => "FormattedText",
                Self::RenderModule => "RenderModule",
                Self::MeshGltfResource => "MeshGltfResource",
                Self::AudioClipOggResource => "AudioClipOggResource",
                Self::AudioClipWavResource => "AudioClipWavResource",
                Self::AudioModule => "AudioModule",
            }
        }
    }

    #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
    #[repr(u64)]
    #[non_exhaustive]
    pub enum WorldDataType {
        String = 0,
        Binary = 1,
        ComponentsMetaData = 2,
        EntityQuery = 3,
        CompoundPhysicsShape = 4,
        SdfProgram = 5,
        SdfSkin = 6,
        AudioClip = 7,
        MorphTargetWeights = 8,
        Mesh = 9,
        WorldMaterial = 10,
        WorldMaterials = 11,
        PlayerIdSet = 12,
        FormattedText = 13,
        RenderModule = 14,
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct RawRenderModuleData {
        pub module_dependency_name_ptr: u32,
        pub module_dependency_name_len: u32,
        pub static_data_ptr: u32,
        pub static_data_len: u32,
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct RawAudioModuleData {
        pub module_dependency_name_ptr: u32,
        pub module_dependency_name_len: u32,
        pub data_ptr: u32,
        pub data_len: u32,
    }

    #[derive(Copy, Clone, Debug, PartialEq, Pod, Zeroable)]
    #[repr(C)]
    pub struct MaterialDesc {
        pub diffuse_albedo: [f32; 3],
        pub alpha: f32,
        pub emissive_color: [f32; 3],
        pub metallic: f32,
        pub perceptual_roughness: f32,
        pub reserved: [f32; 16],
    }

    impl Default for MaterialDesc {
        fn default() -> Self {
            Self {
                diffuse_albedo: [1.0; 3],
                alpha: 1.0,
                metallic: 0.0,
                perceptual_roughness: 0.5,
                emissive_color: [0.0; 3],
                reserved: [0.0; 16],
            }
        }
    }

    /// Mesh primitive topology
    #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
    #[repr(u32)]
    pub enum MeshPrimitiveTopology {
        //PointList = 0,
        //LinesList = 1,
        /// Triangle list
        TriangleList = 2,
    }

    #[deprecated(note = "Use `MeshRawWithName`")] // 2021-08-28
    #[derive(Debug, Copy, Clone, NoUninit, CheckedBitPattern)]
    #[repr(C)]
    pub struct MeshRaw {
        pub primitive_topology: MeshPrimitiveTopology,
        pub streams_ptr: u32,
        pub num_streams: u32,
    }

    #[derive(Debug, Copy, Clone, NoUninit, CheckedBitPattern)]
    #[repr(C)]
    pub struct MeshRawWithName {
        pub primitive_topology: MeshPrimitiveTopology,
        pub streams_ptr: u32,
        pub num_streams: u32,
        pub debug_name_ptr: u32,
        pub debug_name_size: u32,
    }

    #[deprecated(note = "Use `MeshRawWithMaterialAndName`")] // 2021-08-28
    #[derive(Debug, Copy, Clone, NoUninit, CheckedBitPattern)]
    #[repr(C)]
    pub struct MeshRawWithMaterial {
        pub inner: MeshRaw,
        pub _pad: u32,
        pub material: DataHandle,
    }

    #[derive(Debug, Copy, Clone, NoUninit, CheckedBitPattern)]
    #[repr(C)]
    pub struct MeshRawWithMaterialAndName {
        pub inner: MeshRawWithName,
        pub _pad: u32,
        pub material: DataHandle,
    }

    bitflags::bitflags! {
        #[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
        #[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
        #[repr(C)]
        #[derive(Pod, Zeroable)]
        pub struct GltfFlags : u32 {
            /// Set if vertex colors are in sRGB gamma, otherwise linear gamma assumed
            const VERTEX_COLORS_SRGB = 1;
        }
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct MeshGltf {
        pub gltf_data_ptr: u32,
        pub gltf_data_size: u32,
        pub buffer_data_ptr: u32,
        pub buffer_data_size: u32,
        pub flags: GltfFlags,
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct MeshGltfNamed {
        pub debug_name_ptr: u32,
        pub debug_name_size: u32,
        pub gltf_data_ptr: u32,
        pub gltf_data_size: u32,
        pub buffer_data_ptr: u32,
        pub buffer_data_size: u32,
        pub flags: GltfFlags,
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct MeshGltfResource {
        pub debug_name_ptr: u32,
        pub debug_name_size: u32,
        pub gltf_resource: ResourceHandleRepr,
        pub buffer_resource: ResourceHandleRepr,
        pub flags: GltfFlags,
    }

    bitflags::bitflags! {
        #[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
        #[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
        #[repr(C)]
        #[derive(Pod, Zeroable)]
        pub struct MeshSimplifiedFlags : u32 {
            const KEEP_NORMALS = 1;
            const KEEP_COLORS = 2;
            const KEEP_TEXCOORDS = 4;
            const KEEP_BONE_INDICES_WEIGHTS = 8;
            const KEEP_ALL_STREAMS = Self::KEEP_NORMALS.bits() | Self::KEEP_COLORS.bits() | Self::KEEP_TEXCOORDS.bits() | Self::KEEP_BONE_INDICES_WEIGHTS.bits();
        }
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct MeshSimplified {
        pub mesh: DataHandle,
        pub threshold: f32,
        pub target_error: f32,
        pub min_triangle_count: u32,
        pub max_triangle_count: u32,
        pub flags: MeshSimplifiedFlags,
        pub reserved: [f32; 15], // Should be zeroed
    }

    bitflags::bitflags! {
        #[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
        #[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
        #[repr(C)]
        #[derive(Pod, Zeroable)]
        pub struct PlayerIdSetFlags : u32 {
            /// By default (with this bit not set) a PlayerIdSet will be
            /// treated as "inclusive" meaning it will include all players in the list.
            /// With this bit set it will be treated as "exclusive" meaning all the players not
            /// in the list.
            ///
            /// This is useful for different things:
            /// - Things that you want the player(s) to see should be inclusive (i.e. without this bit).
            /// - Things that you want all other player(s) to see should be exclusive (i.e. with this bit set).
            const EXCLUSIVE = 1; // Otherwise inclusive
        }
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct PlayerIdSet {
        pub player_ids_ptr: u32,
        pub num_player_ids: u32,

        pub flags: PlayerIdSetFlags,
        pub reserved: [u32; 4],
    }

    #[derive(Debug, Copy, Clone, Pod, Zeroable)]
    #[repr(C)]
    pub struct MessageRangeAndReceiver {
        pub entity: EntityHandle,
        pub start_index: u32,
        pub length: u32,
    }

    extern "C" {
        #[deprecated_infallible]
        pub fn create_entity(name: &str, entity_type: EntityTemplate) -> EntityHandle;

        /// Add a component and reset it to default values if it already exists.
        #[deprecated_infallible]
        pub fn add_component(entity: EntityHandle, component_type: ComponentType);

        #[deprecated_infallible]
        pub fn remove_component(entity: EntityHandle, component_type: ComponentType);

        #[deprecated_infallible]
        pub fn has_component(entity: EntityHandle, component_type: ComponentType) -> u32;

        #[deprecated_infallible]
        pub fn destroy_entity(entity: EntityHandle);

        #[deprecated_infallible]
        pub fn is_valid_entity(entity: EntityHandle) -> u32;

        #[deprecated_infallible]
        pub fn is_valid_mesh(mesh: MeshHandle) -> u32;

        /// Clones 'entity_src' from memory location to 'entity_dst',
        /// 'entity_src' and 'entity_dst' length should match unless 'entity_src' length is a divisor
        /// of 'entity_dst' length where the src entities are duplicated entity_dst_len / entity_src_len times.
        #[deprecated_infallible]
        pub fn clone_entities(
            name: &str,
            entity_dest: &mut [EntityHandle],
            entity_src: &[EntityHandle],
        );

        #[deprecated_infallible]
        pub fn copy_component(
            entity_dst: EntityHandle,
            entity_src: EntityHandle,
            component_type: ComponentType,
        );

        #[deprecated(note = "Use `create_named_mesh_from_streams` instead")] // 2021-08-27
        #[with_memory]
        pub fn create_mesh_from_streams(
            primitive_topology: MeshPrimitiveTopology,
            streams: &[MeshStreamLayout],
        ) -> FFIResult<MeshHandle>;

        #[deprecated(note = "Use `create_data` instead")] // 2021-10-30
        #[with_memory]
        pub fn create_named_mesh_from_streams(
            primitive_topology: MeshPrimitiveTopology,
            streams: &[MeshStreamLayout],
            name: &str,
        ) -> FFIResult<MeshHandle>;

        #[deprecated_infallible]
        pub fn get_mesh_properties(handle: MeshHandle) -> MeshProperties;

        #[deprecated_infallible]
        pub fn get_mesh_morph_target_count(handle: MeshHandle) -> u32;

        /// TODO: Replace in future version that returns `String` parameter directly
        #[deprecated_infallible]
        pub fn get_mesh_morph_target_name_len(handle: MeshHandle, idx: u32) -> u32;

        /// Get the name of a morph target.
        /// The `name` parameter should have a size of at least `get_mesh_morph_target_name_len(handle, idx)`
        /// TODO: Replace in future version that returns `String` parameter directly
        #[deprecated_infallible]
        pub fn get_mesh_morph_target_name(handle: MeshHandle, idx: u32, name: &mut [u8]);

        #[deprecated_infallible]
        pub fn get_mesh_material_count(handle: MeshHandle) -> u64;

        #[deprecated_infallible]
        pub fn get_mesh_material_desc(handle: MeshHandle, idx: u64) -> MaterialDesc;

        /// TODO: Replace in future version that returns `String` parameter directly
        #[deprecated_infallible]
        pub fn get_mesh_material_name(handle: MeshHandle, idx: u64, out_name: &mut [u8]) -> u64;

        #[deprecated_infallible]
        pub fn set_mesh_offset(handle: MeshHandle, matrix: &[f32]);

        #[deprecated(note = "Use `destroy_data` instead")] // 2021-10-30
        #[deprecated_infallible]
        pub fn destroy_mesh(handle: MeshHandle);

        #[deprecated_infallible]
        pub fn set_entity_value_checked(
            entity: EntityHandle,
            component: ComponentType,
            param_id: u32,
            value: &Value,
        );

        #[deprecated_infallible]
        pub fn get_entity_value_checked(
            entity: EntityHandle,
            component: ComponentType,
            param_id: u32,
            value: &mut Value,
        );

        #[deprecated_infallible]
        pub fn ray_cast(
            ray: &Ray,
            min_t: f32,
            max_t: f32,
            any_hit: u32,
            hit_t: &mut f32,
            exclude_entity: EntityHandle,
        ) -> EntityHandle;

        #[deprecated(note = "Use `send_messages` instead")] // 2021-08-20
        #[deprecated_infallible]
        pub fn push_message(entity: EntityHandle, message: &Message);
        /// Returns > 0 if there's a message to be read
        #[deprecated(note = "Use `get_message_counts` instead")] // 2021-08-20
        #[deprecated_infallible]
        pub fn has_message(entity: EntityHandle) -> u32;
        #[deprecated(note = "Use `retrieve_messages` instead")] // 2021-08-20
        #[deprecated_infallible]
        pub fn pop_message(entity: EntityHandle, msg: &mut Message);

        // Prefer these over push_message, has_message, pop_message
        // retrieve_messages will in contrast to pop_message not remove
        // the message from the entity

        /// `message_struct_size` is the size of the module struct to sanity check size and have
        /// a fallback for older modules if possible.
        /// `range_and_receiever` contains a destination entity and a
        /// range of messages to be grabbed from `messages`and
        /// put into the inbox of the destination entity.
        /// `messages` is a slice of messages `range_and_receiver` points into.
        pub fn send_messages(
            message_struct_size: u32,
            range_and_receiever: &[MessageRangeAndReceiver],
            messages: &[Message],
        );

        /// `message_struct_size` is the size of the module struct to sanity check size and have
        /// a fallback for older modules if possible.
        /// `entities` is a list of entities for which to count messages.
        /// `out_counts` should be the same size as `entities` and
        /// will after this call contain the amount of messages in the outbox
        /// of each entity.
        /// `out_total` will contain the sum of all `out_counts`
        /// which is the number of messages you need to allocate space for if calling
        /// `retrieve_messages` with the same list of entities.
        pub fn get_message_counts(
            message_struct_size: u32,
            entities: &[EntityHandle],
            out_counts: &mut [u32],
            out_total: &mut u32,
        );

        /// `message_struct_size` is the size of the module struct to sanity check size and have
        /// `entities` is a list of entities for which to retrieve messages.
        /// `out_msgs` will contain the messages of the outbox of each entity in `entities` after a call to this
        /// function. Use `get_message_counts` to retrieve the total number of msgs to allocate the right amount of space.
        pub fn retrieve_messages(
            message_struct_size: u32,
            entities: &[EntityHandle],
            out_msgs: &mut [Message],
        );

        /// Returns the component types associated with a specific entity.
        ///
        /// A max_components of 0 should still give you num_components in that argument so that you can use this
        /// to allocate data and call it again with the right amount.
        #[deprecated_infallible]
        pub fn get_components(entity: EntityHandle, components: &mut [ComponentType]) -> u32;

        /// Create a data blob from this input data.
        ///
        /// Some data don't need input, but will generate a handle that you can use
        /// to get data. May or may not return a handle to a cached object for this input data.
        #[with_memory]
        #[deprecated_infallible]
        pub fn create_data(create_data_type: CreateDataType, data: &[u8]) -> DataHandle;

        /// A max_len of 0 should still give you out_len in that argument so that you can use this
        /// to allocate data and call it again with the right amount.
        #[deprecated_infallible]
        pub fn retrieve_data(
            data_handle: DataHandle,
            retrieve_data_type: RetrieveDataType,
            data: &mut [u8],
        ) -> u32;

        /// Releases the ref count of a data object and destroys it if ref count reaches 0.
        #[deprecated_infallible]
        pub fn destroy_data(data: DataHandle);

        /// Increases the ref count of a data object.
        #[deprecated_infallible]
        pub fn retain_data(data: DataHandle);

        /// Asks the host if the data referenced by `data` is valid.
        #[deprecated_infallible]
        pub fn is_valid_data(data: DataHandle) -> u32;
    }
}

pub use world::*;