示例#1
0
int OSUSTANDARD::SCORE::getJudgment(int _frameTime, int _noteTime, bool _pressState)
{
	bool hit = false;
	bool miss = true;  // assume miss to start with
	int hitTiming = _frameTime - _noteTime;

	// check if the note is long gone or not
	if (_pressState != false)	// standard has slider leniency
		if (_frameTime > _noteTime + 200)
			return 2;

	// judge
	{
		// if hit
		if (_pressState == true)
		{
			hit = BTWN(-200, hitTiming, 200);
			miss = BTWN(-300, hitTiming, -200) || BTWN(+100, hitTiming, +200);
		}

		// if release
		if (_pressState == false)
		{
			// standard has slider leniency
			hit = true;   //BTWN(-300, hitTiming, 300);
			miss = false; // BTWN(-350, hitTiming, -300) || BTWN(+300, hitTiming, +350);
		}
	}

	if (hit == true)	return 0;
	else if (miss == true)	return 1;
	else					return 3;
}
void OsuManiaRenderer::RenderHitTimings(Window& _win)
{
	const int KEYS = play->beatmap->getMods().getCS();

	Analyzer* analyzer = AnalysisStruct::beatmapAnalysis.getAnalyzer("Tap Deviation (ms)");
	if (analyzer == nullptr) return;

	for (osu::TIMING timing : *(analyzer->getData()))
	{
		if (BTWN(getStartTime(), timing.time + timing.data, getEndTime())) // hits
		{
			int hitXpos = timing.key * (this->width / KEYS) + (this->absXpos - this->width / 2);
			int width = ((this->width) / KEYS) - (2 * KEYS);

			int hitPos = (*viewTime) - timing.time - timing.data;
			int hitYpos = hitPos*zoom + height;

			_win.driver->draw2DRectangle(SColor(255, 255, 0, 255), rect<s32>(absXpos + hitXpos, absYpos + hitYpos, absXpos + hitXpos + width, absYpos + hitYpos + 2));
		}
		else if (BTWN(getStartTime(), timing.time, getEndTime())) // misses
		{
			if (timing.data == INT_MAX)
			{
				int hitXpos = timing.key * (this->width / KEYS) + (this->absXpos - this->width / 2);
				int width = ((this->width) / KEYS) - (2 * KEYS);

				int hitPos = (*viewTime) - timing.time;
				int hitYpos = hitPos*zoom + height;

				_win.driver->draw2DRectangle(SColor(255, 200, 0, 0), rect<s32>(absXpos + hitXpos, absYpos + hitYpos, absXpos + hitXpos + width, absYpos + hitYpos + 3));
			}	
		}
	}
}
void OsuManiaRenderer::RenderVisible(Window& _win)
{
	Beatmap* beatmap = play->beatmap;
	std::vector<Hitobject*>& hitobjects = beatmap->getHitobjects();

	/// \TODO: Faster object search
	for (int i = 0; i < hitobjects.size(); i++)
	{
		bool HoldStart = BTWN(hitobjects[i]->getTime(), getStartTime(), hitobjects[i]->getEndTime());
		bool HoldEnd = BTWN(hitobjects[i]->getTime(), getEndTime(), hitobjects[i]->getEndTime());
		bool circle = BTWN(getStartTime(), hitobjects[i]->getTime(), getEndTime());
		
		if (HoldStart || HoldEnd || circle)
			hitNotes[i]->Update(_win);
	}
}
示例#4
0
Hitobject* OSUSTANDARD::getNextNote(int* _iNote)
{
	(*_iNote) += 1;
	if (BTWN(0, *_iNote, play->beatmap->getHitobjects().size() - 1))
		return play->beatmap->getHitobjects()[*_iNote];

	return nullptr;
}
void HitTimingGraph::genStdBins()
{
	setBinTable(
	{ 
		0.000,
		4.500,
		10.000,
		20.000,
		40.000,
		80.500,
		160.000,
		320.000 
	});

	bins.resize(binTable.size() + 1);
	for (int& bin : bins)
		bin = 0;

	Analyzer* analyzer = AnalysisStruct::beatmapAnalysis.getAnalyzer("Tap Deviation (ms)");
	if (analyzer == nullptr) return;

	for (auto& timing : *(analyzer->getData()))
	{
		for (int i = 0; i < binTable.size() - 1; i++)
		{
			// miss
			if (timing.data > binTable[binTable.size() - 1])
			{
				bins[binTable.size()]++;
				break;
			}

			// hit
			if (BTWN(binTable[i], abs(timing.data), binTable[i + 1]))
			{
				bins[i]++;
				break;
			}
		}
	}

	textBins.resize(binTable.size() + 1);
	for (int i = 0; i < binTable.size(); i++)
		textBins[i] = (std::to_string((int)binTable[i])/* + " - " + std::to_string((int)binTable[i + 1])*/).data();
	textBins[binTable.size()] = "MISSES";
}
示例#6
0
/* function */
void xContour(Display *dpy, Window win,GC gcc, GC gcl, 
	       float *cp,int nx, float x[], int ny, float y[], float z[], 
	       char lcflag,char *lcf,char *lcc, float *w, int nplaces)
