Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- before:
- class GameObject {
- float m_Pos[2];
- float m_Velocity[2];
- char m_Name[32];
- Model* m_Model;
- // ... other members ...
- float m_Foo;
- void UpdateFoo(float f)
- {
- floag mag = sqrtf(
- m_Velocity[0] * m_Velocity[0] +
- m_Velocity[1] * m_Velocity[1]);
- m_Foo += mag * f;
- }
- after:
- struct FooUpdateIn {
- float m_Velocity[2];
- float m_Foo;
- };
- struct FooUpdateOut {
- float m_Foo;
- }
- // update value depending on time passed and velocity
- void UpdateFoos(const FooUpdateIn* in, size_t count, FooUpdateOut* out, float f) {
- for (size_t = 0; i < count; ++i) {
- float mag = sqrtf(
- in[i].m_Velocity[0] * in[i].m_Velocity[0] +
- in[i].m_Velocity[1] * in[i].m_Velocity[1]));
- out[i].m_Foo = in[i].m_Foo + mag * f;
- }
- }
Add Comment
Please, Sign In to add comment