Jump to content
  • Advertisement
Sign in to follow this  
Waverider

Particles - fast room containment calculation?

This topic is 4059 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been developing a portal engine for a couple months (you can check it out at www.gamemodel.com if you like, I have some demo movies up). I recently added some simple particles and am getting to the point of unifying them more so they can move from room to room and still be rendered properly. I want the particles to be properly blended behind alpha surfaces, and for now this means that I want them to be rendered back to front along with the rooms so that closer alpha walls will properly blend over them. This means that I want particles to be grouped with rooms, so I'll need to be able to detect when they move from one room to the next. Here are some ideas I have: 1. As a particle moves, I can see if it is still in its current room by testing against all the surfaces. If any fail, I know the particle has moved out and need to find the room it is in. (I don't like this idea, it's computationally expensive). 2. I'm using an octree to split up the map into sections. An octree cell lists all the rooms that touch it. I can submit the particle to the octree to see which cell it is in. If that cell has only one room touching it, and it's the room the particle is listed inside, I don't need to do anymore. Otherwise, I need to figure out which room in the list the particle is in. (This method seems like it will be faster) 3. I can see if a particle has moved through a portal, which will tell me that it has moved out of the room, and which room it has moved into. (I like this idea except that particles could float through room walls too - thereby leaving without passing through a portal - and I'd prefer to not have them bounce off the walls since that would require collision detection, which I'd really like to avoid on particles at this point). Is there any simple-ish algorithm that helps with this kind of problem? Any terminology of structure, algorithms or articles would be appreciated. Any other recommended direction would also be appreciated. [Edited by - Waverider on May 15, 2007 9:51:17 AM]

Share this post


Link to post
Share on other sites
Advertisement
As I put more thought into it, I can combine all my ideas above.

1) Get the octree cell the particle is in and access the room list.
2) If the room list has only one item, and it's the room the particle is listed in, I'm done. No need to calculate anymore. Actually I can just assign the particle to the one room in the list and be done.
3) If the particle has moved through a portal, assign it to the room it moved into. Done.
4) Make sure the particle is still in its assigned room. If so, done.
5) Check for containment in any of the rooms in the cell list (all except the currently assigned room). If one is found, assign the particle to that room. If none are found, get rid of the particle.

Any other ideas?

I could augment this algorithm by defining a cube that is absolutely inside the room, and if the particle is inside this cube, I know it's still in that room. But calculating that cube is a ways off for me, I think, since there is a largest possible cube for every room. Multiples are possible, too. ew.

[Edited by - Waverider on May 15, 2007 11:35:59 AM]

Share this post


Link to post
Share on other sites
Got the code working. Here's a demo of it in action.

I increased the particle output and it didn't seem to phase the framerate at all, so I'll keep using it.

And another, after I worked out a couple glitches.

If particles are rendered on room borders, they may sometimes be partially erased, but I'll leave it the way it is for now. I suppose the most accurate graphical solution is to render all the solid walls first, then submit the particles and alpha walls to some sort of scene graph and render them all back to front.

Particles that need to be lit by surrounding lights really slow it down, but it's still playable. And I'm not planning on having too many of those kinds of particles, anyway.

[Edited by - Waverider on May 16, 2007 9:49:37 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!