Sswift's Particle System

Blitz3D Forums/Blitz3D Programming/Sswift's Particle System

Lilprog(Posted 2003) [#1]
To sswift or anyone else with answers:

I have tried using sseift's particle system to create the waterfall scene, it works fine, problem is when i leave the level and return to the level, it complains that an entity is missing right where i try to load the particle system again. I run the same level init both times, why would it work the first and not the second?

Ill post code later today if no one knows


Koriolis(Posted 2003) [#2]
I've never used nor seen the code of this systme, but maybe
it's because you have Type instances that hold the data for particles that are still alive. If such an instance hold an entity handle, then when you leave the level if you change the resolution all the entities are screwed up, so the handle in the type instance is invalid. Try deleting all the instances of types that holds the particle data when you leave the level, to make sure everything is properly cleaned up.
Hop this helps.


Lilprog(Posted 2003) [#3]
Wouldnt this be cleared up when you run the ClearWorld command?


sswift(Posted 2003) [#4]
Koriolis:
Good call. I would have had a tough time figuring out what he was doing wrong. That sounds like a plausible explanation.

Lil:
No, types and other memory are not cleared. So the types for the particles will contain a pointer to an entity which ClearWorld removed.

Call SPS_OFF() when you change levels, and make sure you fix the particle brushes you created, because when you clearworld, you also delete the entities those pointed to. So you willl have to create new template particle meshes, and then set the appropriate field of each particle brush so it points to the new copy of the mesh.

A better game design though would be to keep all your pointers to your level media/entities in an array, and free them individually instead of using clearworld. Otherwise you will needlessly have to reload/recreate some of your graphics which don't change between levels.

And even better game design might determine if the new level uses some of the graphics already loaded and does not free those. If I was making a game that used a lot of textures and models, I'd seriously consider doing this.