Files
UnrealEngineUWP/Engine/Plugins/Experimental/MeshModelingToolset/Source/ModelingComponents/Private/Physics/PhysicsDataCollection.cpp
Marc Audy 7379fa99c5 Merging //UE5/Release-Engine-Staging to Main (//UE5/Main) @ 14229157
[CL 14233282 by Marc Audy in ue5-main branch]
2020-09-01 14:07:48 -04:00

85 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Physics/PhysicsDataCollection.h"
#include "Physics/CollisionGeometryConversion.h"
#include "Engine/Classes/Engine/StaticMesh.h"
#include "Engine/Classes/Components/StaticMeshComponent.h"
#include "Engine/Classes/PhysicsEngine/BodySetup.h"
void FPhysicsDataCollection::InitializeFromComponent(const UActorComponent* Component, bool bInitializeAggGeom)
{
const UStaticMeshComponent* StaticMeshComponent = CastChecked<UStaticMeshComponent>(Component);
const UStaticMesh* StaticMesh = StaticMeshComponent->GetStaticMesh();
SourceComponent = StaticMeshComponent;
BodySetup = StaticMesh->BodySetup;
ExternalScale3D = FVector(1.f, 1.f, 1.f);
if (bInitializeAggGeom)
{
AggGeom = BodySetup->AggGeom;
// transfer AggGeom to FSimpleShapeSet3d...
}
}
void FPhysicsDataCollection::InitializeFromExisting(const FPhysicsDataCollection& Other)
{
SourceComponent = Other.SourceComponent;
BodySetup = Other.BodySetup;
ExternalScale3D = Other.ExternalScale3D;
}
void FPhysicsDataCollection::CopyGeometryFromExisting(const FPhysicsDataCollection& Other)
{
Geometry = Other.Geometry;
AggGeom = Other.AggGeom;
}
void FPhysicsDataCollection::ClearAggregate()
{
AggGeom = FKAggregateGeom();
}
void FPhysicsDataCollection::CopyGeometryToAggregate()
{
for (FBoxShape3d& BoxGeom : Geometry.Boxes)
{
FKBoxElem Element;
UE::Geometry::GetFKElement(BoxGeom.Box, Element);
AggGeom.BoxElems.Add(Element);
}
for (FSphereShape3d& SphereGeom : Geometry.Spheres)
{
FKSphereElem Element;
UE::Geometry::GetFKElement(SphereGeom.Sphere, Element);
AggGeom.SphereElems.Add(Element);
}
for (FCapsuleShape3d& CapsuleGeom : Geometry.Capsules)
{
FKSphylElem Element;
UE::Geometry::GetFKElement(CapsuleGeom.Capsule, Element);
AggGeom.SphylElems.Add(Element);
}
for (FConvexShape3d& ConvexGeom : Geometry.Convexes)
{
FKConvexElem Element;
UE::Geometry::GetFKElement(ConvexGeom.Mesh, Element);
AggGeom.ConvexElems.Add(Element);
}
}