From: Mircea Kitsune Date: Sat, 14 Jan 2012 14:29:10 +0000 (+0200) Subject: Attempt to cache the skeleton for each model, as requested by divVerent. This will... X-Git-Tag: xonotic-v0.6.0~110^2^2~13 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fb58e6195fc71d9a3d510f25b3d0a3c8ddb28a5d;p=xonotic%2Fxonotic-data.pk3dir.git Attempt to cache the skeleton for each model, as requested by divVerent. This will have many uses in the code too. Currently, it uses a new function to set / update the skeleton, which also returns the total number of bones --- diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 57e653113..5c9eaf0e1 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -2212,3 +2212,19 @@ float ReadApproxPastTime() return servertime - dt; } #endif + +#ifndef MENUQC +.float skeletonmodelindex; // used to check if model has changed +float Update_Skeleton(entity e) +{ + // updates the skeleton if needed, and returns the total number of bones + if(e.skeletonmodelindex != e.modelindex) + { + if(e.skeletonindex) + skel_delete(e.skeletonindex); + e.skeletonindex = skel_create(e.modelindex); + e.skeletonmodelindex = e.modelindex; + } + return skel_get_numbones(e.skeletonindex); +} +#endif diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 046c32fc1..d8400a3dc 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -292,10 +292,9 @@ float InterpretBoolean(string input); void Shutdown(); #ifndef MENUQC -// returns the total number of tags on model v -#define TOTAL_TAGS(v) skel_get_numbones(skel_create(v.modelindex)); skel_delete(v.modelindex) +float Update_Skeleton(entity e); // loops through the tags of model v using counter tagnum -#define FOR_EACH_TAG(v) float tagnum, totaltags; totaltags = TOTAL_TAGS(v); for(tagnum = 0; tagnum < totaltags; tagnum++, gettaginfo(v, tagnum)) +#define FOR_EACH_TAG(v) float tagnum, tags; tags = Update_Skeleton(v); for(tagnum = 0; tagnum < tags; tagnum++, gettaginfo(v, tagnum)) #endif #ifdef SVQC void WriteApproxPastTime(float dst, float t);