X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FTerrain.cpp;h=1af30585241816c182360a913e813c112270bcfc;hb=320a287705c0463c6f8943ad9cf4c407c556f703;hp=d9c73b056b320ff90bfcc49f8cadd158cbbc74f3;hpb=46cff1de1e828cb8c04a5dc5377bc07baae57858;p=lugaru.git diff --git a/Source/Terrain.cpp b/Source/Terrain.cpp index d9c73b0..1af3058 100644 --- a/Source/Terrain.cpp +++ b/Source/Terrain.cpp @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Objects.h" extern XYZ viewer; extern float viewdistance; -extern float lightambient[3],lightbrightness[3]; extern float fadestart; extern int environment; extern float texscale; @@ -38,7 +37,6 @@ extern float blurness; extern float targetblurness; extern Objects objects; extern TGAImageRec texture; -extern Game * pgame; extern bool visibleloading; extern bool skyboxtexture; extern int tutoriallevel; @@ -105,7 +103,7 @@ int Terrain::lineTerrain(XYZ p1,XYZ p2, XYZ *p) triangles[2].z=j; intersecting=LineFacet(p1,p2,triangles[0],triangles[1],triangles[2],&point); - distance=findDistancefast(&p1,&point); + distance=distsq(&p1,&point); if((distanceviewdistsquared)distance=viewdistsquared; colors[i][j][3]=(viewdistsquared-(distance-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared; } @@ -224,7 +222,7 @@ void Terrain::UpdateTransparencyotherother(int whichx, int whichy){ vertex.x=i*scale; vertex.z=j*scale; vertex.y=heightmap[i][j]*scale; - distance=findDistancefast(&viewer,&vertex); + distance=distsq(&viewer,&vertex); if(distance>viewdistsquared)distance=viewdistsquared; colors[i][j][3]=(viewdistsquared-(distance-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared; } @@ -401,7 +399,7 @@ bool Terrain::load(const char *fileName) } } texture.bpp=24; - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); texdetail=temptexdetail; @@ -433,7 +431,7 @@ bool Terrain::load(const char *fileName) } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); float slopeness; @@ -442,7 +440,7 @@ bool Terrain::load(const char *fileName) textureness[i][j]=-1; } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); for(i=0;iLoadingScreen(); + if(visibleloading) Game::LoadingScreen(); for(i=0;iLoadingScreen(); + if(visibleloading) Game::LoadingScreen(); /*float total; int todivide; @@ -598,7 +596,7 @@ bool Terrain::load(const char *fileName) } } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); patch_size=size/subdivision; patch_elements=(patch_size)*(patch_size)*54; @@ -984,7 +982,7 @@ void Terrain::draw(int layer) terrainpoint.x=i*patch_size+(patch_size)/2; terrainpoint.y=viewer.y;//heightmap[i][j]*scale; terrainpoint.z=j*patch_size+(patch_size)/2; - distance[i][j]=findDistancefast(&viewer,&terrainpoint); + distance[i][j]=distsq(&viewer,&terrainpoint); } } } @@ -1049,7 +1047,7 @@ void Terrain::drawdecals() for(i=0;i=1)glColor4f(1,1,1,decalopacity[i]); if(distancemult<1)glColor4f(1,1,1,decalopacity[i]*distancemult); } if(decaltype[i]==footprintdecal||decaltype[i]==bodyprintdecal){ - distancemult=(viewdistsquared-(findDistancefast(&viewer,&decalposition[i])-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared; + distancemult=(viewdistsquared-(distsq(&viewer,&decalposition[i])-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared; if(distancemult>=1){ glColor4f(1,1,1,decalopacity[i]); if(decalalivetime[i]>3)glColor4f(1,1,1,decalopacity[i]*(5-decalalivetime[i])/2); @@ -1105,7 +1103,7 @@ void Terrain::drawdecals() } } if((decaltype[i]==blooddecal||decaltype[i]==blooddecalfast||decaltype[i]==blooddecalslow)){ - distancemult=(viewdistsquared-(findDistancefast(&viewer,&decalposition[i])-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared; + distancemult=(viewdistsquared-(distsq(&viewer,&decalposition[i])-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared; if(distancemult>=1){ glColor4f(decalbrightness[i],decalbrightness[i],decalbrightness[i],decalopacity[i]); if(decalalivetime[i]<4)glColor4f(decalbrightness[i],decalbrightness[i],decalbrightness[i],decalopacity[i]*decalalivetime[i]*.25); @@ -1460,12 +1458,12 @@ void Terrain::DoShadows() if(objects.type[l]!=treetrunktype){ testpoint=terrainpoint; testpoint2=terrainpoint+lightloc*50*(1-shadowed); - if(objects.model[l].LineCheck(&testpoint,&testpoint2,&col,&objects.position[l],&objects.rotation[l])!=-1){ + if(objects.model[l].LineCheck(&testpoint,&testpoint2,&col,&objects.position[l],&objects.yaw[l])!=-1){ shadowed=1-(findDistance(&terrainpoint,&col)/50); } } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); } brightness=dotproduct(&lightloc,&normals[i][j]); if(shadowed)brightness*=1-shadowed; @@ -1486,7 +1484,7 @@ void Terrain::DoShadows() } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); //Smooth shadows for(i=0;i