Today I managed to do something pretty interesting, but only partially related to the engine.
I noticed that I often needed to pass different data types from the emitter to the particles, and there is no way to know what will be used inside the lambdas. It is then impossible to decide which parameters to give the particle.
So i decided to write a generic map, which can accept all kinds of data, and you can add them and retrieve them with a string id.
To do so I used void pointers ant templates, and now I have a functioning class that can also be used for other things.
In the picture, instead of making global the cone mesh so that it can be accessed from the lambda, I just added it to the map inside the emitter lambda, and each particle retrieves it inside its lambda and use it to change shape after a certain amount of time.
I also did other little improvements to the engine, for example I added static colors in the color class, so that now I can just type ColorRGBA::red instead of creating it every time.

Nessun commento:
Posta un commento