-
Notifications
You must be signed in to change notification settings - Fork 113
Packed Weaver
Experimental. The current implementation doesn't offer any performance gains over plain or pooled components. Avoid using this feature for now!
@PackedWeaver
achieves a more memory-friendly layout without introducing any of the boilerplate usually associated with these kind of optimizations.
- Structs, contiguously in memory.
- No extra code. Completely transparent.
- Android support
Even in current day hardware, fetching data from RAM is slow. By using packed components, preemptive caching becomes more efficient, which in theory improves Artemis performance.
- Only primitive types are permitted for fields. No Objects.
- Zero-argument/default constructor.
- Must be added to entities
Entity#createComponent(Class<Component>)
, Archetypes or via EntityFactory. - Getters/Setters are allowed, but not required.
Assuming artemis-odb-maven-plugin
is properly configured, simply annotate the component with @PackedWeaver
:
@PackedWeaver
public class PackedWeaverReference extends Component {
public float x;
public float y;
public void set(Vec2f vec) {
this.x = vec.x;
this.y = vec.y;
}
}
For packed components each instance of ComponentMapper#get
reuses a flyweight component. To reference more than one component of the same type at the same time create multiple component mappers.
Alternatively, tuck away an extra instance of the component type with ComponentMapper#get(entity, forceNewInstance)
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference