]> Pileus Git - grits/commitdiff
Minor debugging, precision, and performance updates
authorAndy Spencer <andy753421@gmail.com>
Mon, 25 Jan 2010 20:39:15 +0000 (20:39 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 25 Jan 2010 20:39:15 +0000 (20:39 +0000)
- 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
src/plugins/srtm.c
src/roam.c

index 49fd84af54087c9af9aefcbf84b4ea13f4aa1c4d..b07820612d1d6f7b25d53b2e7ee8d7278a0f74e9 100644 (file)
@@ -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);
index 70be7d9617f6593cc259b7919263c233d519eb86..4e1126aabf7cdd2c5cbbcdc552733d6087f1b47c 100644 (file)
@@ -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)
index 33f5f7c118900b12f8422e881c1c3a5824e8e567..7a1d6d3a86d961ae5c5a7771a026c122108bec88 100644 (file)
@@ -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,