summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/Decals.cpp1
-rw-r--r--src/GameLoop.cpp1
-rw-r--r--src/GameTick.cpp1
-rw-r--r--src/Globals.cpp18
-rw-r--r--src/Person.cpp1
-rw-r--r--src/Skeleton.cpp65
6 files changed, 20 insertions, 67 deletions
diff --git a/src/Decals.cpp b/src/Decals.cpp
index e5971e4..1fb3063 100644
--- a/src/Decals.cpp
+++ b/src/Decals.cpp
@@ -7,7 +7,6 @@
 
 extern float multiplier;
 extern bool slomo;
-extern Fog fog;
 extern bool blood;
 extern float fogcolorr;
 extern float fogcolorg;
diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp
index ccf99ac..bc23f22 100644
--- a/src/GameLoop.cpp
+++ b/src/GameLoop.cpp
@@ -31,7 +31,6 @@ extern float soundscalefactor;
 extern unsigned int gSourceID[37];
 extern Camera camera;
 extern float rad2deg;
-extern Fog fog;
 extern int environment;
 extern int slomo;
 extern struct Key keymap;
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index fa64e6a..bdba3b6 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -34,7 +34,6 @@ extern Sprites sprites;
 extern unsigned int gSourceID[37];
 extern Camera camera;
 extern float camerashake;
-extern Fog fog;
 extern int environment;
 extern float precipitationhorz;
 extern float precipitationvert;
diff --git a/src/Globals.cpp b/src/Globals.cpp
index b8f5d14..2adfd22 100644
--- a/src/Globals.cpp
+++ b/src/Globals.cpp
@@ -48,21 +48,3 @@ bool blood;
 float fogcolorr;
 float fogcolorg;
 float fogcolorb;
-
-XYZ vel;
-XYZ midp;
-XYZ newpoint1,newpoint2;
-
-float oldlength;
-float relaxlength;
-
-float friction;
-int numrepeats;
-float groundlevel;
-float offset;
-XYZ impact;
-XYZ overpoint;
-XYZ underpoint;
-int whichtri;
-XYZ normalrotated;
-bool groundish;
diff --git a/src/Person.cpp b/src/Person.cpp
index c644aab..c5ce963 100644
--- a/src/Person.cpp
+++ b/src/Person.cpp
@@ -198,7 +198,6 @@ HitStruct 	Person::BulletCollideWithPlayer(int who, XYZ start, XYZ end){
 	return hitstruct;
 }
 
