Results 1 to 5 of 5

Thread: Bullet management

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Greenbelt, MD, USA
    Posts
    29

    Bullet management

    I'm trying to figure out the best way to manage many simple moving objects (bulltes, lasers, etc). There are several ways I can think of doing this and each way is inefficient in some major way. I'm hoping someone could give me some advice:

    1) Store each bullet in its own node in a linked list, complete with its own geometry and transformation matrix.

    Good: fast adding/removing and translating/rotating of bullets

    Bad: slow to traverse the large linked list for rendering, and to push, multiply, and pop the transformation matrix for each bullet


    ------------------
    2) Use a large pre-allocated memory block as an interleaved vertex array

    Good: Fast rendering

    Bad: slow to translate each bullet in its own direction (i'd have to loop through each vertex and add the bullet's velocity).
    Limited number of bullets.
    Slow to remove a bullet from the middle of the array (would require copying all subsequent data into the memory location)

    ----------
    3) Linked list, but without matrix push/pops

    Good: fast adding/removing bullets. Less speed hit than #1 when rendering

    Bad: Slow to translate/rotate bullets (would require looping through each vertex and adding velocity as in #2)

    I'm really at a loss here, since none of these seems like a very good solution. Maybe someone has a different way or maybe I'm overestimating the speed costs here?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: Bullet management

    Hi !

    If you have lot's of objects and they are all very simple, then I guess it would be good to try to live without a transformation for each object, instead keeping the object transformed (if it's just a few vertices), but if we are talking about "bullets" in a game for example I guess there would never be that many objects active at one time ?, unless we are talking Gatling minguns with 7000 rounds per minute or so ;o)

    Mikael

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Greenbelt, MD, USA
    Posts
    29

    Re: Bullet management

    Well its a space arcade game, so if there's a big battle with 20 or so ships and each one is shooting then there could be 100 or more shots on screen at a time.

    I think the third one is the most promising so I'm gonna try that.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: Bullet management

    Currently Im working on a first person 3D shooter and for my 'bullets' (actually more like plasma balls or something) i use an array of around 40 elements for the bullets, each array member is a structure for the bullet holding position, velocity, damage, stuff like that. An array of 40 elements shouldnt take up alot of memory and you dont need larger because im never going to have more than 40 active bullets, and it is alot faster than traversing a list.
    I then build a display list for the bullet and traslate the matrix for each bullet...
    :: Sleep is a poor substitute for caffeine ::

  5. #5
    Member Contributor
    Join Date
    Jul 2001
    Location
    Czech Republic
    Posts
    78

    Re: Bullet management

    I use bullets like normal objects in node, so theoreticaly there is no upper limit of their number (except RAM . The framerate of course goes down, but it is because they act as dynamic lights. But having around 50 bullets is still playable. And I dont store their rotation matrices, because I dont need them (I draw them with a kind of billboarding technique).

Similar Threads

  1. 3D Bullet Trajectory
    By spoonbadger in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-12-2012, 12:55 AM
  2. The most realistic bullet holes.
    By DungeonLords in forum OpenGL: General
    Replies: 4
    Last Post: 11-02-2010, 04:33 AM
  3. I can shoot only one bullet not 2 !
    By Leyder Dylan in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-20-2003, 03:40 PM
  4. bullet(well... paintball) physics?
    By c_olin in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-15-2003, 08:51 AM
  5. shooting a bullet
    By spot in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 02-15-2001, 10:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean