engine/particle/src/test/test_particle.cpp
/**
* Verify emitter state change callback is only called when there a state change has occured
*/
Verify emitter state change callback is only called when there a state change has occured
Verify emitter state change callback is only called when there a state change has occured
TEST_F(ParticleTest, CallbackCalledSingleTimePerStateChange)
{
    float dt = 0.1f;
    EmitterStateChangedCallbackTestData* data = new (malloc(sizeof(EmitterStateChangedCallbackTestData))) EmitterStateChangedCallbackTestData();
    m_CallbackData.m_StateChangedCallback = EmitterStateChangedCallback;
    m_CallbackData.m_UserData = (void*)data;
    ASSERT_TRUE(LoadPrototype("once.particlefxc", &m_Prototype));
    dmParticle::HInstance instance = dmParticle::CreateInstance(m_Context, m_Prototype, &m_CallbackData);
    dmParticle::StartInstance(m_Context, instance); 
    dmParticle::Update(m_Context, dt, 0x0); 
    dmParticle::Update(m_Context, dt, 0x0); 
    ASSERT_TRUE(data->m_CallbackWasCalled);
    ASSERT_TRUE(data->m_NumStateChanges == 2);
    dmParticle::DestroyInstance(m_Context, instance);
}
TEST_F ( ParticleTest , CallbackCalledSingleTimePerStateChange ) { float dt = 0.1f ; EmitterStateChangedCallbackTestData * data = new ( malloc ( sizeof ( EmitterStateChangedCallbackTestData ) ) ) EmitterStateChangedCallbackTestData ( ) ; m_CallbackData . m_StateChangedCallback = EmitterStateChangedCallback ; m_CallbackData . m_UserData = ( void * ) data ; ASSERT_TRUE ( LoadPrototype ( " " , & m_Prototype ) ) ; dmParticle :: HInstance instance = dmParticle :: CreateInstance ( m_Context , m_Prototype , & m_CallbackData ) ; dmParticle :: StartInstance ( m_Context , instance ) ; dmParticle :: Update ( m_Context , dt , 0x0 ) ; dmParticle :: Update ( m_Context , dt , 0x0 ) ; ASSERT_TRUE ( data -> m_CallbackWasCalled ) ; ASSERT_TRUE ( data -> m_NumStateChanges == 2 ) ; dmParticle :: DestroyInstance ( m_Context , instance ) ; }
Verify emitter state change callback is only called when there a state change has occured
Verify emitter state change callback is only called when there a state change has occured
// Prespawn // Spawning // Still in Spawning, should not trigger callback