Skip to content

Commit

Permalink
fix rewind bug?
Browse files Browse the repository at this point in the history
  • Loading branch information
Martinii89 committed Aug 9, 2019
1 parent b81804b commit a4a9d4e
Show file tree
Hide file tree
Showing 12 changed files with 4,352 additions and 1,007 deletions.
8 changes: 5 additions & 3 deletions DollyCamPlugin2/DollyCamPlugin2.vcxproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
Expand Down Expand Up @@ -108,8 +108,8 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(BAKKESMOD)\bakkesmodsdk\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WINDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>_WINDLL;NOMINMAX;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand Down Expand Up @@ -155,6 +155,7 @@
<ClInclude Include="interpstrategies\interpstrategy.h" />
<ClInclude Include="interpstrategies\linearinterp.h" />
<ClInclude Include="interpstrategies\supportedstrategies.h" />
<ClInclude Include="interpstrategies\tinyspline\parson.h" />
<ClInclude Include="interpstrategies\tinyspline\tinyspline.h" />
<ClInclude Include="interpstrategies\tinyspline\tinysplinecpp.h" />
<ClInclude Include="models.h" />
Expand All @@ -180,6 +181,7 @@
<ClCompile Include="interpstrategies\interpstrategy.cpp" />
<ClCompile Include="interpstrategies\linearinterp.cpp" />
<ClCompile Include="interpstrategies\splineinterp.cpp" />
<ClCompile Include="interpstrategies\tinyspline\parson.c" />
<ClCompile Include="interpstrategies\tinyspline\tinyspline.c" />
<ClCompile Include="interpstrategies\tinyspline\tinysplinecpp.cpp" />
<ClCompile Include="models.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions DollyCamPlugin2/DollyCamPlugin2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
<ClInclude Include="imgui\imguivariouscontrols.h">
<Filter>imgui\headers</Filter>
</ClInclude>
<ClInclude Include="interpstrategies\tinyspline\parson.h">
<Filter>InterpolationStrategies\Spline\TinySpline</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dollycamplugin.cpp">
Expand Down Expand Up @@ -190,6 +193,9 @@
<ClCompile Include="imgui\imguivariouscontrols.cpp">
<Filter>imgui</Filter>
</ClCompile>
<ClCompile Include="interpstrategies\tinyspline\parson.c">
<Filter>InterpolationStrategies\Spline\TinySpline</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="interpstrategies\tinyspline\tinyspline.i">
Expand Down
11 changes: 1 addition & 10 deletions DollyCamPlugin2/dollycam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ void DollyCam::Apply()
}
if (currentFrame < currentPath->begin()->first || currentFrame >(--currentPath->end())->first)
return;
//cvarManager->log("Frame: " + to_string(currentFrame) + ". Replay time: " + to_string(sw.GetReplayTimeElapsed()));
if (currentFrame == currentPath->begin()->first)
{
if (isFirst) {
Expand All @@ -160,15 +159,7 @@ void DollyCam::Apply()
else {
isFirst = true;
}
/* auto replayServerWrapper = gameWrapper->GetGameEventAsReplay();
auto replay = gameWrapper->GetGameEventAsReplay().GetReplay();
float t = sw.GetSecondsElapsed() - diff + currentPath->begin()->second.timeStamp;
float timeFromFrames = replayServerWrapper.GetCurrentReplayFrame() / replay.GetRecordFPS();
float t2 = replayServerWrapper.GetReplayTimeElapsed();
float t3 = sw.GetReplayDirector().GetReplayTimeSeconds();
cvarManager->log("gameTime:" + to_string(t) + ", frameTime: " + to_string(timeFromFrames) + ", GetReplayTimeSeconds:" + to_string(t3) + ", replayServerTime:" + to_string(t2));
*/
//cvarManager->log("gameTime:" + to_string(t) + ", diff: " + to_string(diff) + ", sw:" + to_string(sw.GetSecondsElapsed()) + ", begin:" + to_string(currentPath->begin()->second.timeStamp) + ", frameTime: " + to_string(timeFromFrames));

NewPOV pov = locationInterpStrategy->GetPOV(sw.GetSecondsElapsed() - diff + currentPath->begin()->second.timeStamp, currentFrame);
if (!usesSameInterp)
{
Expand Down
6 changes: 3 additions & 3 deletions DollyCamPlugin2/dollycamplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ void DollyCamPlugin::onLoad()
gameWrapper->HookEvent("Function TAGame.GFxHUD_Replay_TA.Destroyed", bind(&DollyCamPlugin::onReplayClose, this, _1));


cvarManager->registerCvar("dolly_interpmode", "0", "Used interp mode", true, true, 0, true, 2000).addOnValueChanged(bind(&DollyCamPlugin::OnInterpModeChanged, this, _1, _2));
cvarManager->registerCvar("dolly_interpmode", "5", "Used interp mode", true, true, 0, true, 2000).addOnValueChanged(bind(&DollyCamPlugin::OnInterpModeChanged, this, _1, _2));

cvarManager->registerCvar("dolly_interpmode_location", "0", "Used interp mode for location", true, true, 0, true, 2000)
cvarManager->registerCvar("dolly_interpmode_location", "5", "Used interp mode for location", true, true, 0, true, 2000)
.addOnValueChanged(bind(&DollyCamPlugin::OnInterpModeChanged, this, _1, _2));
cvarManager->registerCvar("dolly_interpmode_rotation", "0", "Used interp mode for rotation", true, true, 0, true, 2000)
cvarManager->registerCvar("dolly_interpmode_rotation", "5", "Used interp mode for rotation", true, true, 0, true, 2000)
.addOnValueChanged(bind(&DollyCamPlugin::OnInterpModeChanged, this, _1, _2));


Expand Down
9 changes: 5 additions & 4 deletions DollyCamPlugin2/interpstrategies/splineinterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ NewPOV SplineInterpStrategy::GetPOV(float gameTime, int latestFrame)
InitRotations(n);
InitFOVs(n);

auto posRes = SolveForT(camPositions, gameTime, 0.0001);
auto rotRes = SolveForT(camRotations, gameTime, 0.0001);
auto fovRes = SolveForT(camFOVs, gameTime, 0.0001);
float epsilon = 0.004; // Acceptable error is 1 / 240 seconds.
auto posRes = camPositions.bisect(gameTime, epsilon).result();
auto rotRes = camRotations.bisect(gameTime, epsilon).result();
auto fovRes = camFOVs.bisect(gameTime, epsilon).result();


Vector v;
v.X = float(posRes[1]);
Expand All @@ -71,7 +73,6 @@ NewPOV SplineInterpStrategy::GetPOV(float gameTime, int latestFrame)
float fov = float(fovRes[1]);

CustomRotator rot = CustomRotator(float(rotRes[1]), float(rotRes[2]), float(rotRes[3]));

return {v, rot, fov};
}

Expand Down
Loading

0 comments on commit a4a9d4e

Please sign in to comment.