X-Git-Url: http://pileus.org/git/?p=grits;a=blobdiff_plain;f=src%2Froam.h;h=361025e4271ab3bdd37ba81461ade4a794a4cb1c;hp=c4a08987456dfb2d329816c5bd36ef37c8e75e4f;hb=b87064909e6d20e1ee2995adae0c1ce5cb692d7e;hpb=ac7156bd84aef88b712f117f7e2f3d847d371719 diff --git a/src/roam.h b/src/roam.h index c4a0898..361025e 100644 --- a/src/roam.h +++ b/src/roam.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Andy Spencer + * Copyright (C) 2009-2010 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 @@ -19,7 +19,6 @@ #define __ROAM_H__ #include "gpqueue.h" -#include "wms.h" /* Roam */ typedef struct _RoamView RoamView; @@ -27,7 +26,7 @@ typedef struct _RoamPoint RoamPoint; typedef struct _RoamTriangle RoamTriangle; typedef struct _RoamDiamond RoamDiamond; typedef struct _RoamSphere RoamSphere; -typedef void (*RoamHeightFunc)(RoamPoint *point, gpointer user_data); +typedef gdouble (*RoamHeightFunc)(gdouble lat, gdouble lon, gpointer user_data); /* Misc */ struct _RoamView { @@ -41,52 +40,68 @@ struct _RoamView { * RoamPoint * *************/ struct _RoamPoint { - gdouble x,y,z; // Model coordinates - gdouble px,py,pz; // Projected coordinates - gint pversion; // Version of cached projection + /*< private >*/ + gdouble x, y, z; /* Model coordinates */ + gdouble px, py, pz; /* Projected coordinates */ + gint pversion; /* Version of cached projection */ - gint tris; // Associated triangles - gdouble norm[3]; // Vertex normal + gint tris; /* Count of associated triangles */ + gdouble norm[3]; /* Vertex normal */ - WmsCacheNode *node; // TODO: don't depend on wms + /* For get_intersect */ + gdouble lat, lon, elev; + + /* For terrain */ + RoamHeightFunc height_func; + gpointer height_data; }; -RoamPoint *roam_point_new(double x, double y, double z); +RoamPoint *roam_point_new(double lat, double lon, double elev); void roam_point_add_triangle(RoamPoint *point, RoamTriangle *triangle); void roam_point_remove_triangle(RoamPoint *point, RoamTriangle *triangle); -void roam_point_update_height(RoamPoint *point, RoamSphere *sphere); -void roam_point_update_projection(RoamPoint *point, RoamSphere *sphere); +void roam_point_update_height(RoamPoint *point); +void roam_point_update_projection(RoamPoint *point, RoamView *view); /**************** * RoamTriangle * ****************/ struct _RoamTriangle { + /*< private >*/ + /* Left, middle and right vertices */ struct { RoamPoint *l,*m,*r; } p; + + /* Left, base, and right neighbor triangles */ struct { RoamTriangle *l,*b,*r; } t; - RoamPoint *split; - RoamDiamond *parent; - double norm[3]; - double error; + + RoamPoint *split; /* Split point */ + RoamDiamond *parent; /* Parent diamond */ + double norm[3]; /* Surface normal */ + double error; /* Screen space error */ GPQueueHandle handle; - WmsCacheNode *nodes[5]; // TODO: don't depend on wms + /* For get_intersect */ + struct { gdouble n,s,e,w; } edge; + RoamTriangle *kids[2]; }; RoamTriangle *roam_triangle_new(RoamPoint *l, RoamPoint *m, RoamPoint *r); +void roam_triangle_free(RoamTriangle *triangle); void roam_triangle_add(RoamTriangle *triangle, RoamTriangle *left, RoamTriangle *base, RoamTriangle *right, RoamSphere *sphere); void roam_triangle_remove(RoamTriangle *triangle, RoamSphere *sphere); void roam_triangle_update_errors(RoamTriangle *triangle, RoamSphere *sphere); void roam_triangle_split(RoamTriangle *triangle, RoamSphere *sphere); +void roam_triangle_draw(RoamTriangle *triangle); void roam_triangle_draw_normal(RoamTriangle *triangle); /*************** * RoamDiamond * ***************/ struct _RoamDiamond { - RoamTriangle *kids[4]; - RoamTriangle *parents[2]; - double error; - gboolean active; + /*< private >*/ + RoamTriangle *kids[4]; /* Child triangles */ + RoamTriangle *parents[2]; /* Parent triangles */ + double error; /* Screen space error */ + gboolean active; /* For internal use */ GPQueueHandle handle; }; RoamDiamond *roam_diamond_new( @@ -96,26 +111,31 @@ RoamDiamond *roam_diamond_new( void roam_diamond_add(RoamDiamond *diamond, RoamSphere *sphere); void roam_diamond_remove(RoamDiamond *diamond, RoamSphere *sphere); void roam_diamond_merge(RoamDiamond *diamond, RoamSphere *sphere); -void roam_diamond_update_errors(RoamDiamond *self, RoamSphere *sphere); +void roam_diamond_update_errors(RoamDiamond *diamond, RoamSphere *sphere); /************** * RoamSphere * **************/ struct _RoamSphere { - GPQueue *triangles; - GPQueue *diamonds; - RoamView *view; - RoamHeightFunc height_func; - gpointer user_data; - gint polys; + /*< private >*/ + GPQueue *triangles; /* List of triangles */ + GPQueue *diamonds; /* List of diamonds */ + RoamView *view; /* Current projection */ + gint polys; /* Polygon count */ + + /* For get_intersect */ + RoamTriangle *roots[8]; /* Original 8 triangles */ }; -RoamSphere *roam_sphere_new(gpointer user_data); +RoamSphere *roam_sphere_new(); +void roam_sphere_update_view(RoamSphere *sphere); void roam_sphere_update_errors(RoamSphere *sphere); void roam_sphere_split_one(RoamSphere *sphere); 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, gboolean all, + gdouble n, gdouble s, gdouble e, gdouble w); void roam_sphere_free(RoamSphere *sphere); #endif