mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02:00
Add an active object step time budget #6721
This can be set via the active_object_interval option.
This commit is contained in:
@@ -230,7 +230,7 @@ inline u32 calc_parity(u32 v)
|
||||
u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed);
|
||||
|
||||
bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir,
|
||||
f32 camera_fov, f32 range, f32 *distance_ptr=NULL);
|
||||
f32 camera_fov, f32 range, f32 *distance_ptr = NULL);
|
||||
|
||||
s16 adjustDist(s16 dist, float zoom_fov);
|
||||
|
||||
@@ -291,18 +291,24 @@ public:
|
||||
return value:
|
||||
true: action should be skipped
|
||||
false: action should be done
|
||||
if passed, the elapsed time since this method last returned true
|
||||
is written to elapsed_ptr
|
||||
*/
|
||||
bool step(float dtime, float wanted_interval)
|
||||
bool step(float dtime, float wanted_interval, float *elapsed_ptr = NULL)
|
||||
{
|
||||
m_accumulator += dtime;
|
||||
if (elapsed_ptr)
|
||||
*elapsed_ptr = m_accumulator - m_last_accumulator;
|
||||
if (m_accumulator < wanted_interval)
|
||||
return false;
|
||||
m_accumulator -= wanted_interval;
|
||||
m_last_accumulator = m_accumulator;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
float m_accumulator = 0.0f;
|
||||
float m_last_accumulator = 0.0f;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user