Archived

This topic is now archived and is closed to further replies.

Linked Lists in games

This topic is 5646 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

Hi, could someone explain me why linked lists are used in 3d graphics engines ? I''ve seen lot of examples and they use a class called CNode and then derive a class CObject from it. I can''t understand the concept. Please help me out. Thanks. Bye

Share this post


Link to post
Share on other sites
Linked lists are used to handle a quantity of objects that is always variable.

For example, if you write a simulation of spacecraft all firing at each other, the craft are objects and the bullets are objects. But there could be any number of bullets in existence at any given time. Even though there might be a given maximum to the number of shots that could be in the arena (meaning that an array COULD be allocated to track all of them), using a linked list makes it dynamic enough that you could actually increase the number of craft and not worry about the shots overflowing a pre-allocated array.

Make sense?

[edited by - Waverider on June 26, 2002 10:28:21 AM]

Share this post


Link to post
Share on other sites
I don''t know if that CNode class is just a singly linked list, but cyclic linked lists are VERY helpful when making an engine or any kind of game.

Deriving CObject from CNode is a common approach IMHO, I''m using it in my game. I derive all my world-based objects from CObject, and then these objects can be linked together.

Doing that just gives the engine some better organization.

Share this post


Link to post
Share on other sites
Remember,
if you code in c++ you "should" (or can) use the templated STL "list" class for linked lists.

my advise is to learn STL... it is fast and easy to use.

zilch_

[edited by - zilch_ on June 26, 2002 2:41:31 PM]

Share this post


Link to post
Share on other sites