Files
UnrealEngineUWP/Engine/Plugins/Experimental/MeshModelingToolset/Source/ModelingComponents/Public/Physics/ComponentCollisionUtil.h
Ryan Schmidt 75a21c9bb9 ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop

#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5

[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00

91 lines
2.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Components/PrimitiveComponent.h"
#include "TransformTypes.h"
class UBodySetup;
class UStaticMesh;
struct FKAggregateGeom;
namespace UE
{
namespace Geometry
{
struct FSimpleShapeSet3d;
/**
* Component/BodySetup collision settings (eg StaticMeshComponent) we might need to pass through the functions below
*/
struct FComponentCollisionSettings
{
int32 CollisionTypeFlag = 0; // this is ECollisionTraceFlag
bool bIsGeneratedCollision = true;
};
/**
* @return true if the component type supports collision settings
*/
MODELINGCOMPONENTS_API bool ComponentTypeSupportsCollision(
const UPrimitiveComponent* Component);
/**
* @return current Component collision settings
*/
MODELINGCOMPONENTS_API FComponentCollisionSettings GetCollisionSettings(
const UPrimitiveComponent* Component);
/**
* Apply Transform to any Simple Collision geometry owned by Component.
* Note that Nonuniform scaling support is very limited and will generally enlarge collision volumes.
*/
MODELINGCOMPONENTS_API bool TransformSimpleCollision(
UPrimitiveComponent* Component,
const FTransform3d& Transform);
/**
* Replace existing Simple Collision geometry in Component with that defined by ShapeSet,
* and update the Component/BodySetup collision settings
*/
MODELINGCOMPONENTS_API bool SetSimpleCollision(
UPrimitiveComponent* Component,
const FSimpleShapeSet3d* ShapeSet,
FComponentCollisionSettings CollisionSettings = FComponentCollisionSettings() );
/**
* Apply Transform to the existing Simple Collision geometry in Component and then append to to ShapeSetOut
*/
MODELINGCOMPONENTS_API bool AppendSimpleCollision(
const UPrimitiveComponent* SourceComponent,
FSimpleShapeSet3d* ShapeSetOut,
const FTransform3d& Transform);
/**
* Apply TransformSequence (in-order) to the existing Simple Collision geometry in Component and then append to to ShapeSetOut
*/
MODELINGCOMPONENTS_API bool AppendSimpleCollision(
const UPrimitiveComponent* SourceComponent,
FSimpleShapeSet3d* ShapeSetOut,
const TArray<FTransform3d>& TransformSeqeuence);
/**
* Replace existing Simple Collision geometry in BodySetup with that defined by NewGeometry,
* and update the Component/BodySetup collision settings. Optional StaticMesh argument allows
* for necessary updates to it and any active UStaticMeshComponent that reference it
*/
MODELINGCOMPONENTS_API void UpdateSimpleCollision(
UBodySetup* BodySetup,
const FKAggregateGeom* NewGeometry,
UStaticMesh* StaticMesh = nullptr,
FComponentCollisionSettings CollisionSettings = FComponentCollisionSettings());
} // end namespace Geometry
} // end namespace UE