Generate Procedural Mesh

Hi,
I have problems to decide where to create my procedural mesh within my actor lifecycle. I need some information about the world around my object before I can create its mesh. So I decided to use PostInitializeComponents where I create the mesh in.

For testing I use this code:



void ATest::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	TArray<FProceduralMeshTriangle> triangles;
	FVector pos( 0, 0, 0 );	// generate cube triangles for every cube in this cunk
	GenerateCube( pos, 10.f, triangles );
	mesh->SetProceduralMeshTriangles( triangles );

}


This creates me a single cube, but I don’t get any collision detection. The cube does not collide with the scene.

I tested it using the same code in the constructor:



ATest::ATest( const class FObjectInitializer& PCIP ) : Super( PCIP )
{
	mesh = PCIP.CreateDefaultSubobject<UProceduralMeshComponent>( this, TEXT( "Test" ) );

	static ConstructorHelpers::FObjectFinder<UMaterialInterface> Material( TEXT( "Material'/Game/Materials/BaseColor.BaseColor'" ) );
	mesh->SetMaterial( 0, Material.Object );

	TArray<FProceduralMeshTriangle> triangles;
	FVector pos( 0, 0, 0 );	// generate cube triangles for every cube in this cunk
	GenerateCube( pos, 10.f, triangles );
	mesh->SetProceduralMeshTriangles( triangles );

	RootComponent = mesh;
}


Spawning the Actor this way gets me collision detection and I cannot walk trough this cube anymore.

But for more complex objects I cannot create the whole mesh in the constructor. It seems that the collision object is built after construction and before PostInitialization. So is there a way to recreate the collision-object after creating my mesh in the PostInitializeComponents method?