defines a policy for rescheduled entities based on the distance of the entity from the player's entities based on a series of rings with a corresponding delay. More...
#include <interest_policy.hh>
Public Types | |
enum | gradient_type { gradient_type::constant, gradient_type::linear } |
the gradient of the delay across the ring. More... | |
Public Member Functions | |
generic_interest_policy () | |
Default constructor. It creates an schedule-all-now policy. More... | |
template<typename TimePoint , typename EntityType > | |
std::optional< TimePoint > | evaluate (const TimePoint &last_sent, const EntityType &entity, const std::vector< std::reference_wrapper< const EntityType >> &player_entities) const |
function called by generic-netcode to determine the next scheduling time for a given entity. More... | |
void | set_has_players (const bool has_players) |
sets no_player_simulation More... | |
bool | has_players () const |
returns true if it a player based simulation More... | |
float | get_cut_off () const |
returns the value of the last ring. Entities beyond that will not be scheduled More... | |
Static Public Member Functions | |
static generic_interest_policy | none () |
generates a schedule-all-now policy More... | |
static generic_interest_policy | default_3d (const bool has_players) |
generates a sample policy for 3d simulation More... | |
static generic_interest_policy | default_2d (const bool has_players) |
generates a sample policy for 2d simulation More... | |
Public Attributes | |
float | scheduling_granularity_hz = 60.0 |
frequency of the updates of entities send to client More... | |
float | per_worker_metadata_frequency_hz = 5.0 |
frequency of the updates of worker information send to client More... | |
bool | no_player_simulation = true |
true when there are no player controlled entities in the simulation. More... | |
std::vector< std::tuple< float, std::chrono::milliseconds, gradient_type > > | rings |
vector of rings used for scheduling entities. More... | |
defines a policy for rescheduled entities based on the distance of the entity from the player's entities based on a series of rings with a corresponding delay.
This results in entities closer to the player to be updated at every packet while entities far away are updated less frequently
the gradient of the delay across the ring.
For constant gradients, all the entities within the ring will be scheduled with the same delay irrespective to its distance to the borders of the ring. Alternately for the linear gradient the delay will be a calculated as a liner function of the distance being the delay assigned to the ring the delay at the outer border and the delay of the previous ring the delay in its innermost border.
Enumerator | |
---|---|
constant | |
linear |
|
inline |
Default constructor. It creates an schedule-all-now policy.
|
inlinestatic |
generates a sample policy for 2d simulation
|
inlinestatic |
generates a sample policy for 3d simulation
|
inline |
function called by generic-netcode to determine the next scheduling time for a given entity.
The time is calculated based distance of the entity to any of the player controlled entities and then calculate the next time based on the previous scheduled time plus the delay corresponding the distance ring.
If the entity is outside the outermost ring it will return nullopt meaning that the entity should not be scheduled
|
inline |
returns the value of the last ring. Entities beyond that will not be scheduled
|
inline |
returns true if it a player based simulation
|
inlinestatic |
generates a schedule-all-now policy
|
inline |
sets no_player_simulation
bool aether::netcode::generic_interest_policy::no_player_simulation = true |
true when there are no player controlled entities in the simulation.
In this case generic-netcode will not perform net-relevancy and all the entities are going to be sent at every update
float aether::netcode::generic_interest_policy::per_worker_metadata_frequency_hz = 5.0 |
frequency of the updates of worker information send to client
std::vector<std::tuple<float, std::chrono::milliseconds, gradient_type> > aether::netcode::generic_interest_policy::rings |
vector of rings used for scheduling entities.
Each ring is a tuple of a radius, a delay for that radius and the gradient function
float aether::netcode::generic_interest_policy::scheduling_granularity_hz = 60.0 |
frequency of the updates of entities send to client