-extern float camerashake;
 void Person::DoAnimations(int who)
 {
 	if (target > 1 && !skeleton.free) {
diff --git a/src/Skeleton.cpp b/src/Skeleton.cpp
index 62861b4..8d5ae3b 100644
--- a/src/Skeleton.cpp
+++ b/src/Skeleton.cpp
@@ -11,31 +11,13 @@ extern float rad2deg;
 extern Camera camera;
 extern float soundscalefactor;
 
-extern XYZ vel;
-extern XYZ midp;
-extern XYZ newpoint1,newpoint2;
-
-extern float oldlength;
-extern float relaxlength;
-
-extern float friction;
-extern int numrepeats;
-extern float groundlevel;
-extern float offset;
-extern XYZ impact;
-extern XYZ overpoint;
-extern XYZ underpoint;
-extern int whichtri;
-extern XYZ normalrotated;
-extern bool groundish;
-
 void Joint::DoConstraint()
 {
 	if(hasparent){
 		//Find midpoint
-		midp=(position+parent->position)/2;
+		XYZ midp = (position + parent->position) / 2;
 		// Find vector from midpoint to second vector
-		vel = normalize(parent->position - midp);
+		XYZ vel = normalize(parent->position - midp);
 		//Apply velocity change
 		velocity+=((midp-vel*length/2)-position);
 		parent->velocity+=((midp+vel*length/2)-parent->position);
@@ -47,8 +29,8 @@ void Joint::DoConstraint()
 
 void Muscle::DoConstraint(int broken)
 {
-	oldlength=length;
-	relaxlength = len(parent1->position - parent2->position);
+	float oldlength = this->length;
+	float relaxlength = len(parent1->position - parent2->position);
 
 	if(type==boneconnect)strength=1;
 	if(type==constraint)strength=0;
@@ -66,12 +48,12 @@ void Muscle::DoConstraint(int broken)
 	if(length>maxlength&&!broken)length=maxlength;
 
 	//Find midpoint
-	midp=(parent1->position+parent2->position)/2;
+	XYZ midp = (parent1->position + parent2->position) / 2;
 	// Find vector from midpoint to second vector
-	vel = normalize(parent2->position - midp);
+	XYZ vel = normalize(parent2->position - midp);
 	//Apply velocity change
-	newpoint1=midp-vel*length/2;
-	newpoint2=midp+vel*length/2;
+	XYZ newpoint1 = midp - vel * length / 2;
+	XYZ newpoint2 = midp + vel * length / 2;
 	parent1->velocity+=(newpoint1-parent1->position);
 	parent2->velocity+=(newpoint2-parent2->position);
 	//Move child point to within certain distance of parent point
@@ -81,19 +63,15 @@ void Muscle::DoConstraint(int broken)
 
 void Skeleton::DoConstraints()
 {
-	numrepeats = 3;
-	for(int i = 0; i < numrepeats; ++i)
+	for (int i = 0; i < 3; ++i)
 		for (auto& joint : joints)
 			joint.DoConstraint();
 }
 
 void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation)
 {
-	friction = 20;
 	move->y += 0.35;
-	groundlevel = 0;
-	numrepeats = 2;
-	for (int j = 0; j < numrepeats; j++) {
+	for (int j = 0; j < 2; j++) {
 		for (int i = 0; i < max_joints; i++) {
 			if (!joints[i].existing && i != lefthand && i != righthand)
 				continue;
@@ -102,11 +80,11 @@ void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation)
 			joints[i].DoConstraint();
 			// Ground constraint
 			auto& pos = joints[i].position;
-			overpoint = pos;
+			XYZ overpoint = pos;
 			overpoint.y += 10;
-			underpoint = pos;
-			underpoint.y -= offset = 0;
-			whichtri = collide->LineCheck2(overpoint, underpoint,
+			XYZ underpoint = pos;
+			XYZ impact;
+			int whichtri = collide->LineCheck2(overpoint, underpoint,
 				&impact, *move, rotation);
 			if (whichtri == -1
 			    || collide->normals[whichtri].y <= 0.8)
@@ -114,25 +92,22 @@ void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation)
 					joints[i].realoldposition, pos,
 					&impact, *move, rotation);
 
-			if (pos.y <= groundlevel + offset || whichtri != -1) {
+			if (pos.y <= 0 || whichtri != -1) {
 				if (whichtri == -1
 				    || collide->normals[whichtri].y > 0.8) {
-					if (whichtri == -1) {
-						pos.y = groundlevel + offset;
-					} else {
+					if (whichtri == -1)
+						pos.y = 0;
+					else
 						pos = impact;
-						pos.y += offset;
-					}
 					joints[i].velocity.y *= -0.3;
 					joints[i].velocity.x *= 0.3;
 					joints[i].velocity.z *= 0.3;
 				}
 
-				offset = true;
 				if (whichtri != -1
 				    && collide->normals[whichtri].y <= 0.8) {
-					normalrotated = rotate(collide->normals[whichtri], 0, rotation, 0);
-					pos = impact + normalrotated * offset;
+					XYZ normalrotated = rotate(collide->normals[whichtri], 0, rotation, 0);
+					pos = impact + normalrotated;
 					reflect(&joints[i].velocity, normalrotated);
 					joints[i].velocity *= 0.3;
 				}