/*
- * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
+ * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
*
* 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
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;
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,
/* 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);
} else {
/* This triangle is an edge case */
if (debug) g_message("edge");
- return g_list_append(list, tri);
+ return g_list_prepend(list, tri);
}
}
+/* Warning: This grabs pointers to triangles which can be changed by other
+ * calls, e.g. split_merge. If you use this, you need to do some locking to
+ * prevent the returned list from becomming stale. */
GList *roam_sphere_get_intersect(RoamSphere *self, gboolean all,
gdouble n, gdouble s, gdouble e, gdouble w)
{