]> Pileus Git - grits/blobdiff - src/roam.h
Document ROAM
[grits] / src / roam.h
index 361025e4271ab3bdd37ba81461ade4a794a4cb1c..11eb171d444833212dd288483a35d4adacb2d6a9 100644 (file)
@@ -26,9 +26,28 @@ typedef struct _RoamPoint    RoamPoint;
 typedef struct _RoamTriangle RoamTriangle;
 typedef struct _RoamDiamond  RoamDiamond;
 typedef struct _RoamSphere   RoamSphere;
+/**
+ * RoamHeightFunc:
+ * @lat:       the latitude
+ * @lon:       the longitude
+ * @user_data: user data passed to the function
+ *
+ * See #GisHeightFunc
+ *
+ * Returns: the elevation
+ */
 typedef gdouble (*RoamHeightFunc)(gdouble lat, gdouble lon, gpointer user_data);
 
 /* Misc */
+/**
+ * RoamView:
+ * @model:   model view matrix
+ * @proj:    projection matrix
+ * @view:    viewport matrix
+ * @version: version
+ *
+ * Stores projection matrices
+ */
 struct _RoamView {
        gdouble model[16];
        gdouble proj[16];
@@ -39,6 +58,14 @@ struct _RoamView {
 /*************
  * RoamPoint *
  *************/
+/**
+ * RoamPoint:
+ *
+ * Points are used as vertices for triangles. A single point my be shared among
+ * several triangles in order to conceive space and avoid recalculating
+ * projections. Points also store a lot of cached data. The normal vertex normal
+ * is the averaged surface normal of each associated triangle.
+ */
 struct _RoamPoint {
        /*< private >*/
        gdouble  x, y, z;    /* Model coordinates */
@@ -64,6 +91,18 @@ void roam_point_update_projection(RoamPoint *point, RoamView *view);
 /****************
  * RoamTriangle *
  ****************/
+/**
+ * RoamTriangle:
+ *
+ * Triangles are one of the key datatypes in ROAM. The surface is made up of
+ * triangles. Each triangle has an associated "error". When the surface is being
+ * updated after the view changes, each triangles error is updated. Afterwards
+ * the triangles with the most error are split int to triangles, each with a
+ * lower error than the original.
+ *
+ * Triangles store a lot of data about their location in the mesh so that they
+ * can be split and merged (unsplit) without having to recreate the mesh.
+ */
 struct _RoamTriangle {
        /*< private >*/
        /* Left, middle and right vertices */
@@ -96,6 +135,17 @@ void roam_triangle_draw_normal(RoamTriangle *triangle);
 /***************
  * RoamDiamond *
  ***************/
+/**
+ * RoamDiamond:
+ *
+ * When two adjacent triangles are split, they, along with the four new child
+ * triangles, are added to a diamond which keeps track of them.
+ *
+ * Like triangles, diamond have an error associated with it. However, when a
+ * diamonds error is small enough it is "merged". That is, the diamond along
+ * with the child triangles is removed and the original two triangles triangles
+ * are added back into the mesh.
+ */
 struct _RoamDiamond {
        /*< private >*/
        RoamTriangle *kids[4];    /* Child triangles */
@@ -116,6 +166,14 @@ void roam_diamond_update_errors(RoamDiamond *diamond, RoamSphere *sphere);
 /**************
  * RoamSphere *
  **************/
+/**
+ * RoamSphere:
+ *
+ * The sphere keeps track of the triangles and diamonds in the mesh. 
+ *
+ * Originally the sphere consists of only 8 triangles forming a octahedron.
+ * These triangles are quickly split to create a smoother sphere.
+ */
 struct _RoamSphere {
        /*< private >*/
        GPQueue *triangles; /* List of triangles */