public OcTreeObject(PhysicalObject obj) { Position = obj.Position; Radius = obj.Radius; Box = new BoundingBox(Position, Radius); LinkedObject = obj; }
private PhysicalObject[] GenerateObstacles(int count) { var objs = new List <PhysicalObject>(); for (int i = 0; i < count; i++) { OcTree tree = null; PhysicalObject obj = null; for (int n = 0; n < MaxTryCount; n++) { obj = ObstacleFactory.MakeObstacle(); obj.Position = GetPointInCircle(WorldScale * _config.ObstacleRange); if (GameMath.MathF.Abs(obj.Position.X) > WorldScale - 2f) { continue; } if (GameMath.MathF.Abs(obj.Position.Y) > WorldScale - 2f) { continue; } tree = new OcTree(_worldZone, objs, false); if (tree != null && !tree.Intersect(obj.Position, obj.Radius + ObstacleFactory.SpaceBetween)) { break; } } objs.Add(obj); } return(objs.ToArray()); }
public bool Intersect(PhysicalObject obj) => _mainNode.Intersect(new OcTreeObject(obj));