You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb jimmy.andrews #preflight 62952aa7e61254772f6b4b5e [CL 20432875 by tyson brochu in ue5-main branch]
79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Physics/CollisionPropertySets.h"
|
|
#include "Physics/PhysicsDataCollection.h"
|
|
|
|
#include "Engine/Classes/PhysicsEngine/BodySetup.h"
|
|
|
|
void UE::PhysicsTools::InitializePhysicsToolObjectPropertySet(const FPhysicsDataCollection* PhysicsData, UPhysicsObjectToolPropertySet* PropSet)
|
|
{
|
|
check(PhysicsData);
|
|
check(PropSet);
|
|
|
|
PropSet->ObjectName = FString::Printf(TEXT("%s - %s"),
|
|
*PhysicsData->SourceComponent->GetOwner()->GetName(),
|
|
*PhysicsData->SourceComponent->GetName());
|
|
|
|
PropSet->CollisionType = (ECollisionGeometryMode)(int32)PhysicsData->BodySetup->GetCollisionTraceFlag();
|
|
|
|
// change object name to above
|
|
//PropSet->Rename(*PropSet->ObjectName, nullptr, REN_NonTransactional | REN_ForceNoResetLoaders | REN_DoNotDirty);
|
|
|
|
const FKAggregateGeom& AggGeom = PhysicsData->AggGeom;
|
|
|
|
for (const FKSphereElem& Sphere : AggGeom.SphereElems)
|
|
{
|
|
FPhysicsSphereData SphereData;
|
|
SphereData.Radius = Sphere.Radius;
|
|
SphereData.Transform = Sphere.GetTransform();
|
|
SphereData.Element = Sphere;
|
|
PropSet->Spheres.Add(SphereData);
|
|
}
|
|
|
|
for (const FKBoxElem& Box : AggGeom.BoxElems)
|
|
{
|
|
FPhysicsBoxData BoxData;
|
|
BoxData.Dimensions = FVector(Box.X, Box.Y, Box.Z);
|
|
BoxData.Transform = Box.GetTransform();
|
|
BoxData.Element = Box;
|
|
PropSet->Boxes.Add(BoxData);
|
|
}
|
|
|
|
for (const FKSphylElem& Capsule : AggGeom.SphylElems)
|
|
{
|
|
FPhysicsCapsuleData CapsuleData;
|
|
CapsuleData.Radius = Capsule.Radius;
|
|
CapsuleData.Length = Capsule.Length;
|
|
CapsuleData.Transform = Capsule.GetTransform();
|
|
CapsuleData.Element = Capsule;
|
|
PropSet->Capsules.Add(CapsuleData);
|
|
}
|
|
|
|
for (const FKConvexElem& Convex : AggGeom.ConvexElems)
|
|
{
|
|
FPhysicsConvexData ConvexData;
|
|
ConvexData.NumVertices = Convex.VertexData.Num();
|
|
ConvexData.NumFaces = Convex.IndexData.Num() / 3;
|
|
ConvexData.Element = Convex;
|
|
PropSet->Convexes.Add(ConvexData);
|
|
}
|
|
|
|
for (const FKLevelSetElem& LevelSet: AggGeom.LevelSetElems)
|
|
{
|
|
FPhysicsLevelSetData LevelSetData;
|
|
LevelSetData.Element = LevelSet;
|
|
PropSet->LevelSets.Add(LevelSetData);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void UPhysicsObjectToolPropertySet::Reset()
|
|
{
|
|
ObjectName = TEXT("");
|
|
Spheres.Reset();
|
|
Boxes.Reset();
|
|
Capsules.Reset();
|
|
Convexes.Reset();
|
|
LevelSets.Reset();
|
|
} |