Skip to content

Commit 37a8f65

Browse files
Fix bugged preset state on soft cut
This explains that redi jedi's presets (or other, for example, gedit imp fiShbRaiN + geiss - witchcraft...) will not parse the state correctly when doing a soft cut. This commit fixes it.
1 parent 7f434fc commit 37a8f65

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

vis_milk2/plugin.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10052,7 +10052,10 @@ void CPlugin::LoadPreset(const wchar_t *szPresetFilename, float fBlendTime)
1005210052
ApplyFlags ^= (m_bWarpShaderLock ? STATE_WARP : 0);
1005310053
ApplyFlags ^= (m_bCompShaderLock ? STATE_COMP : 0);
1005410054

10055-
m_pNewState->Import(szPresetFilename, GetTime(), m_pOldState, ApplyFlags);
10055+
// Import locked/omitted sections from the preset currently on screen.
10056+
// m_pOldState is the spare state here and may belong to an earlier
10057+
// preset, which makes soft cuts inherit stale code and parameters.
10058+
m_pNewState->Import(szPresetFilename, GetTime(), m_pState, ApplyFlags);
1005610059

1005710060
m_nLoadingPreset = 1; // this will cause LoadPresetTick() to get called over the next few frames...
1005810061

vis_milk2/state.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,10 @@ void CState::RecompileExpressions(int flags, int bReInit)
17791779
{
17801780
// now execute the code, save the values of q1..q32, and clean up the code!
17811781

1782-
g_plugin.LoadPerFrameEvallibVars(g_plugin.m_pState);
1782+
// This state may be compiled asynchronously as m_pNewState.
1783+
// Populate the variables for the state being initialized,
1784+
// rather than whichever state is currently on screen.
1785+
g_plugin.LoadPerFrameEvallibVars(this);
17831786

17841787
NSEEL_code_execute(pf_codehandle_init);
17851788

@@ -1845,7 +1848,7 @@ void CState::RecompileExpressions(int flags, int bReInit)
18451848
{
18461849
// now execute the code, save the values of t1..t8, and clean up the code!
18471850

1848-
g_plugin.LoadCustomWavePerFrameEvallibVars(g_plugin.m_pState, i);
1851+
g_plugin.LoadCustomWavePerFrameEvallibVars(this, i);
18491852
// note: q values at this point will actually be same as
18501853
// q_values_after_init_code[], since no per-frame code
18511854
// has actually been executed yet!
@@ -1916,7 +1919,7 @@ void CState::RecompileExpressions(int flags, int bReInit)
19161919
{
19171920
// now execute the code, save the values of q1..q8, and clean up the code!
19181921

1919-
g_plugin.LoadCustomShapePerFrameEvallibVars(g_plugin.m_pState, i, 0);
1922+
g_plugin.LoadCustomShapePerFrameEvallibVars(this, i, 0);
19201923
// note: q values at this point will actually be same as
19211924
// q_values_after_init_code[], since no per-frame code
19221925
// has actually been executed yet!

0 commit comments

Comments
 (0)