/**************************************************************************
xContour - draw contour of a two-dimensional array via X
***************************************************************************
Input:
dpy                     the display to make the contour
win                     the window to draw in
gcc                     GC for the contour lines
gcl                     GC for the contour labels
cp			pointer to the contour value
nx			number of x-coordinates
x			array of x-coordinates (see notes below)
ny			number of y-coordinates
y			array of y-coordinates (see notes below)
lcflag                  flag that defines if we actually are going to have labels 
Least Significat Bits:
z			array of nx*ny z(x,y) values (see notes below)
w			array of nx*ny z(x,y) values (see notes below)
***************************************************************************
Notes:
The two-dimensional array z is actually passed as a one-dimensional
array containing nx*ny values, stored with nx fast and ny slow.

The x and y arrays define a grid that is not necessarily 
uniformly-sampled.  Linear interpolation of z values on the 
grid defined by the x and y arrays is used to determine z values 
between the gridpoints.
		 
The two least significant bits of z are used to mark intersections
of the contour with the x,y grid; therefore, the z values will
almost always be altered (slightly) by contour.

xContour is a modified version of psContour where the use of conmove
and condraw call have been changed to match X-Windows.

Since XDrawLine requires a start and end point, the use of a manually update
of the position variables x0 and y0 is used instead of conmove.

if lcflag is zero no labels are drawn

The w array is used to restrict the range of contour labeling that 
occurs only if w<1. 

As suggested in the reference, the following scheme is used to refer
to a cell of the two-dimensional array z:

                north (0)
      (ix,iy+1)	--------- (ix+1,iy+1)
                | cell  |
       west (3)	| ix,iy	| east (1)
                |       |
        (ix,iy) --------- (ix+1,iy)
                south (2)

***************************************************************************
Reference:
Cottafava, G. and Le Moli, G., 1969, Automatic contour map:
Commuincations of the ACM, v. 12, n. 7, July, 1969.

***************************************************************************
Author:  Morten Wendell Pedersen Aarhus University 07/20/96
Heavily based on psContour by
  Dave Hale, Colorado School of Mines, 06/28/89
  and with contour labeling added by: Zhenyue Liu, June 1993
(actually most of the credit should go to these two guys)
***************************************************************************/
{
	int ix,iy,non,cell,startcell;
	float d;
	float xmin = MIN(x[0],x[nx-1]), xmax = MAX(x[0],x[nx-1]);
	float ymin = MIN(y[0],y[ny-1]), ymax = MAX(y[0],y[ny-1]);
	float xc=0.0, yc=0.0;	/* contour labeling centered at (xc,yc)	*/
 	float xw, yw;	/* width and length of contour labeling */
	float xd, yd;	/* point on contour			*/
	float x0, y0;    /* start plot values (instead of move operation )*/   
	float xdmin, xdmax, ydmin, ydmax; /* range of contour	*/
	int id;	/* =0 if a point on contour has been used as (xc,yc) */
	int cells=0;
	char str[20];
	XCharStruct overall;
	int dummy;
	float c=*cp; /* stupid thing I had to do since I couldn't transfer
			a float without messing up everything 
			but I could transfer a pointer....strange thing
			I will have to track this thing down one day*/

	/* convert a number into a string */
	sprintf(str,"%.*g",nplaces,c);

	/* determine length and width for printing the string */
	XQueryTextExtents(dpy,XGContextFromGC(gcl),str,(int) strlen(str),&dummy,&dummy,&dummy,&overall);
	xw=overall.width;
        yw=overall.ascent+overall.descent;

	/* restrict contour labeling from edges */
	for (iy=0; iy<ny-1; iy++)  
		for (ix=0,cell=iy*nx; ix<nx-1; ix++,cell++) {
			if(x[ix]<xmin+2.0*xw || x[ix]>xmax-2.0*xw 
 				|| y[iy]<ymin+yw || y[iy]>ymax-yw)
  				w[cell] += 1.;
 		}
 
	/* count intersections with cell boundaries */
	non = 0;

	/* find all the intersections */
	for (iy=0; iy<ny; iy++) {
		for (ix=0,cell=iy*nx; ix<nx; ix++,cell++) {

			/* check for intersection with west edge of cell */
			if (iy<ny-1 && BTWN(c,z[cell],z[cell+nx])) {
				SETW(z[cell]);  non++;
			} else {
				CLRW(z[cell]);
			}

			/* check for intersection with south edge of cell */
			if (ix<nx-1 && BTWN(c,z[cell],z[cell+1])) {
				SETS(z[cell]);  non++;
			} else {
				CLRS(z[cell]);
			}
		}
	}


	/* follow contours intersecting north boundary */
	for (ix=0,startcell=(ny-1)*nx; non>0&&ix<nx-1; ix++,startcell++) {
		if (SSET(z[startcell])) {
			d = DELTA(c,z[startcell],z[startcell+1]);
			x0=(1.0-d)*x[ix]+d*x[ix+1];
			y0=y[ny-1];
			CLRS(z[startcell]);  non--;
			cell = startcell-nx;
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(dpy, win,gcc,c,nx,x,ny,y,z,&cell,&xd,&yd,&x0,&y0)){
			  x0=xd;y0=yd;
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcflag && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(dpy,win,gcl,xc-xw/2,yc-yw/2,xw,yw,str,lcf,lcc);
			}
		}
	}

	/* follow contours intersecting east boundary */
	for (iy=0,startcell=nx-1; non>0&&iy<ny-1; iy++,startcell+=nx) {
		if (WSET(z[startcell])) {
			d = DELTA(c,z[startcell],z[startcell+nx]);
			x0=x[nx-1];
			y0=(1.0-d)*y[iy]+d*y[iy+1];
			CLRW(z[startcell]);  non--;
			cell = startcell-1;
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(dpy, win,gcc,c,nx,x,ny,y,z,&cell,&xd,&yd,&x0,&y0)){
			  x0=xd;y0=yd;
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcflag && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(dpy,win,gcl,xc-xw/2,yc-yw/2,xw,yw,str,lcf,lcc);
			}
		}
	}

	/* follow contours intersecting south boundary */
	for (ix=0,startcell=0; non>0&&ix<nx-1; ix++,startcell++) {
		if (SSET(z[startcell])) {
			d = DELTA(c,z[startcell],z[startcell+1]);
			x0=(1.0-d)*x[ix]+d*x[ix+1];
			y0=y[0];
			CLRS(z[startcell]);  non--;
			cell = startcell;
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(dpy, win,gcc,c,nx,x,ny,y,z,&cell,&xd,&yd,&x0,&y0)){
			  x0=xd;y0=yd;
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcflag && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(dpy,win,gcl,xc-xw/2,yc-yw/2,xw,yw,str,lcf,lcc);
			}
		}		 
	}

	/* follow contours intersecting west boundary */
	for (iy=0,startcell=0; non>0&&iy<ny-1; iy++,startcell+=nx) {
		if (WSET(z[startcell])) {
			d = DELTA(c,z[startcell],z[startcell+nx]);
			x0=x[0];
			y0=(1.0-d)*y[iy]+d*y[iy+1];
			CLRW(z[startcell]);  non--;
			cell = startcell;
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(dpy, win,gcc,c,nx,x,ny,y,z,&cell,&xd,&yd,&x0,&y0)){
			  x0=xd;y0=yd;
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcflag && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(dpy,win,gcl,xc-xw/2,yc-yw/2,xw,yw,str,lcf,lcc);
			}
		}
	}

	/* follow interior contours */
	for (iy=1; iy<ny-1; iy++) {
		for (ix=0,startcell=iy*nx; non>0&&ix<nx-1; ix++,startcell++) {

			/* check south edge of cell */
			if (SSET(z[startcell])) {
				d = DELTA(c,z[startcell],z[startcell+1]);
				x0=(1.0-d)*x[ix]+d*x[ix+1];
				y0=y[iy];

				/* clear south edge where we started */
				CLRS(z[startcell]);  non--;

				cell = startcell;

				/* if another intersection exists in this cell */
				if (connect(dpy, win,gcc,c,nx,x,ny,y,z,&cell,&xd,&yd,&x0,&y0)) {
				  x0=xd;y0=yd;
			  
				  /* set south edge so that we finish where we started */
					SETS(z[startcell]);  non++;
			
					/* follow the contour */
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(dpy, win,gcc,c,nx,x,ny,y,z,&cell,&xd,&yd,&x0,&y0)){
			  x0=xd;y0=yd;
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcflag && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(dpy,win,gcl,xc-xw/2,yc-yw/2,xw,yw,str,lcf,lcc);
			}	
				} 		 
			}
		}
	}
	/* contour drawing is done */
}
示例#7
0
/* function */
void psContour (float c, int nx, float x[], int ny, float y[], float z[], 
		float lcs, char *lcf, char *lcc, float *w, int nplaces)
