From 01ca3d15f0981393709f25efc6b4a0e067e0c815 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 25 Jan 2010 20:39:15 +0000 Subject: [PATCH] Minor debugging, precision, and performance updates - Print paths when loading tiles - Only update heights of vertices inside a tile, instead of all the vertices on intersecting triangles. - Use g_list_prepend instead of g_list_append --- src/gis-opengl.c | 9 ++++++--- src/plugins/srtm.c | 10 ++++++---- src/roam.c | 8 +++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/gis-opengl.c b/src/gis-opengl.c index 49fd84a..b078206 100644 --- a/src/gis-opengl.c +++ b/src/gis-opengl.c @@ -523,9 +523,12 @@ static void gis_opengl_set_height_func(GisViewer *_self, GisTile *tile, RoamTriangle *tri = cur->data; RoamPoint *points[] = {tri->p.l, tri->p.m, tri->p.r, tri->split}; for (int i = 0; i < G_N_ELEMENTS(points); i++) { - points[i]->height_func = height_func; - points[i]->height_data = user_data; - roam_point_update_height(points[i]); + if (tile->edge.n >= points[i]->lat && points[i]->lat >= tile->edge.s && + tile->edge.e >= points[i]->lon && points[i]->lon >= tile->edge.w) { + points[i]->height_func = height_func; + points[i]->height_data = user_data; + roam_point_update_height(points[i]); + } } } g_list_free(triangles); diff --git a/src/plugins/srtm.c b/src/plugins/srtm.c index 70be7d9..4e1126a 100644 --- a/src/plugins/srtm.c +++ b/src/plugins/srtm.c @@ -88,6 +88,7 @@ static gdouble _height_func(gdouble lat, gdouble lon, gpointer _self) #define LOAD_OPENGL FALSE struct _LoadTileData { GisPluginSrtm *self; + gchar *path; GisTile *tile; GdkPixbuf *pixbuf; struct _TileData *data; @@ -150,10 +151,12 @@ static guint _load_opengl(GdkPixbuf *pixbuf) static gboolean _load_tile_cb(gpointer _load) { struct _LoadTileData *load = _load; + g_debug("GisPluginSrtm: _load_tile_cb: %s", load->path); GisPluginSrtm *self = load->self; GisTile *tile = load->tile; GdkPixbuf *pixbuf = load->pixbuf; struct _TileData *data = load->data; + g_free(load->path); g_free(load); if (LOAD_OPENGL) @@ -178,19 +181,18 @@ static void _load_tile(GisTile *tile, gpointer _self) { GisPluginSrtm *self = _self; - g_debug("GisPluginSrtm: _load_tile"); - gchar *path = gis_wms_make_local(self->wms, tile); struct _LoadTileData *load = g_new0(struct _LoadTileData, 1); + load->path = gis_wms_make_local(self->wms, tile); + g_debug("GisPluginSrtm: _load_tile: %s", load->path); load->self = self; load->tile = tile; load->data = g_new0(struct _TileData, 1); if (LOAD_BIL || LOAD_OPENGL) - load->data->bil = _load_bil(path); + load->data->bil = _load_bil(load->path); if (LOAD_OPENGL) load->pixbuf = _load_pixbuf(load->data->bil); g_idle_add_full(G_PRIORITY_LOW, _load_tile_cb, load, NULL); - g_free(path); } static gboolean _free_tile_cb(gpointer _data) diff --git a/src/roam.c b/src/roam.c index 33f5f7c..7a1d6d3 100644 --- a/src/roam.c +++ b/src/roam.c @@ -296,6 +296,8 @@ void roam_triangle_split(RoamTriangle *self, RoamSphere *sphere) if (self != self->t.b->t.b) roam_triangle_split(self->t.b, sphere); + if (self != self->t.b->t.b) + g_assert_not_reached(); RoamTriangle *base = self->t.b; @@ -608,7 +610,7 @@ static GList *_roam_sphere_get_leaves(RoamTriangle *tri, GList *list, gboolean a list = _roam_sphere_get_leaves(tri->kids[1], list, all); return list; } else { - return g_list_append(list, tri); + return g_list_prepend(list, tri); } } static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list, @@ -630,7 +632,7 @@ static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list, /* No intersect */ if (debug) g_message("no intersect"); return list; - } else if (tn < n && ts > s && te < e && tw > w) { + } else if (tn <= n && ts >= s && te <= e && tw >= w) { /* Triangle is completely contained */ if (debug) g_message("contained"); if (all) list = g_list_prepend(list, tri); @@ -645,7 +647,7 @@ static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list, } else { /* This triangle is an edge case */ if (debug) g_message("edge"); - return g_list_append(list, tri); + return g_list_prepend(list, tri); } } GList *roam_sphere_get_intersect(RoamSphere *self, gboolean all, -- 2.43.2