X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FAnimation%2FMuscle.cpp;h=ab94d3c449caf7722bcebae2bbda8699ed751d81;hb=1198f8141fe7d5b04a936935c45af3217064b0d7;hp=1e7f0d5e171e8bd3f71ce6d68822ba093de9f87d;hpb=18e718d3ff51c67029f2d4e1416f979b9ad3afc0;p=lugaru.git diff --git a/Source/Animation/Muscle.cpp b/Source/Animation/Muscle.cpp index 1e7f0d5..ab94d3c 100644 --- a/Source/Animation/Muscle.cpp +++ b/Source/Animation/Muscle.cpp @@ -18,35 +18,41 @@ You should have received a copy of the GNU General Public License along with Lugaru. If not, see . */ -#include "Animation/Muscle.h" -#include "binio.h" +#include "Animation/Muscle.hpp" + +#include "Utils/binio.h" extern float multiplier; extern bool freeze; Muscle::Muscle() -{ - length = 0; - targetlength = 0; - parent1 = 0; - parent2 = 0; - maxlength = 0; - minlength = 0; - type = boneconnect; - visible = 0; - rotate1 = 0, rotate2 = 0, rotate3 = 0; - lastrotate1 = 0, lastrotate2 = 0, lastrotate3 = 0; - oldrotate1 = 0, oldrotate2 = 0, oldrotate3 = 0; - newrotate1 = 0, newrotate2 = 0, newrotate3 = 0; - - strength = 0; -} - -Muscle::~Muscle() + : length(0) + , targetlength(0) + , parent1(0) + , parent2(0) + , maxlength(0) + , minlength(0) + , type(boneconnect) + , visible(false) + , rotate1(0) + , rotate2(0) + , rotate3(0) + , lastrotate1(0) + , lastrotate2(0) + , lastrotate3(0) + , oldrotate1(0) + , oldrotate2(0) + , oldrotate3(0) + , newrotate1(0) + , newrotate2(0) + , newrotate3(0) + , + + strength(0) { } -void Muscle::load(FILE* tfile, int vertexNum, Joint* joints) +void Muscle::load(FILE* tfile, int vertexNum, std::vector& joints) { int numvertices, vertice, parentID; @@ -100,7 +106,6 @@ void Muscle::loadVerticesClothes(FILE* tfile, int vertexNum) } } - /* EFFECT * sets strength, length, * parent1->position, parent2->position, @@ -130,27 +135,34 @@ void Muscle::DoConstraint(bool spinny) } // clamp strength - if (strength < 0) + if (strength < 0) { strength = 0; - if (strength > 1) + } + if (strength > 1) { strength = 1; + } length -= (length - relaxlength) * (1 - strength) * multiplier * 10000; - length -= (length - targetlength) * (strength) * multiplier * 10000; - if (strength == 0) + length -= (length - targetlength) * strength * multiplier * 10000; + if (strength == 0) { length = relaxlength; + } - if ((relaxlength - length > 0 && relaxlength - oldlength < 0) || (relaxlength - length < 0 && relaxlength - oldlength > 0)) + if ((relaxlength - length > 0 && relaxlength - oldlength < 0) || (relaxlength - length < 0 && relaxlength - oldlength > 0)) { length = relaxlength; + } // clamp length - if (length < minlength) + if (length < minlength) { length = minlength; - if (length > maxlength) + } + if (length > maxlength) { length = maxlength; + } - if (length == relaxlength) + if (length == relaxlength) { return; + } // relax muscle?