X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FSkeleton.cpp;h=b951830f5e317a4d99212bb873ff2d859f3eb651;hb=cd043e3f9e26c2b3406b40a354c2840941e9db7f;hp=11d7fa9d339b8cff6fca078c36e45be412ccd482;hpb=1eec4500c708d0619abf36759454f59fa175cacf;p=lugaru.git diff --git a/Source/Skeleton.cpp b/Source/Skeleton.cpp index 11d7fa9..b951830 100644 --- a/Source/Skeleton.cpp +++ b/Source/Skeleton.cpp @@ -3,20 +3,18 @@ Copyright (C) 2003, 2010 - Wolfire Games This file is part of Lugaru. -Lugaru is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. +Lugaru is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. -This program is distributed in the hope that it will be useful, +Lugaru is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +along with Lugaru. If not, see . */ /**> HEADER FILES <**/ @@ -45,13 +43,6 @@ extern int whichjointendarray[26]; extern bool visibleloading; -/* convenience functions - */ -Joint& Skeleton::joint(int bodypart) { return joints[jointlabels[bodypart]]; } -XYZ& Skeleton::jointPos(int bodypart) { return joint(bodypart).position; } -XYZ& Skeleton::jointVel(int bodypart) { return joint(bodypart).velocity; } - - /* EFFECT */ void dealloc2(void* param) @@ -192,7 +183,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) XYZ bounceness; const int numrepeats = 3; float groundlevel = .15; - int i, j, k, l, m; + int i, j, k, m; XYZ temp; XYZ terrainnormal; int whichhit; @@ -217,17 +208,20 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) joints[i].position = joints[i].position + joints[i].velocity * multiplier; switch (joints[i].label) { - case head: - groundlevel = .8; break; - case righthand: - case rightwrist: - case rightelbow: - case lefthand: - case leftwrist: - case leftelbow: - groundlevel = .2; break; - default: - groundlevel = .15; break; + case head: + groundlevel = .8; + break; + case righthand: + case rightwrist: + case rightelbow: + case lefthand: + case leftwrist: + case leftelbow: + groundlevel = .2; + break; + default: + groundlevel = .15; + break; } joints[i].position.y -= groundlevel; @@ -347,7 +341,10 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) if (tutoriallevel != 1 || id == 0) if (findLengthfast(&bounceness) > 8000 && breaking) { - objects.model[k].MakeDecal(breakdecal, DoRotation(temp - objects.position[k], 0, -objects.yaw[k], 0), .4, .5, Random() % 360); + // FIXME: this crashes because k is not initialized! + // to reproduce, type 'wolfie' in console and play a while + // I'll just comment it out for now + //objects.model[k].MakeDecal(breakdecal, DoRotation(temp - objects.position[k], 0, -objects.yaw[k], 0), .4, .5, Random() % 360); Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, 1, 1, 1, 4, .2); breaking = false; camerashake += .6; @@ -509,17 +506,20 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) for (i = 0; i < num_joints; i++) { switch (joints[i].label) { - case head: - groundlevel = .8; break; - case righthand: - case rightwrist: - case rightelbow: - case lefthand: - case leftwrist: - case leftelbow: - groundlevel = .2; break; - default: - groundlevel = .15; break; + case head: + groundlevel = .8; + break; + case righthand: + case rightwrist: + case rightelbow: + case lefthand: + case leftwrist: + case leftelbow: + groundlevel = .2; + break; + default: + groundlevel = .15; + break; } joints[i].position.y += groundlevel; joints[i].mass = 1; @@ -597,34 +597,39 @@ void Skeleton::FindRotationMuscle(int which, int animation) const int label1 = muscles[which].parent1->label; const int label2 = muscles[which].parent2->label; switch (label1) { - case head: - fwd = specialforward[0]; break; - case rightshoulder: - case rightelbow: - case rightwrist: - case righthand: - fwd = specialforward[1]; break; - case leftshoulder: - case leftelbow: - case leftwrist: - case lefthand: - fwd = specialforward[2]; break; - case righthip: - case rightknee: - case rightankle: - case rightfoot: - fwd = specialforward[3]; break; - case lefthip: - case leftknee: - case leftankle: - case leftfoot: - fwd = specialforward[4]; break; - default: - if (muscles[which].parent1->lower) - fwd = lowforward; - else - fwd = forward; - break; + case head: + fwd = specialforward[0]; + break; + case rightshoulder: + case rightelbow: + case rightwrist: + case righthand: + fwd = specialforward[1]; + break; + case leftshoulder: + case leftelbow: + case leftwrist: + case lefthand: + fwd = specialforward[2]; + break; + case righthip: + case rightknee: + case rightankle: + case rightfoot: + fwd = specialforward[3]; + break; + case lefthip: + case leftknee: + case leftankle: + case leftfoot: + fwd = specialforward[4]; + break; + default: + if (muscles[which].parent1->lower) + fwd = lowforward; + else + fwd = forward; + break; } if (animation == hanganim) { @@ -827,16 +832,11 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c int parentID; FILE *tfile; float lSize; - int i, j, tempmuscle; - - int newload; + int i, j; int edit; LOGFUNC; - - newload = 0; - num_models = 7; // load various models @@ -927,7 +927,6 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c } // read num_muscles - tempmuscle = num_muscles; funpackf(tfile, "Bi", &num_muscles); // allocate memory @@ -936,12 +935,9 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c delete [] muscles; //dealloc2(muscles); muscles = (Muscle*)new Muscle[num_muscles]; //malloc(sizeof(Muscle)*num_muscles); - newload = 1; - - // for each muscle... + // for each muscle... for (i = 0; i < num_muscles; i++) { // read info - tempmuscle = muscles[i].numvertices; funpackf(tfile, "Bf Bf Bf Bf Bf Bi Bi", &muscles[i].length, &muscles[i].targetlength, &muscles[i].minlength, &muscles[i].maxlength, &muscles[i].strength, &muscles[i].type, &muscles[i].numvertices); // allocate memory for vertices @@ -1064,7 +1060,6 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c fseek(tfile, lSize, SEEK_CUR); // read numverticeslow - tempmuscle = muscles[i].numverticeslow; funpackf(tfile, "Bi", &muscles[i].numverticeslow); if (muscles[i].numverticeslow) { @@ -1178,7 +1173,6 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c fseek(tfile, lSize, SEEK_CUR); // read numverticesclothes - tempmuscle = muscles[i].numverticesclothes; funpackf(tfile, "Bi", &muscles[i].numverticesclothes); // read verticesclothes @@ -1340,24 +1334,24 @@ Skeleton::Skeleton() selected = 0; memset(forwardjoints, 0, sizeof(forwardjoints)); - // XYZ forward; + // XYZ forward; id = 0; memset(lowforwardjoints, 0, sizeof(lowforwardjoints)); - // XYZ lowforward; + // XYZ lowforward; - // XYZ specialforward[5]; + // XYZ specialforward[5]; memset(jointlabels, 0, sizeof(jointlabels)); - // Model model[7]; - // Model modellow; - // Model modelclothes; + // Model model[7]; + // Model modellow; + // Model modelclothes; num_models = 0; - // Model drawmodel; - // Model drawmodellow; - // Model drawmodelclothes; + // Model drawmodel; + // Model drawmodellow; + // Model drawmodelclothes; clothes = 0; spinny = 0;