/**************************************************************************
psContour - draw contour of a two-dimensional array via PostScript
***************************************************************************
Input:
c			contour value
nx			number of x-coordinates
x			array of x-coordinates (see notes below)
ny			number of y-coordinates
y			array of y-coordinates (see notes below)
lcs			font size of contour label
lcf			font name of contour label
lcc			color of contour label
Least Significat Bits:
z			array of nx*ny z(x,y) values (see notes below)
w			array of nx*ny z(x,y) values (see notes below)
***************************************************************************
Notes:
The two-dimensional array z is actually passed as a one-dimensional
array containing nx*ny values, stored with nx fast and ny slow.

The x and y arrays define a grid that is not necessarily 
uniformly-sampled.  Linear interpolation of z values on the 
grid defined by the x and y arrays is used to determine z values 
between the gridpoints.
		 
The two least significant bits of z are used to mark intersections
of the contour with the x,y grid; therefore, the z values will
almost always be altered (slightly) by contour.

pscontour isolates the use of PostScript to four internal functions:

void coninit(void) - called before any contour drawing
void conmove(float x, float y) - moves current position to x,y
void condraw(float x, float y) - draws from current position to x,y
void condone(void) - called when contour drawing is done

These functions can usually be replaced with equivalent functions in
other graphics environments.

The w array is used to restrict the range of contour labeling that 
occurs only if w<1. 

As suggested in the reference, the following scheme is used to refer
to a cell of the two-dimensional array z:

                north (0)
      (ix,iy+1)	--------- (ix+1,iy+1)
                | cell  |
       west (3)	| ix,iy	| east (1)
                |       |
        (ix,iy) --------- (ix+1,iy)
                south (2)

***************************************************************************
Reference:
Cottafava, G. and Le Moli, G., 1969, Automatic contour map:
Commuincations of the ACM, v. 12, n. 7, July, 1969.

***************************************************************************
Author:  Dave Hale, Colorado School of Mines, 06/28/89
contour labeling added by: Zhenyue Liu, June 1993
***************************************************************************/
{
	int ix,iy,non,cell,startcell;
	float d;
	float xmin = MIN(x[0],x[nx-1]), xmax = MAX(x[0],x[nx-1]);
	float ymin = MIN(y[0],y[ny-1]), ymax = MAX(y[0],y[ny-1]);
	float xc=0.0, yc=0.0;	/* contour labeling centered at (xc,yc)	*/
 	float xw, yw;	/* width and length of contour labeling */
	float xd, yd;	/* point on contour			*/
	float xdmin, xdmax, ydmin, ydmax; /* range of contour	*/
	int id;	/* =0 if a point on contour has been used as (xc,yc) */
	int cells=0;
	char str[20];

	/* convert a number into a string */
	sprintf(str,"%.*g",nplaces,c);

	/* determine length and width for printing the string */
 	yw = lcs*0.55*((unsigned int) strlen(str));
	xw = lcs*0.8;
	

	/* restrict contour labeling from edges */
	for (iy=0; iy<ny-1; iy++)  
		for (ix=0,cell=iy*nx; ix<nx-1; ix++,cell++) {
			if(x[ix]<xmin+2.0*xw || x[ix]>xmax-2.0*xw 
 				|| y[iy]<ymin+yw || y[iy]>ymax-yw)
  				w[cell] += 1.;
 		}
 
	/* count intersections with cell boundaries */
	non = 0;

	/* find all the intersections */
	for (iy=0; iy<ny; iy++) {
		for (ix=0,cell=iy*nx; ix<nx; ix++,cell++) {

			/* check for intersection with west edge of cell */
			if (iy<ny-1 && BTWN(c,z[cell],z[cell+nx])) {
				SETW(z[cell]);  non++;
			} else {
				CLRW(z[cell]);
			}

			/* check for intersection with south edge of cell */
			if (ix<nx-1 && BTWN(c,z[cell],z[cell+1])) {
				SETS(z[cell]);  non++;
			} else {
				CLRS(z[cell]);
			}
		}
	}

	/* initialize contour drawing */
	coninit();

	/* follow contours intersecting north boundary */
	for (ix=0,startcell=(ny-1)*nx; non>0&&ix<nx-1; ix++,startcell++) {
		if (SSET(z[startcell])) {
			d = DELTA(c,z[startcell],z[startcell+1]);
			conmove((1.0-d)*x[ix]+d*x[ix+1],y[ny-1]);
			CLRS(z[startcell]);  non--;
			cell = startcell-nx;
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(c,nx,x,ny,y,z,&cell,&xd,&yd)){
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcs>1 && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(xc-xw/2,yc-yw/2,xw,yw,str,lcs,lcf,lcc);
			}
		}
	}

	/* follow contours intersecting east boundary */
	for (iy=0,startcell=nx-1; non>0&&iy<ny-1; iy++,startcell+=nx) {
		if (WSET(z[startcell])) {
			d = DELTA(c,z[startcell],z[startcell+nx]);
			conmove(x[nx-1],(1.0-d)*y[iy]+d*y[iy+1]);
			CLRW(z[startcell]);  non--;
			cell = startcell-1;
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(c,nx,x,ny,y,z,&cell,&xd,&yd)){
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcs>1 && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(xc-xw/2,yc-yw/2,xw,yw,str,lcs,lcf,lcc);
			}
		}
	}

	/* follow contours intersecting south boundary */
	for (ix=0,startcell=0; non>0&&ix<nx-1; ix++,startcell++) {
		if (SSET(z[startcell])) {
			d = DELTA(c,z[startcell],z[startcell+1]);
			conmove((1.0-d)*x[ix]+d*x[ix+1],y[0]);
			CLRS(z[startcell]);  non--;
			cell = startcell;
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(c,nx,x,ny,y,z,&cell,&xd,&yd)){
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcs>1 && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(xc-xw/2,yc-yw/2,xw,yw,str,lcs,lcf,lcc);
			}
		}		 
	}

	/* follow contours intersecting west boundary */
	for (iy=0,startcell=0; non>0&&iy<ny-1; iy++,startcell+=nx) {
		if (WSET(z[startcell])) {
			d = DELTA(c,z[startcell],z[startcell+nx]);
			conmove(x[0],(1.0-d)*y[iy]+d*y[iy+1]);
			CLRW(z[startcell]);  non--;
			cell = startcell;
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(c,nx,x,ny,y,z,&cell,&xd,&yd)){
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcs>1 && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(xc-xw/2,yc-yw/2,xw,yw,str,lcs,lcf,lcc);
			}		
		}
	}

	/* follow interior contours */
	for (iy=1; iy<ny-1; iy++) {
		for (ix=0,startcell=iy*nx; non>0&&ix<nx-1; ix++,startcell++) {

			/* check south edge of cell */
			if (SSET(z[startcell])) {
				d = DELTA(c,z[startcell],z[startcell+1]);
				conmove((1.0-d)*x[ix]+d*x[ix+1],y[iy]);

				/* clear south edge where we started */
				CLRS(z[startcell]);  non--;

				cell = startcell;

				/* if another intersection exists in this cell */
				if (connect(c,nx,x,ny,y,z,&cell,&xd,&yd)) {

					/* set south edge so that we finish where we started */
					SETS(z[startcell]);  non++;
			
					/* follow the contour */
			id = 1; 
			xdmin = xmax;
			xdmax = xmin;
			ydmin = ymax;
			ydmax = ymin;
			while (connect(c,nx,x,ny,y,z,&cell,&xd,&yd)){
				 non--;
				if(w[cell]<0.5 && id) {
					xc = xd; yc = yd;
					cells = cell;
					id = 0;
				}
				xdmin = MIN(xdmin,xd);
				xdmax = MAX(xdmax,xd);
				ydmin = MIN(ydmin,yd);
				ydmax = MAX(ydmax,yd);
			}
			if(lcs>1 && id==0 && xdmax+ydmax-xdmin-ydmin>xw+yw) {
				wcell(nx,x,ny,y,w,cells,xc,yc,xw,yw);
 				labelc(xc-xw/2,yc-yw/2,xw,yw,str,lcs,lcf,lcc);
			}	
				} 		 
			}
		}
	}
	/* contour drawing is done */
	condone();
}
示例#8
0
void Analyzer_Reading::AnalyzeStd(Play* _play)
{
	std::vector<Hitobject*>& hitobjects = _play->beatmap->getHitobjects();
	osu::TIMING timing;

	std::vector<osu::TIMING>& timingsRate = *AnalysisStruct::beatmapAnalysis.getAnalyzer("note rate")->getData();
	std::vector<osu::TIMING>& timingsVel = *AnalysisStruct::beatmapAnalysis.getAnalyzer("velocity (px/ms)")->getData();

	vector2df avgCoor, distractor;
	int i = 0, previ = 0;
	double delay = 10.0;
	double avgCoeff = 0.4; // higher coeff = more precise

	for (int ms = 0; ms < hitobjects[hitobjects.size() - 1]->getTime(); ms += delay)
	{
		// Let index catch up to the time. Bail if out of bounds
		while (hitobjects[i]->getEndTime() < ms) i++;
		if (i >= hitobjects.size()) break;

		// Out of bound check
		if (!BTWN(1, i, hitobjects.size() - 1))
			continue;

		previ = i;

		int iNoteRate = FindTimingAt(timingsRate, ms);
		int iNoteVel = FindTimingAt(timingsVel, ms);

		double noteRateVel = timingsVel[iNoteVel].data*timingsRate[iNoteRate].data;
		const double diffCoeff = 1.02; // interpreted easiness of the note rate velocity. Use this to adjust interpreted reading difficulty. (higher = easier, SENSITIVE to nearest 0.01)

		if (timingsVel[iNoteVel].press == false)
			noteRateVel /= 1.01;
		else
			noteRateVel /= 1.03;

		avgCoeff = 1.0 / ((noteRateVel/*/diffCoeff*/) + 1.0);

		// Apply cursor movement averaging
		if (!hitobjects[i]->isHitobjectLong())
		{
			avgCoor.X = avgCoeff*((double)hitobjects[i]->getPos().X + distractor.X) + (1.0 - avgCoeff)*avgCoor.X;
			avgCoor.Y = avgCoeff*((double)hitobjects[i]->getPos().Y + distractor.Y) + (1.0 - avgCoeff)*avgCoor.Y;
		}
		else
		{
			avgCoor.X = avgCoeff*(double)(hitobjects[i]->getSlider()->GetSliderPos(ms).X + distractor.X) + (1.0 - avgCoeff)*avgCoor.X;
			avgCoor.Y = avgCoeff*(double)(hitobjects[i]->getSlider()->GetSliderPos(ms).Y + distractor.Y) + (1.0 - avgCoeff)*avgCoor.Y;
		}

		timing.press = false;
		if (!hitobjects[i]->isHitobjectLong()) // hitcircle
		{
			if (BTWN(ms - delay / 2.0, hitobjects[i]->getTime(), ms + delay / 2.0))
			{
				double dist = getDist(hitobjects[i]->getPos(), vector2d<double>(avgCoor.X, avgCoor.Y));
				double radius = CS2px(_play->getMod()->getCS()) / 2.0;
				
				const double divider = 1.0;			// SENSITIVE to nearest 1.0
				const double distSensitivity = 1.4; // shifts distance by x radii (1.0 = 1.0*CSpx). Use this to fix imbalance due to interpreted slider reading difficulty. Higher = easier. SENSITIVE to nearest 0.01

				//                  formula											 set x=0 to y=0
				timing.data = exp(dist - radius*distSensitivity)/divider - exp(0 - radius*distSensitivity)/divider;
				timing.press = true;
			}
		}
		else  // slider
		{
			if (BTWN(hitobjects[i]->getTime(), ms, hitobjects[i]->getEndTime()))
			{
				vector2d<double> pos = hitobjects[i]->getSlider()->GetSliderPos(ms);
				double dist = getDist(vector2d<double>(pos.X, pos.Y), vector2d<double>(avgCoor.X, avgCoor.Y));
				double radius = CS2px(_play->getMod()->getCS()) / 2.0;
				
				const double divider = 1.0;          // SENSITIVE to nearest 1.0
				const double distSensitivity = 1.36; // shifts distance by x radii (1.0 = 1.0*CSpx). Use this to adjust interpreted slider reading difficulty. Higher = easier. SENSITIVE to nearest 0.01
	
				//                  formula											 set x=0 to y=0
				timing.data = exp(dist - radius*distSensitivity)/divider - exp(0 - radius*distSensitivity)/divider;
				timing.press = true;
			}
		}

		timing.pos = avgCoor;
		timing.time = ms;

		// i > 1 to remove averaging errors when starting
		if (i > 1)
			data.push_back(timing);
	}
}
示例#9
0
static char *_get_input(CTX *ctx, char *str, char *dflt)
{
  //TODO KEY_ESC cancelation
  static char in[1000];
  char *ptr = in;

  noecho();
  attron( COLOR_PAIR( 2 ) );

  mvchgat( ctx->rows - 4, 2, -1, A_INVIS, 0, NULL );
  move( ctx->rows - 3, 2 );
  for( int i = 0; i < ctx->cols; i++ ) addch( ' ' );
  mvprintw( ctx->rows - 3, 2, "%s > ", str );

  int y, x;
  getyx( stdscr, y, x );

  attron( A_BOLD );
  curs_set( 2 );

  if( dflt ) {
    strcpy( ptr, dflt );
    printw( dflt );
    ptr += strlen( ptr );
  } else
    memset( in, 0, sizeof( in ) );

  int end = 0,
      c = getch();
  do {
    refresh();

    switch( c ) {
    case KEY_BACKSPACE:
      if( ptr != in )
        *(--ptr) = '\0';
      break;
    case '\n':
      end = 1;
      c = '\0';
    default:
      if( strspn( (char*)&c, " ()*,._")
          || BTWN( c, 0x30, 0x39 )
          || BTWN( c, 0x41, 0x5a )
          || BTWN( c, 0x61, 0x7a ) )
        *(ptr++) = c;
    }

    mvprintw( y, x, "%s", in );
    for( int i = 0; i < ctx->cols - strlen( in ) - 3; i++ ) addch( ' ' );
    move( y, x + strlen( in ) );

  } while ( !end && ( c = getch() ) );

  curs_set( 0 );
  attroff( A_BOLD );

  attroff( COLOR_PAIR( 2 ) );
  noecho();

  return in;
}