State Management Best Practices

Hi Everyone,

It would be great if you could share your approach to State Management for Cinder apps. Would you recommend any cinderblock / boost lib / other generic cpp lib for the purpose? If you use mostly custom code in each project, what principles can you reuse across them? How does it affect things when there is a Scene Graph in the picture?

I have been relying on custom code ( simple switches ) for state management. However, in dealing with Scene Graphs and nested states, I suspect this might not be the best approach.

Any thought / code that you could share on this (slightly broad) topic will be deeply appreciated!


I am still a n00b, but from what I understand, you have to roll out your own management and data models.
Paul once recommended Entities Components Systems for managing a big catalog of objects, with the intention of adding behavior (animation) to objects in a compositional way instead of inheritance.
Scene graphs can still work with an ECD, as long as you have separation of concerns where your graph is responsible for rendering but your ECD manages data and behavior over time.
It seems that people are looking for an engine that combines a scene graph and state management but I think there is no one solution that fits all, and the power of Cinder (and this community) is that you can synthesize your own thing without the overhead of one big engine


Thank you for the link. There is an ECS block ready for Cinder right here.

I understand that there is no one size fits all kind of solution for the problem. The problem space is too big for that. However, I suspect that the experts would have a few templates they reach for, to start each project. Even though the code itself might not be reusable for non-experts like me, the design might be educational.


1 Like

Stephen (bantherewind) offered a pretty interesting tool of his for this kind of app management / structure called UiTree (he wrote a comprehensive description of uses and practices here ).

I have never used it in a project but it seems like a pretty powerful tool to build structures like scene graphs etc. for cinder (whilst not being a scene graph its self). It would be nice to see something like this in Cinder its self as it matures.

On another note, I have used PoScene in projects which is a useful scene graph block from Potion. This wont suit every use case though.

It’s quite a broad question (I would also be interested in others’ opinions / experience) but I hope this helps!


EDIT: I just noticed from the other posts that you are probably already aware of these blocks! I’ll leave this post here in case it’s useful to others though.

Hi Felix,

Thank you for the reply. I have used UiTree in a small project ( without much state management ) myself. It deals with a thin layer of relationships between nodes. If the state of the program can be captured through these relationships ( parent/child, visibility, simple geometry - translation, rotation and scale ), UiTree alone will suffice. Otherwise we can store the state in a user defined DS, and stick a pointer to it in these nodes.

I was curious to find out how (whether) state machine libraries can help if we take this route.


I was curious to find out how (whether) state machine libraries can help if we take this route

I’ve gone the state machine route on a couple projects and while I think it is a nice way to organize the logic and control flow of your application, I’ve yet to come across any canned state machine lib that naturally fit our model. On one project we ended up attempting to write something reusable, only to need to customize it mid-project.

I’d be curious to know what others have found in these regards. Some libraries we reviewed were Boost.MSM, which seemed too generic and cumbersome for our tastes, and Machina.js, which actually seems pretty nice but, well, its in javascript. :slight_smile: