Class OctreeLoader
java.lang.Object
gaiasky.data.AbstractSceneLoader
gaiasky.data.OctreeLoader
- All Implemented Interfaces:
IOctantLoader, ISceneLoader, IObserver
Loads Gaia Sky LOD datasets backed by an octree.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThe daemon loader thread. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected OctreeLoader.OctreeLoaderThreadDaemon thread that gets the data loading requests and serves them.protected Stringprotected intstatic OctreeLoaderprotected longLast time of a queue clear event went through.protected static final intMaximum load queue size.protected long[]Loaded octant ids, for logging.protected intprotected booleanWhether loading is paused or not.protected static final intMaximum number of pages to send to load every batch.protected intprotected final longMax number of stars loaded at once.protected Stringprotected static final longMinimum time to pass to be able to clear the queue again.protected Stringprotected intCurrent number of stars that are loaded.protected Stringprotected static final intData will be preloaded at startup down to this octree depth.static final StringStar group name prefix.protected Queue<OctreeNode> The octant loading queue.protected Queue<OctreeNode> This queue is sorted ascending by access date, so that we know which element to release if needed (oldest).Fields inherited from class AbstractSceneLoader
datasetDirectory, dataSource, filePaths, index, loggedArchetypes, parentName, scene -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidTells the daemon to immediately stop the loading of octants and wait for new dataprotected voidaddLoadedInfo(long id, int nobjects) voidaddToQueue(OctreeNode octant) voidClears the current load queue.voidRemoves all octants from the current load queue.protected voidvoidTells the loader to start loading the octants in the queue.intintvoidinitialize(String[] files, Scene scene) voidinitialize(String[] files, String dsLocation, Scene scene) com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> loadData()Performs the loading and returns an array with the entities loaded.voidLoads all the levels of detail until the given one.booleanloadOctant(OctreeNode octant, com.badlogic.ashley.core.Entity octreeWrapper, boolean fullInit, boolean immediate) Loads the data of the given octant.voidloadOctant(OctreeNode octant, com.badlogic.ashley.core.Entity octreeWrapper, Integer level, boolean immediate) Loads the data of the given octant and its children down to the given level.voidloadOctants(com.badlogic.gdx.utils.Array<OctreeNode> octants, com.badlogic.ashley.core.Entity octreeWrapper, boolean immediate, AtomicBoolean abort) Loads the objects of the given octants.protected com.badlogic.ashley.core.EntityLoads the nodes and the octree.voidEvent notification call.voidqueue(OctreeNode octant) Adds the octant to the load queue.voidsetDescription(String description) voidvoidvoidvoidvoidtouch(OctreeNode octant) Moves the octant to the end of the unload queue.voidtouchOctant(OctreeNode octant) Puts it at the end of the toUnloadQueue.voidunloadOctant(OctreeNode octant, com.badlogic.ashley.core.Entity octreeWrapper) Unloads the given octant.Methods inherited from class AbstractSceneLoader
initialize, setIndex, setParentNameModifier and TypeMethodDescriptionvoidinitialize(uk.ac.starlink.util.DataSource dataSource, Scene scene) voidvoidsetParentName(String parentName)
-
Field Details
-
STAR_GROUP_NAME_PREFIX
-
PRELOAD_DEPTH
protected static final int PRELOAD_DEPTHData will be preloaded at startup down to this octree depth.- See Also:
-
LOAD_QUEUE_MAX_SIZE
protected static final int LOAD_QUEUE_MAX_SIZEMaximum load queue size.- See Also:
-
MIN_QUEUE_CLEAR_MS
protected static final long MIN_QUEUE_CLEAR_MSMinimum time to pass to be able to clear the queue again.- See Also:
-
MAX_LOAD_CHUNK
protected static final int MAX_LOAD_CHUNKMaximum number of pages to send to load every batch.- See Also:
-
instance
-
maxLoadedStars
protected final long maxLoadedStarsMax number of stars loaded at once. -
nLoadedStars
protected int nLoadedStarsCurrent number of stars that are loaded. -
toLoadQueue
The octant loading queue. -
loadingPaused
protected boolean loadingPausedWhether loading is paused or not. -
lastQueueClearMs
protected long lastQueueClearMsLast time of a queue clear event went through. -
name
-
description
-
params
-
toUnloadQueue
This queue is sorted ascending by access date, so that we know which element to release if needed (oldest). -
loadedIds
protected long[] loadedIdsLoaded octant ids, for logging. -
loadedObjects
protected int loadedObjects -
maxLoadedIds
protected int maxLoadedIds -
idxLoadedIds
protected int idxLoadedIds -
metadata
-
particles
-
daemon
Daemon thread that gets the data loading requests and serves them.
-
-
Constructor Details
-
OctreeLoader
public OctreeLoader()
-
-
Method Details
-
initialize
- Specified by:
initializein interfaceISceneLoader- Overrides:
initializein classAbstractSceneLoader- Throws:
RuntimeException
-
initialize
- Specified by:
initializein interfaceISceneLoader- Overrides:
initializein classAbstractSceneLoader- Throws:
RuntimeException
-
loadOctreeData
protected com.badlogic.ashley.core.Entity loadOctreeData()Loads the nodes and the octree. -
setEpoch
-
setEpoch
-
loadData
public com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> loadData()Description copied from interface:ISceneLoaderPerforms the loading and returns an array with the entities loaded.- Specified by:
loadDatain interfaceISceneLoader- Returns:
- The loaded entities.
-
addLoadedInfo
protected void addLoadedInfo(long id, int nobjects) -
flushLoadedIds
protected void flushLoadedIds() -
queue
Adds the octant to the load queue.- Specified by:
queuein interfaceIOctantLoader
-
clearQueue
public void clearQueue()Clears the current load queue.- Specified by:
clearQueuein interfaceIOctantLoader
-
getLoadQueueSize
public int getLoadQueueSize()- Specified by:
getLoadQueueSizein interfaceIOctantLoader
-
getNLoadedStars
public int getNLoadedStars()- Specified by:
getNLoadedStarsin interfaceIOctantLoader
-
touch
Moves the octant to the end of the unload queue.- Specified by:
touchin interfaceIOctantLoader
-
emptyLoadQueue
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
-
touchOctant
Puts it at the end of the toUnloadQueue. -
flushLoadQueue
public void flushLoadQueue()Tells the loader to start loading the octants in the queue. -
abortCurrentLoading
public void abortCurrentLoading()Tells the daemon to immediately stop the loading of octants and wait for new data -
loadLod
public void loadLod(Integer lod, com.badlogic.ashley.core.Entity octreeWrapper, boolean immediate) 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
public void loadOctant(OctreeNode octant, com.badlogic.ashley.core.Entity octreeWrapper, Integer level, boolean immediate) 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.immediate- Populate the objects list in the octant immediately.
-
loadOctants
public void loadOctants(com.badlogic.gdx.utils.Array<OctreeNode> octants, com.badlogic.ashley.core.Entity octreeWrapper, boolean immediate, AtomicBoolean abort) Loads the objects of the given octants.- Parameters:
octants- The list holding the octants to load.octreeWrapper- The octree wrapper.immediate- Populate the objects list in the octant immediately.abort- State variable that will be set to true if an abort is called.
-
loadOctant
public boolean loadOctant(OctreeNode octant, com.badlogic.ashley.core.Entity octreeWrapper, boolean fullInit, boolean immediate) 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)immediate- Populate the octant list immediately with the new star group.- Returns:
- True if the octant was loaded, false otherwise
-
unloadOctant
Unloads the given octant. -
notify
-
setName
- Specified by:
setNamein interfaceISceneLoader
-
setDescription
- Specified by:
setDescriptionin interfaceISceneLoader
-
setParams
- Specified by:
setParamsin interfaceISceneLoader
-