Skip to main content
gamedev.net
🔒 Locked

Object management

Started by Amadrias 3 replies 550+ views
Original Post
Amadrias
Amadrias
Hi, I have a qustion on what is the best way to handle objects in a code point of view. I have a class called CWorld that I want to use to get access to a list of cameras and objects. At the beginning, I don''t know how much of these cameras or objects I will have to manage on it and I''d like to dynamically create these things so I can then access them. I tried to use defined camera and object tables (cameras[MAXCAMERAS] and objects[MAXOBJECTS]) but the way they work, it allocates all table cameras and objects which is a waste of memory and also performance when you try to search one of these objects. I also tried from the STL (vector mCameras and vector mObjects) but my engine is within a dll which cause too much troubles in order to compile and link it (the STL classes are difficult to export from a dll). I didn''t try trees because I thought it wouldn''t work correctly with the cameras but I may be wrong. If anyone could give me some tips, I would appreciate. thanks, Amadrias
Arild Fines
Arild Fines
Since it seems a std::vector is sufficient for your needs, maybe you could implement your own vector class. Or if you dont require random access, why not just make a simple linked list? - shouldnt be hard to find sample code for that.

Fantastic doctrines (like Christianity or Islam or Marxism or Microsoft-bashing) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Shannon Barber
Shannon Barber
How is the user going to specify which camera or object they want to manipulate?
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
acw83
acw83
You need linked lists.
Amadrias
Amadrias
Arild Fines: How do you implement your own vector class ?

Magmai Kai Holmlor : In quite the same way the developer will use DirectX. the World Class is part of a global class and he will use the following way:

CWorld* myWorld = CEngine.CreateWorld();
myWorld->InitializeCameras(1);
myWorld->InitializeObjects(5); // for the objects it can be a linked list

Since myWorld is part of the CEngine class, it will also be shared with other classes.

acw83 : I know that there is a performance problem on using linked list : If I want to traverse it and change the variables there shouldn''t be problems, but if I want to get access to only one link, I will have to search for it before being allowed to change something.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.