MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / UpdateBounds

Method UpdateBounds

Source/Engine/Level/Actors/AnimatedModel.cpp:863–899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

861}
862
863void 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
901void AnimatedModel::UpdateSockets()
902{

Callers

nothing calls this directly

Calls 12

UpdateActorMethod · 0.80
TransformClass · 0.50
MaxFunction · 0.50
BoundingBoxClass · 0.50
GetMethod · 0.45
LengthSquaredMethod · 0.45
GetSizeMethod · 0.45
IsLoadedMethod · 0.45
CountMethod · 0.45
GetBoxMethod · 0.45
MergeMethod · 0.45
LocalToWorldMethod · 0.45

Tested by

no test coverage detected