Thank you for your help and ideas, i checked each one of “UPROPERTY” and it turned out that “EditAnywhere” is fatal to performance.
in .h
UPROPERTY(Category = DynamicTerrain, BlueprintReadOnly)
TArray HeightMap;
in .cpp
void ATerrainCreatorBase::InitMap()
{
if(HeightMap.Num() == 0){
ChunksX = FMath::Max(1, ChunksX);
ChunksY = ChunksX;
MapSize = ChunksX * 16 + 4;
HeightMap.SetNum(MapSize * MapSize);
}
}
and it works like a charm.