Gravity Engine  1.5
Unity Asset for Gravity
MasslessBodyEngine Class Reference

More...

Public Member Functions

 MasslessBodyEngine (double dt)
 
MasslessBodyEngine DeepClone ()
 
Vector3 InactivateBody (GameObject toInactivate)
 Inactivates the body. Ensures body is skipped in force calculations and physics evolution. More...
 
Vector3 ActivateBody (GameObject toInactivate)
 Re-activates an inactive body More...
 
void AddBody (GameObject gameObject, float physToWorldFactor)
 
void RemoveBody (GameObject gameObject)
 
int NumBodies ()
 
void PreEvolve (int numMasses, GravityState gravityState)
 Pre-evolve the massless bodies based in the array information about the massive bodies in the system. More...
 
double Evolve (double evolveFor, int numMasses, GravityState gravityState, ref byte[] massive_info)
 Evolve the position of the active massless bodies based on the gravitational field by the objects provided in the arguments m, r_m. More...
 
double EvolveWithForce (double evolveFor, int numMasses, GravityState gravityState, ref byte[] massive_info, IForceDelegate force)
 Evolve the position of the active massless bodies based on the gravitational field by the objects provided in the arguments m, r_m and the specified force. More...
 
void UpdateBodies (float physicalScale)
 
void UpdateTrajectories (float physicalScale, float trajectoryWorldTime, float worldTime)
 
void ResetTrajectories (float worldTime)
 
void TrajectoryEnable (bool enable)
 
void GetPositionVelocityScaled (int index, ref double[] p, ref double[] vel)
 
Vector3 GetVelocity (GameObject body)
 
void SetVelocity (GameObject body, Vector3 velocity)
 
void SetVelocityAtIndex (int i, Vector3 velocity)
 
void SetPositionAtIndex (int i, Vector3 pos, float phyToWorldFactor)
 
Vector3 GetAcceleration (GameObject body)
 

Detailed Description

This class handles massless test bodies (e.g a spaceship, satellite etc.) that are influenced by the gravity in the GravityEngine but do not affect the gravitation field felt by others.

If massless bodies are required, the GravityEngine engine will create an instance of this class to manage their evolution IF the option OptimizeMassless has been set.

Another good reason to enable OptimizeMAssless is it allows test bodies to be used with an integrator with a limited number of massive bodies (e.g. AZTTriple)

Other benefits:

  • reduces computational complexity (since GravityEngine runs as O(N^2) adding test bodies can be expensive)
  • allows a simpler integration to be used
  • allows multiple complex objects (i.e. meshes) to be added when GravityParticles is not suitable

This engine has a "baked in" Leapfrog integrator; close encounters with masses will result in inaccurate evolution.

If higher precision is needed, use GravityEngine with Hermite and set the mass of the object to zero

This class is only called from GravityEngine and should not be called from user scripts.

Member Function Documentation

Vector3 MasslessBodyEngine.ActivateBody ( GameObject  toInactivate)

Re-activates an inactive body

Returns
The body.
Parameters
toInactivateTo inactivate.
double MasslessBodyEngine.Evolve ( double  evolveFor,
int  numMasses,
GravityState  gravityState,
ref byte[]  massive_info 
)

Evolve the position of the active massless bodies based on the gravitational field by the objects provided in the arguments m, r_m.

This does not use the standard integrators since the list of bodies and the loop structure differs.

Parameters
evolveForTotal time to evolve for
numMassesNumber masses.
mM.
r_mR m.
size2Size2.
double MasslessBodyEngine.EvolveWithForce ( double  evolveFor,
int  numMasses,
GravityState  gravityState,
ref byte[]  massive_info,
IForceDelegate  force 
)

Evolve the position of the active massless bodies based on the gravitational field by the objects provided in the arguments m, r_m and the specified force.

This does not use the standard integrators since the list of bodies and the loop structure differs.

Returns
The with force.
Parameters
evolveForEvolve for.
numMassesNumber masses.
mM.
r_mR m.
massive_infoMassive info.
forceForce.
Vector3 MasslessBodyEngine.InactivateBody ( GameObject  toInactivate)

Inactivates the body. Ensures body is skipped in force calculations and physics evolution.

Returns
The body.
Parameters
toInactivateTo inactivate.
void MasslessBodyEngine.PreEvolve ( int  numMasses,
GravityState  gravityState 
)

Pre-evolve the massless bodies based in the array information about the massive bodies in the system.

Parameters
numMassesNumber masses.
mMass array for massive bodies
r_mPosition array for massive bodies.

The documentation for this class was generated from the following file: