Taken from Focus on 3D Terrain programming:
//--------------------------------------------------------------//name:cterrain::filterheightband-private//description:apply The erosion filter to an individual//Band of height values//Arguments:-fpband:the band to be filtered//-istride:how far to advance per pass//-icount:number of passes to make//-ffilter:the Filter Strength//Return Value:none//--------------------------------------------------------------voidCterrain::filterheightband (float* Fpband,intIstride,intICount,floatffilter) { floatv= fpband[0]; intj =Istride; inti; //go through (traverse) the height band and apply the erosion filter for(i=0; i<icount-1; i++) {Fpband[j]= Ffilter*v + (1-ffilter) *Fpband[j]; V=Fpband[j]; J+=Istride; }}
Filter a piece of code, where Istride is the step, ffilter is the coefficient, for this, you can change the function parameter name to the following name seems to be more descriptive function function: void Filterheightband (float* fpband,int istep,int Icount,float ffilterfactor)
A comment on a piece of code in the book