public void DeleteObjectByMousePos(Vector3 in_mouse_position) { _deleted_objects_id.Clear(); int comparator = 1; int depth = _tree_depth; int x = (int)((in_mouse_position.x - _origin.x) / _unity_meters_in_piece); int y = (int)((in_mouse_position.z - _origin.z) / _unity_meters_in_piece); CQuadLeaf current_quad = _initial_quad; CQuadLeaf prev_quad = null; while (current_quad != null) { if (current_quad.GetQuadObjectectsCount() != 0) { current_quad.DeleteObjectByMousePosition(in_mouse_position, _deleted_objects_id); for (int i = 0; i < _deleted_objects_id.Count; i++) { _objs_ht.Remove(_deleted_objects_id[i]); } } depth--; int k = comparator << depth; int x_bin = (k & x) > 0 ? 1 : 0; int y_bin = (k & y) > 0 ? 1 : 0; int index = (y_bin << 1) + x_bin; prev_quad = current_quad; current_quad = current_quad.GetQuad(index); } prev_quad.DeleteNodeIfEmpty(); }
public bool IsEmpty() { return(_initial_quad.GetQuadObjectectsCount() == 0 && !_initial_quad.HaveChilds()); }