Skip to content

Commit

Permalink
check first person weight
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Aug 4, 2024
1 parent d154011 commit 4f70b4e
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions crates/bevy_vrm/src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,38 @@ fn is_primitive_head_weighted(
if let Some(accessor) = primitive.attribute(graph, Semantic::Joints(0)) {
match accessor.iter(graph) {
Ok(AccessorIter::U16x4(elements)) => {
for el in elements {
for idx in el {
for (i, el) in elements.enumerate() {
for (j, idx) in el.into_iter().enumerate() {
let joint = joints[idx as usize];

let is_child = find_child(graph, joint, head_node);

if is_child {
return true;
if let Some(accessor) =
primitive.attribute(graph, Semantic::Weights(0))
{
match accessor.iter(graph) {
Ok(AccessorIter::F32x4(elements)) => {
for (k, weights) in elements.enumerate() {
if i != k {
continue;
}

if weights[j] > 0.0 {
return true;
}
}
}
Ok(other) => {
warn!(
"Unsupported weight accessor type: {:?} {:?}",
other.component_type(),
other.element_type(),
);
}
Err(e) => {
error!("Error reading weight accessor: {}", e);
}
}
}
}
}
}
Expand Down

0 comments on commit 4f70b4e

Please sign in to comment.