]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Skeleton.cpp
convenience functions
[lugaru.git] / Source / Skeleton.cpp
index ff195387e5227d044a6df8a193e92beab28c5389..cb8e043e4dc57ff26edc1598bfebfb13e1f73a78 100644 (file)
@@ -31,7 +31,6 @@ extern Skeleton testskeleton;
 extern Terrain terrain;
 extern Objects objects;
 extern int environment;
-extern float terraindetail;
 extern float camerashake;
 extern bool freeze;
 extern int detail;
@@ -44,7 +43,6 @@ extern int tutoriallevel;
 extern int whichjointstartarray[26];
 extern int whichjointendarray[26];
 
-extern Game * pgame;
 extern bool visibleloading;
 
 void dealloc2(void* param){
@@ -52,6 +50,8 @@ void dealloc2(void* param){
        param=0;
 }
 
+enum {boneconnect, constraint, muscle};
+
 void Muscle::DoConstraint(bool spinny)
 {
        static XYZ vel;
@@ -192,8 +192,8 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale)
        if(free){
                freetime+=multiplier;
 
-               whichpatchx=coords->x/(terrain.size/subdivision*terrain.scale*terraindetail);
-               whichpatchz=coords->z/(terrain.size/subdivision*terrain.scale*terraindetail);
+               whichpatchx=coords->x/(terrain.size/subdivision*terrain.scale);
+               whichpatchz=coords->z/(terrain.size/subdivision*terrain.scale);
 
                terrainlight=*coords;
                objects.SphereCheckPossible(&terrainlight, 1);
@@ -308,7 +308,7 @@ 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.rotation[k],0),.4,.5,Random()%360);
+                                                               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);
                                                                //Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 1, .2);
                                                                breaking=0;
@@ -366,7 +366,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale)
                                                                        friction=objects.friction[k];
                                                                        start=joints[i].realoldposition;
                                                                        end=joints[i].position*(*scale)+*coords;
-                                                                       whichhit=objects.model[k].LineCheckPossible(&start,&end,&temp,&objects.position[k],&objects.rotation[k]);
+                                                                       whichhit=objects.model[k].LineCheckPossible(&start,&end,&temp,&objects.position[k],&objects.yaw[k]);
                                                                        if(whichhit!=-1){
                                                                                if(joints[i].label==groin&&!joints[i].locked&&joints[i].delay<=0){
                                                                                        joints[i].locked=1;
@@ -385,7 +385,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale)
                                                                                        }
                                                                                }
 
-                                                                               terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
+                                                                               terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.yaw[k],0)*-1;
                                                                                if(terrainnormal.y>.8)freefall=0;
                                                                                bounceness=terrainnormal*findLength(&joints[i].velocity)*(abs(normaldotproduct(joints[i].velocity,terrainnormal)));
                                                                                if(findLengthfast(&joints[i].velocity)>findLengthfast(&joints[i].oldvelocity)){
@@ -394,7 +394,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale)
                                                                                }
                                                                                if(tutoriallevel!=1||id==0)
                                                                                        if(findLengthfast(&bounceness)>4000&&breaking){
-                                                                                               objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360);
+                                                                                               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=0;
                                                                                                camerashake+=.6;
@@ -469,7 +469,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale)
                                                //Make this less stupid
                                                start=joints[jointlabels[whichjointstartarray[i]]].position*(*scale)+*coords;
                                                end=joints[jointlabels[whichjointendarray[i]]].position*(*scale)+*coords;
-                                               whichhit=objects.model[k].LineCheckSlidePossible(&start,&end,&temp,&objects.position[k],&objects.rotation[k]);
+                                               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++){
@@ -712,6 +712,7 @@ void Skeleton::SetJoint(float x, float y, float z, int which, int whichjoint)
 
 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];
@@ -833,7 +834,7 @@ void Animation::Load(const char *filename, int aheight, int aattack)
        height=aheight;
        attack=aattack;
 
-       if(visibleloading)pgame->LoadingScreen();
+       if(visibleloading) Game::LoadingScreen();
 
        tfile=fopen( fixedFN, "rb" );
        if(tfile){