Skip to content

Commit

Permalink
Incorporated SMH fix by ovni from steam workshop that fixes the issue… (
Browse files Browse the repository at this point in the history
#28)

Incorporated SMH fix by ovni from steam workshop that fixes the issue with duplicating frames. Added setting to disable tweening. Fixed smh_makescreenshot to start rendering from frame 0
  • Loading branch information
penolakushari authored May 15, 2021
1 parent 39e6164 commit 9b14479
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 25 deletions.
2 changes: 2 additions & 0 deletions lua/smh/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ local function Setup()
menuStreams.Output.Save:subscribe(function() SMH.Data.ShowSave = true end);

menuStreams.Settings.Output.FreezeAll:subscribe(function(value) SMH.Data.FreezeAll = value end);
menuStreams.Settings.Output.TweenDisable:subscribe(function(value) SMH.Data.TweenDisable = value end);
menuStreams.Settings.Output.LocalizePhysBones:subscribe(function(value) SMH.Data.LocalizePhysBones = value end);
menuStreams.Settings.Output.IgnorePhysBones:subscribe(function(value) SMH.Data.IgnorePhysBones = value end);
menuStreams.Settings.Output.GhostPrevFrame:subscribe(function(value) SMH.Data.GhostPrevFrame = value end);
Expand All @@ -126,6 +127,7 @@ local function Setup()
end);

menuStreams.Settings.Input.FreezeAll(SMH.DefaultData.FreezeAll);
menuStreams.Settings.Input.TweenDisable(SMH.DefaultData.TweenDisable);
menuStreams.Settings.Input.LocalizePhysBones(SMH.DefaultData.LocalizePhysBones);
menuStreams.Settings.Input.IgnorePhysBones(SMH.DefaultData.IgnorePhysBones);
menuStreams.Settings.Input.GhostPrevFrame(SMH.DefaultData.GhostPrevFrame);
Expand Down
5 changes: 4 additions & 1 deletion lua/smh/client/derma/frame_pointer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ local function Create(parent, pointyBottom)
local height = panel.VerticalPosition;

local frameAreaWidth = endX - startX;
if position == nil then
position = -1;
end
local positionWithOffset = position - scrollOffset;
local x = startX + (positionWithOffset / zoom) * frameAreaWidth;

Expand Down Expand Up @@ -160,4 +163,4 @@ local function Create(parent, pointyBottom)
};
end

return Create;
return Create;
15 changes: 11 additions & 4 deletions lua/smh/client/derma/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ local function Create(parent)
panel.GhostAllEntities = vgui.Create("DCheckBoxLabel", panel);
panel.GhostAllEntities:SetText("Ghost all entities");
panel.GhostAllEntities:SizeToContents();

panel.TweenDisable = vgui.Create("DCheckBoxLabel", panel);
panel.TweenDisable:SetText("Disable tweening");
panel.TweenDisable:SizeToContents();

panel.GhostTransparency = vgui.Create("Slider", panel);
panel.GhostTransparency:SetMinMax(0, 1);
Expand All @@ -42,7 +46,7 @@ local function Create(parent)
panel.HelpButton = vgui.Create("DButton", panel);
panel.HelpButton:SetText("Help");

panel:SetSize(160, 225);
panel:SetSize(160, 245);

local basePerformLayout = panel.PerformLayout;
panel.PerformLayout = function()
Expand All @@ -59,15 +63,17 @@ local function Create(parent)
panel.GhostNextFrame:SetPos(5, 105);
panel.GhostAllEntities:SetPos(5, 125);

panel.TweenDisable:SetPos(5, 145);

local gt = panel.GhostTransparency;
local label = panel.GhostTransparencyLabel;
label:SizeToContents();
local LW, LH = label:GetSize();
gt:SetPos(5, 145 + LH - 5);
gt:SetPos(5, 165 + LH - 5);
gt:SetSize(panel:GetWide() - 5 - 5, 25);
label:SetPos(10, 145);
label:SetPos(10, 165);

panel.HelpButton:SetPos(5, 190);
panel.HelpButton:SetPos(5, 210);
panel.HelpButton:SetSize(150, 20);

end
Expand All @@ -81,6 +87,7 @@ local function Create(parent)
input.GhostPrevFrame, output.GhostPrevFrame = RxUtils.bindDPanel(panel.GhostPrevFrame, "SetValue", "OnChange");
input.GhostNextFrame, output.GhostNextFrame = RxUtils.bindDPanel(panel.GhostNextFrame, "SetValue", "OnChange");
input.GhostAllEntities, output.GhostAllEntities = RxUtils.bindDPanel(panel.GhostAllEntities, "SetValue", "OnChange");
input.TweenDisable, output.TweenDisable = RxUtils.bindDPanel(panel.TweenDisable, "SetValue", "OnChange");
input.GhostTransparency, output.GhostTransparency = RxUtils.bindDPanel(panel.GhostTransparency, "SetValue", "OnValueChanged");
input.ShowHelp, output.ShowHelp = RxUtils.bindDPanel(panel.HelpButton, nil, "DoClick");

Expand Down
8 changes: 4 additions & 4 deletions lua/smh/client/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ SMH.RenderTimerName = "SMHRender";
local function RenderTick()

local newPos = SMH.Data.Position + 1;
if newPos > SMH.Data.PlaybackLength then
if newPos >= SMH.Data.PlaybackLength then
SMH.StopRender();
return;
end

