|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xith3d.render.states.StateMap
public class StateMap
A state map is used to map objects to state id's. This is based on the assumption that many state objects (like materials) are different objects but are actually the same values. This class provides a way to assign unique id's to unique combinations of objects and then map all the other objects to the same id. This allows for efficient state sorting and state changes. The weakness is that it will keep a pointer one more frame than it would normally be kept, since reference count would not go to zero until the next frame render.
| Constructor Summary | |
|---|---|
StateMap()
|
|
| Method Summary | |
|---|---|
void |
assignState(StateTrackable<?> trackable)
Ok this is a little tricky. |
static int |
newStateType()
Used to get an integer ID which uniquely defined a state type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StateMap()
| Method Detail |
|---|
public static int newStateType()
public void assignState(StateTrackable<?> trackable)
So we take the item and use it as a key into a TreeMap. The state trackable items have to implement Comparable, so we we can use it as a key. Now this can be expensive since some shader components have many sub-items which will have to be compared. But if the comparators are written properly we can quickly match against the tree state in log(n) compares, which is very few.
If we find and entry then we just assign that state node to the state trackable item. If we do not then we create a new node. This node copies the statetrackable item, assigns it a unique id and inserts it into the tree.
trackable -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||