engine/particle/src/test/test_particle.cpp
/**
 * Verify that multiple emitters have the same time each time they are replayed, even when starting from a large play time.
 */
Verify that multiple emitters have the same time each time they are replayed, even when starting from a large play time.
Verify that multiple emitters have the same time each time they are replayed even when starting from a large play time .
TEST_F(ParticleTest, ReplayLoopLargePlayTime)
{
    float dt = 1.0f / 60.0f;
    const uint32_t emitter_count = 3;
    float times[emitter_count];
    ASSERT_TRUE(LoadPrototype("reload_loop_multi.particlefxc", &m_Prototype));
    dmParticle::HInstance instance = dmParticle::CreateInstance(m_Context, m_Prototype, 0x0);
    dmParticle::StartInstance(m_Context, instance);
    const float time = 1.1f;
    float timer = 0.0f;
    while (timer < time)
    {
        dmParticle::Update(m_Context, dt, 0x0);
        timer += dt;
    }
    dmParticle::ReloadInstance(m_Context, instance, true);
    for (uint32_t i = 0; i < emitter_count; ++i)
    {
        dmParticle::Emitter* e = GetEmitter(m_Context, instance, i);
        times[i] = e->m_Timer;
    }
    for (uint32_t i = 0; i < 3; ++i)
    {
        dmParticle::ReloadInstance(m_Context, instance, true);
        for (uint32_t emitter_i = 0; emitter_i < emitter_count; ++emitter_i)
        {
            dmParticle::Emitter* e = GetEmitter(m_Context, instance, i);
            ASSERT_EQ(times[i], e->m_Timer);
        }
    }
    dmParticle::DestroyInstance(m_Context, instance);
}
TEST_F ( ParticleTest , ReplayLoopLargePlayTime ) { float dt = 1.0f / 60.0f ; const uint32_t emitter_count = 3 ; float times [ emitter_count ] ; ASSERT_TRUE ( LoadPrototype ( " " , & m_Prototype ) ) ; dmParticle :: HInstance instance = dmParticle :: CreateInstance ( m_Context , m_Prototype , 0x0 ) ; dmParticle :: StartInstance ( m_Context , instance ) ; const float time = 1.1f ; float timer = 0.0f ; while ( timer < time ) { dmParticle :: Update ( m_Context , dt , 0x0 ) ; timer += dt ; } dmParticle :: ReloadInstance ( m_Context , instance , true ) ; for ( uint32_t i = 0 ; i < emitter_count ; ++ i ) { dmParticle :: Emitter * e = GetEmitter ( m_Context , instance , i ) ; times [ i ] = e -> m_Timer ; } for ( uint32_t i = 0 ; i < 3 ; ++ i ) { dmParticle :: ReloadInstance ( m_Context , instance , true ) ; for ( uint32_t emitter_i = 0 ; emitter_i < emitter_count ; ++ emitter_i ) { dmParticle :: Emitter * e = GetEmitter ( m_Context , instance , i ) ; ASSERT_EQ ( times [ i ] , e -> m_Timer ) ; } } dmParticle :: DestroyInstance ( m_Context , instance ) ; }
Verify that multiple emitters have the same time each time they are replayed, even when starting from a large play time.
Verify that multiple emitters have the same time each time they are replayed even when starting from a large play time .