public IItem AddItem(IsoRect bounds, T content) { if (bounds.x.size > 0.0f && bounds.y.size > 0.0f) { if (_rootNode == null) { var initial_side = IsoUtils.Vec2From( IsoUtils.Vec2MaxF(bounds.size)); var initial_bounds = new IsoRect( bounds.center - initial_side * 2.0f, bounds.center + initial_side * 2.0f); _rootNode = _nodePool.Take().Init(null, initial_bounds); } Item item; while (!_rootNode.AddItem(bounds, content, out item, _nodePool, _itemPool)) { GrowUp( bounds.center.x < _rootNode.SelfBounds.center.x, bounds.center.y < _rootNode.SelfBounds.center.y); } return(item); } else { return(_itemPool.Take().Init(null, bounds, content)); } }
void SetupObjectsSectors() { _sectorsMinNumPos = IsoUtils.Vec2From(float.MaxValue); _sectorsMaxNumPos = IsoUtils.Vec2From(float.MinValue); var visibles_iter = _visibles.GetEnumerator(); while ( visibles_iter.MoveNext() ) { var iso_internal = visibles_iter.Current.Internal; iso_internal.MinSector = IsoUtils.Vec3DivFloor(iso_internal.ScreenRect.min, _sectorsSize); iso_internal.MaxSector = IsoUtils.Vec3DivCeil (iso_internal.ScreenRect.max, _sectorsSize); _sectorsMinNumPos = IsoUtils.Vec3Min(_sectorsMinNumPos, iso_internal.MinSector); _sectorsMaxNumPos = IsoUtils.Vec3Max(_sectorsMaxNumPos, iso_internal.MaxSector); } _sectorsNumPosCount = _sectorsMaxNumPos - _sectorsMinNumPos; }