Module |
|
Header |
/Engine/Source/Editor/UnrealEd/Public/ImportUtils/StaticMeshImportUtils.h |
Include |
#include "ImportUtils/StaticMeshImportUtils.h" |
Source |
/Engine/Source/Editor/UnrealEd/Private/ImportUtils/StaticMeshImportUtils.cpp |
namespace StaticMeshImportUtils
{
bool StaticMeshImportUtils::AddBoxGeomFromTris
(
const TArray< FPoly > & Tris,
FKAggregateGeom * AggGeom,
const TCHAR * ObjName
)
}
Function for adding a box collision primitive to the supplied collision geometry based on the mesh of the box.
We keep a list of triangle normals found so far. For each normal direction, we should have 2 distances from the origin (2 parallel box faces). If the mesh is a box, we should have 3 distinct normal directions, and 2 distances found for each. The difference between these distances should be the box dimensions. The 3 directions give us the key axes, and therefore the box transformation matrix. This shouldn't rely on any vertex-ordering on the triangles (normals are compared +ve & -ve). It also shouldn't matter about how many triangles make up each side (but it will take longer). We get the centre of the box from the centre of its AABB.