From 2a9d19feea3589e45e3f6aa4e7b6052732b35f3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Thu, 24 Nov 2016 00:23:33 +0800 Subject: [PATCH] Removed unused methods Note: I left some unused methods just in case: Input.cpp::CharToKey Quaternions.cpp::Quat_Mult Quaternions.cpp::To_Quat Quaternions.cpp::Quat_2_Matrix Quaternions.cpp::Quat_2_AA Quaternions.cpp::Quat2Vector Models.cpp::loadraw Models.cpp::Translate Sprite.cpp::clearTextures GameTick.cpp::getEndX GameTick.cpp::getEndY pack.c::packf pack.c::spackf unpack.c::sunpackf unpack.c::unpackf --- Source/Lights.cpp | 19 ----- Source/Lights.h | 1 - Source/Models.cpp | 81 -------------------- Source/Models.h | 2 - Source/OpenGL_Windows.cpp | 7 -- Source/Terrain.cpp | 152 -------------------------------------- Source/Terrain.h | 2 - Source/openal_wrapper.cpp | 5 -- Source/openal_wrapper.h | 1 - 9 files changed, 270 deletions(-) diff --git a/Source/Lights.cpp b/Source/Lights.cpp index d3437ee..f7e9d75 100644 --- a/Source/Lights.cpp +++ b/Source/Lights.cpp @@ -70,22 +70,3 @@ void SetUpLight(Light* whichsource, int whichlight) } } - -void SetUpMainLight(Light* whichsource, int whichlight, float ambientr, float ambientg, float ambientb) -{ - static float qattenuation[] = {0.0f}; - - //Initialize lights - - if (whichlight == 0) { - GLfloat LightAmbient[] = { ambientr, ambientg, ambientb, 1.0f}; - GLfloat LightDiffuse[] = { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f }; - GLfloat LightPosition[] = { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f }; - - glLightfv(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, qattenuation); - glLightfv(GL_LIGHT0, GL_POSITION, LightPosition); - glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); - glEnable(GL_LIGHT0); - } -} diff --git a/Source/Lights.h b/Source/Lights.h index b4a1b2f..f07bb86 100644 --- a/Source/Lights.h +++ b/Source/Lights.h @@ -44,7 +44,6 @@ public: } }; -void SetUpMainLight(Light* whichsource, int whichlight, float ambientr, float ambientg, float ambientb); void SetUpLight(Light* whichsource, int whichlight); #endif diff --git a/Source/Models.cpp b/Source/Models.cpp index f6a2a91..0b81053 100644 --- a/Source/Models.cpp +++ b/Source/Models.cpp @@ -64,43 +64,6 @@ int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate) return firstintersecting; } -int Model::LineCheckSlide(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate) -{ - static int j; - static float distance; - static float olddistance; - static int intersecting; - static int firstintersecting; - static XYZ point; - - *p1 = *p1 - *move; - *p2 = *p2 - *move; - if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius)) - return -1; - firstintersecting = -1; - if (*rotate) - *p1 = DoRotation(*p1, 0, -*rotate, 0); - if (*rotate) - *p2 = DoRotation(*p2, 0, -*rotate, 0); - - for (j = 0; j < TriangleNum; j++) { - intersecting = LineFacetd(p1, p2, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], &facenormals[j], &point); - distance = (point.x - p1->x) * (point.x - p1->x) + (point.y - p1->y) * (point.y - p1->y) + (point.z - p1->z) * (point.z - p1->z); - if ((distance < olddistance || firstintersecting == -1) && intersecting) { - olddistance = distance; - firstintersecting = j; - } - } - - distance = abs((facenormals[firstintersecting].x * p2->x) + (facenormals[firstintersecting].y * p2->y) + (facenormals[firstintersecting].z * p2->z) - ((facenormals[firstintersecting].x * vertex[Triangles[firstintersecting].vertex[0]].x) + (facenormals[firstintersecting].y * vertex[Triangles[firstintersecting].vertex[0]].y) + (facenormals[firstintersecting].z * vertex[Triangles[firstintersecting].vertex[0]].z))); - *p2 -= facenormals[firstintersecting] * distance; - - if (*rotate) - *p2 = DoRotation(*p2, 0, *rotate, 0); - *p2 = *p2 + *move; - return firstintersecting; -} - int Model::LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate) { static int j; @@ -1027,7 +990,6 @@ void Model::drawdifftex(GLuint texture) glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - //drawdiffteximmediate(texture); } void Model::drawdifftex(Texture texture) @@ -1060,49 +1022,6 @@ void Model::drawdifftex(Texture texture) glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - //drawdiffteximmediate(texture); -} - -void Model::drawdiffteximmediate(GLuint texture) -{ - glBindTexture(GL_TEXTURE_2D, (unsigned long)texture); - - glBegin(GL_TRIANGLES); - for (int i = 0; i < TriangleNum; i++) { - /*if(Triangles[i].vertex[0]=0&&Triangles[i].vertex[1]>=0&&Triangles[i].vertex[2]>=0){ - if(isnormal(vertex[Triangles[i].vertex[0]].x)&&isnormal(vertex[Triangles[i].vertex[0]].y)&&isnormal(vertex[Triangles[i].vertex[0]].z) - &&isnormal(vertex[Triangles[i].vertex[1]].x)&&isnormal(vertex[Triangles[i].vertex[1]].y)&&isnormal(vertex[Triangles[i].vertex[1]].z) - &&isnormal(vertex[Triangles[i].vertex[2]].x)&&isnormal(vertex[Triangles[i].vertex[2]].y)&&isnormal(vertex[Triangles[i].vertex[2]].z)){ - */glTexCoord2f(Triangles[i].gx[0], Triangles[i].gy[0]); - if (color) - glColor3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z); - if (!color && !flat) - glNormal3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z); - if (!color && flat) - glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y); - glVertex3f(vertex[Triangles[i].vertex[0]].x, vertex[Triangles[i].vertex[0]].y, vertex[Triangles[i].vertex[0]].z); - - glTexCoord2f(Triangles[i].gx[1], Triangles[i].gy[1]); - if (color) - glColor3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z); - if (!color && !flat) - glNormal3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z); - if (!color && flat) - glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y); - glVertex3f(vertex[Triangles[i].vertex[1]].x, vertex[Triangles[i].vertex[1]].y, vertex[Triangles[i].vertex[1]].z); - - glTexCoord2f(Triangles[i].gx[2], Triangles[i].gy[2]); - if (color) - glColor3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z); - if (!color && !flat) - glNormal3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z); - if (!color && flat) - glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y); - glVertex3f(vertex[Triangles[i].vertex[2]].x, vertex[Triangles[i].vertex[2]].y, vertex[Triangles[i].vertex[2]].z); - //} - //} - } - glEnd(); } void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture) diff --git a/Source/Models.h b/Source/Models.h index 6cbb5c5..a861acd 100644 --- a/Source/Models.h +++ b/Source/Models.h @@ -121,7 +121,6 @@ public: int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate); int SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate); int LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate); - int LineCheckSlide(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate); int LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate); int LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate); void UpdateVertexArray(); @@ -142,7 +141,6 @@ public: void drawdifftex(GLuint texture); void drawdifftex(Texture texture); void drawimmediate(); - void drawdiffteximmediate(GLuint texture); void Rotate(float xang, float yang, float zang); ~Model(); void deallocate(); diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index 6d684ba..8af915c 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -772,13 +772,6 @@ bool LoadImage(const char * fname, TGAImageRec & tex) return load_image(fname, tex); } -void ScreenShot(const char * fname) -{ - -} - - - static bool load_image(const char *file_name, TGAImageRec &tex) { const char *ptr = strrchr((char *)file_name, '.'); diff --git a/Source/Terrain.cpp b/Source/Terrain.cpp index ea3b802..b0aff61 100644 --- a/Source/Terrain.cpp +++ b/Source/Terrain.cpp @@ -889,75 +889,6 @@ float Terrain::getHeight(float pointx, float pointz) //return height1*(1-(pointz-tiley))*scale+height2*(pointz-tiley)*scale; } -float Terrain::getHeightExtrude(float pointx, float pointz, float point2x, float point2z) -{ - static int tilex, tiley; - static XYZ startpoint, endpoint, intersect, triangle[3], average; - - pointx /= scale; - pointz /= scale; - point2x /= scale; - point2z /= scale; - - if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0) - return 0; - if (point2x >= size - 1 || point2z >= size - 1 || point2x <= 0 || point2z <= 0) - return 0; - - startpoint.x = point2x; - startpoint.y = -1000; - startpoint.z = point2z; - - endpoint = startpoint; - endpoint.y = 1000; - - tilex = pointx; - tiley = pointz; - - triangle[0].x = tilex; - triangle[0].z = tiley; - triangle[0].y = heightmap[tilex][tiley]; - - triangle[1].x = tilex + 1; - triangle[1].z = tiley; - triangle[1].y = heightmap[tilex + 1][tiley]; - - triangle[2].x = tilex; - triangle[2].z = tiley + 1; - triangle[2].y = heightmap[tilex][tiley + 1]; - - XYZ mid; - - mid = (triangle[0] + triangle[1] + triangle[2]) / 2; - - triangle[0] = mid + (triangle[0] - mid) * 10; - triangle[1] = mid + (triangle[0] - mid) * 10; - triangle[2] = mid + (triangle[0] - mid) * 10; - - /* - if(!LineFacetd(&startpoint,&endpoint,&triangle[0],&triangle[1],&triangle[2],&intersect)){ - triangle[0].x=tilex+1; - triangle[0].z=tiley; - triangle[0].y=heightmap[tilex+1][tiley]; - - triangle[1].x=tilex+1; - triangle[1].z=tiley+1; - triangle[1].y=heightmap[tilex+1][tiley+1]; - - triangle[2].x=tilex; - triangle[2].z=tiley+1; - triangle[2].y=heightmap[tilex][tiley+1]; - LineFacetd(&startpoint,&endpoint,&triangle[0],&triangle[1],&triangle[2],&intersect); - }*/ - return intersect.y * scale + getOpacity(pointx * scale, pointz * scale) / 8; - - //height1=heightmap[tilex][tiley]*(1-(pointx-tilex))+heightmap[tilex+1][tiley]*(pointx-tilex); - //height2=heightmap[tilex][tiley+1]*(1-(pointx-tilex))+heightmap[tilex+1][tiley+1]*(pointx-tilex); - - //return height1*(1-(pointz-tiley))*scale+height2*(pointz-tiley)*scale; -} - - float Terrain::getOpacity(float pointx, float pointz) { static float height1, height2; @@ -1465,89 +1396,6 @@ void Terrain::MakeDecalLock(int type, XYZ where, int whichx, int whichy, float s } } -void Terrain::DoLighting() -{ - static int i, j, k, todivide; - static float brightness, total; - static XYZ blank, terrainpoint, lightloc; - lightloc = light.location; - Normalise(&lightloc); - //Calculate shadows - for (i = 0; i < size; i++) { - for (j = 0; j < size; j++) { - terrainpoint.x = (float)i * scale; - terrainpoint.z = (float)j * scale; - terrainpoint.y = heightmap[i][j] * scale + .1; - /*brightness=0; - if(lineTerrain(lightlocation*10+terrainpoint,terrainpoint,&blank)==-1) - */ - brightness = dotproduct(&lightloc, &normals[i][j]); - - if (brightness > 1) - brightness = 1; - if (brightness < 0) - brightness = 0; - - colors[i][j][0] = light.color[0] * brightness + light.ambient[0]; - colors[i][j][1] = light.color[1] * brightness + light.ambient[1]; - colors[i][j][2] = light.color[2] * brightness + light.ambient[2]; - - if (colors[i][j][0] > 1) colors[i][j][0] = 1; - if (colors[i][j][1] > 1) colors[i][j][1] = 1; - if (colors[i][j][2] > 1) colors[i][j][2] = 1; - if (colors[i][j][0] < 0) colors[i][j][0] = 0; - if (colors[i][j][1] < 0) colors[i][j][1] = 0; - if (colors[i][j][2] < 0) colors[i][j][2] = 0; - } - } - - //Smooth shadows - for (i = 0; i < size; i++) { - for (j = 0; j < size; j++) { - for (k = 0; k < 3; k++) { - total = 0; - todivide = 0; - if (i != 0) { - total += colors[j][i - 1][k]; - todivide++; - } - if (i != size - 1) { - total += colors[j][i + 1][k]; - todivide++; - } - if (j != 0) { - total += colors[j - 1][i][k]; - todivide++; - } - if (j != size - 1) { - total += colors[j + 1][i][k]; - todivide++; - } - if (i != 0 && j != 0) { - total += colors[j - 1][i - 1][k]; - todivide++; - } - if (i != size - 1 && j != 0) { - total += colors[j - 1][i + 1][k]; - todivide++; - } - if (j != size - 1 && i != size - 1) { - total += colors[j + 1][i + 1][k]; - todivide++; - } - if (j != size - 1 && i != 0) { - total += colors[j + 1][i - 1][k]; - todivide++; - } - total += colors[j][i][k]; - todivide++; - - colors[j][i][k] = total / todivide; - } - } - } -} - void Terrain::DoShadows() { static int i, j, k, l, todivide; diff --git a/Source/Terrain.h b/Source/Terrain.h index bc57ca0..9f919b4 100644 --- a/Source/Terrain.h +++ b/Source/Terrain.h @@ -109,7 +109,6 @@ public: void MakeDecalLock(int type, XYZ where, int whichx, int whichy, float size, float opacity, float rotation); int lineTerrain(XYZ p1, XYZ p2, XYZ *p); float getHeight(float pointx, float pointz); - float getHeightExtrude(float pointx, float pointz, float point2x, float point2z); float getOpacity(float pointx, float pointz); XYZ getLighting(float pointx, float pointz); XYZ getNormal(float pointx, float pointz); @@ -124,7 +123,6 @@ public: void drawpatch(int whichx, int whichy, float opacity); void drawpatchother(int whichx, int whichy, float opacity); void drawpatchotherother(int whichx, int whichy, float opacity); - void DoLighting(); void DoShadows(); Terrain(); diff --git a/Source/openal_wrapper.cpp b/Source/openal_wrapper.cpp index 209ce1a..65fe055 100644 --- a/Source/openal_wrapper.cpp +++ b/Source/openal_wrapper.cpp @@ -528,11 +528,6 @@ AL_API signed char OPENAL_StopSound(int channel) return true; } -AL_API void OPENAL_Stream_Close(OPENAL_STREAM *stream) -{ - OPENAL_Sample_Free((OPENAL_SAMPLE *) stream); -} - static OPENAL_SAMPLE *OPENAL_Stream_GetSample(OPENAL_STREAM *stream) { if (!initialized) diff --git a/Source/openal_wrapper.h b/Source/openal_wrapper.h index 39f05eb..6b95730 100644 --- a/Source/openal_wrapper.h +++ b/Source/openal_wrapper.h @@ -98,7 +98,6 @@ extern "C" { AL_API signed char OPENAL_SetPaused(int channel, signed char paused); AL_API void OPENAL_SetSFXMasterVolume(int volume); AL_API signed char OPENAL_StopSound(int channel); - AL_API void OPENAL_Stream_Close(OPENAL_STREAM *stream); AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM *stream, unsigned int mode); AL_API void OPENAL_Update(); AL_API signed char OPENAL_SetOutput(int outputtype); -- 2.39.5