void UCapsuleComponent::UpdateBodySetup() { if (ShapeBodySetup == NULL || ShapeBodySetup->IsPendingKill()) { ShapeBodySetup = NewObject<UBodySetup>(this); ShapeBodySetup->CollisionTraceFlag = CTF_UseSimpleAsComplex; ShapeBodySetup->AggGeom.SphylElems.Add(FKSphylElem()); } check(ShapeBodySetup->AggGeom.SphylElems.Num() == 1); FKSphylElem* SE = ShapeBodySetup->AggGeom.SphylElems.GetData(); SE->SetTransform(FTransform::Identity); SE->Radius = CapsuleRadius; SE->Length = 2 * FMath::Max(CapsuleHalfHeight - CapsuleRadius, 0.f); //SphylElem uses height from center of capsule spheres, but UCapsuleComponent uses halfHeight from end of the sphere }
template <> void UShapeComponent::AddShapeToGeomArray<FKSphylElem>() { ShapeBodySetup->AggGeom.SphylElems.Add(FKSphylElem()); }