]> git.jsancho.org Git - lugaru.git/commitdiff
Replaced muscles and joints in Skeleton by vectors
authorCôme Chilliet <come@chilliet.eu>
Fri, 9 Dec 2016 17:15:46 +0000 (00:15 +0700)
committerCôme Chilliet <come@chilliet.eu>
Fri, 9 Dec 2016 17:15:46 +0000 (00:15 +0700)
Source/Animation/Joint.cpp
Source/Animation/Joint.h
Source/Animation/Muscle.cpp
Source/Animation/Muscle.h
Source/Animation/Skeleton.cpp
Source/Animation/Skeleton.h
Source/GameDraw.cpp
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Person.cpp

index 760e49b2cde1fd1d381079afc999baf56b6653cb..96f94c97ac6d5a03546017cd8ff63e54cd0ed1b6 100644 (file)
@@ -19,6 +19,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "Animation/Joint.h"
+#include "binio.h"
 
 Joint::Joint() :
     blurred(0),
@@ -36,3 +37,22 @@ Joint::Joint() :
     delay(0)
 {
 }
+
+void Joint::load(FILE* tfile, std::vector<Joint>& joints)
+{
+    int parentID;
+
+    funpackf(tfile, "Bf Bf Bf Bf Bf", &position.x, &position.y, &position.z, &length, &mass);
+    funpackf(tfile, "Bb Bb", &hasparent, &locked);
+    funpackf(tfile, "Bi", &modelnum);
+    funpackf(tfile, "Bb Bb", &visible, &sametwist);
+    funpackf(tfile, "Bi Bi", &label, &hasgun);
+    funpackf(tfile, "Bb", &lower);
+    funpackf(tfile, "Bi", &parentID);
+    if (hasparent) {
+        parent = &joints[parentID];
+    }
+    velocity = 0;
+    oldposition = position;
+    startpos = position;
+}
index 9073e7af081ae41109194effd016e91ac1b49f42..764b095de9ff44d69c7ef48f89f2b45be573c89d 100644 (file)
@@ -22,6 +22,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #define _JOINT_H_
 
 #include "Quaternions.h"
+#include <vector>
 
 class Joint
 {
@@ -48,6 +49,7 @@ public:
     XYZ velchange;
 
     Joint();
+    void load(FILE* tfile, std::vector<Joint>& joints);
 };
 
 #endif
index 1e7f0d5e171e8bd3f71ce6d68822ba093de9f87d..627b8e067eda4eea98d889251dee78dd9227a301 100644 (file)
@@ -46,7 +46,7 @@ Muscle::~Muscle()
 {
 }
 
