Is this a case for smart pointer usage or is my design wrong,help needed.

Started by
11 comments, last by BeerNutts 11 years, 6 months ago
ankd,

What sednihp said is correct for your typical particle systems. "Particles" are typically just residue left from an emitter. Once a particle has been created, it doesn't matter where the emitter is. Think about a car with bad exhaust. When the smoke (ie, the particle) leaves the car, it just starts floating up. It doesn't care if the car has turned left, it's doing it's own thing once separate from the car (ie, the emitter).

In simple games, a particle could just be a small block of red/yellow/orange that is created by a rocket, and fades away a short time after to look like some kind of fire (when combined with many particles). These particles don't care where the emitter is once they have been created.

It sounds like you are trying to define something else, not the typical particle emitter.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

Advertisement
ok this is the last time i'm going to say this. This is not about the particles its about linking the emitter to my objects.

My particle systems are define to do a certain task, Eg. Muzzel flash it luanches 50 particles that come from the emitter at some direction.
This emitter can be moved around but that only changes any new particle that is launched, at its new world position.

Now ParticleManager managers a bunch of particle systems that do there own thing and each one has a world position emitter that I would like
to set at runtime, like when a unit walks. ParticleManager also adds request from objects when a object need to activate a particle system.
It's at this stage, I would like to link objects that are bound to the particle manager and what one it is using, and like wise with the objects.
So what I have done todate is in the particle manager when a unit adds a request I also store a pointer to the object and the add function
returns back to the unit data containing where and what elements its in.

Now when a unit dies or no longer needs its particle system it will message particlemanager to do so.
all good so for but none of my objects have death built into them yet and Im also in the process of making the rest of the particles,
I'll get back as soon as I can with the test results.
Oops, my bad. I did misunderstand.

So, my initial thought is there may be a design flaw with using a "particle manager" to control the emitters. I would have the emitter itself (which is given to rocket) handle how it renders and processes the particles. As for when it needs to be removed, it could come from the rocket (or whatever object is using the particle system), and that object removes the particle system (emitter).

The specific emitter can be copied from your vector of the possible systems, but you're getting into trouble having to share it across multiple objects.

There are a number of posts throughout discussing the pitfalls of using "managers" You can search through and find them.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

This topic is closed to new replies.

Advertisement