Closed junkdog closed 11 years ago
would that mean one array for each primitive and class type?
No, one array per Component. Something like this: http://mechanical-sympathy.blogspot.se/2012/10/compact-off-heap-structurestuples-in.html - but instead of using the Unsafe class (which is limited on Android), rely on primitve arrays (long or maybe int, maybe per component basis).
Haven't really investigated how to handle object types, such as libgdx's Vector2, which tend to be quite common data types for components.
Sounds definitely promising!
For object types, you probably have to traverse the entire class tree up to Object
for every object field.
Sounds... heavy. And what about all the casting that must be done for the getters. phew.
Would love to see what you have cooking once you got something useful. :)
I'm thinking about only allowing certain types of objects inside components to be packed... maybe limit it to those which have full interfaces (in libgdx, there is a partial Vector interface, for instance). An alternative, and perhaps easier way, would be to provide separate sub-packages for each framework (libgdx etc) with support for packing said classes.
All this would be a whole lot easier if android/dalvik compatibility wasn't an issue (Ofc, there's an asm port for dalvik, but I don't know how complete it is nor do I feel the urge to maintain such a thing).
For starters though, I'll just work out a prototype with support for primitives.
On Mon, Sep 30, 2013 at 8:11 PM, lopho notifications@github.com wrote:
Sounds definitely promising! For object types, you probably have to traverse the entire class tree down to Object for every object field. Sounds... heavy. And what about all the casting that must be done. phew.
Would love to see what you have cooking once you got something useful. :)
— Reply to this email directly or view it on GitHubhttps://github.com/junkdog/artemis-odb/issues/9#issuecomment-25387898 .
What it does:
Packs components into a single per component class primitive array by annotating the component with
@PackedComponent
.A post-compilation hook rewrites setters and getters to access the backing array at the correct offsets. Will take the form of a maven plugin and eclipse builder.
Problems:
Caveats:
@PackedComponent
on components utilizing public fields.(Possible) New methods (at a glance):
ComponentMapper#get(Entity e, boolean forceNewInstance)
- if a flyweight object is used for accessing the component data.World#createComponent(Class<Component> component, boolean forceNewInstance)
World#createComponent(Class<Component> component)
Similar endeavors