map convert precision change. fixed map load issue. changed time functions to std::chrono

Former-commit-id: a774a5bdbcf9e1c643e56277dbeedcedacb54905
This commit is contained in:
nathan 2020-06-11 21:55:04 -07:00
parent bc88c0ba5d
commit def7ee20e1
11 changed files with 123 additions and 126 deletions

View file

@ -1,15 +1,12 @@
#include "AircraftList.h" #include "AircraftList.h"
static uint64_t mstime(void) { #include <chrono>
struct timeval tv;
uint64_t mst;
gettimeofday(&tv, nullptr); static uint64_t now() {
mst = ((uint64_t)tv.tv_sec)*1000; return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
mst += tv.tv_usec/1000;
return mst;
} }
Aircraft *AircraftList::find(uint32_t addr) { Aircraft *AircraftList::find(uint32_t addr) {
Aircraft *p = head; Aircraft *p = head;
@ -35,7 +32,6 @@ void AircraftList::update(Modes *modes) {
p = find(a->addr); p = find(a->addr);
if (!p) { if (!p) {
//p = createPlaneObj(a);
p = new Aircraft(a->addr); p = new Aircraft(a->addr);
p->next = head; p->next = head;
head = p; head = p;
@ -51,7 +47,7 @@ void AircraftList::update(Modes *modes) {
} }
p->seen = a->seen; p->seen = a->seen;
p->msSeen = mstime(); p->msSeen = now();
if((p->seen - p->prev_seen) > 0) { if((p->seen - p->prev_seen) > 0) {
p->messageRate = 1.0 / (double)(p->seen - p->prev_seen); p->messageRate = 1.0 / (double)(p->seen - p->prev_seen);
@ -68,7 +64,7 @@ void AircraftList::update(Modes *modes) {
p->lat = a->lat; p->lat = a->lat;
if(p->seenLatLon < a->seenLatLon) { if(p->seenLatLon < a->seenLatLon) {
p->msSeenLatLon = mstime(); p->msSeenLatLon = now();
// p->oldIdx = (p->oldIdx+1) % 32; // p->oldIdx = (p->oldIdx+1) % 32;
@ -120,4 +116,4 @@ AircraftList::~AircraftList() {
head = head->next; head = head->next;
delete(temp); delete(temp);
} }
} }

View file

@ -81,31 +81,31 @@ void AppData::updateStatus() {
msgRateAccumulate = 0.0; msgRateAccumulate = 0.0;
// PlaneObj *p = appData.planes; Aircraft *p = aircraftList.head;
// while(p) { while(p) {
// unsigned char * pSig = p->signalLevel; unsigned char * pSig = p->signalLevel;
// unsigned int signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] + unsigned int signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] +
// pSig[4] + pSig[5] + pSig[6] + pSig[7]); pSig[4] + pSig[5] + pSig[6] + pSig[7]);
// sigAccumulate += signalAverage; sigAccumulate += signalAverage;
// if (p->lon && p->lat) { if (p->lon && p->lat) {
// numVisiblePlanes++; numVisiblePlanes++;
// } }
// totalCount++; totalCount++;
// msgRateAccumulate += p->messageRate; msgRateAccumulate += p->messageRate;
// p = p->next; p = p->next;
// } }
// Status.msgRate = msgRateAccumulate; msgRate = msgRateAccumulate;
// Status.avgSig = sigAccumulate / (double) totalCount; avgSig = sigAccumulate / (double) totalCount;
// Status.numPlanes = totalCount; numPlanes = totalCount;
// Status.numVisiblePlanes = numVisiblePlanes; numVisiblePlanes = numVisiblePlanes;
// Status.maxDist = maxDist; maxDist = maxDist;
} }

View file

@ -1,13 +1,13 @@
#include "Input.h" #include "Input.h"
static uint64_t mstime(void) { #include <chrono>
struct timeval tv;
uint64_t mst;
gettimeofday(&tv, NULL); static uint64_t now() {
mst = ((uint64_t)tv.tv_sec)*1000; return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
mst += tv.tv_usec/1000; }
return mst;
static uint64_t elapsed(uint64_t ref) {
return now() - ref;
} }
template <typename T> int sgn(T val) { template <typename T> int sgn(T val) {
@ -54,13 +54,13 @@ void Input::getInput()
view->mapTargetMaxDist = 0; view->mapTargetMaxDist = 0;
view->mapMoved = 1; view->mapMoved = 1;
if(mstime() - touchDownTime > 100) { if(elapsed(touchDownTime) > 100) {
touchDownTime = 0; touchDownTime = 0;
} }
break; break;
case SDL_FINGERMOTION:; case SDL_FINGERMOTION:;
if(mstime() - touchDownTime > 150) { if(elapsed(touchDownTime) > 150) {
tapCount = 0; tapCount = 0;
touchDownTime = 0; touchDownTime = 0;
} }
@ -68,17 +68,19 @@ void Input::getInput()
break; break;
case SDL_FINGERDOWN: case SDL_FINGERDOWN:
if(mstime() - touchDownTime > 500) { if(elapsed(touchDownTime) > 500) {
tapCount = 0; tapCount = 0;
} }
if(SDL_GetNumTouchFingers(event.tfinger.touchId) == 0) {
touchDownTime = mstime(); //this finger number is always 1 for down and 0 for up an rpi+hyperpixel??
if(SDL_GetNumTouchFingers(event.tfinger.touchId) == 1) {
touchDownTime = now();
} }
break; break;
case SDL_FINGERUP: case SDL_FINGERUP:
if(mstime() - touchDownTime < 150 && SDL_GetNumTouchFingers(event.tfinger.touchId) == 0) { if(elapsed(touchDownTime) < 150 && SDL_GetNumTouchFingers(event.tfinger.touchId) == 0) {
touchx = view->screen_width * event.tfinger.x; touchx = view->screen_width * event.tfinger.x;
touchy = view->screen_height * event.tfinger.y; touchy = view->screen_height * event.tfinger.y;
tapCount++; tapCount++;
@ -93,10 +95,10 @@ void Input::getInput()
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
if(event.button.which != SDL_TOUCH_MOUSEID) { if(event.button.which != SDL_TOUCH_MOUSEID) {
if(mstime() - touchDownTime > 500) { if(elapsed(touchDownTime) > 500) {
tapCount = 0; tapCount = 0;
} }
touchDownTime = mstime(); touchDownTime = now();
} }
break; break;

View file

@ -3,7 +3,7 @@
# sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local # sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local
# #
CFLAGS=-O2 -g -Wno-write-strings CFLAGS=-O3 -Wno-write-strings
LIBS=-lm -lSDL2 -lSDL2_ttf -lSDL2_gfx LIBS=-lm -lSDL2 -lSDL2_ttf -lSDL2_gfx
CC=g++ CC=g++

12
Map.cpp
View file

@ -157,7 +157,6 @@ Map::Map() {
} }
Polygon *currentPolygon = new Polygon; Polygon *currentPolygon = new Polygon;
printf("A\n");
for(int i = 0; i < mapPoints_count; i+=2) { for(int i = 0; i < mapPoints_count; i+=2) {
if(mapPoints[i] == 0) { if(mapPoints[i] == 0) {
@ -171,13 +170,17 @@ printf("A\n");
if(mapPoints[i] < currentPolygon->lon_min) { if(mapPoints[i] < currentPolygon->lon_min) {
currentPolygon->lon_min = mapPoints[i]; currentPolygon->lon_min = mapPoints[i];
} else if(mapPoints[i] > currentPolygon->lon_max) { }
if(mapPoints[i] > currentPolygon->lon_max) {
currentPolygon->lon_max = mapPoints[i]; currentPolygon->lon_max = mapPoints[i];
} }
if(mapPoints[i+1] < currentPolygon->lat_min) { if(mapPoints[i+1] < currentPolygon->lat_min) {
currentPolygon->lat_min = mapPoints[i+1]; currentPolygon->lat_min = mapPoints[i+1];
} else if(mapPoints[i+1] > currentPolygon->lat_max) { }
if(mapPoints[i+1] > currentPolygon->lat_max) {
currentPolygon->lat_max = mapPoints[i+1]; currentPolygon->lat_max = mapPoints[i+1];
} }
@ -186,6 +189,5 @@ printf("A\n");
currentPolygon->points.push_back(*currentPoint); currentPolygon->points.push_back(*currentPoint);
} }
printf("B\n");
} }

View file

@ -7,14 +7,24 @@
#include "View.h" #include "View.h"
static uint64_t mstime(void) { #include <iostream>
struct timeval tv;
uint64_t mst;
gettimeofday(&tv, NULL); #include <chrono>
mst = ((uint64_t)tv.tv_sec)*1000;
mst += tv.tv_usec/1000; static uint64_t now() {
return mst; return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
}
static time_t now_s() {
return std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
}
static uint64_t elapsed(uint64_t ref) {
return now() - ref;
}
static time_t elapsed_s(time_t ref) {
return now_s() - ref;
} }
static float sign(float x) { static float sign(float x) {
@ -239,7 +249,7 @@ void View::SDL_init() {
} }
window = SDL_CreateWindow("viz1090", SDL_WINDOWPOS_CENTERED_DISPLAY(screen_index), SDL_WINDOWPOS_CENTERED_DISPLAY(screen_index), screen_width, screen_height, flags); window = SDL_CreateWindow("viz1090", SDL_WINDOWPOS_CENTERED_DISPLAY(screen_index), SDL_WINDOWPOS_CENTERED_DISPLAY(screen_index), screen_width, screen_height, flags);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
mapTexture = SDL_CreateTexture(renderer, mapTexture = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_TARGET, SDL_TEXTUREACCESS_TARGET,
@ -278,11 +288,11 @@ void View::font_init() {
// todo separate style stuff // todo separate style stuff
// //
SDL_Color bgcolor = {10,20,30,255}; SDL_Color bgcolor = {0,0,0,255};
SDL_Color greenblue = {236,192,68,255}; SDL_Color greenblue = {236,192,68,255};
SDL_Color lightblue = {211,208,203,255}; SDL_Color lightblue = {211,208,203,255};
SDL_Color mediumblue ={110,136,152,255}; SDL_Color mediumblue ={110,136,152,255};
SDL_Color darkblue = {46,82,102,255}; SDL_Color darkblue = {23,41,51,255};
style.backgroundColor = bgcolor; style.backgroundColor = bgcolor;
style.selectedColor = pink; style.selectedColor = pink;
@ -522,9 +532,12 @@ void View::drawPlaneIcon(int x, int y, float heading, SDL_Color planeColor)
} }
void View::drawTrail(Aircraft *p) { void View::drawTrail(Aircraft *p) {
return;
int currentX, currentY, prevX, prevY; int currentX, currentY, prevX, prevY;
if(p->lonHistory.empty()) {
return;
}
std::vector<float>::iterator lon_idx = p->lonHistory.begin(); std::vector<float>::iterator lon_idx = p->lonHistory.begin();
std::vector<float>::iterator lat_idx = p->latHistory.begin(); std::vector<float>::iterator lat_idx = p->latHistory.begin();
std::vector<float>::iterator heading_idx = p->headingHistory.begin(); std::vector<float>::iterator heading_idx = p->headingHistory.begin();
@ -534,15 +547,12 @@ void View::drawTrail(Aircraft *p) {
for(; std::next(lon_idx) != p->lonHistory.end(); ++lon_idx, ++lat_idx, ++heading_idx) { for(; std::next(lon_idx) != p->lonHistory.end(); ++lon_idx, ++lat_idx, ++heading_idx) {
float dx, dy; float dx, dy;
pxFromLonLat(&dx, &dy, *(std::next(lon_idx)), *(std::next(lat_idx)));
pxFromLonLat(&dx, &dy, *std::next(lon_idx), *std::next(lat_idx));
screenCoords(&currentX, &currentY, dx, dy); screenCoords(&currentX, &currentY, dx, dy);
pxFromLonLat(&dx, &dy, *lon_idx, *lat_idx); pxFromLonLat(&dx, &dy, *lon_idx, *lat_idx);
screenCoords(&prevX, &prevY, dx, dy); screenCoords(&prevX, &prevY, dx, dy);
if(outOfBounds(currentX,currentY)) { if(outOfBounds(currentX,currentY)) {
continue; continue;
} }
@ -631,11 +641,11 @@ void View::drawPolys(float screen_lat_min, float screen_lat_max, float screen_lo
std::vector<Polygon> polyList = map.getPolys(screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max); std::vector<Polygon> polyList = map.getPolys(screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
std::vector<Polygon>::iterator currentPolygon; std::vector<Polygon>::iterator currentPolygon;
for (currentPolygon = polyList.begin(); currentPolygon != polyList.end(); ++currentPolygon) { for (currentPolygon = polyList.begin(); currentPolygon != polyList.end(); ++currentPolygon) {
int x1,y1,x2,y2; int x1,y1,x2,y2;
float dx,dy; float dx,dy;
std::vector<Point>::iterator currentPoint; std::vector<Point>::iterator currentPoint;
std::vector<Point>::iterator prevPoint = currentPolygon->points.begin(); std::vector<Point>::iterator prevPoint = currentPolygon->points.begin();
@ -644,16 +654,12 @@ void View::drawPolys(float screen_lat_min, float screen_lat_max, float screen_lo
pxFromLonLat(&dx, &dy, prevPoint->lon, prevPoint->lat); pxFromLonLat(&dx, &dy, prevPoint->lon, prevPoint->lat);
screenCoords(&x1, &y1, dx, dy); screenCoords(&x1, &y1, dx, dy);
if(outOfBounds(x1,y1)) {
continue;
}
float d1 = dx* dx + dy * dy; float d1 = dx* dx + dy * dy;
pxFromLonLat(&dx, &dy, currentPoint->lon, currentPoint->lat); pxFromLonLat(&dx, &dy, currentPoint->lon, currentPoint->lat);
screenCoords(&x2, &y2, dx, dy); screenCoords(&x2, &y2, dx, dy);
if(outOfBounds(x2,y2)) { if(outOfBounds(x1,y1) && outOfBounds(x2,y2)) {
continue; continue;
} }
@ -703,11 +709,11 @@ void View::drawSignalMarks(Aircraft *p, int x, int y) {
SDL_Color barColor = signalToColor(signalAverage); SDL_Color barColor = signalToColor(signalAverage);
Uint8 seenFade = (Uint8) (255.0 - (mstime() - p->msSeen) / 4.0); Uint8 seenFade = (Uint8) (255.0 - elapsed(p->msSeen) / 4.0);
circleRGBA(renderer, x + mapFontWidth, y - 5, 2 * screen_uiscale, barColor.r, barColor.g, barColor.b, seenFade); circleRGBA(renderer, x + mapFontWidth, y - 5, 2 * screen_uiscale, barColor.r, barColor.g, barColor.b, seenFade);
seenFade = (Uint8) (255.0 - (mstime() - p->msSeenLatLon) / 4.0); seenFade = (Uint8) (255.0 - elapsed(p->msSeenLatLon) / 4.0);
hlineRGBA(renderer, x + mapFontWidth + 5 * screen_uiscale, x + mapFontWidth + 9 * screen_uiscale, y - 5, barColor.r, barColor.g, barColor.b, seenFade); hlineRGBA(renderer, x + mapFontWidth + 5 * screen_uiscale, x + mapFontWidth + 9 * screen_uiscale, y - 5, barColor.r, barColor.g, barColor.b, seenFade);
vlineRGBA(renderer, x + mapFontWidth + 7 * screen_uiscale, y - 2 * screen_uiscale - 5, y + 2 * screen_uiscale - 5, barColor.r, barColor.g, barColor.b, seenFade); vlineRGBA(renderer, x + mapFontWidth + 7 * screen_uiscale, y - 2 * screen_uiscale - 5, y + 2 * screen_uiscale - 5, barColor.r, barColor.g, barColor.b, seenFade);
@ -1037,7 +1043,6 @@ void View::resolveLabelConflicts() {
void View::drawPlanes() { void View::drawPlanes() {
Aircraft *p = appData->aircraftList.head; Aircraft *p = appData->aircraftList.head;
time_t now = time(NULL);
SDL_Color planeColor; SDL_Color planeColor;
// draw all trails first so they don't cover up planes and text // draw all trails first so they don't cover up planes and text
@ -1063,10 +1068,10 @@ void View::drawPlanes() {
screenCoords(&x, &y, dx, dy); screenCoords(&x, &y, dx, dy);
if(p->created == 0) { if(p->created == 0) {
p->created = mstime(); p->created = now();
} }
float age_ms = (float)(mstime() - p->created); float age_ms = (float)elapsed(p->created);
if(age_ms < 500) { if(age_ms < 500) {
circleRGBA(renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0)); circleRGBA(renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
} else { } else {
@ -1083,11 +1088,11 @@ void View::drawPlanes() {
float velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->timestampHistory.back())); float velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->timestampHistory.back()));
float vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->timestampHistory.back())); float vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->timestampHistory.back()));
usex = x + (mstime() - p->msSeenLatLon) * velx; usex = x + elapsed(p->msSeenLatLon) * velx;
usey = y + (mstime() - p->msSeenLatLon) * vely; usey = y + elapsed(p->msSeenLatLon) * vely;
} }
planeColor = lerpColor(style.planeColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE); planeColor = lerpColor(style.planeColor, style.planeGoneColor, float(elapsed_s(p->seen)) / (float) DISPLAY_ACTIVE);
if(p == selectedAircraft) { if(p == selectedAircraft) {
planeColor = style.selectedColor; planeColor = style.selectedColor;
@ -1165,8 +1170,8 @@ void View::moveCenterRelative(float dx, float dy) {
float scale_factor = (screen_width > screen_height) ? screen_width : screen_height; float scale_factor = (screen_width > screen_height) ? screen_width : screen_height;
dx = -1.0 * (0.75*(double)screen_width / (double)screen_height) * dx * maxDist / (0.95 * scale_factor * 0.5); dx = -1.0 * dx * maxDist / (0.95 * scale_factor * 0.5);
dy = 1.0 * dy * maxDist / (0.95 * scale_factor * 0.5); dy = 1.0 * dy * maxDist / (0.95 * scale_factor * 0.5);
float outLat = dy * (1.0/6371.0) * (180.0f / M_PI); float outLat = dy * (1.0/6371.0) * (180.0f / M_PI);
@ -1209,12 +1214,12 @@ void View::moveMapToTarget() {
} }
void View::drawMouse() { void View::drawMouse() {
if(mouseMovedTime == 0 || (mstime() - mouseMovedTime) > 1000) { if(mouseMovedTime == 0 || elapsed(mouseMovedTime) > 1000) {
mouseMovedTime = 0; mouseMovedTime = 0;
return; return;
} }
int alpha = (int)(255.0f - 255.0f * (float)(mstime() - mouseMovedTime) / 1000.0f); int alpha = (int)(255.0f - 255.0f * (float)elapsed(mouseMovedTime) / 1000.0f);
lineRGBA(renderer, mousex - 10 * screen_uiscale, mousey, mousex + 10 * screen_uiscale, mousey, white.r, white.g, white.b, alpha); lineRGBA(renderer, mousex - 10 * screen_uiscale, mousey, mousex + 10 * screen_uiscale, mousey, white.r, white.g, white.b, alpha);
lineRGBA(renderer, mousex, mousey - 10 * screen_uiscale, mousex, mousey + 10 * screen_uiscale, white.r, white.g, white.b, alpha); lineRGBA(renderer, mousex, mousey - 10 * screen_uiscale, mousex, mousey + 10 * screen_uiscale, white.r, white.g, white.b, alpha);
@ -1223,8 +1228,8 @@ void View::drawMouse() {
void View::drawClick() { void View::drawClick() {
if(clickx && clicky) { if(clickx && clicky) {
int radius = .25 * (mstime() - clickTime); int radius = .25 * elapsed(clickTime);
int alpha = 128 - (int)(0.5 * (mstime() - clickTime)); int alpha = 128 - (int)(0.5 * elapsed(clickTime));
if(alpha < 0 ) { if(alpha < 0 ) {
alpha = 0; alpha = 0;
clickx = 0; clickx = 0;
@ -1237,11 +1242,10 @@ void View::drawClick() {
if(selectedAircraft) { if(selectedAircraft) {
// this logic should be in input, register a callback for click? // this logic should be in input, register a callback for click?
float elapsed = mstime() - clickTime;
int boxSize; int boxSize;
if(elapsed < 300) { if(elapsed(clickTime) < 300) {
boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed)))); boxSize = (int)(20.0 * (1.0 - (1.0 - float(elapsed(clickTime)) / 300.0) * cos(sqrt(float(elapsed(clickTime))))));
} else { } else {
boxSize = 20; boxSize = 20;
} }
@ -1290,11 +1294,11 @@ void View::registerClick(int tapcount, int x, int y) {
clickx = x; clickx = x;
clicky = y; clicky = y;
clickTime = mstime(); clickTime = now();
} }
void View::registerMouseMove(int x, int y) { void View::registerMouseMove(int x, int y) {
mouseMovedTime = mstime(); mouseMovedTime = now();
this->mousex = x; this->mousex = x;
this->mousey = y; this->mousey = y;
} }
@ -1304,7 +1308,7 @@ void View::registerMouseMove(int x, int y) {
// //
void View::draw() { void View::draw() {
uint64_t drawStartTime = mstime(); uint64_t drawStartTime = now();
moveMapToTarget(); moveMapToTarget();
zoomMapToTarget(); zoomMapToTarget();
@ -1344,16 +1348,17 @@ void View::draw() {
drawClick(); drawClick();
char fps[13] = " "; char fps[13] = " ";
snprintf(fps,13," %.1ffps", 1000.0 / (mstime() - lastFrameTime)); snprintf(fps,13," %.1ffps", 1000.0 / elapsed(lastFrameTime));
drawStringBG(fps, 0,0, mapFont, grey, black); drawStringBG(fps, 0,0, mapFont, grey, black);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
lastFrameTime = mstime(); lastFrameTime = now();
if ((mstime() - drawStartTime) < FRAMETIME) { if (elapsed(drawStartTime) < FRAMETIME) {
usleep(1000 * (FRAMETIME - (mstime() - drawStartTime))); usleep(1000 * (FRAMETIME - elapsed(drawStartTime)));
} }
} }
View::View(AppData *appData){ View::View(AppData *appData){
@ -1381,4 +1386,4 @@ View::~View() {
TTF_Quit(); TTF_Quit();
SDL_Quit(); SDL_Quit();
} }

4
View.h
View file

@ -9,7 +9,7 @@
//defs - should all move to config file setup //defs - should all move to config file setup
#define ROUND_RADIUS 3 //radius of text box corners #define ROUND_RADIUS 3 //radius of text box corners
#define CENTEROFFSET .375 //vertical offset for middle of screen #define CENTEROFFSET .5 //vertical offset for middle of screen
#define TRAIL_LENGTH 120 #define TRAIL_LENGTH 120
#define TRAIL_TTL 240.0 #define TRAIL_TTL 240.0
@ -147,4 +147,4 @@ class View {
int messageFontHeight; int messageFontHeight;
}; };
#endif #endif

1
drawPolys.REMOVED.git-id Normal file
View file

@ -0,0 +1 @@
85c850fc7f07d0cf30352d3385c7a2aeb57fecf3

View file

@ -18,11 +18,10 @@ bin_file = open("mapdata.bin", "wb")
outlist = [] outlist = []
precision = 2 resolution = 250
print("Reading points") print("Reading points")
#for i in tqdm(range(len(polys))): for i in tqdm(range(len(polys))):
for i in range(40): #for i in range(40):
p = polys[i] p = polys[i]
currentPoints = (p.attrib['points']).replace(","," ").split() currentPoints = (p.attrib['points']).replace(","," ").split()
@ -35,22 +34,25 @@ for i in range(40):
temp = [] temp = []
for i in range(int(len(currentPoints)/2)): for i in range(int(len(currentPoints)/2)):
currentPoints[2 * i + 0] = "%.*f" % (precision, float(currentPoints[2 * i + 0])) #currentPoints[2 * i + 0] = "%.*f" % (precision, float(currentPoints[2 * i + 0]))
currentPoints[2 * i + 1] = "%.*f" % (precision, float(currentPoints[2 * i + 1])) #currentPoints[2 * i + 1] = "%.*f" % (precision, float(currentPoints[2 * i + 1]))
if(currentPoints[2 * i + 0] != prevx and currentPoints[2 * i + 1] != prevy): currentPoints[2 * i + 0] = float(int(resolution * float(currentPoints[2 * i + 0]))) / resolution
temp.extend([currentPoints[2 * i + 0],currentPoints[2 * i + 1]]) currentPoints[2 * i + 1] = float(int(resolution * float(currentPoints[2 * i + 1]))) / resolution
prevx = currentPoints[2 * i + 0]
prevy = currentPoints[2 * i + 1]
if(currentPoints[2 * i + 0] != prevx and currentPoints[2 * i + 1] != prevy):
temp.extend([currentPoints[2 * i + 0],currentPoints[2 * i + 1]])
if(len(currentPoints) > 14): prevx = currentPoints[2 * i + 0]
outlist.extend(temp) prevy = currentPoints[2 * i + 1]
outlist.extend(["0","0"])
if(len(currentPoints) > 6): #must be at least a triangle
outlist.extend(temp)
outlist.extend([temp[0],temp[1]])
outlist.extend(["0","0"])
np.asarray(outlist).astype(np.single).tofile(bin_file) np.asarray(outlist).astype(np.single).tofile(bin_file)
bin_file.close() bin_file.close()
print("Wrote %d points" % (len(outlist) / 2)) print("Wrote %d points" % (len(outlist) / 2))

1
out.prof.REMOVED.git-id Normal file
View file

@ -0,0 +1 @@
34c8403286643597ad193fa68d13266d3a5f07a6

View file

@ -34,18 +34,6 @@
#include "Input.h" #include "Input.h"
#include <cstring> #include <cstring>
//time utility, might change to std::chrono
uint64_t mstime(void) {
struct timeval tv;
uint64_t mst;
gettimeofday(&tv, NULL);
mst = ((uint64_t)tv.tv_sec)*1000;
mst += tv.tv_usec/1000;
return mst;
}
int go = 1; int go = 1;