Created
December 7, 2010 04:50
-
-
Save eyston/731468 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct foo { | |
float *stuff; | |
int offset; | |
float operator[](size_t i) const | |
{ | |
return stuff[i + offset]; | |
} | |
float &operator[](size_t i) | |
{ | |
return stuff[i + offset]; | |
} | |
}; | |
struct Particles | |
{ | |
float *pos; | |
foo x, y, z; | |
Particles(int num) | |
{ | |
pos = new float[num * 3]; | |
x.stuff = y.stuff = z.stuff = pos; | |
x.offset = 0; | |
y.offset = num; | |
z.offset = num * 2; | |
for(int i = 0; i < num * 3; i++) | |
{ | |
pos[i] = (float)i; | |
} | |
} | |
~Particles() | |
{ | |
delete[] pos; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment