RavEngine
Loading...
Searching...
No Matches
RavEngine::World Class Reference
Inheritance diagram for RavEngine::World:
[legend]
Collaboration diagram for RavEngine::World:
[legend]

Classes

class  EntitySparseSet
 
struct  PolymorphicIndirection
 

Public Member Functions

auto VersionForEntity (entity_id_t id) const
 
bool CorrectVersion (entity_t id) const
 
void SetEntityRenderlayer (entity_t globalid, renderlayer_t layers)
 
void SetEntityAttributes (entity_t globalid, perobject_t attributes)
 
perobject_t GetEntityAttributes (entity_t globalid)
 
template<typename T , typename ... A>
T Instantiate (A &&... args)
 
template<typename func >
void Filter (func &&f)
 
template<typename func >
void FilterPolymorphic (func &&f)
 
template<typename func_t >
void EnumerateComponentsOn (entity_t local_id, const func_t &fn)
 
template<typename T , typename U >
void CreateDependency ()
 
template<typename T >
void RemoveSystem ()
 
template<typename T , typename ... Args>
auto EmplaceSystem (Args &&... args)
 
template<typename T , typename interval_t , typename ... Args>
auto EmplaceTimedSystem (const interval_t interval, Args &&... args)
 
template<typename T , typename ... Args>
auto EmplacePolymorphicSystem (Args &&... args)
 
template<typename T , typename interval_t , typename ... Args>
auto EmplacePolymorphicTimedSystem (const interval_t interval, Args &&... args)
 
template<typename T , typename ... Args>
auto EmplaceSerialSystem (Args &&... args)
 
template<typename T , typename interval_t , typename ... Args>
auto EmplaceSerialTimedSystem (const interval_t interval, Args &&... args)
 
template<typename T , typename ... Args>
auto EmplaceSerialPolymorphicSystem (Args &&... args)
 
template<typename T , typename interval_t , typename ... Args>
auto EmplaceSerialPolymorphicTimedSystem (const interval_t interval, Args &&... args)
 
const auto & getTypeToSystem () const
 
template<typename T >
T & GetComponent ()
 
float GetCurrentFPSScale () const
 
void ExportTaskGraph (std::ostream &out)
 
bool InitPhysics ()
 
void Tick (float)
 
 World (const std::string &name)
 
 World (const decltype(skybox)&sk)
 
void PlaySound (const InstantaneousAudioSource &ias)
 
void PlayAmbientSound (const InstantaneousAmbientAudioSource &iaas)
 
void DeallocatePhysics ()
 
virtual void OnActivate ()
 
virtual void OnDeactivate ()
 
void DispatchAsync (const Function< void(void)> &func, double delaySeconds)
 
template<typename T >
auto GetAllComponentsOfType ()
 

Static Public Member Functions

template<typename T >
static PointerInputBinder< T > GetInput (T *ptr)
 

Public Attributes

Ref< Skybox > skybox
 
std::string_view worldID { worldIDbuf,id_size }
 
std::atomic< bool > newFrame = false
 

Static Public Attributes

static constexpr uint8_t id_size = 8
 

Protected Member Functions

virtual void PreTick (float fpsScale)
 
void TickECS (float)
 
void setupRenderTasks ()
 
virtual void PostTick (float fpsScale)
 

Protected Attributes

std::unique_ptr< PhysicsSolver > Solver
 
LinkedList< InstantaneousAudioSourceToPlay > instantaneousToPlay
 
LinkedList< InstantaneousAmbientAudioSource > ambientToPlay
 
bool physicsActive = false
 

Friends

class AudioPlayer
 
class App
 
class PhysicsBodyComponent
 
class Entity
 
class Registry
 
class StaticMesh
 
class SkinnedMeshComponent
 
class RenderEngine
 
class PhysicsLinkSystemWrite
 

Constructor & Destructor Documentation

◆ World() [1/2]

RavEngine::World::World ( const std::string &  name)
inline

Constructor useful for setting the world name

Parameters
namethe string name for this world. Note that if the name has more characters than id_size, only the first id_size characters will be included.

◆ World() [2/2]

RavEngine::World::World ( const decltype(skybox)&  sk)
inline

Constructor that takes a custom skybox. This constructor will bypass loading the default skybox.

Parameters
skthe skybox to use

Member Function Documentation

◆ CorrectVersion()

bool RavEngine::World::CorrectVersion ( entity_t  id) const
inline
Returns
true if the entity handle has the correct version (is not stale), false otherwise.

◆ CreateDependency()

template<typename T , typename U >
void RavEngine::World::CreateDependency ( )
inline

Specify a dependency. T depends on U

◆ DeallocatePhysics()

void World::DeallocatePhysics ( )
inline

Called by GameplayStatics when the final world is being deallocated

◆ DispatchAsync()

void World::DispatchAsync ( const Function< void(void)> &  func,
double  delaySeconds 
)

Dispatch a function to run in a given number of seconds in the future

Parameters
functhe function to run
delaySecondsthe delay in the future to run
Note
You must ensure data your function references is kept loaded when this function runs. For example, to keep an entity loaded, capture by value an owning pointer to it. In addition, do not make assumptions about what thread your dispatched function runs on.

◆ EmplacePolymorphicSystem()

template<typename T , typename ... Args>
auto RavEngine::World::EmplacePolymorphicSystem ( Args &&...  args)
inline

Instantiate a parallel system that performs polymorphic queries to get component data. T is the class/struct type of the system.

Parameters
argsvalues to pass to the system constructor

◆ EmplacePolymorphicTimedSystem()

template<typename T , typename interval_t , typename ... Args>
auto RavEngine::World::EmplacePolymorphicTimedSystem ( const interval_t  interval,
Args &&...  args 
)
inline

Instantiate a parallel system that performs polymorphic queries to get component data, and runs on an interval. T is the class/struct type of the system.

Note
The interval is is not a guarentee. I the engine is running too slowly to satisfy the interval, it will be called on a best-effort basis.
Parameters
argsvalues to pass to the system constructor

◆ EmplaceSerialPolymorphicSystem()

template<typename T , typename ... Args>
auto RavEngine::World::EmplaceSerialPolymorphicSystem ( Args &&...  args)
inline

Instantiate a parallel system that performs polymorphic queries to get component data. T is the class/struct type of the system.

Parameters
argsvalues to pass to the system constructor

◆ EmplaceSerialPolymorphicTimedSystem()

template<typename T , typename interval_t , typename ... Args>
auto RavEngine::World::EmplaceSerialPolymorphicTimedSystem ( const interval_t  interval,
Args &&...  args 
)
inline

Instantiate a parallel system that performs polymorphic queries to get component data, and runs on an interval. T is the class/struct type of the system.

Note
The interval is is not a guarentee. I the engine is running too slowly to satisfy the interval, it will be called on a best-effort basis.
Parameters
argsvalues to pass to the system constructor

◆ EmplaceSerialSystem()

template<typename T , typename ... Args>
auto RavEngine::World::EmplaceSerialSystem ( Args &&...  args)
inline

Instantiate a parallel system. T is the class/struct type of the system.

Parameters
argsvalues to pass to the system constructor

◆ EmplaceSerialTimedSystem()

template<typename T , typename interval_t , typename ... Args>
auto RavEngine::World::EmplaceSerialTimedSystem ( const interval_t  interval,
Args &&...  args 
)
inline

Instantiate a parallel system that runs on an interval. T is the class/struct type of the system.

Note
The interval is is not a guarentee. I the engine is running too slowly to satisfy the interval, it will be called on a best-effort basis.
Parameters
intervalthe frequency of execution of the system.
argsvalues to pass to the system constructor

◆ EmplaceSystem()

template<typename T , typename ... Args>
auto RavEngine::World::EmplaceSystem ( Args &&...  args)
inline

Instantiate a parallel system. T is the class/struct type of the system.

Parameters
argsvalues to pass to the system constructor

◆ EmplaceTimedSystem()

template<typename T , typename interval_t , typename ... Args>
auto RavEngine::World::EmplaceTimedSystem ( const interval_t  interval,
Args &&...  args 
)
inline

Instantiate a parallel system that runs on an interval. T is the class/struct type of the system.

