Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Private/GeomFitUtils.h
Ben Marsh 149375b14b Update copyright notices to 2015.
[CL 2379638 by Ben Marsh in Main branch]
2014-12-07 19:09:38 -05:00

123 lines
3.9 KiB
C

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
/*=============================================================================
GeomFitUtils.h: Utilities for fitting collision models to static meshes.
=============================================================================*/
// k-DOP (k-Discrete Oriented Polytopes) Direction Vectors
#define RCP_SQRT2 (0.70710678118654752440084436210485f)
#define RCP_SQRT3 (0.57735026918962576450914878050196f)
const FVector KDopDir10X[10] =
{
FVector( 1.f, 0.f, 0.f),
FVector(-1.f, 0.f, 0.f),
FVector( 0.f, 1.f, 0.f),
FVector( 0.f,-1.f, 0.f),
FVector( 0.f, 0.f, 1.f),
FVector( 0.f, 0.f,-1.f),
FVector( 0.f, RCP_SQRT2, RCP_SQRT2),
FVector( 0.f,-RCP_SQRT2, -RCP_SQRT2),
FVector( 0.f, RCP_SQRT2, -RCP_SQRT2),
FVector( 0.f,-RCP_SQRT2, RCP_SQRT2)
};
const FVector KDopDir10Y[10] =
{
FVector( 1.f, 0.f, 0.f),
FVector(-1.f, 0.f, 0.f),
FVector( 0.f, 1.f, 0.f),
FVector( 0.f,-1.f, 0.f),
FVector( 0.f, 0.f, 1.f),
FVector( 0.f, 0.f,-1.f),
FVector( RCP_SQRT2, 0.f, RCP_SQRT2),
FVector(-RCP_SQRT2, 0.f, -RCP_SQRT2),
FVector( RCP_SQRT2, 0.f, -RCP_SQRT2),
FVector(-RCP_SQRT2, 0.f, RCP_SQRT2)
};
const FVector KDopDir10Z[10] =
{
FVector( 1.f, 0.f, 0.f),
FVector(-1.f, 0.f, 0.f),
FVector( 0.f, 1.f, 0.f),
FVector( 0.f,-1.f, 0.f),
FVector( 0.f, 0.f, 1.f),
FVector( 0.f, 0.f,-1.f),
FVector( RCP_SQRT2, RCP_SQRT2, 0.f),
FVector(-RCP_SQRT2, -RCP_SQRT2, 0.f),
FVector( RCP_SQRT2, -RCP_SQRT2, 0.f),
FVector(-RCP_SQRT2, RCP_SQRT2, 0.f)
};
const FVector KDopDir18[18] =
{
FVector( 1.f, 0.f, 0.f),
FVector(-1.f, 0.f, 0.f),
FVector( 0.f, 1.f, 0.f),
FVector( 0.f,-1.f, 0.f),
FVector( 0.f, 0.f, 1.f),
FVector( 0.f, 0.f,-1.f),
FVector( 0.f, RCP_SQRT2, RCP_SQRT2),
FVector( 0.f,-RCP_SQRT2, -RCP_SQRT2),
FVector( 0.f, RCP_SQRT2, -RCP_SQRT2),
FVector( 0.f,-RCP_SQRT2, RCP_SQRT2),
FVector( RCP_SQRT2, 0.f, RCP_SQRT2),
FVector(-RCP_SQRT2, 0.f, -RCP_SQRT2),
FVector( RCP_SQRT2, 0.f, -RCP_SQRT2),
FVector(-RCP_SQRT2, 0.f, RCP_SQRT2),
FVector( RCP_SQRT2, RCP_SQRT2, 0.f),
FVector(-RCP_SQRT2, -RCP_SQRT2, 0.f),
FVector( RCP_SQRT2, -RCP_SQRT2, 0.f),
FVector(-RCP_SQRT2, RCP_SQRT2, 0.f)
};
const FVector KDopDir26[26] =
{
FVector( 1.f, 0.f, 0.f),
FVector(-1.f, 0.f, 0.f),
FVector( 0.f, 1.f, 0.f),
FVector( 0.f,-1.f, 0.f),
FVector( 0.f, 0.f, 1.f),
FVector( 0.f, 0.f,-1.f),
FVector( 0.f, RCP_SQRT2, RCP_SQRT2),
FVector( 0.f,-RCP_SQRT2, -RCP_SQRT2),
FVector( 0.f, RCP_SQRT2, -RCP_SQRT2),
FVector( 0.f,-RCP_SQRT2, RCP_SQRT2),
FVector( RCP_SQRT2, 0.f, RCP_SQRT2),
FVector(-RCP_SQRT2, 0.f, -RCP_SQRT2),
FVector( RCP_SQRT2, 0.f, -RCP_SQRT2),
FVector(-RCP_SQRT2, 0.f, RCP_SQRT2),
FVector( RCP_SQRT2, RCP_SQRT2, 0.f),
FVector(-RCP_SQRT2, -RCP_SQRT2, 0.f),
FVector( RCP_SQRT2, -RCP_SQRT2, 0.f),
FVector(-RCP_SQRT2, RCP_SQRT2, 0.f),
FVector( RCP_SQRT3, RCP_SQRT3, RCP_SQRT3),
FVector( RCP_SQRT3, RCP_SQRT3, -RCP_SQRT3),
FVector( RCP_SQRT3, -RCP_SQRT3, RCP_SQRT3),
FVector( RCP_SQRT3, -RCP_SQRT3, -RCP_SQRT3),
FVector(-RCP_SQRT3, RCP_SQRT3, RCP_SQRT3),
FVector(-RCP_SQRT3, RCP_SQRT3, -RCP_SQRT3),
FVector(-RCP_SQRT3, -RCP_SQRT3, RCP_SQRT3),
FVector(-RCP_SQRT3, -RCP_SQRT3, -RCP_SQRT3),
};
// Utilities
UNREALED_API int32 GenerateKDopAsSimpleCollision(UStaticMesh* StaticMesh, const TArray<FVector> &dirs);
UNREALED_API int32 GenerateBoxAsSimpleCollision(UStaticMesh* StaticMesh);
UNREALED_API int32 GenerateSphereAsSimpleCollision(UStaticMesh* StaticMesh);
UNREALED_API int32 GenerateSphylAsSimpleCollision(UStaticMesh* StaticMesh);
UNREALED_API void ComputeBoundingBox(UStaticMesh* StaticMesh, FVector& Center, FVector& Extents);
/**
* Refresh Collision Change
*
* Collision has been changed, so it will need to recreate physics state to reflect it
* Utilities functions to propagate BodySetup change for StaticMesh
*
* @param StaticMesh StaticMesh that collision has been changed for
*/
UNREALED_API void RefreshCollisionChange(const UStaticMesh* StaticMesh);