Archived

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

Merick

Dungeon Siege Style Resource Management???

Recommended Posts

I've been wondering, how do games that have no (or virtually no) levels work? Alot of games recently have come out which dont seem to have to divide the game up into levels, and can let a player walk from one end of the world to the other, into the deepest cavern and back out, without requiring a point where the game gets rid of all the current resources (textures, models, sounds, etc) used in that level, and loads up everything for the next one. How do they do this?? Most every where i read about how to deal with resources, everyone just says, "load up everything you need for a level, and get rid of it when you change levels" ... i know tons of games do this, but i've noticed a few that dont ... Dungeon Siege doesn't seem to, and some massively online games dont like Asheron's Call and Asheron's Call 2 ... Anyone have any idea what they're doing?? .. When do they release resources, how do they know how much to load up? ... how do they (or do they) determine things to pre-load? .. Or do they simply find clever ways to hide their "levels"? [edited by - Merick on January 19, 2003 1:42:27 AM]

Share this post


Link to post
Share on other sites
That has just very general information, nothing specific.

One of the resource manager''s primary functions is to make sure duplicate resources dont get loaded.

If you go with the level idea, then things are simple, tell the resource manager what it needs to load up, when something requests an object, give it to him. When you change levels, unload everything, and reload everything for the new level.


But in a game with no levels, you have to resort to maybe, loading things up when they''re requested and haven''t been previously loaded. This seems pretty obvious, maybe possibly adding some way for giving the resource manager a list of things to "preload" when it thinks it should.

But the real question i can''t seem to answer is, how do you know when to get rid of things? How do we know when its ok to remove things from memory? A simple answer would be, unload something when its no longer being used. But i''ve read things that say, DONT DO THIS, it causes your resource manager to be constantly unloading and loading something if it keeps getting requested... then released... then requested again ... released... etc etc .... they seem to suggest ... keeping a resource around until some point .... again this makes sense ... BUT ... how do you know when enough is enough??

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I would have to say you would load and unload things based on thier proximity to you. If there happens to be something you might encounter a few screens away load it up. Or if that specific monstar or terrain is no where near you, unload it. I know this is very general, but I think it wouldnt be to terrible to put into code.

Share this post


Link to post
Share on other sites
If you''ve played with creating maps for DS, you''d notice that it does in essence have levels. The difference is that each level doesn''t end with a wall, cliff, or any kind of boundry. Its like somebody just forgot to finish half the level. Well, each section fits together and to make a whole level you piece them together to get a solid terrain.

I''m guessing that what the game does is keep the segment your on in memory in addition to all the ones that connect to the one your in. When you move to one of the connecting edges, it dumps the ones not connected to it and loads the ones that are. It probably loads a few bytes and times it to figure out how many bytes to load per frame without disrupting the framerate too bad.

Share this post


Link to post
Share on other sites
Between that and E3, I had a blast... doing it all over again this year! Next year, however, GDC will be free since I am likely going to be a presenter. That doesn''t suck too bad.

Dave Mark - President and Lead Designer
Intrinsic Algorithm -
"Reducing the world to mathematical equations!"
RIPPL Sports - NFL Statistical Analysis and Prediction System

Share this post


Link to post
Share on other sites
im playing around with something like that (not textures and objects yet, but terrain). to include monsters, sounds, textures etc. i would probably just add them to a list for this ''sector''. so the manager can have a look at whats loaded next and probably needed and whats far enough away. i would keep everything within say 16 sectors in memory and while moving just load/unload a little each frame. im doing this with the terrain itself and while it takes about 1 second to load a sector that way and fps go down a little you dont feel that anything is just being loaded (couple of textures, the heightfield, the geometry is built.. in the final version the geometry will be exported by the editor and can just be loaded without extra processing (calculating thousands of normals and hundreds of sqrts takes some time).

with 3x3 sectors terrain (and maybe 4x4 objects, etc.) you just have to make sure the player will need at least 2-3 seconds to cross one sector (with a scale of 2.5x2.5km per sector id say that isnt a problem *g*). so what i think is important here: dont try to do it all at once but over time. just like the only way i see for decent ai is not doing the whole ai for everything every single frame.

Share this post


Link to post
Share on other sites
Is there anyway those of us not lucky enough to make it to these conferences could get even a small part of the information being given? even if it was just a cryptic powerpoint slideshow?

Share this post


Link to post
Share on other sites
good question. i got an "international priority airmail" a while ago whit a code to save some money. but even 40% less wont help a student to fly to the us and still have money enough for the con *g*.
i wondered why the even bother to send that all the way to germany with only a slim chance that person will show up. well, after looking at the prices i guess its already worth it, if at least 1/100 will appear. but i guess thats not unusual, as its probably not meant as a con for hobby programmers (making me wonder again why i get this).

but: i think a lot of papers etc. show up later. i might be wrong, but a lot of the stuff i find on the net seem to be presentations from the gdc.

Share this post


Link to post
Share on other sites
well, i''ll suggest some sort of garbage collector. that means, what ever you need for a scene, you load up (that you can find out. you move a bit forward, and load everything (best of all in another data-loading thread) that will be in front of you but not yet visible but soon visible..) that _should_ be rather easy

next thing is that your resource manager does save your data, even while you don''t use it, it will stay in ram.. the objects are refcounted => the resource manager knows when they are useless.. once they are useless, you start counting for how long they where useless.. if they where useless for too long, unload them from the ram..

a typical refcounted, gc collected obj wich _should_ be useful for you..


  
class Object : IGCObject {
int refCounter;
int unusedSince;
public:
Object() {
refCounter = 1;
GarbageCollector::addObject(this);
this->addRef();
}
void addRef() { ++refCounter; }
void release() { if(!--refCounter) delete this; }
int checkUnused() { if(refCounter==1) ++unusedSince; else unusedSince = 0; return unusedSince; }
friend GarbageCollector;
};


and the gc has two methods:

addObject(IGCObject* obj) {
objectList.push(obj);
}

and

garbageCollect() {
foreach(IGCObject* obj in objectList) {
if(obj->checkUnused()>this->maxUnused) {
obj->release(); // deletes itself
obj = NULL;
}
}
objectList.removeAllEqual(NULL);
}

yes, the gc code is a bit pseudocode.. anyways...


of course (never forget!!), you have to check if the gc does have some resource when you want to load one..


  
IGCObject* loadResource(someParams) {
IGCObject* yetLoaded = GarbageCollector::hasObject(someParams);
if(yetLoaded) {
yetLoaded->addRef();
} else {
yetLoaded = new ResourceFromFile(someParams);
}
return yetLoaded;
}


have i forgot something? i think thats about all..

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites