Sdk/BaseSystem: Fix udpate with max update rate + unit tests
This commit is contained in:
parent
cc4fdf2476
commit
f95fc332f1
|
|
@ -171,7 +171,7 @@ namespace Ndk
|
|||
|
||||
if (m_maxUpdateRate > 0.f)
|
||||
{
|
||||
if (m_updateCounter > elapsedTime)
|
||||
if (m_updateCounter >= m_maxUpdateRate)
|
||||
{
|
||||
if (m_fixedUpdateRate > 0.f)
|
||||
{
|
||||
|
|
@ -184,7 +184,7 @@ namespace Ndk
|
|||
else
|
||||
{
|
||||
OnUpdate(m_maxUpdateRate);
|
||||
m_updateCounter -= elapsedTime;
|
||||
m_updateCounter -= m_maxUpdateRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ SCENARIO("BaseSystem", "[NDK][BASESYSTEM]")
|
|||
{
|
||||
GIVEN("Our TestSystem")
|
||||
{
|
||||
Ndk::World world;
|
||||
Ndk::World world(false);
|
||||
|
||||
Ndk::BaseSystem& system = world.AddSystem<TestSystem>();
|
||||
REQUIRE(&system.GetWorld() == &world);
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ SCENARIO("Entity", "[NDK][ENTITY]")
|
|||
{
|
||||
GIVEN("A world & an entity")
|
||||
{
|
||||
Ndk::World world;
|
||||
Ndk::World world(false);
|
||||
|
||||
Ndk::BaseSystem& system = world.AddSystem<UpdateSystem>();
|
||||
Ndk::EntityHandle entity = world.CreateEntity();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ SCENARIO("EntityList", "[NDK][ENTITYLIST]")
|
|||
{
|
||||
GIVEN("A world & a set of entities")
|
||||
{
|
||||
Ndk::World world;
|
||||
Ndk::World world(false);
|
||||
|
||||
const Ndk::EntityHandle& entity = world.CreateEntity();
|
||||
Ndk::EntityList entityList;
|
||||
entityList.Insert(entity);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]")
|
|||
{
|
||||
GIVEN("A world & an entity")
|
||||
{
|
||||
Ndk::World world;
|
||||
Ndk::World world(false);
|
||||
Ndk::EntityHandle entity = world.CreateEntity();
|
||||
|
||||
WHEN("We set the ownership of the entity to our owner")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
|
|||
Ndk::NodeComponent& nodeComponent = movingEntity->GetComponent<Ndk::NodeComponent>();
|
||||
Ndk::PhysicsComponent2D& physicsComponent2D = movingEntity->AddComponent<Ndk::PhysicsComponent2D>();
|
||||
|
||||
world.GetSystem<Ndk::PhysicsSystem2D>().SetFixedUpdateRate(30.f);
|
||||
|
||||
WHEN("We update the world")
|
||||
{
|
||||
world.Update(1.f);
|
||||
|
|
@ -77,6 +79,8 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
|
|||
Ndk::NodeComponent& nodeComponent = movingEntity->GetComponent<Ndk::NodeComponent>();
|
||||
Ndk::PhysicsComponent2D& physicsComponent2D = movingEntity->AddComponent<Ndk::PhysicsComponent2D>();
|
||||
|
||||
world.GetSystem<Ndk::PhysicsSystem2D>().SetFixedUpdateRate(30.f);
|
||||
|
||||
WHEN("We make rotate our entity")
|
||||
{
|
||||
float angularSpeed = Nz::FromDegrees(45.f);
|
||||
|
|
@ -119,6 +123,8 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
|
|||
Ndk::NodeComponent& nodeComponent = movingEntity->GetComponent<Ndk::NodeComponent>();
|
||||
Ndk::PhysicsComponent2D& physicsComponent2D = movingEntity->AddComponent<Ndk::PhysicsComponent2D>();
|
||||
|
||||
world.GetSystem<Ndk::PhysicsSystem2D>().SetFixedUpdateRate(30.f);
|
||||
|
||||
WHEN("We make rotate our entity")
|
||||
{
|
||||
float angularSpeed = Nz::FromDegrees(45.f);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ SCENARIO("VelocitySystem", "[NDK][VELOCITYSYSTEM]")
|
|||
Ndk::VelocityComponent& velocityComponent = entity->AddComponent<Ndk::VelocityComponent>();
|
||||
Ndk::NodeComponent& nodeComponent = entity->AddComponent<Ndk::NodeComponent>();
|
||||
|
||||
world.GetSystem<Ndk::VelocitySystem>().SetFixedUpdateRate(30.f);
|
||||
|
||||
WHEN("We give a speed to our entity")
|
||||
{
|
||||
Nz::Vector3f velocity = Nz::Vector3f::Unit() * 2.f;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ SCENARIO("World", "[NDK][WORLD]")
|
|||
{
|
||||
GIVEN("A brave new world and the update system")
|
||||
{
|
||||
Ndk::World world;
|
||||
Ndk::World world(false);
|
||||
Ndk::BaseSystem& system = world.AddSystem<UpdateSystem>();
|
||||
|
||||
WHEN("We had a new entity with an updatable component and a system")
|
||||
|
|
|
|||
Loading…
Reference in New Issue