X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Froam.c;h=cfcdd54d0328be9d8258cca25ba92df293581287;hb=2513ab088774458af5a0419afc7eff5250dfce8e;hp=aa488fcc560a7d033b5c321d52a0f12e1afa6fa6;hpb=2303ef60aac043b63daec4a70a9ee7d70e0ce62f;p=grits diff --git a/src/roam.c b/src/roam.c index aa488fc..cfcdd54 100644 --- a/src/roam.c +++ b/src/roam.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2010 Andy Spencer + * Copyright (C) 2009-2011 Andy Spencer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,8 +21,8 @@ * * A spherical version of the Realtime Optimally-Adapting Meshes (ROAM) * algorithm is use for drawing the surface of the planet. ROAM provide a - * continuous level-of-detail mesh of the planet which is used by #GisOpenGL - * when drawing surface textures for GisTiles. + * continuous level-of-detail mesh of the planet which is used by #GritsOpenGL + * when drawing surface textures for GritsTiles. * * This implementation of the ROAM algorithm is based on an octahedron as the * base model. @@ -31,11 +31,10 @@ #include #include #include -#include -#include +#include "gtkgl.h" #include "gpqueue.h" -#include "gis-util.h" +#include "grits-util.h" #include "roam.h" /* @@ -206,27 +205,10 @@ RoamTriangle *roam_triangle_new(RoamPoint *l, RoamPoint *m, RoamPoint *r, // triangle->split->lat, l->lat); /* Update normal */ - double pa[3]; - double pb[3]; - pa[0] = triangle->p.l->x - triangle->p.m->x; - pa[1] = triangle->p.l->y - triangle->p.m->y; - pa[2] = triangle->p.l->z - triangle->p.m->z; - - pb[0] = triangle->p.r->x - triangle->p.m->x; - pb[1] = triangle->p.r->y - triangle->p.m->y; - pb[2] = triangle->p.r->z - triangle->p.m->z; - - triangle->norm[0] = pa[1] * pb[2] - pa[2] * pb[1]; - triangle->norm[1] = pa[2] * pb[0] - pa[0] * pb[2]; - triangle->norm[2] = pa[0] * pb[1] - pa[1] * pb[0]; - - double total = sqrt(triangle->norm[0] * triangle->norm[0] + - triangle->norm[1] * triangle->norm[1] + - triangle->norm[2] * triangle->norm[2]); - - triangle->norm[0] /= total; - triangle->norm[1] /= total; - triangle->norm[2] /= total; + crossd3((gdouble*)triangle->p.l, + (gdouble*)triangle->p.m, + (gdouble*)triangle->p.r, triangle->norm); + normd(triangle->norm); /* Store bounding box, for get_intersect */ RoamPoint *p[] = {l,m,r}; @@ -361,7 +343,6 @@ static gboolean roam_triangle_backface(RoamTriangle *triangle, RoamSphere *spher */ void roam_triangle_update_errors(RoamTriangle *triangle, RoamSphere *sphere) { -#if 0 /* Update points */ roam_point_update_projection(triangle->p.l, sphere->view); roam_point_update_projection(triangle->p.m, sphere->view); @@ -394,19 +375,8 @@ void roam_triangle_update_errors(RoamTriangle *triangle, RoamSphere *sphere) if (roam_triangle_backface(triangle->t.l, sphere) || roam_triangle_backface(triangle->t.b, sphere) || roam_triangle_backface(triangle->t.r, sphere)) - triangle->error *= 500; + triangle->error *= 50; } -#endif - - /* For pure distance based errors */ - (void)roam_triangle_visible; - (void)roam_triangle_backface; - RoamPoint *l = triangle->p.l; - RoamPoint *m = triangle->p.m; - RoamPoint *r = triangle->p.r; - double base = distd((gdouble*)l, (gdouble*)r); - double dist = distd((gdouble*)m, (gdouble*)sphere->view->pos); - triangle->error = base/dist; } /** @@ -789,9 +759,9 @@ void roam_sphere_merge_one(RoamSphere *sphere) gint roam_sphere_split_merge(RoamSphere *sphere) { gint iters = 0, max_iters = 500; - gint target = 10000; + //gint target = 20000; //gint target = 4000; - //gint target = 2000; + gint target = 2000; //gint target = 500; if (!sphere->view)