Download

new to C++: optional TArray parameter/ UProceduralMeshComponent

Hello!
I’m new to UE4 and rather new to C++ as well. I have experience in a C-like language and engine. I did the “Battery Collector” Tutorial (for the most part) and played around with the editor for a bit, that’s it so far.
I’m interested in making randomly/ procedurally generated games with UE4 and (its) C++.
I’m trying to create a mesh using UProceduralMeshComponent and this function:

I do not know or understand how the parameters marked with “Optional array” can be omitted and I cannot find much about that on google (except that regular optional parameters in C++ seem to need a default variable specified and be the last parameters of that function - which bool bCreateCollision is not either).
In C or my old engine I would have put “NULL” there for those parameters but this gives me an error that there’s no typecast available for int to TArray.
It seems to work when I supply dummy arrays (arrays of the correct size with random values/ entries) but I doubt this is the right approach.

Any help, advice or insight would be greatly appreciated! Thanks.

I don’t know this method, but you’re right - they cannot be nullptr as they are references. I guess they would have to be empty instead. Normally this is made easier for the caller by giving them default values like TArray<FVector>() so the caller doesn’t have to type all that pointless stuff in. Or they should be pointers not references.

Hey,

Yes in this case just pass in empty arrays.

I also recommend you check out Koderz’s much faster RuntimeMeshComponent:
Runtime Mesh Component - Marketplace - Unreal Engine Forums!

You can also check out my examples on how to use it:

Thanks to the both of you! I will use empty arrays then.

Yeah I’ve found that one (Koderz’s) yesterday and planned on looking into it today, as the PMC only supports one UV channel currently (maybe I could extend that myself easily? not sure yet).
Your examples look interesting and I’d like to check them out, but I have to ask you to help this noob out once more please:
What do I have to do to get that ProceduralMeshDemos.uproject running in 4.15?
When I unzip it (GitHub - SiggiG/ProceduralMeshDemos: Examples of procedural mesh generation in Unreal 4.), I double click ProceduralMeshDemos.uproject and a “Select Unreal Engine Version” dialog pops up. The only option is 4.15 (because I only have that one installed I guess), I press OK and then I get this error:
[spoiler]

[/spoiler]
I only have Visual Studio 2015 installed on my machine. Does that make a difference? It’s probably rather an issue with my UE version, right?
When I press OK and double click that project again, I get a dialog pop up that says “UE4Editor-ProceduralMeshDemos.dll” is missing. “Would you like to rebuild them now?” -> Yes. -> Error: ProceduralMeshDemos could not be compiled. Try rebuilding from source manually.

What can I do? Thanks!

Rest assured this is not the last time you’re going to see inconsistency in Unreal’s source code.
Although the greatest public AAA engine out there, nothing is perfect (specially in the world of computer software).

I recently updated the sample to work in UE 4.16 which has a few changes to the build system. I created a branch with the 4.15 version you can use, but not updating that one anymore.