Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_mesh/src/skinning.rs
6595 views
1
use bevy_asset::{AsAssetId, Asset, AssetId, Handle};
2
use bevy_ecs::{component::Component, entity::Entity, prelude::ReflectComponent};
3
use bevy_math::Mat4;
4
use bevy_reflect::prelude::*;
5
use core::ops::Deref;
6
7
#[derive(Component, Debug, Default, Clone, Reflect)]
8
#[reflect(Component, Default, Debug, Clone)]
9
pub struct SkinnedMesh {
10
pub inverse_bindposes: Handle<SkinnedMeshInverseBindposes>,
11
#[entities]
12
pub joints: Vec<Entity>,
13
}
14
15
impl AsAssetId for SkinnedMesh {
16
type Asset = SkinnedMeshInverseBindposes;
17
18
// We implement this so that `AssetChanged` will work to pick up any changes
19
// to `SkinnedMeshInverseBindposes`.
20
fn as_asset_id(&self) -> AssetId<Self::Asset> {
21
self.inverse_bindposes.id()
22
}
23
}
24
25
#[derive(Asset, TypePath, Debug)]
26
pub struct SkinnedMeshInverseBindposes(Box<[Mat4]>);
27
28
impl From<Vec<Mat4>> for SkinnedMeshInverseBindposes {
29
fn from(value: Vec<Mat4>) -> Self {
30
Self(value.into_boxed_slice())
31
}
32
}
33
34
impl Deref for SkinnedMeshInverseBindposes {
35
type Target = [Mat4];
36
fn deref(&self) -> &Self::Target {
37
&self.0
38
}
39
}
40
41