| 861 | } |
| 862 | |
| 863 | void AnimatedModel::UpdateBounds() |
| 864 | { |
| 865 | const auto model = SkinnedModel.Get(); |
| 866 | BoundingSphere prevSphere = _sphere; |
| 867 | if (CustomBounds.GetSize().LengthSquared() > 0.01f) |
| 868 | { |
| 869 | BoundingBox::Transform(CustomBounds, _transform, _box); |
| 870 | } |
| 871 | else if (model && model->IsLoaded() && model->LODs.Count() != 0) |
| 872 | { |
| 873 | Matrix world; |
| 874 | GetLocalToWorldMatrix(world); |
| 875 | const BoundingBox modelBox = model->GetBox(world); |
| 876 | BoundingBox box = modelBox; |
| 877 | if (GraphInstance.NodesPose.Count() != 0) |
| 878 | { |
| 879 | // Per-bone bounds estimated from positions |
| 880 | auto& skeleton = model->Skeleton; |
| 881 | const int32 bonesCount = skeleton.Bones.Count(); |
| 882 | for (int32 boneIndex = 0; boneIndex < bonesCount; boneIndex++) |
| 883 | box.Merge(_transform.LocalToWorld(GraphInstance.NodesPose[skeleton.Bones.Get()[boneIndex].NodeIndex].GetTranslation())); |
| 884 | } |
| 885 | |
| 886 | // Apply margin based on model dimensions |
| 887 | const Vector3 modelBoxSize = modelBox.GetSize(); |
| 888 | const Vector3 center = box.GetCenter(); |
| 889 | const Vector3 sizeHalf = Vector3::Max(box.GetSize() + modelBoxSize * 0.2f, modelBoxSize) * (0.5f * BoundsScale); |
| 890 | _box = BoundingBox(center - sizeHalf, center + sizeHalf); |
| 891 | } |
| 892 | else |
| 893 | { |
| 894 | _box = BoundingBox(_transform.Translation); |
| 895 | } |
| 896 | BoundingSphere::FromBox(_box, _sphere); |
| 897 | if (_sceneRenderingKey != -1 && prevSphere != _sphere) |
| 898 | GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); |
| 899 | } |
| 900 | |
| 901 | void AnimatedModel::UpdateSockets() |
| 902 | { |
nothing calls this directly
no test coverage detected