Struct of arrays for Data-Driven Design

Hi!

I’m trying to understand data-driven design.

struct MyStruct
{
   TArray Transforms;

   TArray<FVector> Colors;
	
   TArray<int32> IDs;

   TArray<bool> Visible;

   TArray<FName> Names;

};

Would this be an effective approach to data-driven design? I ask because each array has a different data type and I can’t see how this would optimise the CPU cache.

Perhaps the optimisation would come from using arrays of the same data type, rather than using a structure containing data of different sizes as the data type of an array.

What do you think?

Thanks!

same type arrays is the part that helps the cache, since the loop only touches one type. keep the arrays the same length and walk them with the same index, or it gets messy fast.

I would opt for an array of structures instead of a structure of arrays.

I’m sorry, but your answer isn’t very helpful. No explanation—just one sentence, and that’s it.

Since you didn’t explain the purpose, I suggest a data type like this, for example:

I assume that all the arrays have the same size

struct MyStruct
{
     FTransform Transform;
     FColor Color;
     int32 ID;
}

.
.
.

TArray<MyStruct> MyData;

To understand Data-Driven Design.

If it does.

I recommend you to watch this video to learn about Aligment: https://youtu.be/WwkuAqObplU?t=1994

“Data-driven design” has two meanings. What you’re asking about is data-oriented design (memory layout for performance).
In Unreal, “data-driven” often means behaviour defined by data assets and data tables (UDataAsset, UDataTable, FTableRowBase), which is about designer workflow, not cache.

But in general, With Structure of array (your solution) you’d pull from five different memory regions per element, which can cost more cache misses.

sadly we’re overrun by AI responses lately, but to answer you question we’d need a better idea of your purpose, ie transform is likely better isolated since it updates frequently and colors likely don’t.