Last active
August 29, 2015 14:27
-
-
Save MrSmith33/e861a289d295ec4659a0 to your computer and use it in GitHub Desktop.
Data driven API
This file contains hidden or 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 Transform { | |
float x, y, z; | |
} | |
struct Velocity { | |
float x, y, z; | |
} | |
enum entityCountMax = 1_000_000; | |
enum entityCountMin = 100_000; | |
HashmapComponentStorage!Transform transformStorage; | |
HashmapComponentStorage!Velocity velocityStorage; | |
foreach(index; 0..entityCountMin) { | |
velocityStorage.add(EntityId(index), Velocity(1, 1, 1)); | |
} | |
foreach(index; 0..entityCountMax) { | |
transformStorage.add(EntityId(index), Transform(0, 0, 0)); | |
} | |
auto query = componentQuery(transformStorage, velocityStorage); | |
foreach(row; query) | |
{ | |
row.transform.x += row.velocity.x; | |
row.transform.y += row.velocity.y; | |
row.transform.z += row.velocity.z; | |
} | |
// Time 0.035,439 secs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment