Gravity Engine 2 5.1
|
The GSController (GSC) manages a set of gravitational bodies in an orbital system and their associated scene display components. There may be zero, one or many GSControllers that make reference to the gravitational bodies managed by this controller. More...
Public Types | |
enum | AddMode { CHILDREN , LIST , SCENE } |
Mode the controller will use to find GSBody objects to add CHILDREN: Scan all children of this controller for GSBody LIST: Add objects explicitly listed SCENE: Find all objects in the scene with GSBody components. | |
enum | EvolveMode { IMMEDIATE , IJOB_LATEUPDATE } |
enum | TimeScale { PER_ORBIT , WORLD } |
Time for Typical circular orbit. | |
Public Member Functions | |
List< GSBody > | BodiesForInit () |
Used by GSControllerEditor script. | |
void | BodyAdd (GSBody gsbody) |
Add a GSBody to the physics engine managed by this controller. | |
void | BodyRemove (GSBody gsBody) |
Remove the specified body from the controller and underlying GE. | |
bool | BodyState (GSBody gsBody, ref GEBodyState state, GBUnits.Units units) |
delegate void | ControllerStartedCallback (GSController gsc) |
void | ControllerStartedCallbackAdd (ControllerStartedCallback startCB) |
Add a callback that will be invoked once the GScontroller has completed setup. | |
void | DisplayRegister (GSDisplay gsd) |
Register a GSDisplay class with this controller. Typically used by GSDisplay as part of startup and not as part of user code. | |
List< GSDisplay > | Displays () |
Return a list of the active displays managed by this GSController. | |
GECore | GECore () |
double | JDTime () |
Return the current world time expressed as a Juliam date. | |
void | LogDebugInfo (GECore ge, object arg=null) |
Log the internal state of GECore and all registered display classes to the console. | |
void | PausedSet (bool paused) |
Set the paused state for the GSController. Used to pause and resume physics evolution of the bodies managed by this controller. | |
GSController | PrimaryController () |
void | PrimaryControllerSet (GSController gsc) |
double | TimeUnityToWorld (double unityDelta) |
double | TimeWorldDeltaSinceLastPhyLoop () |
Compute the elapsed world time from the last physics update to now. This assumes there was not a pause in the corresponding interval. | |
double | TimeWorldOvershoot () |
Retrieve the time by which internal GEPhysicsCore time exceeds the reported world time due to dt granularity. For a system that is all on rails this will be zero. | |
bool | TimeWorldSet (double time) |
IF all bodies are on rails the time can be set to a value in the future or past and on the next physics evolution cycle all bodies will jump to the new locations. | |
float | TimeZoomAndFactor () |
void | TrajectoryAdd (int bodyId) |
Used to add a trajectory after the controller has started. (Those in display bodies added during startup will be handled in startup code). | |
void | TrajectoryRemove (int bodyId) |
Remove a trajectory from the physics engine. | |
double | WorldTime () |
Return the current simulation time in time units for the chosen default world units. | |
double | WorldTimePerGameSec () |
Public Attributes | |
GSBody[] | addBodies |
AddMode | addMode = AddMode.CHILDREN |
CR3BP.CR3BPSystemData | cr3bpSysData |
CR3BP.TB_System | cr3bpSystem = CR3BP.TB_System.EARTH_MOON |
int | day = 1 |
bool | DEBUG = true |
bool | debugKeys = false |
bool | debugLogEvents = false |
GBUnits.Units | defaultUnits |
bool | dumpInWorldUnits = true |
bool | editorReferenceFrameFoldout = false |
bool | editorScalingDetailsFoldout |
bool | editorTrajectoryFoldout |
Trajectory prediction. Bodies can ask for trajectory prediction. Typically done with a bool in the GSDisplayBody (since this is typically a per-display choice). | |
bool | editorWorldTimeFoldout |
EvolveMode | evolveMode |
double | gameSecPerOrbit = 60.0 |
int | |
Retrieve the current time zoom level and associated zoom factor. | |
Integrators.Type | integrator |
int | month = 1 |
double | orbitMass = 1000.0 |
Mass scale scale in default units for the most common center object. | |
double | orbitScale = 100.0 |
Typical orbit scale in default units. | |
GSBody | primaryBody |
GECore.ReferenceFrame | referenceFrame = GravityEngine2.GECore.ReferenceFrame.INERTIAL |
GSBody | secondaryBody |
double | stepsPerOrbit = 500.0 |
TimeScale | timeScale |
bool | trajEnabled |
double | trajLookAhead = 10.0 |
int | trajNumSteps = 200 |
double | utc = 0.0 |
double | worldSecPerGameSec = 60.0 |
int | year = 2023 |
Static Public Attributes | |
static double | MIN_STEPS_ORBIT = 100.0 |
The GSController (GSC) manages a set of gravitational bodies in an orbital system and their associated scene display components. There may be zero, one or many GSControllers that make reference to the gravitational bodies managed by this controller.
In-scene gravitational bodies MUST contain a GSBody component to be added by GSC. GSC can find the bodies to be added in one of three ways: CHILDREN: scan the children of the GSC game object for GSBody objects LIST: provide a list of references in the inspector SCENE: Scan the entire scene for GSBody objects. (In this case there will likely only be 1 GSC in the scene)
There can be any number of independent sets of gravitational bodies managed by separate instances of this component in a scene i.e. it is not a singleton.
The goal of the scene controller is to handle the creation of a system of gravitational bodies via components attached to game objects in the scene and to evolve these bodies forward in time.
Gravitational evolution/simulation is performed in the Update() function via gravitySystem.
DISPLAYING: The updating of game objects based on gravitational interaction is delegated to GSDisplay components. This allows multiple views of objects in the scene and allow the scene display components to select which objects should be displayed based on game state, distance from camera etc.
List< GSBody > GravityEngine2.GSController.BodiesForInit | ( | ) |
Used by GSControllerEditor script.
void GravityEngine2.GSController.BodyAdd | ( | GSBody | gsbody | ) |
Add a GSBody to the physics engine managed by this controller.
Note that any display routines (GSDisplayBody, GSDisplayOrbit) asociated with the body must be added by calls to the appropriate GSDisplay.
gsbody |
void GravityEngine2.GSController.BodyRemove | ( | GSBody | gsBody | ) |
Remove the specified body from the controller and underlying GE.
If trajectories are in play, the body will also be removed from the trajectory GE.
Remove is done when the ge physics is not running. In IMMEDIATE mode will be run immediatly, otherwise will be in LateUpdate when job completes.
gsBody |
void GravityEngine2.GSController.ControllerStartedCallbackAdd | ( | ControllerStartedCallback | startCB | ) |
Add a callback that will be invoked once the GScontroller has completed setup.
This is a useful mechanism for Monobehaviours in the scene to do setupin a way that does not rely on Start() operations occuring in a specific time order.
startCB |
void GravityEngine2.GSController.DisplayRegister | ( | GSDisplay | gsd | ) |
Register a GSDisplay class with this controller. Typically used by GSDisplay as part of startup and not as part of user code.
gsd |
List< GSDisplay > GravityEngine2.GSController.Displays | ( | ) |
Return a list of the active displays managed by this GSController.
GECore GravityEngine2.GSController.GECore | ( | ) |
double GravityEngine2.GSController.JDTime | ( | ) |
Return the current world time expressed as a Juliam date.
void GravityEngine2.GSController.LogDebugInfo | ( | GECore | ge, |
object | arg = null ) |
Log the internal state of GECore and all registered display classes to the console.
ge | |
arg |
void GravityEngine2.GSController.PausedSet | ( | bool | paused | ) |
Set the paused state for the GSController. Used to pause and resume physics evolution of the bodies managed by this controller.
paused |
GSController GravityEngine2.GSController.PrimaryController | ( | ) |
void GravityEngine2.GSController.PrimaryControllerSet | ( | GSController | gsc | ) |
gsc |
double GravityEngine2.GSController.TimeWorldOvershoot | ( | ) |
Retrieve the time by which internal GEPhysicsCore time exceeds the reported world time due to dt granularity. For a system that is all on rails this will be zero.
Result will be at most dt
bool GravityEngine2.GSController.TimeWorldSet | ( | double | time | ) |
IF all bodies are on rails the time can be set to a value in the future or past and on the next physics evolution cycle all bodies will jump to the new locations.
The caller needs to ensure this is not done when GE is running, so it might be necessary to do this as a PhysLoop callback.
time |
void GravityEngine2.GSController.TrajectoryAdd | ( | int | bodyId | ) |
Used to add a trajectory after the controller has started. (Those in display bodies added during startup will be handled in startup code).
If there have been no trajectories added so far, then need to setup the parallel GE to compute them.
If we have a GE doing traj evolution, it needs to restart from the current GE state so the new trajectory can be included.
In addition, if a body with mass is added (that could affect existing trajectories) also need to restart.
bodyId |
void GravityEngine2.GSController.TrajectoryRemove | ( | int | bodyId | ) |
Remove a trajectory from the physics engine.
bodyId |
double GravityEngine2.GSController.WorldTime | ( | ) |
Return the current simulation time in time units for the chosen default world units.
bool GravityEngine2.GSController.editorTrajectoryFoldout |
Trajectory prediction. Bodies can ask for trajectory prediction. Typically done with a bool in the GSDisplayBody (since this is typically a per-display choice).
This requires the instantiation of a second GE which tracks the first but runs ahead of the current one. Data recording into recordedOutput is done. Initially (and when something changes in the GE via Add/Maneuuver etc.) the traj GE needs to do re-do the work to compute up to the timeAhead requested. After that it just does the incremental advance as time goes forward.
GravityEngine2.GSController.int |
Retrieve the current time zoom level and associated zoom factor.