| 866 | } |
| 867 | |
| 868 | void SceneGraph::extend_animation(Ref<SceneGraph::Node> node0, Ref<SceneGraph::Node> node1) |
| 869 | { |
| 870 | if (node0 == node1) return; |
| 871 | |
| 872 | if (Ref<SceneGraph::TransformNode> xfmNode0 = node0.dynamicCast<SceneGraph::TransformNode>()) |
| 873 | { |
| 874 | if (Ref<SceneGraph::TransformNode> xfmNode1 = node1.dynamicCast<SceneGraph::TransformNode>()) |
| 875 | { |
| 876 | xfmNode0->spaces.add(xfmNode1->spaces); |
| 877 | extend_animation(xfmNode0->child, xfmNode1->child); |
| 878 | } |
| 879 | else THROW_RUNTIME_ERROR("incompatible scene graph"); |
| 880 | } |
| 881 | else if (Ref<SceneGraph::GroupNode> groupNode0 = node0.dynamicCast<SceneGraph::GroupNode>()) |
| 882 | { |
| 883 | if (Ref<SceneGraph::GroupNode> groupNode1 = node1.dynamicCast<SceneGraph::GroupNode>()) |
| 884 | { |
| 885 | if (groupNode0->children.size() != groupNode1->children.size()) |
| 886 | THROW_RUNTIME_ERROR("incompatible scene graph"); |
| 887 | |
| 888 | for (size_t i=0; i<groupNode0->children.size(); i++) |
| 889 | extend_animation(groupNode0->children[i],groupNode1->children[i]); |
| 890 | } |
| 891 | else THROW_RUNTIME_ERROR("incompatible scene graph"); |
| 892 | } |
| 893 | else if (Ref<SceneGraph::TriangleMeshNode> mesh0 = node0.dynamicCast<SceneGraph::TriangleMeshNode>()) |
| 894 | { |
| 895 | if (Ref<SceneGraph::TriangleMeshNode> mesh1 = node1.dynamicCast<SceneGraph::TriangleMeshNode>()) |
| 896 | { |
| 897 | if (mesh0->numVertices() != mesh1->numVertices()) |
| 898 | THROW_RUNTIME_ERROR("incompatible scene graph"); |
| 899 | |
| 900 | for (auto& p : mesh1->positions) |
| 901 | mesh0->positions.push_back(std::move(p)); |
| 902 | } |
| 903 | else THROW_RUNTIME_ERROR("incompatible scene graph"); |
| 904 | } |
| 905 | else if (Ref<SceneGraph::QuadMeshNode> mesh0 = node0.dynamicCast<SceneGraph::QuadMeshNode>()) |
| 906 | { |
| 907 | if (Ref<SceneGraph::QuadMeshNode> mesh1 = node1.dynamicCast<SceneGraph::QuadMeshNode>()) |
| 908 | { |
| 909 | if (mesh0->numVertices() != mesh1->numVertices()) |
| 910 | THROW_RUNTIME_ERROR("incompatible scene graph"); |
| 911 | |
| 912 | for (auto& p : mesh1->positions) |
| 913 | mesh0->positions.push_back(std::move(p)); |
| 914 | } |
| 915 | else THROW_RUNTIME_ERROR("incompatible scene graph"); |
| 916 | } |
| 917 | else if (Ref<SceneGraph::HairSetNode> mesh0 = node0.dynamicCast<SceneGraph::HairSetNode>()) |
| 918 | { |
| 919 | if (Ref<SceneGraph::HairSetNode> mesh1 = node1.dynamicCast<SceneGraph::HairSetNode>()) |
| 920 | { |
| 921 | if (mesh0->numVertices() != mesh1->numVertices()) |
| 922 | THROW_RUNTIME_ERROR("incompatible scene graph"); |
| 923 | |
| 924 | for (auto& p : mesh1->positions) |
| 925 | mesh0->positions.push_back(std::move(p)); |
nothing calls this directly
no test coverage detected