Note
The interval is is not a guarentee. I the engine is running too slowly to satisfy the interval, it will be called on a best-effort basis.
Parameters
intervalthe frequency of execution of the system.
argsvalues to pass to the system constructor

◆ ExportTaskGraph()

void RavEngine::World::ExportTaskGraph ( std::ostream &  out)
inline

Log the task graph in graphivz format.

◆ Filter()

template<typename func >
void RavEngine::World::Filter ( func &&  f)
inline

Iterate the world, invoking a function for all entities with the requested components

Parameters
fthe function to invoke. The parameters of
f
are the types used to query the scene

◆ FilterPolymorphic()

template<typename func >
void RavEngine::World::FilterPolymorphic ( func &&  f)
inline

Iterate the world, invoking a function for all entities with the requested components via a polymoprhic query.

Parameters
fthe function to invoke. The parameters of
f
are the types used to query the scene

◆ GetAllComponentsOfType()

template<typename T >
auto RavEngine::World::GetAllComponentsOfType ( )
inline
Returns
the internal data structure storing all components of a given type.
Note
Do not assume ordering of components within the structure.

◆ GetComponent()

template<typename T >
T & RavEngine::World::GetComponent ( )
inline
Returns
the "first" of a component type. Do not make assumptions regarding ordering of components.

◆ GetCurrentFPSScale()

float RavEngine::World::GetCurrentFPSScale ( ) const
inline
Returns
the current tick scale factor. If the engine is running above expected speed, this value will be (0,1). If the engine is running below expected speed, this value will be > 1.

◆ GetEntityAttributes()

perobject_t World::GetEntityAttributes ( entity_t  globalid)
Parameters
globalidthe entity ID
Returns
the per-object rendering attributes bitmask

◆ InitPhysics()

bool RavEngine::World::InitPhysics ( )

Initializes the physics-related Systems.

Returns
true if the systems were loaded, false if they were not loaded because they are already loaded

◆ Instantiate()

template<typename T , typename ... A>
T RavEngine::World::Instantiate ( A &&...  args)
inline

Add an entity of type

T

to the world. Invokes the

Create

function of T.

Parameters
argsparameters to pass to
Create
Returns
a handle to the constructed entity.

◆ OnActivate()

virtual void RavEngine::World::OnActivate ( )
inlinevirtual

Called when this world is made the active world for the App

◆ OnDeactivate()

virtual void RavEngine::World::OnDeactivate ( )
inlinevirtual

Called when this world was the active world for the App but has been replaced by a different world

◆ PostTick()

virtual void RavEngine::World::PostTick ( float  fpsScale)
inlineprotectedvirtual

Called after physics and rendering synchronously

Parameters
fpsScalethe scale factor calculated

◆ PreTick()

virtual void RavEngine::World::PreTick ( float  fpsScale)
inlineprotectedvirtual

Called before ticking components and entities synchronously

Parameters
fpsScalethe scale factor calculated

◆ RemoveSystem()

template<typename T >
void RavEngine::World::RemoveSystem ( )
inline

Remove a system from the world by type.

◆ SetEntityAttributes()

void World::SetEntityAttributes ( entity_t  globalid,
perobject_t  attributes 
)

Specify per-object rendering attributes

Parameters
globalidthe entity ID
layersthe attribute bitmask

◆ SetEntityRenderlayer()

void World::SetEntityRenderlayer ( entity_t  globalid,
renderlayer_t  layers 
)

Specify render layers for an entity

Parameters
globalidthe entity ID
layersthe render layer bitmask

◆ Tick()

void RavEngine::World::Tick ( float  scale)

Evaluate the world given a scale factor. One tick = 1/GetApp()->EvalNormal

Parameters
thetick fraction to evaluate
Note
the GameplayStatics CurrentWorld is ticked automatically in the App

◆ TickECS()

void RavEngine::World::TickECS ( float  fpsScale)
protected

Tick all of the objects in the world, multithreaded

Parameters
fpsScalethe scale factor to apply to all operations based on the frame rate

◆ VersionForEntity()

auto RavEngine::World::VersionForEntity ( entity_id_t  id) const
inline
Returns
the internal "Version" of the entity. This is for detecting use-after-destroy bugs.

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