SMH.Data.Position = newPos;

local command = "jpeg";
if SMH.UseScreenshot then
command = "screenshot";
Expand All @@ -22,6 +20,8 @@ local function RenderTick()
RunConsoleCommand(command);
end);

SMH.Data.Position = newPos; --put line down here

end

function SMH.StartRender(useScreenshot)
Expand All @@ -30,7 +30,7 @@ function SMH.StartRender(useScreenshot)
useScreenshot = false;
end

SMH.Data.Position = 0;
SMH.Data.Position = -1;

LocalPlayer():EmitSound("buttons/blip1.wav");

Expand Down
4 changes: 3 additions & 1 deletion lua/smh/modifiers/bodygroup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ function MOD:Load(player, entity, data)
end

function MOD:LoadBetween(player, entity, data1, data2, percentage)
self:Load(player, entity, data1);

self:Load(player, entity, data1);

end
1 change: 0 additions & 1 deletion lua/smh/modifiers/bones.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ function MOD:LoadBetween(player, entity, data1, data2, percentage)
entity:ManipulateBoneScale(b, Scale);

end

end
2 changes: 1 addition & 1 deletion lua/smh/modifiers/flex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function MOD:Load(player, entity, data)
end

function MOD:LoadBetween(player, entity, data1, data2, percentage)

local count = entity:GetFlexNum();
if count <= 0 then return; end --Shouldn't happen, but meh

Expand Down
2 changes: 2 additions & 0 deletions lua/smh/modifiers/modelscale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function MOD:Load(player, entity, data)
end

function MOD:LoadBetween(player, entity, data1, data2, percentage)

local lerpedModelScale = SMH.LerpLinear(data1.ModelScale, data2.ModelScale, percentage);
entity:SetModelScale(lerpedModelScale);

end
10 changes: 5 additions & 5 deletions lua/smh/modifiers/physbones.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,30 @@ function MOD:LoadGhost(player, entity, ghost, data)
end

function MOD:LoadBetween(player, entity, data1, data2, percentage)

if player.SMHData.IgnorePhysBones then
return;
end

local count = entity:GetPhysicsObjectCount();

for i = 0, count - 1 do

local pb = entity:GetPhysicsObjectNum(i);

local d1 = data1[i];
local d2 = data2[i];

local Pos = SMH.LerpLinearVector(d1.Pos, d2.Pos, percentage);
local Ang = SMH.LerpLinearAngle(d1.Ang, d2.Ang, percentage);



pb:EnableMotion(false);

pb:SetPos(Pos);
pb:SetAngles(Ang);

pb:Wake();

end

end
2 changes: 2 additions & 0 deletions lua/smh/modifiers/poseparameter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function MOD:Load(player, entity, data)
end

function MOD:LoadBetween(player, entity, data1, data2, percentage)

for name, value1 in pairs(data1) do

local value2 = data2[name];
Expand All @@ -34,4 +35,5 @@ function MOD:LoadBetween(player, entity, data1, data2, percentage)
end

end

end
4 changes: 2 additions & 2 deletions lua/smh/modifiers/position.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function MOD:Load(player, entity, data)
end

function MOD:LoadBetween(player, entity, data1, data2, percentage)

local Pos = SMH.LerpLinearVector(data1.Pos, data2.Pos, percentage);
local Ang = SMH.LerpLinearAngle(data1.Ang, data2.Ang, percentage);

entity:SetPos(Pos);
entity:SetAngles(Ang);

end
4 changes: 3 additions & 1 deletion lua/smh/modifiers/skin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ function MOD:Load(player, entity, data)
end

function MOD:LoadBetween(player, entity, data1, data2, percentage)
self:Load(player, entity, data1);

self:Load(player, entity, data1);

end
14 changes: 10 additions & 4 deletions lua/smh/server/positioning.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ function SMH.GetPositionFrames(frames, framepos, ignoreCurrentFrame)

for _, frame in pairs(frames) do

if frame.Position == nil then
frame.Position = -1;
end

local diff = frame.Position - framepos;
local aDiff = math.abs(diff);
if diff < 0 and aDiff < closestPrevFramePos then
Expand Down Expand Up @@ -76,10 +80,12 @@ function SMH.PositionEntity(player, entity, framepos)
return;
end

for name, mod in pairs(SMH.Modifiers) do
local data1, data2 = frame1.EntityData[name], frame2.EntityData[name];
if data1 ~= nil and data2 ~= nil then
mod:LoadBetween(player, entity, data1, data2, perc);
if not player.SMHData.TweenDisable then
for name, mod in pairs(SMH.Modifiers) do
local data1, data2 = frame1.EntityData[name], frame2.EntityData[name];
if data1 ~= nil and data2 ~= nil then
mod:LoadBetween(player, entity, data1, data2, perc);
end
end
end

Expand Down
4 changes: 3 additions & 1 deletion lua/smh/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ SMH.DefaultData = {
FreezeAll = false,
LocalizePhysBones = false,
IgnorePhysBones = false,

TweenDisable = false,

ShowHelp = false,
ShowSave = false,
Expand All @@ -54,4 +56,4 @@ SMH.DefaultData = {
Rendering = false,
UseScreenshot = false,

};
};

0 comments on commit 9b14479

Please sign in to comment.