File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
crates/bevy_render/src/mesh/mesh Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ impl Mesh {
110
110
attribute : MeshVertexAttribute ,
111
111
values : impl Into < VertexAttributeValues > ,
112
112
) {
113
- let values = values. into ( ) ;
113
+ let mut values = values. into ( ) ;
114
114
let values_format = VertexFormat :: from ( & values) ;
115
115
if values_format != attribute. format {
116
116
panic ! (
@@ -119,6 +119,17 @@ impl Mesh {
119
119
) ;
120
120
}
121
121
122
+ // validate attributes
123
+ if attribute. id == Self :: ATTRIBUTE_JOINT_WEIGHT . id {
124
+ let VertexAttributeValues :: Float32x4 ( ref mut values) = values else {
125
+ unreachable ! ( ) // we confirmed the format above
126
+ } ;
127
+ for value in values. iter_mut ( ) . filter ( |v| * v == & [ 0.0 , 0.0 , 0.0 , 0.0 ] ) {
128
+ // zero weights are invalid
129
+ value[ 0 ] = 1.0 ;
130
+ }
131
+ }
132
+
122
133
self . attributes
123
134
. insert ( attribute. id , MeshAttributeData { attribute, values } ) ;
124
135
}
You can’t perform that action at this time.
0 commit comments