| 500 | } |
| 501 | |
| 502 | fn validate_node_refs(node: &AnimationTreeGraphNode, keys: &HashSet<String>) -> Result<(), String> { |
| 503 | let check = |value: &str| { |
| 504 | if keys.contains(value) { |
| 505 | Ok(()) |
| 506 | } else { |
| 507 | Err(format!("unknown animation tree ref `@{value}`")) |
| 508 | } |
| 509 | }; |
| 510 | match &node.kind { |
| 511 | AnimationTreeNodeKind::Blend { inputs, .. } => { |
| 512 | for input in inputs.iter() { |
| 513 | check(input.as_ref())?; |
| 514 | } |
| 515 | Ok(()) |
| 516 | } |
| 517 | AnimationTreeNodeKind::Add { base, inputs, .. } => { |
| 518 | check(base.as_ref())?; |
| 519 | for input in inputs.iter() { |
| 520 | check(input.as_ref())?; |
| 521 | } |
| 522 | Ok(()) |
| 523 | } |
| 524 | AnimationTreeNodeKind::Invert { input, .. } => check(input.as_ref()), |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | #[cfg(test)] |
| 529 | mod tests { |