]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't keep the skeletal object around, but only check if the model index has changed
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 14 Jan 2012 15:00:49 +0000 (17:00 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 14 Jan 2012 15:00:49 +0000 (17:00 +0200)
qcsrc/common/util.qc
qcsrc/common/util.qh

index 534eca15c293359aae288018533e5e402b6f4c38..9e4bdf7e74c90fcb0df4f4fcf062bfee62d691ea 100644 (file)
@@ -2214,17 +2214,17 @@ float ReadApproxPastTime()
 #endif
 
 #ifndef MENUQC
-.float skeletonmodelindex; // used to check if the model has changed
-float Update_Skeleton(entity e)
-{
-       // updates the fake skeleton if needed, and returns the total number of bones
-       if(e.skeletonmodelindex != e.modelindex)
-       {
-               if(e.fake_skeletonindex)
-                       skel_delete(e.fake_skeletonindex);
-               e.fake_skeletonindex = skel_create(e.modelindex);
-               e.skeletonmodelindex = e.modelindex;
-       }
-       return skel_get_numbones(e.fake_skeletonindex);
+.float skeleton_bones_index;
+void Skeleton_SetBones(entity e)
+{
+       // set skeleton_bones to the total number of bones on the model
+       if(e.skeleton_bones_index == e.modelindex)
+               return; // same model, nothing to update
+
+       float skelindex;
+       skelindex = skel_create(e.modelindex);
+       e.skeleton_bones = skel_get_numbones(skelindex);
+       skel_delete(skelindex);
+       e.skeleton_bones_index = e.modelindex;
 }
 #endif
index cdaf27c73ebe9872b53bb0ad348fc57d1c934ca1..db075ec2a0576efc3cbec05f3b1a433d54fbebe8 100644 (file)
@@ -292,10 +292,10 @@ float InterpretBoolean(string input);
 void Shutdown();
 
 #ifndef MENUQC
-.float fake_skeletonindex; // maintains a fake skeleton for property checking without affecting the actual mesh
-float Update_Skeleton(entity e);
+.float skeleton_bones;
+void Skeleton_SetBones(entity e);
 // loops through the tags of model v using counter tagnum
-#define FOR_EACH_TAG(v) float tagnum, tags; tags = Update_Skeleton(v); for(tagnum = 0; tagnum < tags; tagnum++, gettaginfo(v, tagnum))
+#define FOR_EACH_TAG(v) float tagnum; Skeleton_SetBones(v); for(tagnum = 0; tagnum < v.skeleton_bones; tagnum++, gettaginfo(v, tagnum))
 #endif
 #ifdef SVQC
 void WriteApproxPastTime(float dst, float t);