Ejemplo n.º 1
0
void UBoxComponent::UpdateBodySetup()
{
	if(ShapeBodySetup == NULL || ShapeBodySetup->IsPendingKill())
	{
		ShapeBodySetup = NewObject<UBodySetup>(this);
		ShapeBodySetup->CollisionTraceFlag = CTF_UseSimpleAsComplex;
		ShapeBodySetup->AggGeom.BoxElems.Add(FKBoxElem());
	}

	check(ShapeBodySetup->AggGeom.BoxElems.Num() == 1);
	FKBoxElem* se = ShapeBodySetup->AggGeom.BoxElems.GetData();

	// @todo UE4 do we allow this now?
	// check for malformed values
	if( BoxExtent.X < KINDA_SMALL_NUMBER )
	{
		BoxExtent.X = 1.0f;
	}

	if( BoxExtent.Y < KINDA_SMALL_NUMBER )
	{
		BoxExtent.Y = 1.0f;
	}

	if( BoxExtent.Z < KINDA_SMALL_NUMBER )
	{
		BoxExtent.Z = 1.0f;
	}

	// now set the PhysX data values
	se->SetTransform( FTransform::Identity );
	se->X = BoxExtent.X*2;
	se->Y = BoxExtent.Y*2;
	se->Z = BoxExtent.Z*2;
}
template <> void UShapeComponent::AddShapeToGeomArray<FKBoxElem>() { ShapeBodySetup->AggGeom.BoxElems.Add(FKBoxElem()); }