I don't understand the purpose of separate SystemClass for functions.
My composition looks like this:
class Color {
void Blend(uint32_t entityID, float factor) {
red[entityID] *= factor;
green[entityID] *= factor;
blue[entityID] *= factor;
}
static std::vector<float> red;
static std::vector<float> green;
static std::vector<float> blue;
}
std::vector<float> Color::red;
std::vector<float> Color::green;
std::vector<float> Color::blue;
I am keeping vectors of members to have possibility to iterate over specific member instead of loading whole struct.
My question is: what exactly is the reason for SystemClass with only logic?
class ColorComponent {
static std::vector<float> red;
static std::vector<float> green;
static std::vector<float> blue;
}
std::vector<float> ColorComponent::red;
std::vector<float> ColorComponent::green;
std::vector<float> ColorComponent::blue;
class ColorSystem {
void Blend(uint32_t entityID, float factor) {
ColorComponent::red[entityID] *= factor;
ColorComponent::green[entityID] *= factor;
ColorComponent::blue[entityID] *= factor;
}
}
How the second composition suppose to be better for performance?
I will be very grateful for explanation.