Package gaiasky.data

Class OctreeLoader

All Implemented Interfaces:
IOctantLoader, ISceneLoader, IObserver

public class OctreeLoader extends AbstractSceneLoader implements IObserver, IOctantLoader
Loads Gaia Sky LOD datasets backed by an octree.
  • Field Details Link icon

    • PRELOAD_DEPTH Link icon

      protected static final int PRELOAD_DEPTH
      Data will be preloaded at startup down to this octree depth.
      See Also:
    • LOAD_QUEUE_MAX_SIZE Link icon

      protected static final int LOAD_QUEUE_MAX_SIZE
      Maximum load queue size.
      See Also:
    • MIN_QUEUE_CLEAR_MS Link icon

      protected static final long MIN_QUEUE_CLEAR_MS
      Minimum time to pass to be able to clear the queue again.
      See Also:
    • MAX_LOAD_CHUNK Link icon

      protected static final int MAX_LOAD_CHUNK
      Maximum number of pages to send to load every batch.
      See Also:
    • instance Link icon

      public static OctreeLoader instance
    • maxLoadedStars Link icon

      protected final long maxLoadedStars
      Max number of stars loaded at once.
    • nLoadedStars Link icon

      protected int nLoadedStars
      Current number of stars that are loaded.
    • toLoadQueue Link icon

      protected Queue<OctreeNode> toLoadQueue
      The octant loading queue.
    • loadingPaused Link icon

      protected boolean loadingPaused
      Whether loading is paused or not.
    • lastQueueClearMs Link icon

      protected long lastQueueClearMs
      Last time of a queue clear event went through.
    • name Link icon

      protected String name
    • description Link icon

      protected String description
    • params Link icon

      protected Map<String,Object> params
    • toUnloadQueue Link icon

      protected Queue<OctreeNode> toUnloadQueue
      This queue is sorted ascending by access date, so that we know which element to release if needed (oldest).
    • loadedIds Link icon

      protected long[] loadedIds
      Loaded octant ids, for logging.
    • loadedObjects Link icon

      protected int loadedObjects
    • maxLoadedIds Link icon

      protected int maxLoadedIds
    • idxLoadedIds Link icon

      protected int idxLoadedIds
    • metadata Link icon

      protected String metadata
    • particles Link icon

      protected String particles
    • daemon Link icon

      Daemon thread that gets the data loading requests and serves them.
  • Constructor Details Link icon

    • OctreeLoader Link icon

      public OctreeLoader()
  • Method Details Link icon

    • initialize Link icon

      public void initialize(String[] files, String dsLocation, Scene scene) throws RuntimeException
      Specified by:
      initialize in interface ISceneLoader
      Overrides:
      initialize in class AbstractSceneLoader
      Throws:
      RuntimeException
    • initialize Link icon

      public void initialize(String[] files, Scene scene) throws RuntimeException
      Specified by:
      initialize in interface ISceneLoader
      Overrides:
      initialize in class AbstractSceneLoader
      Throws:
      RuntimeException
    • loadOctreeData Link icon

      protected com.badlogic.ashley.core.Entity loadOctreeData()
      Loads the nodes and the octree.
    • setEpoch Link icon

      public void setEpoch(Double epoch)
    • setEpoch Link icon

      public void setEpoch(Long epoch)
    • loadData Link icon

      public com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> loadData()
      Description copied from interface: ISceneLoader
      Performs the loading and returns an array with the entities loaded.
      Specified by:
      loadData in interface ISceneLoader
      Returns:
      The loaded entities.
    • addLoadedInfo Link icon

      protected void addLoadedInfo(long id, int nobjects)
    • flushLoadedIds Link icon

      protected void flushLoadedIds()
    • queue Link icon

      public void queue(OctreeNode octant)
      Adds the octant to the load queue.
      Specified by:
      queue in interface IOctantLoader
    • clearQueue Link icon

      public void clearQueue()
      Clears the current load queue.
      Specified by:
      clearQueue in interface IOctantLoader
    • getLoadQueueSize Link icon

      public int getLoadQueueSize()
      Specified by:
      getLoadQueueSize in interface IOctantLoader
    • getNLoadedStars Link icon

      public int getNLoadedStars()
      Specified by:
      getNLoadedStars in interface IOctantLoader
    • touch Link icon

      public void touch(OctreeNode octant)
      Moves the octant to the end of the unload queue.
      Specified by:
      touch in interface IOctantLoader
    • emptyLoadQueue Link icon

      public void emptyLoadQueue()
      Removes all octants from the current load queue. This happens when the camera viewport changes radically (velocity is high, direction changes a lot, etc.) so that the old octants are dropped and newly observed octants are loaded right away.
    • addToQueue Link icon

      public void addToQueue(OctreeNode octant)
    • touchOctant Link icon

      public void touchOctant(OctreeNode octant)
      Puts it at the end of the toUnloadQueue.
    • flushLoadQueue Link icon

      public void flushLoadQueue()
      Tells the loader to start loading the octants in the queue.
    • abortCurrentLoading Link icon

      public void abortCurrentLoading()
      Tells the daemon to immediately stop the loading of octants and wait for new data
    • loadLod Link icon

      public void loadLod(Integer lod, com.badlogic.ashley.core.Entity octreeWrapper) throws IOException
      Loads all the levels of detail until the given one.
      Parameters:
      lod - The level of detail to load.
      octreeWrapper - The octree wrapper entity.
      Throws:
      IOException - When any of the level's files fails to load.
    • loadOctant Link icon

      public void loadOctant(OctreeNode octant, com.badlogic.ashley.core.Entity octreeWrapper, Integer level)
      Loads the data of the given octant and its children down to the given level.
      Parameters:
      octant - The octant to load.
      octreeWrapper - The octree wrapper.
      level - The depth to load.
    • loadOctants Link icon

      public void loadOctants(com.badlogic.gdx.utils.Array<OctreeNode> octants, com.badlogic.ashley.core.Entity octreeWrapper, AtomicBoolean abort)
      Loads the objects of the given octants.
      Parameters:
      octants - The list holding the octants to load.
      octreeWrapper - The octree wrapper.
      abort - State variable that will be set to true if an abort is called.
    • loadOctant Link icon

      public boolean loadOctant(OctreeNode octant, com.badlogic.ashley.core.Entity octreeWrapper, boolean fullInit)
      Loads the data of the given octant.
      Parameters:
      octant - The octant to load.
      octreeWrapper - The octree wrapper entity.
      fullInit - Whether to fully initialise the objects (on-demand load) or not (startup)
      Returns:
      True if the octant was loaded, false otherwise
    • unloadOctant Link icon

      public void unloadOctant(OctreeNode octant, com.badlogic.ashley.core.Entity octreeWrapper)
      Unloads the given octant.
    • notify Link icon

      public void notify(Event event, Object source, Object... data)
      Description copied from interface: IObserver
      Event notification call.
      Specified by:
      notify in interface IObserver
      Parameters:
      event - The event type.
      source - The source object, if any.
      data - The data associated with this event.
    • setName Link icon

      public void setName(String name)
      Specified by:
      setName in interface ISceneLoader
    • setDescription Link icon

      public void setDescription(String description)
      Specified by:
      setDescription in interface ISceneLoader
    • setParams Link icon

      public void setParams(Map<String,Object> params)
      Specified by:
      setParams in interface ISceneLoader