FBoxSphereBounds UDebugSkelMeshComponent::CalcBounds(const FTransform& LocalToWorld) const { FBoxSphereBounds Result = Super::CalcBounds(LocalToWorld); if (! IsUsingInGameBounds()) { // extend bounds by bones but without root bone FBox BoundingBox(0); for (int32 BoneIndex = 1; BoneIndex < SpaceBases.Num(); ++ BoneIndex) { BoundingBox += GetBoneMatrix(BoneIndex).GetOrigin(); } Result = Result + FBoxSphereBounds(BoundingBox); } return Result; }
bool UDebugSkelMeshComponent::CheckIfBoundsAreCorrrect() { if (GetPhysicsAsset()) { bool bWasUsingInGameBounds = IsUsingInGameBounds(); FTransform TempTransform = FTransform::Identity; UseInGameBounds(true); FBoxSphereBounds InGameBounds = CalcBounds(TempTransform); UseInGameBounds(false); FBoxSphereBounds PreviewBounds = CalcBounds(TempTransform); UseInGameBounds(bWasUsingInGameBounds); // calculate again to have bounds as requested CalcBounds(TempTransform); // if in-game bounds are of almost same size as preview bounds or bigger, it seems to be fine if (! InGameBounds.GetSphere().IsInside(PreviewBounds.GetSphere(), PreviewBounds.GetSphere().W * 0.1f) && // for spheres: A.IsInside(B) checks if A is inside of B ! PreviewBounds.GetBox().IsInside(InGameBounds.GetBox().ExpandBy(PreviewBounds.GetSphere().W * 0.1f))) // for boxes: A.IsInside(B) checks if B is inside of A { return true; } } return false; }