Exemple #1
0
        /// <summary>
        /// Provides the set of all floating objects in the world.
        /// </summary>
        /// <returns>Set of all floating objects in the world.</returns>
        public FloatingObjectsSet ToSet()
        {
            FloatingObjectsSet allFltObjects = new FloatingObjectsSet();

            foreach (var bar in v_Grid.Values)
            {
                allFltObjects.UnionWith(bar.OldSet.GetHashSet());
                allFltObjects.UnionWith(bar.NewSet.GetHashSet());
            }
            return(allFltObjects);
        }
Exemple #2
0
        /// <summary>
        /// Gets the set of floating objects within a given prism.
        /// Both objects used and unused in this simulation step are considered.
        /// </summary>
        public FloatingObjectsSet GetObjectsInPrism(Polygon3D basePolygon, Vector3D vector)
        {
            FloatingObjectsSet insideObjects = new FloatingObjectsSet();
            var topPolygon = basePolygon.Select(vertex => vertex + vector);

            foreach (var key in KeysInBox(new Box3D(basePolygon.Union(topPolygon))))
            {
                insideObjects.UnionWith(v_Grid[key].OldSet.GetHashSet().Where(fltObject =>
                                                                              basePolygon.IntersectsWith(fltObject.Position, fltObject.Position - vector)));
                insideObjects.UnionWith(v_Grid[key].NewSet.GetHashSet().Where(fltObject =>
                                                                              basePolygon.IntersectsWith(fltObject.Position, fltObject.Position - vector)));
            }
            return(insideObjects);
        }
Exemple #3
0
        /// <summary>
        /// Gets the set of floating objects within the reaction distance from any position of a given connector.
        /// Only objects unused in this simulation step are considered.
        /// TODO low priority: return floating objects close to the whole shape of the connector except endpoints
        /// </summary>
        public FloatingObjectsSet GetNearObjects(ConnectorOnTileInSpace connector, NamedMultiset targetMultiset)
        {
            FloatingObjectsSet objectsSet = new FloatingObjectsSet();

            foreach (var position in connector.Positions)
            {
                objectsSet.UnionWith(GetNearObjects(connector.SidePoint(position), targetMultiset));
            }
            return(objectsSet);
        }