From bba3631a5899f8f9f26fd596e13f097ae2d6f8b8 Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Sun, 2 Jan 2011 00:43:13 +0300 Subject: [PATCH] Simplify DoMipmaps * * * foldme --- Source/GameTick.cpp | 8 ++--- Source/Globals.cpp | 1 - Source/Person.cpp | 78 +++------------------------------------------ Source/Person.h | 11 ++++++- 4 files changed, 18 insertions(+), 80 deletions(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 38d379e..6deec40 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -610,7 +610,7 @@ static void set_clothes(int pnum, Game *game, const char *args) if (!game->AddClothes(buf,0,1,&player[pnum].skeleton.skinText[pnum],&player[pnum].skeleton.skinsize)) return; - player[pnum].DoMipmaps(5,0,0,player[pnum].skeleton.skinsize,player[pnum].skeleton.skinsize); + player[pnum].DoMipmaps(); strcpy(player[pnum].clothes[player[pnum].numclothes],buf); player[pnum].clothestintr[player[pnum].numclothes]=tintr; player[pnum].clothestintg[player[pnum].numclothes]=tintg; @@ -2060,7 +2060,7 @@ void Game::Loadlevel(char *name){ tintb=player[i].clothestintb[j]; AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize); } - player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize); + player[i].DoMipmaps(); } player[i].currentanimation=bounceidleanim; @@ -4426,7 +4426,7 @@ void Game::Tick() tintb=player[closest].clothestintb[i]; AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize); } - player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize); + player[closest].DoMipmaps(); } detailtogglekeydown=1; @@ -4884,7 +4884,7 @@ void Game::Tick() AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize); } if(player[numplayers].numclothes){ - player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize); + player[numplayers].DoMipmaps(); } player[numplayers].power=player[0].power; diff --git a/Source/Globals.cpp b/Source/Globals.cpp index 901ac1a..a4fa92e 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -126,7 +126,6 @@ short vRefNum = 0; long dirID = 0; int mainmenu = 0; int oldmainmenu = 0; -GLubyte texturearray[512*512*3] = {0}; int loadscreencolor = 0; int whichjointstartarray[26] = {0}; int whichjointendarray[26] = {0}; diff --git a/Source/Person.cpp b/Source/Person.cpp index b60c350..3640a0b 100644 --- a/Source/Person.cpp +++ b/Source/Person.cpp @@ -67,7 +67,6 @@ extern bool tiltweird; extern bool midweird; extern bool proportionweird; extern bool vertexweird[6]; -extern GLubyte texturearray[512*512*3]; extern XYZ envsound[30]; extern float envsoundvol[30]; extern float envsoundlife[30]; @@ -475,8 +474,7 @@ void Person::DoBloodBig(float howmuch,int which){ } } glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr); - if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize); - else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail); + DoMipmaps(); bleedxint=0; bleedyint=0; @@ -704,8 +702,7 @@ bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){ } } glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr); - if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize); - else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail); + DoMipmaps(); bleedy=(1+coordsy)*512; bleedx=coordsx*512; @@ -735,73 +732,6 @@ bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){ } -void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){ - int i,j,k; - static float temp; - static int bytesPerPixel=3; - static int newsize,totalsize,rowsize,bigstep,smallstep,sum; - static int newstartx,newstarty,newendx,newendy; - static int newnewstartx,newnewstarty,newnewendx,newnewendy; - static int which; - static float sizemult; - /* - for(i=0;iskeleton.skinsize-1)endx=skeleton.skinsize-1; - if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1; - if((endx>startx&&endy>starty)||howmanylevels){ - - newstartx=startx; - newstarty=starty; - newendx=endx; - newendy=endy; - - for(i=startx;iaitype==playercontrolled||hostiletime>1) @@ -3915,7 +3845,7 @@ void Person::DoStuff(){ bleeding-=multiplier*.3; if(bloodtoggle==2){ glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr); - if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize); + if(bleeding<=0&&(detail!=2||osx))DoMipmaps(); } } @@ -4042,7 +3972,7 @@ void Person::DoStuff(){ } if(!osx&&detail>1){ glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr); - DoMipmaps(0,startx,endx,starty,endy); + DoMipmaps(); } if(!skeleton.free){ diff --git a/Source/Person.h b/Source/Person.h index 8882633..b831b28 100644 --- a/Source/Person.h +++ b/Source/Person.h @@ -411,7 +411,16 @@ struct Person void Reverse(); void DoDamage(float howmuch); void DoHead(); - void DoMipmaps(int howmanylevels, float startx, float endx, float starty, float endy); + void DoMipmaps() + { + glBindTexture(GL_TEXTURE_2D, skeleton.drawmodel.textureptr); + gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, + skeleton.skinsize, + skeleton.skinsize, + GL_RGB, GL_UNSIGNED_BYTE, + &skeleton.skinText[0]); + } + int SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model); int DrawSkeleton(); void Puff(int whichlabel); -- 2.39.5