X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FAnimation%2FSkeleton.cpp;h=8e5cb0c9a8e7336350703c1077fb983465f9c949;hb=cd451341c5ee01374268559885871ca9d454cbd0;hp=31f98860c8528fc05f82caad26144bda85a3e9e3;hpb=7d2f9d40d94d14a61ecdaaa2c41f964029815bc2;p=lugaru.git diff --git a/Source/Animation/Skeleton.cpp b/Source/Animation/Skeleton.cpp index 31f9886..8e5cb0c 100644 --- a/Source/Animation/Skeleton.cpp +++ b/Source/Animation/Skeleton.cpp @@ -24,6 +24,7 @@ along with Lugaru. If not, see . #include "Audio/openal_wrapper.hpp" #include "Game.hpp" #include "Utils/Folders.hpp" +#include "Tutorial.hpp" extern float multiplier; extern float gravity; @@ -32,13 +33,10 @@ extern int environment; extern float camerashake; extern bool freeze; extern int detail; -extern int tutoriallevel; extern int whichjointstartarray[26]; extern int whichjointendarray[26]; -extern bool visibleloading; - Skeleton::Skeleton() : selected(0), id(0), @@ -109,12 +107,11 @@ void Skeleton::FindForwards() */ float Skeleton::DoConstraints(XYZ *coords, float *scale) { - float friction = 1.5; const float elasticity = .3; XYZ bounceness; const int numrepeats = 3; float groundlevel = .15; - int k, m; + int m; unsigned i; XYZ temp; XYZ terrainnormal; @@ -232,6 +229,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) muscles[i].DoConstraint(spinny); } + float friction; for (i = 0; i < joints.size(); i++) { //Length constraints //Ground constraint @@ -242,7 +240,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) if (joints[i].label == groin && !joints[i].locked && joints[i].delay <= 0) { joints[i].locked = 1; joints[i].delay = 1; - if (tutoriallevel != 1 || id == 0) { + if (!Tutorial::active || id == 0) { emit_sound_at(landsound1, joints[i].position * (*scale) + *coords, 128.); } breaking = true; @@ -251,7 +249,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) if (joints[i].label == head && !joints[i].locked && joints[i].delay <= 0) { joints[i].locked = 1; joints[i].delay = 1; - if (tutoriallevel != 1 || id == 0) { + if (!Tutorial::active || id == 0) { emit_sound_at(landsound2, joints[i].position * (*scale) + *coords, 128.); } } @@ -270,7 +268,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) else joints[i].velocity = 0; - if (tutoriallevel != 1 || id == 0) + if (!Tutorial::active || id == 0) if (findLengthfast(&bounceness) > 8000 && breaking) { // FIXME: this crashes because k is not initialized! // to reproduce, type 'wolfie' in console and play a while @@ -325,8 +323,8 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) } if (terrain.patchobjectnum[whichpatchx][whichpatchz]) for (m = 0; m < terrain.patchobjectnum[whichpatchx][whichpatchz]; m++) { - k = terrain.patchobjects[whichpatchx][whichpatchz][m]; - if (k < Object::objects.size() && k >= 0) + unsigned int k = terrain.patchobjects[whichpatchx][whichpatchz][m]; + if (k < Object::objects.size()) { if (Object::objects[k]->possible) { friction = Object::objects[k]->friction; XYZ start = joints[i].realoldposition; @@ -336,7 +334,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) if (joints[i].label == groin && !joints[i].locked && joints[i].delay <= 0) { joints[i].locked = 1; joints[i].delay = 1; - if (tutoriallevel != 1 || id == 0) { + if (!Tutorial::active || id == 0) { emit_sound_at(landsound1, joints[i].position * (*scale) + *coords, 128.); } breaking = true; @@ -345,7 +343,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) if (joints[i].label == head && !joints[i].locked && joints[i].delay <= 0) { joints[i].locked = 1; joints[i].delay = 1; - if (tutoriallevel != 1 || id == 0) { + if (!Tutorial::active || id == 0) { emit_sound_at(landsound2, joints[i].position * (*scale) + *coords, 128.); } } @@ -358,7 +356,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) bounceness = 0; joints[i].velocity = joints[i].oldvelocity; } - if (tutoriallevel != 1 || id == 0) + if (!Tutorial::active || id == 0) if (findLengthfast(&bounceness) > 4000 && breaking) { Object::objects[k]->model.MakeDecal(breakdecal, DoRotation(temp - Object::objects[k]->position, 0, -Object::objects[k]->yaw, 0), .4, .5, Random() % 360); Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, 1, 1, 1, 4, .2); @@ -402,6 +400,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) broken = 1; } } + } } joints[i].realoldposition = joints[i].position * (*scale) + *coords; } @@ -411,13 +410,13 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) if (terrain.patchobjectnum[whichpatchx][whichpatchz]) for (m = 0; m < terrain.patchobjectnum[whichpatchx][whichpatchz]; m++) { - k = terrain.patchobjects[whichpatchx][whichpatchz][m]; + unsigned int k = terrain.patchobjects[whichpatchx][whichpatchz][m]; if (Object::objects[k]->possible) { for (i = 0; i < 26; i++) { //Make this less stupid XYZ start = joints[jointlabels[whichjointstartarray[i]]].position * (*scale) + *coords; XYZ end = joints[jointlabels[whichjointendarray[i]]].position * (*scale) + *coords; - whichhit = Object::objects[k]->model.LineCheckSlidePossible(&start, &end, &temp, &Object::objects[k]->position, &Object::objects[k]->yaw); + whichhit = Object::objects[k]->model.LineCheckSlidePossible(&start, &end, &Object::objects[k]->position, &Object::objects[k]->yaw); if (whichhit != -1) { joints[jointlabels[whichjointendarray[i]]].position = (end - *coords) / (*scale); for (unsigned j = 0; j < muscles.size(); j++) { @@ -638,11 +637,11 @@ void Skeleton::Load(const std::string& filename, const std::string& lowfil model[i].CalculateNormals(0); } - drawmodel.load(modelfilename, 0); + drawmodel.load(modelfilename); drawmodel.Rotate(180, 0, 0); drawmodel.Scale(.04, .04, .04); drawmodel.FlipTexCoords(); - if ((tutoriallevel == 1) && (id != 0)) { + if ((Tutorial::active) && (id != 0)) { drawmodel.UniformTexCoords(); drawmodel.ScaleTexCoords(0.1); } @@ -653,13 +652,13 @@ void Skeleton::Load(const std::string& filename, const std::string& lowfil modellow.Scale(.04, .04, .04); modellow.CalculateNormals(0); - drawmodellow.load(modellowfilename, 0); + drawmodellow.load(modellowfilename); drawmodellow.Rotate(180, 0, 0); drawmodellow.Scale(.04, .04, .04); drawmodellow.FlipTexCoords(); - if (tutoriallevel == 1 && id != 0) + if (Tutorial::active && id != 0) drawmodellow.UniformTexCoords(); - if (tutoriallevel == 1 && id != 0) + if (Tutorial::active && id != 0) drawmodellow.ScaleTexCoords(0.1); drawmodellow.CalculateNormals(0); @@ -669,7 +668,7 @@ void Skeleton::Load(const std::string& filename, const std::string& lowfil modelclothes.Scale(.041, .04, .041); modelclothes.CalculateNormals(0); - drawmodelclothes.load(modelclothesfilename, 0); + drawmodelclothes.load(modelclothesfilename); drawmodelclothes.Rotate(180, 0, 0); drawmodelclothes.Scale(.04, .04, .04); drawmodelclothes.FlipTexCoords();