All8Up wrote:CuteAlien wrote:Could you also add your example somewhere - beside the patch or post it in the forum. Saves me the time to write my own when testing this :-)
I didn't want to put it in there as it is just a hacked up version of the per pixel lighting. I suppose if you remember to remove the changes to that it should be fine though. Or I could post it as a separate patch file. Of course I should actually post a completely new patch, found/fixed a couple bugs later in the day and ended up finding/fixing a bunch of other issues when I did a cleanup pass. Just a list of the changes I have locally now (perhaps too much for integrating to trunk at this point, lots of small and large changes here and there):
Yeah, pixel lighting origin was visible, but I didn't think of a patch for it, but as it's just a single file you can just add that main.cpp completely in an extra file as example so we can test it without having to write our own first (yeah, I'm lazy).
All8Up wrote:
1. Moved all shared code for the emitters into a new CParticleEmitter.h file. Not sure if you folks will like this as it uses a template injection so all the concrete classes can share the code. I could have done this a couple different ways but the pattern in question is the lowest maintenance variation, there is probably 90% less code in the remaining files now. Most of the emitters are now not much more than a constructor, overridden "where" to emit new particles and serialization of their custom parameters. All the core routines/update etc is moved to the shared code.
Template injection is certainly an idea, the part that makes me worry there a little is that it's very different from the usual Irrlicht style which works throughout with interfaces (except in core-classes, but those are an own topic). Also if it's put in a CParticleEmitter the common part is not useable for users trying to do own emitters and supporting custom emitters from users should be the long-term target (yes template injection could be made visible to users, but that would introduce a complete new style in the API which might be the preferred style when starting a lib from scratch these days, but having it mixed is probably not a good idea). Then again I haven't had a good idea yet how to fix that stuff, it's obvious from the code that one more layer is necessary (a parameter class might be another possibility).
All8Up wrote:
2. Fixed a couple bugs in serialization I found when making sure all the emitters shared the common code. Cylinder for instance was writing "Distance" out as the "Center" attribute I think was one of them. I was going to go ahead and add in serialization for mesh and animated mesh emitters but couldn't find a good reference about how to serialize the node pointers in those two items.
Ok, have to look that up. Preferably keep patches independent, as for example a single-line serialization patch can be added without much review. And yes - you run into the reason why mesh and animated mesh emitters don't have serialization. Our serialization system has no common style so far for creating objects - so it's using workarounds there all over the place and in many places things are not serialized for exactly that reason. Basically we have 2-3 directions to go there... adding more factories - replacing factories by a common factory system for all serializable objects - or maybe even continuing with creating types in the attribute-system itself (the way textures are created). But also an own thread, for emitters it just means that it's currently hard to fix without thinking about reworking serialization first.
All8Up wrote:
3. Reworked the emission direction vector randomization. I noticed in many cases that the randomization only worked in one quadrant around the direction vector which made it nearly useless for my purposes (seemed like a bug at least). At the same time I wanted to add in a MinAngle ability so you can build a point emitter with direction set to yaxis, set min to 85 and max to 95 and it will spit particles out to the sides but none up or down. I did not add this to the constructors though as that would have changed the interfaces too much.
Great, but another candidate for an own patch.
All8Up wrote:
4. Added an option to the gravity affector to use "real" gravity. The version doing interpolation looks too funky for my tastes, it is an option and defaults to using the interpolation method so no changes to anyone expecting the current behavior.
Hm, yeah - someone mentioned that before (
http://irrlicht.sourceforge.net/forum/v ... 09#p260109), but didn't make it optional.
All8Up wrote:
5. Moved the rotation about arbitrary axis code (the big equation in the rotation bit) into the vector class and fixed a goof in it when I translated it from my right handed math library to the left handed Irrlicht version.
Again great - but preferably an own patch.
All8Up wrote:
I think the only two things I care to do from here on out with the existing code is perhaps adding a noise affector to give particles a random drift and the other thing would be related to the gravity change, basically because true physics are unstable with variable frame rates, I'll add an option to the update loop to do a max step update. I.e. if the delta time is more than 10 ms, run the movement/affectors in multiple steps as an option.
Anyway, that will have to be in a couple hours. Late here and have errands to run in the morning.
Thanks for all the work.