1#define_import_path bevy_pbr::mesh_types3struct Mesh {4 // Affine 4x3 matrices transposed to 3x45 // Use bevy_render::maths::affine3_to_square to unpack6 world_from_local: mat3x4<f32>,7 previous_world_from_local: mat3x4<f32>,8 // 3x3 matrix packed in mat2x4 and f32 as:9 // [0].xyz, [1].x,10 // [1].yz, [2].xy11 // [2].z12 // Use bevy_pbr::mesh_functions::mat2x4_f32_to_mat3x3_unpack to unpack13 local_from_world_transpose_a: mat2x4<f32>,14 local_from_world_transpose_b: f32,15 // 'flags' is a bit field indicating various options. u32 is 32 bits so we have up to 32 options.16 flags: u32,17 lightmap_uv_rect: vec2<u32>,18 // The index of the mesh's first vertex in the vertex buffer.19 first_vertex_index: u32,20 current_skin_index: u32,21 // Low 16 bits: index of the material inside the bind group data.22 // High 16 bits: index of the lightmap in the binding array.23 material_and_lightmap_bind_group_slot: u32,24 // User supplied index to identify the mesh instance25 tag: u32,26 morph_descriptor_index: u32,27};29#ifdef SKINNED30struct SkinnedMesh {31 data: array<mat4x4<f32>, 256u>,32};33#endif35#ifdef MORPH_TARGETS37struct MorphWeights {38 weights: array<vec4<f32>, 64u>, // 64 = 256 / 4 (256 = MAX_MORPH_WEIGHTS)39};41// Describes a single mesh instance that uses morph targets.42struct MorphDescriptor {43 // The index of the first morph target weight in the `morph_weights` array.44 current_weights_offset: u32,45 // The index of the first morph target weight in the `prev_morph_weights`46 // array.47 prev_weights_offset: u32,48 // The index of the first morph target for this mesh in the49 // `MorphAttributes` array.50 targets_offset: u32,51 // The number of vertices in the mesh.52 vertex_count: u32,53 // The number of morph targets this mesh has.54 weight_count: u32,55};57// Morph displacement for a single vertex.58struct MorphAttributes {59 // The position delta.60 position: vec3<f32>,61 // Padding, to ensure that each `vec3<f32>` is aligned to 16 bytes.62 pad_a: f32,63 // The normal delta.64 normal: vec3<f32>,65 // Padding, to ensure that each `vec3<f32>` is aligned to 16 bytes.66 pad_b: f32,67 // The tangent delta.68 tangent: vec3<f32>,69 // Padding, to ensure that each `vec3<f32>` is aligned to 16 bytes.70 pad_c: f32,71};73#endif // MORPH_TARGETS75// [2^0, 2^16)76const MESH_FLAGS_VISIBILITY_RANGE_INDEX_BITS: u32 = (1u << 16u) - 1u;77const MESH_FLAGS_AABB_BASED_VISIBILITY_RANGE_BIT: u32 = 1u << 27u;78const MESH_FLAGS_NO_FRUSTUM_CULLING_BIT: u32 = 1u << 28u;79const MESH_FLAGS_SHADOW_RECEIVER_BIT: u32 = 1u << 29u;80const MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT: u32 = 1u << 30u;81// if the flag is set, the sign is positive, else it is negative82const MESH_FLAGS_SIGN_DETERMINANT_MODEL_3X3_BIT: u32 = 1u << 31u;