]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Attempt to cache the skeleton for each model, as requested by divVerent. This will...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 14 Jan 2012 14:29:10 +0000 (16:29 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 14 Jan 2012 14:29:10 +0000 (16:29 +0200)
qcsrc/common/util.qc
qcsrc/common/util.qh

index 57e653113235c27ac3babe72102a286a1c249366..5c9eaf0e1fed43de6f04f96806af6d8e9e2f101c 100644 (file)
@@ -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
index 046c32fc1c117d8a10ab5d055958b23517c1043a..d8400a3dc52d662a8e0e600d1eb996ade5b3ac52 100644 (file)
@@ -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);