public void split() { int mid_x = (bound.left + bound.right) / 2; int mid_y = (bound.top + bound.bottom) / 2; nodes [0] = new mario_qtree(this, level + 1, new mario_bound(mid_x, bound.right, bound.top, mid_y)); nodes [1] = new mario_qtree(this, level + 1, new mario_bound(bound.left, mid_x, bound.top, mid_y)); nodes [2] = new mario_qtree(this, level + 1, new mario_bound(bound.left, mid_x, mid_y, bound.bottom)); nodes [3] = new mario_qtree(this, level + 1, new mario_bound(mid_x, bound.right, mid_y, bound.bottom)); }
public void retrive(mario_obj obj, ref List <mario_obj> objs, int type) { retrive_ex(obj.m_bound, ref objs, type); mario_qtree t = obj.m_qtree.parent; while (t != null) { objs.AddRange(t.objects[type]); t = t.parent; } }
public void retrive_right(mario_obj obj, ref List <mario_obj> objs) { retrive_ex_fx(obj.get_right_bound(), ref objs); mario_qtree t = obj.m_qtree.parent; while (t != null) { objs.AddRange(t.objects[(int)mario_obj.mario_type.mt_block]); objs.AddRange(t.objects[(int)mario_obj.mario_type.mt_block1]); t = t.parent; } }
public mario_qtree(mario_qtree p, int l, mario_bound b) { parent = p; level = l; bound = b; for (int i = 0; i < 4; ++i) { nodes.Add(null); } for (int i = (int)mario_obj.mario_type.mt_null; i < (int)mario_obj.mario_type.mt_end; ++i) { objects.Add(new List <mario_obj>()); } }
public mario_qtree() { parent = null; level = 1; bound = new mario_bound(-20480, 143360, 143360, -20480); for (int i = 0; i < 4; ++i) { nodes.Add(null); } for (int i = (int)mario_obj.mario_type.mt_null; i < (int)mario_obj.mario_type.mt_end; ++i) { objects.Add(new List <mario_obj>()); } }