-void Muscle::load(FILE* tfile, int vertexNum, Joint* joints)
+void Muscle::load(FILE* tfile, int vertexNum, std::vector<Joint>& joints)
 {
     int numvertices, vertice, parentID;
 
index 5f51161af3926f9895732be2bb1f8c0711ba618c..3a080ba28eff41fbfa9e56d923cc7cd025e9b733 100644 (file)
@@ -49,7 +49,7 @@ public:
 
     Muscle();
     ~Muscle();
-    void load(FILE* tfile, int vertexNum, Joint* joints);
+    void load(FILE* tfile, int vertexNum, std::vector<Joint>& joints);
     void loadVerticesLow(FILE* tfile, int vertexNum);
     void loadVerticesClothes(FILE* tfile, int vertexNum);
     void DoConstraint(bool spinny);
index 065b28ef14cc6c983a2f8ae4761ecff5cb8326b5..607be81689c4c3b787229d0c8829692af5248c18 100644 (file)
@@ -42,10 +42,6 @@ extern bool visibleloading;
 
 Skeleton::Skeleton()
 {
-    num_joints = 0;
-
-    num_muscles = 0;
-
     selected = 0;
 
     memset(forwardjoints, 0, sizeof(forwardjoints));
@@ -73,22 +69,10 @@ Skeleton::Skeleton()
     oldfree = 0;
     freetime = 0;
     freefall = 0;
-
-    joints = 0;
-    muscles = 0;
 }
 
 Skeleton::~Skeleton()
 {
-    if (muscles) {
-        delete [] muscles;
-    }
-    muscles = 0;
-
-    if (joints) {
-        delete [] joints;
-    }
-    joints = 0;
 }
 
 /* EFFECT
@@ -166,7 +150,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
         objects.SphereCheckPossible(&terrainlight, 1);
 
         //Add velocity
-        for (i = 0; i < num_joints; i++) {
+        for (i = 0; i < joints.size(); i++) {
             joints[i].position = joints[i].position + joints[i].velocity * multiplier;
 
             switch (joints[i].label) {
@@ -241,14 +225,14 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
                 }
             }
 
-            for (i = 0; i < num_joints; i++) {
+            for (i = 0; i < joints.size(); i++) {
                 if (joints[i].locked && !spinny && findLengthfast(&joints[i].velocity) > 320)
                     joints[i].locked = 0;
                 if (spinny && findLengthfast(&joints[i].velocity) > 600)
                     joints[i].locked = 0;
                 if (joints[i].delay > 0) {
                     bool freely = true;
-                    for (j = 0; j < num_joints; j++) {
+                    for (j = 0; j < joints.size(); j++) {
                         if (joints[j].locked)
                             freely = false;
                     }
@@ -257,13 +241,12 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
                 }
             }
 
-            if (num_muscles)
-                for (i = 0; i < num_muscles; i++) {
-                    //Length constraints
-                    muscles[i].DoConstraint(spinny);
-                }
+            for (i = 0; i < muscles.size(); i++) {
+                //Length constraints
+                muscles[i].DoConstraint(spinny);
+            }
 
-            for (i = 0; i < num_joints; i++) {
+            for (i = 0; i < joints.size(); i++) {
                 //Length constraints
                 //Ground constraint
                 groundlevel = 0;
@@ -451,7 +434,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
                         whichhit = objects.model[k].LineCheckSlidePossible(&start, &end, &temp, &objects.position[k], &objects.yaw[k]);
                         if (whichhit != -1) {
                             joints[jointlabels[whichjointendarray[i]]].position = (end - *coords) / (*scale);
-                            for (j = 0; j < num_muscles; j++) {
+                            for (j = 0; j < muscles.size(); j++) {
                                 if ((muscles[j].parent1->label == whichjointstartarray[i] && muscles[j].parent2->label == whichjointendarray[i]) || (muscles[j].parent2->label == whichjointstartarray[i] && muscles[j].parent1->label == whichjointendarray[i]))
                                     muscles[j].DoConstraint(spinny);
                             }
@@ -460,7 +443,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
                 }
             }
 
-        for (i = 0; i < num_joints; i++) {
+        for (i = 0; i < joints.size(); i++) {
             switch (joints[i].label) {
             case head:
                 groundlevel = .8;
@@ -490,7 +473,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
     }
 
     if (!free) {
-        for (i = 0; i < num_muscles; i++) {
+        for (i = 0; i < muscles.size(); i++) {
             if (muscles[i].type == boneconnect)
                 muscles[i].DoConstraint(0);
         }
@@ -508,7 +491,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
 void Skeleton::DoGravity(float *scale)
 {
     static int i;
-    for (i = 0; i < num_joints; i++) {
+    for (i = 0; i < joints.size(); i++) {
         if (
                 (
                     ((joints[i].label != leftknee) && (joints[i].label != rightknee)) ||
@@ -644,11 +627,9 @@ void Skeleton::Load(const std::string& filename,       const std::string& lowfil
                     const std::string& modelclothesfilename, bool clothes)
 {
     GLfloat M[16];
-    int parentID;
     FILE *tfile;
     float lSize;
-    int i, j;
-    int edit;
+    int i, j, num_joints, num_muscles;
 
     LOGFUNC;
 
@@ -719,34 +700,18 @@ void Skeleton::Load(const std::string& filename,       const std::string& lowfil
     // read num_joints
     funpackf(tfile, "Bi", &num_joints);
 
-    // allocate memory
-    if (joints)
-        delete [] joints; //dealloc2(joints);
-    joints = (Joint*)new Joint[num_joints];
+    joints.resize(num_joints);
 
     // read info for each joint
     for (i = 0; i < num_joints; i++) {
-        funpackf(tfile, "Bf Bf Bf Bf Bf", &joints[i].position.x, &joints[i].position.y, &joints[i].position.z, &joints[i].length, &joints[i].mass);
-        funpackf(tfile, "Bb Bb", &joints[i].hasparent, &joints[i].locked);
-        funpackf(tfile, "Bi", &joints[i].modelnum);
-        funpackf(tfile, "Bb Bb", &joints[i].visible, &joints[i].sametwist);
-        funpackf(tfile, "Bi Bi", &joints[i].label, &joints[i].hasgun);
-        funpackf(tfile, "Bb", &joints[i].lower);
-        funpackf(tfile, "Bi", &parentID);
-        if (joints[i].hasparent)
-            joints[i].parent = &joints[parentID];
-        joints[i].velocity = 0;
-        joints[i].oldposition = joints[i].position;
-        joints[i].startpos = joints[i].position;
+        joints[i].load(tfile, joints);
     }
 
     // read num_muscles
     funpackf(tfile, "Bi", &num_muscles);
 
     // allocate memory
-    if (muscles)
-        delete [] muscles; //dealloc2(muscles);
-    muscles = (Muscle*)new Muscle[num_muscles]; //malloc(sizeof(Muscle)*num_muscles);
+    muscles.resize(num_muscles);
 
     // for each muscle...
     for (i = 0; i < num_muscles; i++) {
@@ -804,8 +769,7 @@ void Skeleton::Load(const std::string& filename,       const std::string& lowfil
 
     // skip joints section
 
-    lSize = sizeof(num_joints);
-    fseek(tfile, lSize, SEEK_CUR);
+    fseek(tfile, sizeof(num_joints), SEEK_CUR);
     for (i = 0; i < num_joints; i++) {
         // skip joint info
         lSize = sizeof(XYZ)
@@ -823,8 +787,8 @@ void Skeleton::Load(const std::string& filename,       const std::string& lowfil
         fseek(tfile, lSize, SEEK_CUR);
     }
 
-    // read num_muscles
-    funpackf(tfile, "Bi", &num_muscles);
+    // skip num_muscles
+    fseek(tfile, sizeof(num_muscles), SEEK_CUR);
 
     for (i = 0; i < num_muscles; i++) {
         // skip muscle info
@@ -878,8 +842,7 @@ void Skeleton::Load(const std::string& filename,       const std::string& lowfil
         tfile = Folders::openMandatoryFile( Folders::getResourcePath(clothesfilename), "rb" );
 
         // skip num_joints
-        lSize = sizeof(num_joints);
-        fseek ( tfile, lSize, SEEK_CUR);
+        fseek(tfile, sizeof(num_joints), SEEK_CUR);
 
         for (i = 0; i < num_joints; i++) {
             // skip joint info
@@ -898,8 +861,8 @@ void Skeleton::Load(const std::string& filename,       const std::string& lowfil
             fseek(tfile, lSize, SEEK_CUR);
         }
 
-        // read num_muscles
-        funpackf(tfile, "Bi", &num_muscles);
+        // skip num_muscles
+        fseek(tfile, sizeof(num_muscles), SEEK_CUR);
 
         for (i = 0; i < num_muscles; i++) {
             // skip muscle info
@@ -960,302 +923,3 @@ void Skeleton::Load(const std::string& filename,       const std::string& lowfil
 
     free = 0;
 }
-
-#if 0
-
-// the following functions are not used anywhere
-
-/* EFFECT
- * sets forward, lowforward, specialforward[]
- *
- * USES:
- * NONE
- */
-void Skeleton::FindForwardsfirst()
-{
-    //Find forward vectors
-    CrossProduct(joints[forwardjoints[1]].position - joints[forwardjoints[0]].position, joints[forwardjoints[2]].position - joints[forwardjoints[0]].position, &forward);
-    Normalise(&forward);
-
-    CrossProduct(joints[lowforwardjoints[1]].position - joints[lowforwardjoints[0]].position, joints[lowforwardjoints[2]].position - joints[lowforwardjoints[0]].position, &lowforward);
-    Normalise(&lowforward);
-
-    //Special forwards
-    specialforward[0] = forward;
-    specialforward[1] = forward;
-    specialforward[2] = forward;
-    specialforward[3] = forward;
-    specialforward[4] = forward;
-
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::Draw(int muscleview)
-{
-    static float jointcolor[4];
-
-    if (muscleview == 2) {
-        jointcolor[0] = 0;
-        jointcolor[1] = 0;
-        jointcolor[2] = 0;
-        jointcolor[3] = .5;
-    } else {
-        jointcolor[0] = 0;
-        jointcolor[1] = 0;
-        jointcolor[2] = .5;
-        jointcolor[3] = 1;
-    }
-
-    //Calc motionblur-ness
-    for (int i = 0; i < num_joints; i++) {
-        joints[i].oldposition = joints[i].position;
-        joints[i].blurred = findDistance(&joints[i].position, &joints[i].oldposition) * 100;
-        if (joints[i].blurred < 1)
-            joints[i].blurred = 1;
-    }
-
-    //Do Motionblur
-    glDepthMask(0);
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glBegin(GL_QUADS);
-    for (int i = 0; i < num_joints; i++) {
-        if (joints[i].hasparent) {
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].blurred);
-            glVertex3f(joints[i].position.x, joints[i].position.y, joints[i].position.z);
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].parent->blurred);
-            glVertex3f(joints[i].parent->position.x, joints[i].parent->position.y, joints[i].parent->position.z);
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].parent->blurred);
-            glVertex3f(joints[i].parent->oldposition.x, joints[i].parent->oldposition.y, joints[i].parent->oldposition.z);
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].blurred);
-            glVertex3f(joints[i].oldposition.x, joints[i].oldposition.y, joints[i].oldposition.z);
-        }
-    }
-    for (int i = 0; i < num_muscles; i++) {
-        if (muscles[i].type == boneconnect) {
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent2->blurred);
-            glVertex3f(muscles[i].parent1->position.x, muscles[i].parent1->position.y, muscles[i].parent1->position.z);
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent2->blurred);
-            glVertex3f(muscles[i].parent2->position.x, muscles[i].parent2->position.y, muscles[i].parent2->position.z);
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent2->blurred);
-            glVertex3f(muscles[i].parent2->oldposition.x, muscles[i].parent2->oldposition.y, muscles[i].parent2->oldposition.z);
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent1->blurred);
-            glVertex3f(muscles[i].parent1->oldposition.x, muscles[i].parent1->oldposition.y, muscles[i].parent1->oldposition.z);
-        }
-    }
-    glEnd();
-
-    glBegin(GL_LINES);
-    for (int i = 0; i < num_joints; i++) {
-        if (joints[i].hasparent) {
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].blurred);
-            glVertex3f(joints[i].position.x, joints[i].position.y, joints[i].position.z);
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / joints[i].parent->blurred);
-            glVertex3f(joints[i].parent->position.x, joints[i].parent->position.y, joints[i].parent->position.z);
-        }
-    }
-    for (int i = 0; i < num_muscles; i++) {
-        if (muscles[i].type == boneconnect) {
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent1->blurred);
-            glVertex3f(muscles[i].parent1->position.x, muscles[i].parent1->position.y, muscles[i].parent1->position.z);
-            glColor4f(jointcolor[0], jointcolor[1], jointcolor[2], jointcolor[3] / muscles[i].parent2->blurred);
-            glVertex3f(muscles[i].parent2->position.x, muscles[i].parent2->position.y, muscles[i].parent2->position.z);
-        }
-    }
-    glColor3f(.6, .6, 0);
-    if (muscleview == 1)
-        for (int i = 0; i < num_muscles; i++) {
-            if (muscles[i].type != boneconnect) {
-                glVertex3f(muscles[i].parent1->position.x, muscles[i].parent1->position.y, muscles[i].parent1->position.z);
-                glVertex3f(muscles[i].parent2->position.x, muscles[i].parent2->position.y, muscles[i].parent2->position.z);
-            }
-        }
-    glEnd();
-
-    if (muscleview != 2) {
-        glPointSize(3);
-        glBegin(GL_POINTS);
-        for (int i = 0; i < num_joints; i++) {
-            if (i != selected)
-                glColor4f(0, 0, .5, 1);
-            if (i == selected)
-                glColor4f(1, 1, 0, 1);
-            if (joints[i].locked && i != selected)
-                glColor4f(1, 0, 0, 1);
-            glVertex3f(joints[i].position.x, joints[i].position.y, joints[i].position.z);
-        }
-        glEnd();
-    }
-
-    //Set old position to current position
-    if (muscleview == 2)
-        for (int i = 0; i < num_joints; i++) {
-            joints[i].oldposition = joints[i].position;
-        }
-    glDepthMask(1);
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::AddJoint(float x, float y, float z, int which)
-{
-    if (num_joints < max_joints - 1) {
-        joints[num_joints].velocity = 0;
-        joints[num_joints].position.x = x;
-        joints[num_joints].position.y = y;
-        joints[num_joints].position.z = z;
-        joints[num_joints].mass = 1;
-        joints[num_joints].locked = 0;
-
-        joints[num_joints].hasparent = 0;
-        num_joints++;
-        if (which < num_joints && which >= 0)
-            AddMuscle(num_joints - 1, which, 0, 10, boneconnect);
-    }
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::DeleteJoint(int whichjoint)
-{
-    if (whichjoint < num_joints && whichjoint >= 0) {
-        joints[whichjoint].velocity = joints[num_joints - 1].velocity;
-        joints[whichjoint].position = joints[num_joints - 1].position;
-        joints[whichjoint].oldposition = joints[num_joints - 1].oldposition;
-        joints[whichjoint].hasparent = joints[num_joints - 1].hasparent;
-        joints[whichjoint].parent = joints[num_joints - 1].parent;
-        joints[whichjoint].length = joints[num_joints - 1].length;
-        joints[whichjoint].locked = joints[num_joints - 1].locked;
-        joints[whichjoint].modelnum = joints[num_joints - 1].modelnum;
-        joints[whichjoint].visible = joints[num_joints - 1].visible;
-
-        for (int i = 0; i < num_muscles; i++) {
-            while (muscles[i].parent1 == &joints[whichjoint] && i < num_muscles)DeleteMuscle(i);
-            while (muscles[i].parent2 == &joints[whichjoint] && i < num_muscles)DeleteMuscle(i);
-        }
-        for (int i = 0; i < num_muscles; i++) {
-            while (muscles[i].parent1 == &joints[num_joints - 1] && i < num_muscles)muscles[i].parent1 = &joints[whichjoint];
-            while (muscles[i].parent2 == &joints[num_joints - 1] && i < num_muscles)muscles[i].parent2 = &joints[whichjoint];
-        }
-        for (int i = 0; i < num_joints; i++) {
-            if (joints[i].parent == &joints[whichjoint])
-                joints[i].hasparent = 0;
-        }
-        for (int i = 0; i < num_joints; i++) {
-            if (joints[i].parent == &joints[num_joints - 1])
-                joints[i].parent = &joints[whichjoint];
-        }
-
-        num_joints--;
-    }
-}
-
-/* EFFECT
- *
- * USES:
- * Skeleton::DeleteJoint - UNUSED
- */
-void Skeleton::DeleteMuscle(int whichmuscle)
-{
-    if (whichmuscle < num_muscles) {
-        muscles[whichmuscle].minlength = muscles[num_muscles - 1].minlength;
-        muscles[whichmuscle].maxlength = muscles[num_muscles - 1].maxlength;
-        muscles[whichmuscle].strength = muscles[num_muscles - 1].strength;
-        muscles[whichmuscle].parent1 = muscles[num_muscles - 1].parent1;
-        muscles[whichmuscle].parent2 = muscles[num_muscles - 1].parent2;
-        muscles[whichmuscle].length = muscles[num_muscles - 1].length;
-        muscles[whichmuscle].visible = muscles[num_muscles - 1].visible;
-        muscles[whichmuscle].type = muscles[num_muscles - 1].type;
-        muscles[whichmuscle].targetlength = muscles[num_muscles - 1].targetlength;
-
-        num_muscles--;
-    }
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::SetJoint(float x, float y, float z, int which, int whichjoint)
-{
-    if (whichjoint < num_joints) {
-        joints[whichjoint].velocity = 0;
-        joints[whichjoint].position.x = x;
-        joints[whichjoint].position.y = y;
-        joints[whichjoint].position.z = z;
-
-        if (which >= num_joints || which < 0)
-            joints[whichjoint].hasparent = 0;
-        if (which < num_joints && which >= 0) {
-            joints[whichjoint].parent = &joints[which];
-            joints[whichjoint].hasparent = 1;
-            joints[whichjoint].length = findDistance(&joints[whichjoint].position, &joints[whichjoint].parent->position);
-        }
-    }
-}
-
-/* EFFECT
- *
- * USES:
- * Skeleton::AddJoint - UNUSED
- */
-void Skeleton::AddMuscle(int attach1, int attach2, float minlength, float maxlength, int type)
-{
-    const int max_muscles = 100; // FIXME: Probably can be dropped
-    if (num_muscles < max_muscles - 1 && attach1 < num_joints && attach1 >= 0 && attach2 < num_joints && attach2 >= 0 && attach1 != attach2) {
-        muscles[num_muscles].parent1 = &joints[attach1];
-        muscles[num_muscles].parent2 = &joints[attach2];
-        muscles[num_muscles].length = findDistance(&muscles[num_muscles].parent1->position, &muscles[num_muscles].parent2->position);
-        muscles[num_muscles].targetlength = findDistance(&muscles[num_muscles].parent1->position, &muscles[num_muscles].parent2->position);
-        muscles[num_muscles].strength = .7;
-        muscles[num_muscles].type = type;
-        muscles[num_muscles].minlength = minlength;
-        muscles[num_muscles].maxlength = maxlength;
-
-        num_muscles++;
-    }
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::MusclesSet()
-{
-    for (int i = 0; i < num_muscles; i++) {
-        muscles[i].length = findDistance(&muscles[i].parent1->position, &muscles[i].parent2->position);
-    }
-}
-
-/* EFFECT
- *
- * USES:
- * NONE
- */
-void Skeleton::DoBalance()
-{
-    /*XYZ newpoint;
-    newpoint=joints[0].position;
-    newpoint.x=(joints[2].position.x+joints[4].position.x)/2;
-    newpoint.z=(joints[2].position.z+joints[4].position.z)/2;
-    joints[0].velocity=joints[0].velocity+(newpoint-joints[0].position);
-    //Move child point to within certain distance of parent point
-    joints[0].position=newpoint;
-
-    MusclesSet();*/
-}
-
-#endif
-
index fe1ceb1106035bfc59f1bc9da76999152dd20ebe..f94b2417616577d210e46f3afa5b63ed7f38b6a3 100644 (file)
@@ -47,15 +47,9 @@ const int max_joints = 50;
 class Skeleton
 {
 public:
-    int num_joints;
-    //Joint joints[max_joints];
-    //Joint *joints;
-    Joint* joints;
-
-    int num_muscles;
-    //Muscle muscles[max_muscles];
-    //Muscle *muscles;
-    Muscle* muscles;
+    std::vector<Joint> joints;
+
+    std::vector<Muscle> muscles;
 
     int selected;
 
index d8cf5bcec0119eab9a4440c5bf65d11a184e0ba6..45d2873ef862092cfc4af50ff2c2b0d5b2f9a788 100644 (file)
@@ -311,7 +311,7 @@ int Game::DrawGLScene(StereoSide side)
         for (unsigned k = 0; k < Person::players.size(); k++) {
             if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
                 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y + Person::players[k]->scale * 3, Person::players[k]->coords.z, Person::players[k]->scale * 7) && Person::players[k]->occluded < 25)
-                    for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
+                    for (int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
                         if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin) {
                             point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
                             size = .4f;
@@ -336,7 +336,7 @@ int Game::DrawGLScene(StereoSide side)
                     }
             if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
                 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5) && Person::players[k]->occluded < 25)
-                    for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
+                    for (int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
                         if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin || Person::players[k]->skeleton.joints[i].label == leftelbow || Person::players[k]->skeleton.joints[i].label == rightelbow || Person::players[k]->skeleton.joints[i].label == neck) {
                             if (Person::players[k]->skeleton.free)
                                 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
@@ -422,7 +422,7 @@ int Game::DrawGLScene(StereoSide side)
                     if (distance >= 1)
                         glDisable(GL_BLEND);
                     if (distance >= .5) {
-                        checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
+                        checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
                         checkpoint.y += 1;
                         int i = -1;
                         if (Person::players[k]->occluded != 0)
@@ -487,7 +487,7 @@ int Game::DrawGLScene(StereoSide side)
                 if (distance >= 1)
                     glDisable(GL_BLEND);
                 if (distance >= .5) {
-                    checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
+                    checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
                     checkpoint.y += 1;
                     int i = -1;
                     if (Person::players[k]->occluded != 0)
index 705ae23154c4ef830bc2e2a000fcb7ef986e510c..b20c1966c963bb34ee91e6effefd169b7af55d72 100644 (file)
@@ -825,9 +825,9 @@ void Game::LoadStuff()
     XYZ moveamount;
     moveamount = 0;
     moveamount.z = 2;
-    // FIXME - Why this uses skeleton.num_joints and not Animation::numjoints? (are they equal?)
-    // It seems skeleton.num_joints is 0 at this point, so this is useless.
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+    // FIXME - Why this uses skeleton.joints.size() and not Animation::numjoints? (are they equal?)
+    // It seems skeleton.joints.size() is 0 at this point, so this is useless.
+    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
         for (j = 0; j < Animation::animations[knifesneakattackanim].frames.size(); j++) {
             Animation::animations[knifesneakattackanim].frames[j].joints[i].position += moveamount;
         }
@@ -835,7 +835,7 @@ void Game::LoadStuff()
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
         for (j = 0; j < Animation::animations[knifesneakattackedanim].frames.size(); j++) {
             Animation::animations[knifesneakattackedanim].frames[j].joints[i].position += moveamount;
         }
@@ -843,7 +843,7 @@ void Game::LoadStuff()
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
         Animation::animations[dead1anim].frames[1].joints[i].position = Animation::animations[dead1anim].frames[0].joints[i].position;
         Animation::animations[dead2anim].frames[1].joints[i].position = Animation::animations[dead2anim].frames[0].joints[i].position;
         Animation::animations[dead3anim].frames[1].joints[i].position = Animation::animations[dead3anim].frames[0].joints[i].position;
@@ -859,7 +859,7 @@ void Game::LoadStuff()
     Animation::animations[dead3anim].frames[1].speed = 0.001;
     Animation::animations[dead4anim].frames[1].speed = 0.001;
 
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
         for (j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) {
             Animation::animations[swordsneakattackanim].frames[j].joints[i].position += moveamount;
         }
@@ -871,7 +871,7 @@ void Game::LoadStuff()
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
         for (j = 0; j < Animation::animations[swordsneakattackedanim].frames.size(); j++) {
             Animation::animations[swordsneakattackedanim].frames[j].joints[i].position += moveamount;
         }
index 8ec62250fe9f871e7716958c9e8436b84d4b75bf..7ec218f4bf966239e056e9883b1e8b4256b8f555 100644 (file)
@@ -1309,7 +1309,7 @@ void doTutorial()
 
             emit_sound_at(fireendsound, Person::players[1]->coords);
 
-            for (int i = 0; i < Person::players[1]->skeleton.num_joints; i++) {
+            for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
                 if (Random() % 2 == 0) {
                     if (!Person::players[1]->skeleton.free)
                         temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
@@ -1579,7 +1579,7 @@ void doTutorial()
             XYZ temp, temp2;
             emit_sound_at(fireendsound, Person::players[1]->coords);
 
-            for (int i = 0; i < Person::players[1]->skeleton.num_joints; i++) {
+            for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
                 if (Random() % 2 == 0) {
                     if (!Person::players[1]->skeleton.free)
                         temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
@@ -1945,7 +1945,7 @@ void doDebugKeys()
                 XYZ headspurtdirection;
                 //int i = Person::players[closest]->skeleton.jointlabels[head];
                 Joint& headjoint = Person::players[closest]->joint(head);
-                for (int k = 0; k < Person::players[closest]->skeleton.num_joints; k++) {
+                for (int k = 0; k < Person::players[closest]->skeleton.joints.size(); k++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -1988,7 +1988,7 @@ void doDebugKeys()
                 emit_sound_at(splattersound, blah);
                 emit_sound_at(breaksound2, blah);
 
-                for (int i = 0; i < Person::players[closest]->skeleton.num_joints; i++) {
+                for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -2005,7 +2005,7 @@ void doDebugKeys()
                     Sprite::MakeSprite(cloudsprite, flatfacing2, flatvelocity2 * 0, .6, 0, 0, 1, .5);
                 }
 
-                for (int i = 0; i < Person::players[closest]->skeleton.num_joints; i++) {
+                for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -2021,7 +2021,7 @@ void doDebugKeys()
                     Sprite::MakeSprite(bloodsprite, flatfacing2, flatvelocity2, 1, 1, 1, .4, 1);
                 }
 
-                for (int i = 0; i < Person::players[closest]->skeleton.num_joints; i++) {
+                for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -2037,7 +2037,7 @@ void doDebugKeys()
                     Sprite::MakeSprite(bloodsprite, flatfacing2, flatvelocity2 * 2, 1, 1, 1, .4, 1);
                 }
 
-                for (int i = 0; i < Person::players[closest]->skeleton.num_joints; i++) {
+                for (int i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
                     if (!Person::players[closest]->skeleton.free)
                         flatvelocity2 = Person::players[closest]->velocity;
                     if (Person::players[closest]->skeleton.free)
@@ -2062,7 +2062,7 @@ void doDebugKeys()
                                 Person::players[j]->skeleton.free = 1;
                             Person::players[j]->skeleton.longdead = 0;
                             Person::players[j]->RagDoll(0);
-                            for (int i = 0; i < Person::players[j]->skeleton.num_joints; i++) {
+                            for (int i = 0; i < Person::players[j]->skeleton.joints.size(); i++) {
                                 temppos = Person::players[j]->skeleton.joints[i].position + Person::players[j]->coords;
                                 if (distsq(&temppos, &Person::players[closest]->coords) < 25) {
                                     flatvelocity2 = temppos - Person::players[closest]->coords;
@@ -3543,10 +3543,10 @@ void doPlayerCollisions()
                                                                                 }
                                                                                 Person::players[k]->DoDamage(findLengthfast(&rotatetarget) / 4);
 
-                                                                                for (int j = 0; j < Person::players[i]->skeleton.num_joints; j++) {
+                                                                                for (int j = 0; j < Person::players[i]->skeleton.joints.size(); j++) {
                                                                                     Person::players[i]->skeleton.joints[j].velocity = Person::players[i]->skeleton.joints[j].velocity / 5 + Person::players[k]->velocity;
                                                                                 }
-                                                                                for (int j = 0; j < Person::players[k]->skeleton.num_joints; j++) {
+                                                                                for (int j = 0; j < Person::players[k]->skeleton.joints.size(); j++) {
                                                                                     Person::players[k]->skeleton.joints[j].velocity = Person::players[k]->skeleton.joints[j].velocity / 5 + Person::players[i]->velocity;
                                                                                 }
 
@@ -6067,7 +6067,7 @@ void Game::Tick()
                                                                 Person::players[i]->victim->skeleton.free = 1;
                                                                 Person::players[i]->victim->skeleton.broken = 0;
 
-                                                                for (int l = 0; l < Person::players[i]->victim->skeleton.num_joints; l++) {
+                                                                for (int l = 0; l < Person::players[i]->victim->skeleton.joints.size(); l++) {
                                                                     Person::players[i]->victim->skeleton.joints[l].velchange = 0;
                                                                     Person::players[i]->victim->skeleton.joints[l].locked = 0;
                                                                 }
@@ -6694,7 +6694,7 @@ void Game::Tick()
                     if (distsq(&temp, &Person::players[1]->coords) >= distsq(&temp, &temp2) - 1 || distsq(&temp3, &Person::players[1]->coords) < 4) {
                         emit_sound_at(fireendsound, Person::players[1]->coords);
 
-                        for (int i = 0; i < Person::players[1]->skeleton.num_joints; i++) {
+                        for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
                             if (Random() % 2 == 0) {
                                 if (!Person::players[1]->skeleton.free)
                                     temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
@@ -6709,7 +6709,7 @@ void Game::Tick()
                         }
 
                         Person::players[1]->coords = (oldtemp + oldtemp2) / 2;
-                        for (int i = 0; i < Person::players[1]->skeleton.num_joints; i++) {
+                        for (int i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
                             Person::players[1]->skeleton.joints[i].velocity = 0;
                             if (Random() % 2 == 0) {
                                 if (!Person::players[1]->skeleton.free)
@@ -7112,7 +7112,7 @@ void Game::TickOnceAfter()
             target = Person::players[0]->oldcoords + Person::players[0]->currentoffset * (1 - Person::players[0]->target) * Person::players[0]->scale + Person::players[0]->targetoffset * Person::players[0]->target * Person::players[0]->scale - Person::players[0]->facing * .05;
         target.y += .1;
         if (Person::players[0]->skeleton.free) {
-            for (int i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
+            for (int i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
                 if (Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y > target.y)
                     target.y = Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y;
             }
index ca54e701c8e1810620727806eed305deaf3d2f78..f0b00193a059cedf58339f9857d904e1745238c7 100644 (file)
@@ -483,7 +483,7 @@ void Person::CheckKick()
         if (tutoriallevel != 1)
             emit_sound_at(heavyimpactsound, victim->coords);
         victim->RagDoll(0);
-        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
             victim->skeleton.joints[i].velocity += relative * 120 * damagemult;
         }
         victim->Puff(neck);
@@ -531,7 +531,7 @@ void Person::CatchFire()
     XYZ flatfacing, flatvelocity;
     int howmany;
     for (int i = 0; i < 10; i++) {
-        howmany = abs(Random() % (skeleton.num_joints));
+        howmany = abs(Random() % (skeleton.joints.size()));
         if (skeleton.free) {
             flatvelocity = skeleton.joints[howmany].velocity;
             flatfacing = skeleton.joints[howmany].position * scale + coords;
@@ -1531,7 +1531,7 @@ void Person::DoDamage(float howmuch)
     if (howmuch > damagetolerance * 50 && skeleton.free != 2) {
         XYZ flatvelocity2;
         XYZ flatfacing2;
-        for (int i = 0; i < skeleton.num_joints; i++) {
+        for (int i = 0; i < skeleton.joints.size(); i++) {
             if (skeleton.free) {
                 flatvelocity2 = skeleton.joints[i].velocity;
                 flatfacing2 = skeleton.joints[i].position * scale + coords;
@@ -1674,7 +1674,7 @@ void Person::DoHead()
 
         skeleton.specialforward[0] = facing;
         //skeleton.specialforward[0]=DoRotation(facing,0,yaw,0);
-        for (int i = 0; i < skeleton.num_muscles; i++) {
+        for (int i = 0; i < skeleton.muscles.size(); i++) {
             if (skeleton.muscles[i].visible && (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head)) {
                 skeleton.FindRotationMuscle(i, animTarget);
             }
@@ -1720,7 +1720,7 @@ void Person::RagDoll(bool checkcollision)
         if (!isnormal(tilt)) tilt = 0;
         if (!isnormal(tilt2)) tilt2 = 0;
 
-        for (int i = 0; i < skeleton.num_joints; i++) {
+        for (int i = 0; i < skeleton.joints.size(); i++) {
             skeleton.joints[i].delay = 0;
             skeleton.joints[i].locked = 0;
             skeleton.joints[i].position = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
@@ -1731,7 +1731,7 @@ void Person::RagDoll(bool checkcollision)
             skeleton.joints[i].realoldposition = skeleton.joints[i].position * scale + coords;
         }
 
-        for (int i = 0; i < skeleton.num_joints; i++) {
+        for (int i = 0; i < skeleton.joints.size(); i++) {
             skeleton.joints[i].velocity = 0;
             skeleton.joints[i].velchange = 0;
         }
@@ -1752,7 +1752,7 @@ void Person::RagDoll(bool checkcollision)
 
         speed *= speedmult;
 
-        for (int i = 0; i < skeleton.num_joints; i++) {
+        for (int i = 0; i < skeleton.joints.size(); i++) {
             if ((Animation::animations[animCurrent].attack != reversed || animCurrent == swordslashreversedanim) && animCurrent != rabbitkickanim && !isLanding() && !wasLanding() && Animation::animations[animCurrent].height == Animation::animations[animTarget].height)
                 skeleton.joints[i].velocity = velocity / scale + facing * 5 + DoRotation(DoRotation(DoRotation((targetFrame().joints[i].position - currentFrame().joints[i].position) * speed, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
             else
@@ -1761,13 +1761,13 @@ void Person::RagDoll(bool checkcollision)
             change.y = (float)(Random() % 100) / 100;
             change.z = (float)(Random() % 100) / 100;
             skeleton.joints[i].velocity += change;
-            skeleton.joints[abs(Random() % skeleton.num_joints)].velocity -= change;
+            skeleton.joints[abs(Random() % skeleton.joints.size())].velocity -= change;
 
             change.x = (float)(Random() % 100) / 100;
             change.y = (float)(Random() % 100) / 100;
             change.z = (float)(Random() % 100) / 100;
             skeleton.joints[i].velchange += change;
-            skeleton.joints[abs(Random() % skeleton.num_joints)].velchange -= change;
+            skeleton.joints[abs(Random() % skeleton.joints.size())].velchange -= change;
         }
 
         if (checkcollision) {
@@ -1777,13 +1777,13 @@ void Person::RagDoll(bool checkcollision)
             int howmany;
             average = 0;
             howmany = 0;
-            for (j = 0; j < skeleton.num_joints; j++) {
+            for (j = 0; j < skeleton.joints.size(); j++) {
                 average += skeleton.joints[j].position;
                 howmany++;
             }
             average /= howmany;
             coords += average * scale;
-            for (j = 0; j < skeleton.num_joints; j++) {
+            for (j = 0; j < skeleton.joints.size(); j++) {
                 skeleton.joints[j].position -= average;
             }
 
@@ -1805,10 +1805,10 @@ void Person::RagDoll(bool checkcollision)
         updatedelay = 0;
 
         velocity = 0;
-        for (int i = 0; i < skeleton.num_joints; i++) {
+        for (int i = 0; i < skeleton.joints.size(); i++) {
             velocity += skeleton.joints[i].velocity * scale;
         }
-        velocity /= skeleton.num_joints;
+        velocity /= skeleton.joints.size();
 
         // drop weapon
         if (Random() % 2 == 0) {
@@ -2193,7 +2193,7 @@ void Person::DoAnimations()
                                     victim->skeleton.free = 1;
                                     victim->skeleton.broken = 0;
 
-                                    for (int j = 0; j < victim->skeleton.num_joints; j++) {
+                                    for (int j = 0; j < victim->skeleton.joints.size(); j++) {
                                         victim->skeleton.joints[j].velchange = 0;
                                         victim->skeleton.joints[j].locked = 0;
                                     }
@@ -2355,7 +2355,7 @@ void Person::DoAnimations()
                         relative.y = 0;
                         Normalise(&relative);
                         relative = DoRotation(relative, 0, -90, 0);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 40;
                         }
                         victim->jointVel(head) += relative * damagemult * 200;
@@ -2390,7 +2390,7 @@ void Person::DoAnimations()
                         relative.y -= 1;
                         Normalise(&relative);
                         relative = DoRotation(relative, 0, 90, 0);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 20;
                         }
                         victim->jointVel(head) += relative * damagemult * 100;
@@ -2420,7 +2420,7 @@ void Person::DoAnimations()
                         relative.y = 0;
                         Normalise(&relative);
                         relative = DoRotation(relative, 0, -90, 0);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 40;
                         }
                         victim->jointVel(head) += relative * damagemult * 200;
@@ -2455,7 +2455,7 @@ void Person::DoAnimations()
                         relative.y = 0;
                         Normalise(&relative);
                         relative = DoRotation(relative, 0, 90, 0);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 40;
                         }
                         victim->jointVel(head) += relative * damagemult * 200;
@@ -2484,7 +2484,7 @@ void Person::DoAnimations()
                         relative = victim->coords - coords;
                         relative.y = 0;
                         Normalise(&relative);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 30;
                         }
                         victim->jointVel(head) += relative * damagemult * 100;
@@ -2505,7 +2505,7 @@ void Person::DoAnimations()
                         victim->skeleton.broken = 0;
                         victim->skeleton.spinny = 1;
 
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velchange = 0;
                             victim->skeleton.joints[i].delay = 0;
                             victim->skeleton.joints[i].locked = 0;
@@ -2516,7 +2516,7 @@ void Person::DoAnimations()
                         relative = 0;
                         relative.y = 1;
                         Normalise(&relative);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity.y = relative.y * 10;
                             victim->skeleton.joints[i].position.y += relative.y * .3;
                             victim->skeleton.joints[i].oldposition.y += relative.y * .3;
@@ -2539,7 +2539,7 @@ void Person::DoAnimations()
                         relative = victim->coords - coords;
                         relative.y = 0;
                         Normalise(&relative);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 90;
                         }
                         victim->Puff(abdomen);
@@ -2566,7 +2566,7 @@ void Person::DoAnimations()
                         victim->skeleton.broken = 0;
                         victim->skeleton.spinny = 1;
 
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velchange = 0;
                             //victim->skeleton.joints[i].delay=0;
                             victim->skeleton.joints[i].locked = 0;
@@ -2576,7 +2576,7 @@ void Person::DoAnimations()
                         Normalise(&relative);
                         relative.y += .3;
                         Normalise(&relative);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 20;
                         }
                         if (!victim->dead)
@@ -2662,7 +2662,7 @@ void Person::DoAnimations()
                                 victim->skeleton.free = 1;
                                 victim->skeleton.broken = 0;
 
-                                for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                                for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                     victim->skeleton.joints[i].velchange = 0;
                                     victim->skeleton.joints[i].locked = 0;
                                     //victim->skeleton.joints[i].velocity=0;
@@ -2752,7 +2752,7 @@ void Person::DoAnimations()
                                 victim->skeleton.free = 1;
                                 victim->skeleton.broken = 0;
 
-                                for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                                for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                     victim->skeleton.joints[i].velchange = 0;
                                     victim->skeleton.joints[i].locked = 0;
                                     //victim->skeleton.joints[i].velocity=0;
@@ -2799,7 +2799,7 @@ void Person::DoAnimations()
                         relative = victim->coords - coords;
                         relative.y = 0;
                         Normalise(&relative);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity = relative * 30;
                         }
                         victim->jointVel(head) += relative * damagemult * 150;
@@ -2846,7 +2846,7 @@ void Person::DoAnimations()
                         Normalise(&relative);
                         relative.y = .3;
                         Normalise(&relative);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity = relative * 5;
                         }
                         victim->jointVel(abdomen) += relative * damagemult * 400;
@@ -3073,7 +3073,7 @@ void Person::DoAnimations()
                         relative = DoRotation(relative, 0, 90, 0);
                         relative.y -= 1;
                         Normalise(&relative);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 60;
                         }
                         victim->jointVel(head) += relative * damagemult * 230;
@@ -3105,7 +3105,7 @@ void Person::DoAnimations()
                         relative.y = 0;
                         Normalise(&relative);
                         relative = DoRotation(relative, 0, -90, 0);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity += relative * damagemult * 40;
                         }
                         victim->jointVel(head) += relative * damagemult * 220;
@@ -3136,7 +3136,7 @@ void Person::DoAnimations()
                         victim->skeleton.free = 1;
                         victim->skeleton.broken = 0;
 
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velchange = 0;
                             victim->skeleton.joints[i].locked = 0;
                             //victim->skeleton.joints[i].velocity=0;
@@ -3148,13 +3148,13 @@ void Person::DoAnimations()
                         relative.y = -1;
                         Normalise(&relative);
                         if (!victim->dead) {
-                            for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                            for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                 victim->skeleton.joints[i].velocity = relative * damagemult * 40;
                             }
                             victim->jointVel(abdomen) += relative * damagemult * 40;
                         }
                         if (victim->dead) {
-                            for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                            for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                 victim->skeleton.joints[i].velocity = relative * damagemult * abs(Random() % 20);
                             }
                         }
@@ -3187,7 +3187,7 @@ void Person::DoAnimations()
                                 DoBlood(.2, 250);
                             }
                             victim->RagDoll(0);
-                            for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                            for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
                             }
                             victim->jointVel(head) += relative * damagemult * 200;
@@ -3206,7 +3206,7 @@ void Person::DoAnimations()
                         } else {
                             if (victim->damage >= victim->damagetolerance)
                                 victim->RagDoll(0);
-                            for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                            for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                 victim->skeleton.joints[i].velocity += relative * damagemult * 10;
                             }
                             victim->jointVel(abdomen) += relative * damagemult * 200;
@@ -3247,12 +3247,12 @@ void Person::DoAnimations()
                         if (Animation::animations[victim->animTarget].height == middleheight || Animation::animations[victim->animCurrent].height == middleheight || victim->damage >= victim->damagetolerance - 40) {
                             victim->RagDoll(0);
 
-                            for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                            for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                 victim->skeleton.joints[i].velocity += relative * damagemult * 15;
                             }
                             relative = DoRotation(relative, 0, -90, 0);
                             relative.y += .1;
-                            for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                            for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                 if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
                                     victim->skeleton.joints[i].velocity = relative * 80;
                             }
@@ -3262,11 +3262,11 @@ void Person::DoAnimations()
                         } else {
                             if (victim->damage >= victim->damagetolerance)
                                 victim->RagDoll(0);
-                            for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                            for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                 victim->skeleton.joints[i].velocity += relative * damagemult * 10;
                             }
                             relative = DoRotation(relative, 0, -90, 0);
-                            for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                            for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                                 if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
                                     victim->skeleton.joints[i].velocity += relative * damagemult * 80;
                             }
@@ -3309,7 +3309,7 @@ void Person::DoAnimations()
                     relative = victim->coords - oldcoords;
                     relative.y = 0;
                     Normalise(&relative);
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 40;
                     }
                     victim->jointVel(abdomen) += relative * damagemult * 200;
@@ -3346,7 +3346,7 @@ void Person::DoAnimations()
                     relative = victim->coords - oldcoords;
                     relative.y = 0;
                     Normalise(&relative);
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 30;
                     }
                     victim->jointVel(abdomen) += relative * damagemult * 200;
@@ -3375,7 +3375,7 @@ void Person::DoAnimations()
                     relative = victim->coords - oldcoords;
                     relative.y = 0;
                     Normalise(&relative);
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 30;
                     }
                     victim->jointVel(abdomen) += relative * damagemult * 200;
@@ -3391,7 +3391,7 @@ void Person::DoAnimations()
                     relative.y = 0;
                     Normalise(&relative);
                     relative.y -= .1;
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 70;
                     }
                     victim->jointVel(lefthand) *= .1;
@@ -3441,7 +3441,7 @@ void Person::DoAnimations()
                     relative.y = 0;
                     Normalise(&relative);
                     relative.y -= .1;
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 70;
                     }
                     victim->jointVel(lefthand) *= .1 - 1;
@@ -3473,7 +3473,7 @@ void Person::DoAnimations()
                     relative.y = 0;
                     Normalise(&relative);
                     relative = DoRotation(relative, 0, -90, 0);
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 40;
                     }
                     victim->jointVel(abdomen) += relative * damagemult * 200;
@@ -3493,7 +3493,7 @@ void Person::DoAnimations()
                     Normalise(&relative);
                     if (victim->id == 0)
                         relative /= 30;
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 40;
                     }
                     victim->damage = victim->damagetolerance;
@@ -3568,12 +3568,12 @@ void Person::DoAnimations()
                 if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
                     escapednum = 0;
                     victim->velocity = 0;
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity = 0;
                     }
                     if (animTarget == knifefollowanim) {
                         victim->RagDoll(0);
-                        for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                        for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                             victim->skeleton.joints[i].velocity = 0;
                         }
                     }
@@ -3626,7 +3626,7 @@ void Person::DoAnimations()
                 if (hasvictim && animTarget == swordsneakattackanim && Animation::animations[animTarget].frames[frameCurrent].label == 6) {
                     escapednum = 0;
                     victim->velocity = 0;
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity = 0;
                     }
                     if (weaponactive != -1) {
@@ -3694,7 +3694,7 @@ void Person::DoAnimations()
                     relative = DoRotation(relative, 0, 90, 0);
                     relative.y = .5;
                     Normalise(&relative);
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 20;
                     }
                     victim->jointVel(head) += relative * damagemult * 200;
@@ -3714,7 +3714,7 @@ void Person::DoAnimations()
                     relative = DoRotation(relative, 0, 90, 0);
                     relative.y = .5;
                     Normalise(&relative);
-                    for (int i = 0; i < victim->skeleton.num_joints; i++) {
+                    for (int i = 0; i < victim->skeleton.joints.size(); i++) {
                         victim->skeleton.joints[i].velocity += relative * damagemult * 20;
                     }
                     victim->jointVel(head) += relative * damagemult * 200;
@@ -4183,18 +4183,18 @@ void Person::DoAnimations()
             }
             if (animCurrent != oldanimCurrent || animTarget != oldanimTarget || ((frameCurrent != oldframeCurrent || frameTarget != oldframeTarget) && !calcrot)) {
                 //Old rotates
-                for (int i = 0; i < skeleton.num_joints; i++) {
+                for (int i = 0; i < skeleton.joints.size(); i++) {
                     skeleton.joints[i].position = currentFrame().joints[i].position;
                 }
 
                 skeleton.FindForwards();
 
-                for (int i = 0; i < skeleton.num_muscles; i++) {
+                for (int i = 0; i < skeleton.muscles.size(); i++) {
                     if (skeleton.muscles[i].visible) {
                         skeleton.FindRotationMuscle(i, animTarget);
                     }
                 }
-                for (int i = 0; i < skeleton.num_muscles; i++) {
+                for (int i = 0; i < skeleton.muscles.size(); i++) {
                     if (skeleton.muscles[i].visible) {
                         if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
                             skeleton.muscles[i].oldrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
@@ -4206,18 +4206,18 @@ void Person::DoAnimations()
                 }
 
                 //New rotates
-                for (int i = 0; i < skeleton.num_joints; i++) {
+                for (int i = 0; i < skeleton.joints.size(); i++) {
                     skeleton.joints[i].position = targetFrame().joints[i].position;
                 }
 
                 skeleton.FindForwards();
 
-                for (int i = 0; i < skeleton.num_muscles; i++) {
+                for (int i = 0; i < skeleton.muscles.size(); i++) {
                     if (skeleton.muscles[i].visible) {
                         skeleton.FindRotationMuscle(i, animTarget);
                     }
                 }
-                for (int i = 0; i < skeleton.num_muscles; i++) {
+                for (int i = 0; i < skeleton.muscles.size(); i++) {
                     if (skeleton.muscles[i].visible) {
                         if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
                             skeleton.muscles[i].newrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
@@ -4243,12 +4243,12 @@ void Person::DoAnimations()
             oldframeTarget = frameTarget;
             oldframeCurrent = frameCurrent;
 
-            for (int i = 0; i < skeleton.num_joints; i++) {
+            for (int i = 0; i < skeleton.joints.size(); i++) {
                 skeleton.joints[i].velocity = (currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target) - skeleton.joints[i].position) / multiplier;
                 skeleton.joints[i].position = currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target);
             }
             offset = currentoffset * (1 - target) + targetoffset * target;
-            for (int i = 0; i < skeleton.num_muscles; i++) {
+            for (int i = 0; i < skeleton.muscles.size(); i++) {
                 if (skeleton.muscles[i].visible) {
                     skeleton.muscles[i].rotate1 = skeleton.muscles[i].oldrotate1 * (1 - target) + skeleton.muscles[i].newrotate1 * (target);
                     skeleton.muscles[i].rotate2 = skeleton.muscles[i].oldrotate2 * (1 - target) + skeleton.muscles[i].newrotate2 * (target);
@@ -4380,7 +4380,7 @@ void Person::DoStuff()
     }
     while (flamedelay < 0 && onfire) {
         flamedelay += .006;
-        howmany = abs(Random() % (skeleton.num_joints));
+        howmany = abs(Random() % (skeleton.joints.size()));
         if (skeleton.free) {
             flatvelocity = skeleton.joints[howmany].velocity * scale / 2;
             flatfacing = skeleton.joints[howmany].position * scale + coords;
@@ -4393,7 +4393,7 @@ void Person::DoStuff()
 
     while (flamedelay < 0 && !onfire && tutoriallevel == 1 && id != 0) {
         flamedelay += .05;
-        howmany = abs(Random() % (skeleton.num_joints));
+        howmany = abs(Random() % (skeleton.joints.size()));
         if (skeleton.free) {
             flatvelocity = skeleton.joints[howmany].velocity * scale / 2;
             flatfacing = skeleton.joints[howmany].position * scale + coords;
@@ -4485,7 +4485,7 @@ void Person::DoStuff()
             }
             dead = 2;
             if (animTarget == knifefollowedanim && !skeleton.free) {
-                for (int i = 0; i < skeleton.num_joints; i++) {
+                for (int i = 0; i < skeleton.joints.size(); i++) {
                     skeleton.joints[i].velocity = 0;
                     skeleton.joints[i].velocity.y = -2;
                 }
@@ -4923,7 +4923,7 @@ void Person::DoStuff()
         dead = 0;
         skeleton.free = 1;
         damage -= 20;
-        for (int i = 0; i < skeleton.num_joints; i++) {
+        for (int i = 0; i < skeleton.joints.size(); i++) {
             skeleton.joints[i].velocity = 0;
         }
     }
@@ -4997,22 +4997,22 @@ void Person::DoStuff()
 
         average = 0;
         howmany = 0;
-        for (j = 0; j < skeleton.num_joints; j++) {
+        for (j = 0; j < skeleton.joints.size(); j++) {
             average += skeleton.joints[j].position;
             howmany++;
         }
         average /= howmany;
         coords += average * scale;
-        for (j = 0; j < skeleton.num_joints; j++) {
+        for (j = 0; j < skeleton.joints.size(); j++) {
             skeleton.joints[j].position -= average;
         }
         average /= multiplier;
 
         velocity = 0;
-        for (int i = 0; i < skeleton.num_joints; i++) {
+        for (int i = 0; i < skeleton.joints.size(); i++) {
             velocity += skeleton.joints[i].velocity * scale;
         }
-        velocity /= skeleton.num_joints;
+        velocity /= skeleton.joints.size();
 
         if (!isnormal(velocity.x) && velocity.x) {
             velocity = 0;
@@ -5123,7 +5123,7 @@ void Person::DoStuff()
                 frameCurrent = 0;
                 target = 0;
 
-                for (int i = 0; i < skeleton.num_joints; i++) {
+                for (int i = 0; i < skeleton.joints.size(); i++) {
                     tempanimation.frames[0].joints[i].position = skeleton.joints[i].position;
                     tempanimation.frames[0].joints[i].position = DoRotation(tempanimation.frames[0].joints[i].position, 0, -yaw, 0);
                 }
@@ -5214,7 +5214,7 @@ void Person::DoStuff()
                 if (middle.y > 0 && animTarget != rollanim)
                     targetoffset.y = middle.y + 1;
 
-                for (int i = 0; i < skeleton.num_joints; i++) {
+                for (int i = 0; i < skeleton.joints.size(); i++) {
                     tempanimation.frames[0].joints[i].position = skeleton.joints[i].position;
                     tempanimation.frames[0].joints[i].position = DoRotation(tempanimation.frames[0].joints[i].position, 0, -yaw, 0);
                 }
@@ -6101,7 +6101,7 @@ int Person::DrawSkeleton()
                 skeleton.drawmodelclothes.vertex[i] = 0;
                 skeleton.drawmodelclothes.vertex[i].y = 999;
             }
-            for (int i = 0; i < skeleton.num_muscles; i++) {
+            for (int i = 0; i < skeleton.muscles.size(); i++) {
                 // convenience renames
                 const int p1 = skeleton.muscles[i].parent1->label;
                 const int p2 = skeleton.muscles[i].parent2->label;
@@ -6446,12 +6446,12 @@ int Person::DrawSkeleton()
                 i = weaponids[k];
                 if (weaponactive == k) {
                     if (weapons[i].getType() != staff) {
-                        for (j = 0; j < skeleton.num_muscles; j++) {
+                        for (j = 0; j < skeleton.muscles.size(); j++) {
                             if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].vertices.size() > 0) {
                                 weaponattachmuscle = j;
                             }
                         }
-                        for (j = 0; j < skeleton.num_muscles; j++) {
+                        for (j = 0; j < skeleton.muscles.size(); j++) {
                             if ((skeleton.muscles[j].parent1->label == rightwrist || skeleton.muscles[j].parent2->label == rightwrist) && (skeleton.muscles[j].parent1->label != righthand && skeleton.muscles[j].parent2->label != righthand) && skeleton.muscles[j].vertices.size() > 0) {
                                 weaponrotatemuscle = j;
                             }
@@ -6461,12 +6461,12 @@ int Person::DrawSkeleton()
                             weaponpoint = (jointPos(rightwrist) * .7 + jointPos(righthand) * .3);
                     }
                     if (weapons[i].getType() == staff) {
-                        for (j = 0; j < skeleton.num_muscles; j++) {
+                        for (j = 0; j < skeleton.muscles.size(); j++) {
                             if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].vertices.size() > 0) {
                                 weaponattachmuscle = j;
                             }
                         }
-                        for (j = 0; j < skeleton.num_muscles; j++) {
+                        for (j = 0; j < skeleton.muscles.size(); j++) {
                             if ((skeleton.muscles[j].parent1->label == rightelbow || skeleton.muscles[j].parent2->label == rightelbow) && (skeleton.muscles[j].parent1->label != rightshoulder && skeleton.muscles[j].parent2->label != rightshoulder) && skeleton.muscles[j].vertices.size() > 0) {
                                 weaponrotatemuscle = j;
                             }
@@ -6490,7 +6490,7 @@ int Person::DrawSkeleton()
                         weaponpoint = jointPos(abdomen) + (jointPos(lefthip) - jointPos(righthip)) * .09 + (jointPos(leftshoulder) - jointPos(rightshoulder)) * .33;
                     if (weapons[i].getType() == staff)
                         weaponpoint = jointPos(abdomen) + (jointPos(lefthip) - jointPos(righthip)) * .09 + (jointPos(leftshoulder) - jointPos(rightshoulder)) * .33;
-                    for (j = 0; j < skeleton.num_muscles; j++) {
+                    for (j = 0; j < skeleton.muscles.size(); j++) {
                         if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].vertices.size() > 0) {
                             weaponrotatemuscle = j;
                         }
@@ -6501,7 +6501,7 @@ int Person::DrawSkeleton()
                         weaponpoint = jointPos(abdomen) * .5 + jointPos(neck) * .5 - skeleton.forward * .8;
                     else
                         weaponpoint = jointPos(abdomen) * .5 + jointPos(neck) * .5 + skeleton.forward * .8;
-                    for (j = 0; j < skeleton.num_muscles; j++) {
+                    for (j = 0; j < skeleton.muscles.size(); j++) {
                         if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].vertices.size() > 0) {
                             weaponrotatemuscle = j;
                         }