X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Froam.c;h=e4848fa3b04c0df426bc04d47a79be62d0358c00;hb=41ac199155afce20286027beb0261fbdd5cee7c5;hp=33f5f7c118900b12f8422e881c1c3a5824e8e567;hpb=34c7dbdf473f66024fd3ab3301b9921593d9d420;p=grits diff --git a/src/roam.c b/src/roam.c index 33f5f7c..e4848fa 100644 --- a/src/roam.c +++ b/src/roam.c @@ -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 @@ -296,6 +296,8 @@ void roam_triangle_split(RoamTriangle *self, RoamSphere *sphere) 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; @@ -608,7 +610,7 @@ static GList *_roam_sphere_get_leaves(RoamTriangle *tri, GList *list, gboolean a 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, @@ -630,7 +632,7 @@ 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); @@ -645,9 +647,12 @@ static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list, } 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) {