experimental: allow implementing effects in Lua.

The biggest risk here is performance; we rarely call Lua per-frame.  However,
there are lots of places where we can call Lua while rendering (any time we
call a command), and there's little difference between calling Lua once
every ten frames or once every frame; either way you're counting against the
per-frame time quota to hit vsync.  So, this probably isn't much of a stretch.

Usage is simple:

  OnCommand=luaeffect,Foo
  FooCommand=addx,math.random()*10

Actor commands run during the effect will only apply for that frame.  Don't
call tweening commands ("linear") or anything else that doesn't make sense
in this context; you're modifying m_TempState instead of the tweening queue.
This is hoped to replace some of the more esoteric stuff in the effect code.

For this to be of much use, Lua access to m_fSecsIntoEffect and probably
other stuff is needed.
This commit is contained in:
Glenn Maynard
2005-04-28 10:18:36 +00:00
parent 0a71994d01
commit 8b76b5eafd
2 changed files with 29 additions and 2 deletions
+21
View File
@@ -15,6 +15,7 @@
#include "ThemeManager.h"
#include "LuaReference.h"
#include "MessageManager.h"
#include "LightsManager.h" // for NUM_CABINET_LIGHTS
// lua start
@@ -171,6 +172,19 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties
{
m_pTempState = &m_current;
}
else if( m_Effect == effect_lua )
{
/* Allow a Lua function to set the frame's draw state. This may be expensive
* and has not been well-benchmarked yet; use wisely. This allows arbitrary
* effects, instead of the mess of parameters below. (In fact, all this does
* is run a command, but to avoid calling RunCommand() all the time, and due
* to the fact that this is the only place where the TempState is meaningful,
* we treat this as an effect.) */
m_pTempState = &m_tempState;
m_tempState = m_current;
PlayCommand( m_sEffectCommand );
}
else
{
m_pTempState = &m_tempState;
@@ -348,6 +362,7 @@ void Actor::SetTextureRenderStates()
void Actor::EndDraw()
{
DISPLAY->PopMatrix();
m_pTempState = NULL;
}
void Actor::UpdateTweening( float fDeltaTime )
@@ -621,6 +636,12 @@ void Actor::StretchTo( const RectF &r )
// effect "macros"
void Actor::SetEffectLua( const CString &sCommand )
{
m_Effect = effect_lua;
m_sEffectCommand = sCommand;
}
void Actor::SetEffectDiffuseBlink( float fEffectPeriodSeconds, RageColor c1, RageColor c2 )
{
if( m_Effect != diffuse_blink )