FCollisionShape UPrimitiveComponent::GetCollisionShape(float Inflation) const
// This is intended to be overridden by shape classes, so this is a simple, large bounding shape.
FVector Extent = Bounds.BoxExtent + Inflation;
if (Inflation < 0.f)
// Don't shrink below zero size.
Extent = Extent.ComponentMax(FVector::ZeroVector);
return FCollisionShape::MakeBox(Bounds.BoxExtent + Inflation);
the Extent variable is computed, but not used. I suppose the intent was to have last line:
Thank you for pointing this out to us. After looking over the code here, I believe you are correct in this being a mistake. I suspect that the return line is intended to be: return FCollisionShape::MakeBox(Extent);
I have entered a ticket to have this investigated further (UE-22436).
From what I can tell, the code here is operating on the assumption that Bounds.BoxExtent contains an FVector value greater than zero. I’m not sure if this is verified anywhere else in the code. Since the float value being passed in can be negative, the if statement checks to make sure Extent does not contain a negative FVector, and sets it equal to ZeroVector if it is. This should only be possible if the value passed in is negative.
It may make sense to check Extent against ZeroVector in this case, but only if we do not make sure BoxExtent never contains a negative value. I am trying to find out if we do check this somewhere else.