removed map continue mode (continue drawing map on next frame) because it produces annoying flashes

Former-commit-id: 57448a74eed032e6630d6f3cdfb1e39ba076f092
Former-commit-id: 69a64e4fe977ed0bcb6500b7d19979c6084560cb
This commit is contained in:
nathan 2020-03-02 22:44:32 -08:00
parent e2de0076c2
commit 93e26cc2e4
5 changed files with 20 additions and 98 deletions

View file

@ -35,6 +35,7 @@ cd spidr
### Runtime Options ### Runtime Options
--server [domain name or ip] Specify a dump1090 server. Renamed from the view1090 "--net-bo-ip-addr" argument --server [domain name or ip] Specify a dump1090 server. Renamed from the view1090 "--net-bo-ip-addr" argument
--port [port number] Specify dump1090 server port. Renamed from the view1090 "--net-bo-port" argument
--metric Display metric units rather than imperial. --metric Display metric units rather than imperial.
--screensize [width] [height] Specify a specific resolution to pass to SDL_RenderSetLogicalSize, otherwise use resolution of display --screensize [width] [height] Specify a specific resolution to pass to SDL_RenderSetLogicalSize, otherwise use resolution of display

113
draw.c
View file

@ -225,7 +225,7 @@ void drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color planeCo
*returny = y3; *returny = y3;
} }
void drawPlaneHeading(int x, int y, float heading, SDL_Color planeColor) void drawPlaneIcon(int x, int y, float heading, SDL_Color planeColor)
{ {
float body = 8.0 * appData.screen_uiscale; float body = 8.0 * appData.screen_uiscale;
float wing = 6.0 * appData.screen_uiscale; float wing = 6.0 * appData.screen_uiscale;
@ -245,11 +245,6 @@ void drawPlaneHeading(int x, int y, float heading, SDL_Color planeColor)
int x1, x2, y1, y2; int x1, x2, y1, y2;
// tempCenter
// circleRGBA(appData.renderer, x, y, 10, 255, 0, 0, 255);
//body //body
x1 = x + round(-body*vec[0]); x1 = x + round(-body*vec[0]);
y1 = y + round(-body*vec[1]); y1 = y + round(-body*vec[1]);
@ -277,14 +272,6 @@ void drawPlaneHeading(int x, int y, float heading, SDL_Color planeColor)
filledTrigonRGBA (appData.renderer, x1, y1, x2, y2, x+round(-body*.5*vec[0]), y+round(-body*.5*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE); filledTrigonRGBA (appData.renderer, x1, y1, x2, y2, x+round(-body*.5*vec[0]), y+round(-body*.5*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
} }
void drawPlane(int x, int y, SDL_Color planeColor)
{
int length = 3.0;
rectangleRGBA (appData.renderer, x - length, y - length, x+length, y + length, planeColor.r, planeColor.g, planeColor.b, SDL_ALPHA_OPAQUE);
}
void drawTrail(float *oldDx, float *oldDy, float *oldHeading, time_t * oldSeen, int idx) { void drawTrail(float *oldDx, float *oldDy, float *oldHeading, time_t * oldSeen, int idx) {
int currentIdx, prevIdx; int currentIdx, prevIdx;
@ -333,7 +320,14 @@ void drawTrail(float *oldDx, float *oldDy, float *oldHeading, time_t * oldSeen,
uint8_t colorVal = (uint8_t)floor(255.0 * age); uint8_t colorVal = (uint8_t)floor(255.0 * age);
thickLineRGBA(appData.renderer, prevX, prevY, currentX, currentY, 2 * appData.screen_uiscale, colorVal, colorVal, colorVal, 64); thickLineRGBA(appData.renderer, prevX, prevY, currentX, currentY, 2 * appData.screen_uiscale, colorVal, colorVal, colorVal, 64);
//most recent reported location
if(i == 0) {
boxRGBA(appData.renderer,currentX - 2 * appData.screen_uiscale, currentY - 2 * appData.screen_uiscale, currentX + 2 * appData.screen_uiscale, currentY - 2 * appData.screen_uiscale,
orange.r, orange.g, orange.b, 255);
}
//tick marks //tick marks
@ -381,11 +375,9 @@ void drawScaleBars()
char scaleLabel[13] = ""; char scaleLabel[13] = "";
// thickLineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,pink.r, pink.g, pink.b, 255); lineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
while(scaleBarDist < appData.screen_width) { while(scaleBarDist < appData.screen_width) {
// thickLineRGBA(appData.renderer,10+scaleBarDist,10,10+scaleBarDist,10*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,pink.r, pink.g, pink.b, 255); lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
if (Modes.metric) { if (Modes.metric) {
@ -403,20 +395,7 @@ void drawScaleBars()
scalePower--; scalePower--;
scaleBarDist = screenDist((float)pow(10,scalePower)); scaleBarDist = screenDist((float)pow(10,scalePower));
// thickLineRGBA(appData.renderer,10,10+5*appData.screen_uiscale,10+scaleBarDist,10+5*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer,10,10+5*appData.screen_uiscale,10+scaleBarDist,10+5*appData.screen_uiscale,pink.r, pink.g, pink.b, 255); lineRGBA(appData.renderer,10,10+5*appData.screen_uiscale,10+scaleBarDist,10+5*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
// int p1km = screenDist(1.0);
// int p10km = screenDist(10.0);
// int p100km = screenDist(100.0);
// circleRGBA (appData.renderer, appData.screen_width>>1, appData.screen_height * CENTEROFFSET, p1km, pink.r, pink.g, pink.b, 255);
// circleRGBA (appData.renderer, appData.screen_width>>1, appData.screen_height * CENTEROFFSET, p10km, pink.r, pink.g, pink.b, 195);
// circleRGBA (appData.renderer, appData.screen_width>>1, appData.screen_height * CENTEROFFSET, p100km, pink.r, pink.g, pink.b, 127);
// drawString("1km", (appData.screen_width>>1) + (0.707 * p1km) + 5, (appData.screen_height * CENTEROFFSET) + (0.707 * p1km) + 5, appData.mapFont, pink);
// drawString("10km", (appData.screen_width>>1) + (0.707 * p10km) + 5, (appData.screen_height * CENTEROFFSET) + (0.707 * p10km) + 5, appData.mapFont, pink);
// drawString("100km", (appData.screen_width>>1) + (0.707 * p100km) + 5, (appData.screen_height * CENTEROFFSET) + (0.707 * p100km) + 5, appData.mapFont, pink);
} }
void drawPolys(QuadTree *tree, float screen_lat_min, float screen_lat_max, float screen_lon_min, float screen_lon_max) { void drawPolys(QuadTree *tree, float screen_lat_min, float screen_lat_max, float screen_lon_min, float screen_lon_max) {
@ -424,19 +403,6 @@ void drawPolys(QuadTree *tree, float screen_lat_min, float screen_lat_max, float
return; return;
} }
if(appData.mapContinue && appData.mapContinue != tree) {
return;
}
if(appData.mapContinue && appData.mapContinue == tree) {
appData.mapContinue = NULL;
}
if(mstime() - appData.lastFrameTime > FRAMETIME) {
appData.mapContinue = tree;
return;
}
if (tree->lat_min > screen_lat_max || screen_lat_min > tree->lat_max) { if (tree->lat_min > screen_lat_max || screen_lat_min > tree->lat_max) {
return; return;
} }
@ -448,34 +414,10 @@ void drawPolys(QuadTree *tree, float screen_lat_min, float screen_lat_max, float
drawPolys(tree->nw, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max); drawPolys(tree->nw, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
drawPolys(tree->sw, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max); drawPolys(tree->sw, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
drawPolys(tree->ne, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max); drawPolys(tree->ne, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
//if we didn't make it to the last child then need to set mapContinue to this node to make sure all children get drawn next time
if(appData.mapContinue) {
appData.mapContinue = tree;
}
drawPolys(tree->se, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max); drawPolys(tree->se, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
float dx, dy; float dx, dy;
//Draw quadtree bounds
//
// int x, y;
// pxFromLonLat(&dx, &dy, tree->lon_min, tree->lat_min);
// screenCoords(&x, &y, dx, dy);
// int top = y;
// int left = x;
// pxFromLonLat(&dx, &dy, tree->lon_max, tree->lat_max);
// screenCoords(&x, &y, dx, dy);
// int bottom = y;
// int right = x;
// rectangleRGBA(appData.renderer, left, top, right, bottom, red.r, red.g, red.b, 255);
Polygon *currentPolygon = tree->polygons; Polygon *currentPolygon = tree->polygons;
while(currentPolygon != NULL) { while(currentPolygon != NULL) {
@ -553,11 +495,7 @@ void drawGeography() {
latLonFromScreenCoords(&screen_lat_min, &screen_lon_min, 0, appData.screen_height * -0.2); latLonFromScreenCoords(&screen_lat_min, &screen_lon_min, 0, appData.screen_height * -0.2);
latLonFromScreenCoords(&screen_lat_max, &screen_lon_max, appData.screen_width, appData.screen_height * 1.2); latLonFromScreenCoords(&screen_lat_max, &screen_lon_max, appData.screen_width, appData.screen_height * 1.2);
if(appData.mapContinue) { drawPolys(&root, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
drawPolys(appData.mapContinue, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
} else {
drawPolys(&root, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
}
} }
void drawSignalMarks(struct planeObj *p, int x, int y) { void drawSignalMarks(struct planeObj *p, int x, int y) {
@ -1004,33 +942,20 @@ void drawPlanes() {
} else { } else {
planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE); planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
} }
// if((int)(now - p->seen) > DISPLAY_ACTIVE) {
// planeColor = grey;
// }
if(outOfBounds(x,y)) { if(outOfBounds(x,y)) {
drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor); drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor);
//lineRGBA(appData.renderer, p->cx, p->cy, p->x+(p->w/2), p->y, 200,200,200,SDL_ALPHA_OPAQUE);
} else { } else {
drawPlaneHeading(usex, usey, p->track, planeColor); drawPlaneIcon(usex, usey, p->track, planeColor);
p->cx = usex;
p->cx = usex;// + 5; p->cy = usey;
p->cy = usey;// + 10 * appData.screen_uiscale;
//lineRGBA(appData.renderer, usex, usey, p->x+(p->w/2), p->y, 200,200,200, SDL_ALPHA_OPAQUE);
} }
if(p != selectedPlane) { if(p != selectedPlane) {
drawPlaneText(p); drawPlaneText(p);
} }
} else { }
//drawPlane(x, y, planeColor);
}
} }
} }
} }
@ -1065,14 +990,12 @@ void draw() {
updateStatus(); updateStatus();
if(appData.mapMoved || appData.mapContinue) { if(appData.mapMoved) {
SDL_SetRenderTarget(appData.renderer, appData.mapTexture); SDL_SetRenderTarget(appData.renderer, appData.mapTexture);
if(appData.mapContinue == NULL) { SDL_SetRenderDrawColor(appData.renderer, 0, 0, 0, 0);
SDL_SetRenderDrawColor(appData.renderer, 0, 0, 0, 0); SDL_RenderClear(appData.renderer);
SDL_RenderClear(appData.renderer);
}
drawGeography(); drawGeography();
drawScaleBars(); drawScaleBars();

1
init.c
View file

@ -44,7 +44,6 @@ void init(char *title) {
appData.mapMoved = 1; appData.mapMoved = 1;
selectedPlane = NULL; selectedPlane = NULL;
appData.mapContinue = NULL;
if(appData.fullscreen) { if(appData.fullscreen) {
//\SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother. //\SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother.

View file

@ -42,7 +42,6 @@ typedef struct AppData
int touchy; int touchy;
int mapMoved; int mapMoved;
QuadTree *mapContinue;
uint64_t lastFrameTime; uint64_t lastFrameTime;
} AppData; } AppData;

View file

@ -1 +1 @@
ade669691e5258a9db857adaedb879bb3c653d1e cd3abc894d6c0a4ec31ca1210552bf4da06145a5