]> Pileus Git - grits/commitdiff
Fix holes in the earth
authorAndy Spencer <andy753421@gmail.com>
Mon, 25 Jan 2010 20:35:13 +0000 (20:35 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 25 Jan 2010 20:35:13 +0000 (20:35 +0000)
- Add user_data to tile before updating height, otherwise the latest
  tile doesn't get used.

- Add flag to get_intersect to fetch all triangles, not just leaves.
  Update these heights when setting height funcs.

src/gis-opengl.c
src/gis_test.c
src/plugins/srtm.c
src/roam.c
src/roam.h

index dc26348c3dccce5cd8bb9eb02ee2040dff1345c6..49fd84af54087c9af9aefcbf84b4ea13f4aa1c4d 100644 (file)
@@ -448,7 +448,7 @@ static void gis_opengl_render_tile(GisViewer *_self, GisTile *tile)
        GisOpenGL *self = GIS_OPENGL(_self);
        if (!tile || !tile->data)
                return;
-       GList *triangles = roam_sphere_get_intersect(self->sphere,
+       GList *triangles = roam_sphere_get_intersect(self->sphere, FALSE,
                        tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w);
        if (!triangles)
                g_warning("GisOpenGL: render_tiles - No triangles to draw: edges=%f,%f,%f,%f",
@@ -517,7 +517,7 @@ static void gis_opengl_set_height_func(GisViewer *_self, GisTile *tile,
        if (!tile)
                return;
        /* TODO: get points? */
-       GList *triangles = roam_sphere_get_intersect(self->sphere,
+       GList *triangles = roam_sphere_get_intersect(self->sphere, TRUE,
                        tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w);
        for (GList *cur = triangles; cur; cur = cur->next) {
                RoamTriangle *tri = cur->data;
index 7a68afa5e144bfb9d4b6a10ec808bf4a48172686..646de7700e5c4291bfdbdac71ef6b96dbef5248f 100644 (file)
@@ -58,7 +58,7 @@ int main(int argc, char **argv)
        gdk_threads_leave();
 
        gis_plugins_load(plugins, "bmng", viewer, prefs);
-       //gis_plugins_load(plugins, "srtm", viewer, prefs);
+       gis_plugins_load(plugins, "srtm", viewer, prefs);
        gis_plugins_load(plugins, "test", viewer, prefs);
 
        gdk_threads_enter();
index 15e5b37f96b73d6fa907a907634bc35ad3d91103..70be7d9617f6593cc259b7919263c233d519eb86 100644 (file)
@@ -159,6 +159,8 @@ static gboolean _load_tile_cb(gpointer _load)
        if (LOAD_OPENGL)
                data->opengl = _load_opengl(pixbuf);
 
+       tile->data = data;
+
        /* Do necessasairy processing */
        /* TODO: Lock this and move to thread, can remove self from _load then */
        if (LOAD_BIL)
@@ -170,7 +172,6 @@ static gboolean _load_tile_cb(gpointer _load)
        if (LOAD_OPENGL)
                g_object_unref(pixbuf);
 
-       tile->data = data;
        return FALSE;
 }
 static void _load_tile(GisTile *tile, gpointer _self)
index 7f131825d4735bb57fc95ffda639325705e3b486..33f5f7c118900b12f8422e881c1c3a5824e8e567 100644 (file)
@@ -600,18 +600,19 @@ void roam_sphere_draw_normals(RoamSphere *self)
        g_debug("RoamSphere: draw_normal");
        g_pqueue_foreach(self->triangles, (GFunc)roam_triangle_draw_normal, NULL);
 }
-static GList *_roam_sphere_get_leaves(RoamTriangle *tri, GList *list)
+static GList *_roam_sphere_get_leaves(RoamTriangle *tri, GList *list, gboolean all)
 {
        if (tri->kids[0] && tri->kids[1]) {
-               list = _roam_sphere_get_leaves(tri->kids[0], list);
-               list = _roam_sphere_get_leaves(tri->kids[1], list);
+               if (all) list = g_list_prepend(list, tri);
+               list = _roam_sphere_get_leaves(tri->kids[0], list, all);
+               list = _roam_sphere_get_leaves(tri->kids[1], list, all);
                return list;
        } else {
                return g_list_append(list, tri);
        }
 }
 static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list,
-               gdouble n, gdouble s, gdouble e, gdouble w)
+               gboolean all, gdouble n, gdouble s, gdouble e, gdouble w)
 {
        gdouble tn = tri->edge.n;
        gdouble ts = tri->edge.s;
@@ -632,12 +633,14 @@ static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list,
        } else if (tn < n && ts > s && te < e && tw > w) {
                /* Triangle is completely contained */
                if (debug) g_message("contained");
-               return _roam_sphere_get_leaves(tri, list);
+               if (all) list = g_list_prepend(list, tri);
+               return _roam_sphere_get_leaves(tri, list, all);
        } else if (tri->kids[0] && tri->kids[1]) {
                /* Paritial intersect with children */
                if (debug) g_message("edge w/ child");
-               list = _roam_sphere_get_intersect_rec(tri->kids[0], list, n, s, e, w);
-               list = _roam_sphere_get_intersect_rec(tri->kids[1], list, n, s, e, w);
+               if (all) list = g_list_prepend(list, tri);
+               list = _roam_sphere_get_intersect_rec(tri->kids[0], list, all, n, s, e, w);
+               list = _roam_sphere_get_intersect_rec(tri->kids[1], list, all, n, s, e, w);
                return list;
        } else {
                /* This triangle is an edge case */
@@ -645,7 +648,7 @@ static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list,
                return g_list_append(list, tri);
        }
 }
-GList *roam_sphere_get_intersect(RoamSphere *self,
+GList *roam_sphere_get_intersect(RoamSphere *self, gboolean all,
                gdouble n, gdouble s, gdouble e, gdouble w)
 {
        /* I think this is correct..
@@ -655,7 +658,7 @@ GList *roam_sphere_get_intersect(RoamSphere *self,
        GList *list = NULL;
        for (int i = 0; i < G_N_ELEMENTS(self->roots); i++)
                list = _roam_sphere_get_intersect_rec(self->roots[i],
-                               list, n, s, e, w);
+                               list, all, n, s, e, w);
        return list;
 }
 void roam_sphere_free_tri(RoamTriangle *tri)
index 815390f2d4616f17816ad684c71962e6d1bc1fae..492ab3958b4accd097bb19b295e7d43b93f797f0 100644 (file)
@@ -124,7 +124,7 @@ void roam_sphere_merge_one(RoamSphere *sphere);
 gint roam_sphere_split_merge(RoamSphere *sphere);
 void roam_sphere_draw(RoamSphere *sphere);
 void roam_sphere_draw_normals(RoamSphere *sphere);
-GList *roam_sphere_get_intersect(RoamSphere *sphere,
+GList *roam_sphere_get_intersect(RoamSphere *sphere, gboolean all,
                gdouble n, gdouble s, gdouble e, gdouble w);
 void roam_sphere_free(RoamSphere *sphere);