prevent crash in case of invalid node handle in animation
@@ -210,8 +210,8 @@ impl AnimationPose {
for (node, local_pose) in self.local_poses.iter() {
if node.is_none() {
Log::writeln(MessageKind::Error, "Invalid node handle found for animation pose, most likely it means that animation retargeting failed!");
- } else {
- local_pose.values.apply(&mut graph[*node]);
+ } else if let Some(node) = graph.try_get_mut(*node) {
+ local_pose.values.apply(node);
}
}
}
@@ -225,8 +225,8 @@ impl AnimationPose {
for (node, local_pose) in self.local_poses.iter() {
if node.is_none() {
Log::writeln(MessageKind::Error, "Invalid node handle found for animation pose, most likely it means that animation retargeting failed!");
- } else {
- callback(&mut graph[*node], *node, local_pose);
+ } else if let Some(node_ref) = graph.try_get_mut(*node) {
+ callback(node_ref, *node, local_pose);
}
}
}
