Auto-precache
Moderator: InsideQC Admins
8 posts
• Page 1 of 1
Auto-precache
One thing that drives me crazy is the need of precaching models everywhere in QuakeC code. Soon it becomes unmaintainable. Has anyone implemented some sort of auto-precaching? If yes, what were the implications of this? Terrible slowdowns or just smaller performance?
- JasonX
- Posts: 411
- Joined: Tue Apr 21, 2009 2:08 pm
Re: Auto-precache
JasonX wrote:One thing that drives me crazy is the need of precaching models everywhere in QuakeC code. Soon it becomes unmaintainable. Has anyone implemented some sort of auto-precaching? If yes, what were the implications of this? Terrible slowdowns or just smaller performance?
you can precache files with "frik_file"
hi, I am nahuel, I love quake and qc.
-

Nahuel - Posts: 492
- Joined: Wed Jan 12, 2011 8:42 pm
- Location: mar del plata
JasonX wrote:frik_file?
if you are using darkplaces
http://dpwiki.slipgateconstruct.com/index.php?title=FRIK_FILE_Precaches
you can precache the files "scripted" in system/precache.txt.
hi, I am nahuel, I love quake and qc.
-

Nahuel - Posts: 492
- Joined: Wed Jan 12, 2011 8:42 pm
- Location: mar del plata
no need for anything that fancy.
preach clued me in on this great method:
basically, you create a wrapper for setmodel.
first, rename the setmodel builtin function:
then create a new setmodel function, that calls the builtin function and with any other checks you want:
note the check for framecount, this is so we don't try to precache a model after the map has loaded (that crashes the engine).
this way, we don't have to change anything beyond the above. any entities that get setmodeled at map start will automatically precache their models and won't cause crashes if a setmodel is called later on.
alternatively, the DP engine will just precache things on the fly (not really PREcacheing i guess... just caching..... uhhh) if you aren't trying to keep your code compatible with other engines. it will complain about it in the console though.
preach clued me in on this great method:
basically, you create a wrapper for setmodel.
first, rename the setmodel builtin function:
- Code: Select all
void(entity e, string m) setmodel_builtin = #3;
then create a new setmodel function, that calls the builtin function and with any other checks you want:
- Code: Select all
void(entity e, string modelFile) setmodel =
{
if(framecount == 0)
{
if(m != "")
precache_model(modelFile);
}
setmodel_builtin(e, modelFile);
};
note the check for framecount, this is so we don't try to precache a model after the map has loaded (that crashes the engine).
this way, we don't have to change anything beyond the above. any entities that get setmodeled at map start will automatically precache their models and won't cause crashes if a setmodel is called later on.
alternatively, the DP engine will just precache things on the fly (not really PREcacheing i guess... just caching..... uhhh) if you aren't trying to keep your code compatible with other engines. it will complain about it in the console though.
- necros
- Posts: 77
- Joined: Thu Dec 16, 2004 10:32 pm
Re: Auto-precache
Stalls when loading, both on the client and server. Missing models when files are missing until the precache slowly winds its way to the client. Segfaults in clients that don't support it. Shutdowns in servers that don't support it. Breaking the precache determinism can and will break saved games if the engine doesn't take steps to cope with that.JasonX wrote:If yes, what were the implications of this?
Delayed precaches might be considered unused and thus be flushed from memory over map changes, increasing total load times.
Apart from the bug, necros' wrapper is safe enough, but it won't function as hoped in delayed-spawn situations.
For the rest, you can just precache_model every single model you can find.
Precaches are there for a reason, even though they're a pain.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest