X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FObjects%2FObject.cpp;h=a7d991d6907e1a81360f910ae199cfbc838d35f5;hb=0aab437dc560d2afa982e61cc2547756ad7b0761;hp=f0dd169b3b05dd02e01eaa96d6057b329e463187;hpb=8b6e8f3ad7390309795eb35c0959264cb7924402;p=lugaru.git diff --git a/Source/Objects/Object.cpp b/Source/Objects/Object.cpp index f0dd169..a7d991d 100644 --- a/Source/Objects/Object.cpp +++ b/Source/Objects/Object.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games -Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) +Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -251,42 +251,58 @@ void Object::handleRot(int divide) { messedwith -= multiplier; if (rotxvel || rotx) { - if (rotx > 0) + if (rotx > 0) { rotxvel -= multiplier * 8 * fabs(rotx); - if (rotx < 0) + } + if (rotx < 0) { rotxvel += multiplier * 8 * fabs(rotx); - if (rotx > 0) + } + if (rotx > 0) { rotxvel -= multiplier * 4; - if (rotx < 0) + } + if (rotx < 0) { rotxvel += multiplier * 4; - if (rotxvel > 0) + } + if (rotxvel > 0) { rotxvel -= multiplier * 4; - if (rotxvel < 0) + } + if (rotxvel < 0) { rotxvel += multiplier * 4; - if (fabs(rotx) < multiplier * 4) + } + if (fabs(rotx) < multiplier * 4) { rotx = 0; - if (fabs(rotxvel) < multiplier * 4) + } + if (fabs(rotxvel) < multiplier * 4) { rotxvel = 0; + } rotx += rotxvel * multiplier * 4; } if (rotyvel || roty) { - if (roty > 0) + if (roty > 0) { rotyvel -= multiplier * 8 * fabs(roty); - if (roty < 0) + } + if (roty < 0) { rotyvel += multiplier * 8 * fabs(roty); - if (roty > 0) + } + if (roty > 0) { rotyvel -= multiplier * 4; - if (roty < 0) + } + if (roty < 0) { rotyvel += multiplier * 4; - if (rotyvel > 0) + } + if (rotyvel > 0) { rotyvel -= multiplier * 4; - if (rotyvel < 0) + } + if (rotyvel < 0) { rotyvel += multiplier * 4; - if (fabs(roty) < multiplier * 4) + } + if (fabs(roty) < multiplier * 4) { roty = 0; - if (fabs(rotyvel) < multiplier * 4) + } + if (fabs(rotyvel) < multiplier * 4) { rotyvel = 0; + } roty += rotyvel * multiplier * 4; } @@ -296,14 +312,18 @@ void Object::handleRot(int divide) if (rotx) { glRotatef(-rotx / divide, 0, 0, 1); } - if (rotx > 10) + if (rotx > 10) { rotx = 10; - if (rotx < -10) + } + if (rotx < -10) { rotx = -10; - if (roty > 10) + } + if (roty > 10) { roty = 10; - if (roty < -10) + } + if (roty < -10) { roty = -10; + } } void Object::draw() @@ -321,22 +341,25 @@ void Object::draw() hidden = !(distsqflat(&viewer, &position) > playerdist + 3 || (type != bushtype && type != treeleavestype)); if (!hidden) { - if (detail == 2 && distance > viewdistance * viewdistance / 4 && environment == desertenvironment) + if (detail == 2 && distance > viewdistance * viewdistance / 4 && environment == desertenvironment) { glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness); - else + } else { glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0); + } distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance; - if (distance > 1) + if (distance > 1) { distance = 1; + } if (distance > 0) { if (occluded < 6) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); - if (!model.color) + if (!model.color) { glEnable(GL_LIGHTING); - else + } else { glDisable(GL_LIGHTING); + } glDepthMask(1); glTranslatef(position.x, position.y, position.z); if (type == bushtype) { @@ -533,7 +556,8 @@ void Object::LoadObjectsFromFile(FILE* tfile, bool skip) int numobjects; int type; XYZ position; - float yaw, pitch, scale, lastscale; + float yaw, pitch, scale; + float lastscale = 1.0f; funpackf(tfile, "Bi", &numobjects); if (!skip) { objects.clear(); @@ -634,8 +658,9 @@ void Object::DoShadows() { XYZ lightloc; lightloc = light.location; - if (!skyboxtexture) + if (!skyboxtexture) { lightloc = 0; + } lightloc.y += 10; Normalise(&lightloc);