Skip to content

Commit

Permalink
only use advanced camera nonsense if manually verified
Browse files Browse the repository at this point in the history
  • Loading branch information
sylae committed Jun 18, 2023
1 parent e51e0e3 commit 0eb17fa
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
19 changes: 18 additions & 1 deletion CameraDetection.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/

namespace Camera {

bool CameraNodSafe = false;

void UpdateActiveGameCam()
{
g_activeCam = ActiveCam::None;
Expand Down Expand Up @@ -176,11 +179,25 @@ namespace Camera {
mat4 g_rotation = mat4::Identity();
vec3 g_direction = vec3();
ActiveCam g_activeCam = ActiveCam::None;

void CheckIfSafe() {
string curVer = GetApp().SystemPlatform.ExeVersion;
auto req = Net::HttpGet("https://openplanet.dev/plugin/did/config/camera-nod-safe");
while (!req.Finished()) yield();
if (req.ResponseCode() == 200) {
auto js = req.Json();
if (js.GetType() == Json::Type::Object && js.HasKey(curVer)) {
CameraNodSafe = js[curVer];
}
}
}
}

void RenderEarly()
{
Camera::UpdateActiveGameCam();
if (useCameraDetection == CameraDetectionMode::On || (Camera::CameraNodSafe && useCameraDetection == CameraDetectionMode::Auto)) {
Camera::UpdateActiveGameCam();
}
if (Camera::GetCurrent() is null) return;
iso4 camLoc = Camera::GetCurrent().Location;
Camera::g_direction = vec3(camLoc.xz, camLoc.yz, camLoc.zz);
Expand Down
23 changes: 22 additions & 1 deletion DID.as
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,22 @@ namespace DID {

DID::ResetDrawState(vis);

switch (Camera::GetCurrentGameCamera()) {
Camera::ActiveCam curCam;
if (useCameraDetection == CameraDetectionMode::On || (Camera::CameraNodSafe && useCameraDetection == CameraDetectionMode::Auto)) {
curCam = Camera::GetCurrentGameCamera();
} else {
vec3 cam1 = DID::projectHatSpace(vec3(0,0,-2));
vec3 cam3 = DID::projectHatSpace(vec3(0,0,-1));
if (Camera::IsBehind(cam3)) {
curCam = Camera::ActiveCam::Cam3Alt;
} else if (Camera::IsBehind(cam1)) {
curCam = Camera::ActiveCam::Cam3;
} else {
curCam = Camera::ActiveCam::Cam1;
}
}

switch (curCam) {
case Camera::ActiveCam::Cam3:
CSP.diegeticCustomOffset = diegeticCustomOffsetCam3;
CSP.diegeticHorizontalDistance = diegeticHorizontalDistanceCam3;
Expand Down Expand Up @@ -185,6 +200,12 @@ namespace DID {
}

SetLaneProvidersFromSettings();

startnew(initYield);
}

void initYield() {
Camera::CheckIfSafe();
}

// Currently, this takes about 0.3ms for me which is approx 1/3 of total execution time with a basic DID layout.
Expand Down
20 changes: 20 additions & 0 deletions Settings.as
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,24 @@ void RenderSettingsHelp()
UI::Markdown(Icons::Github + " [https://github.com/MisfitMaid/DiegeticInfoDisplay](https://github.com/MisfitMaid/DiegeticInfoDisplay)");
UI::Markdown(Icons::Discord + " [https://discord.gg/BdKpuFcYzG](https://discord.gg/BdKpuFcYzG)");
UI::Markdown(Icons::Twitch + " [https://twitch.tv/MisfitMaid](https://twitch.tv/MisfitMaid)");

UI::Separator();

switch (useCameraDetection) {
case CameraDetectionMode::Auto:
UI::TextWrapped("Advanced camera detection support: " + Camera::CameraNodSafe);
break;
case CameraDetectionMode::On:
UI::TextWrapped("Forced on, current reported status: " + Camera::CameraNodSafe);
break;
case CameraDetectionMode::Off:
UI::TextWrapped("Forced off, current reported status: " + Camera::CameraNodSafe);
break;
}

UI::TextWrapped("Game version: " + GetApp().SystemPlatform.ExeVersion);
UI::SameLine();
if (UI::Button(Icons::Clipboard)) {
IO::SetClipboard(GetApp().SystemPlatform.ExeVersion);
}
}
10 changes: 10 additions & 0 deletions Settings_Positioning.as
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// CameraDetection.as stuff
enum CameraDetectionMode {
On,
Auto,
Off
}

[Setting category="Advanced" name="Use advanced cam3 detection" description="Advanced detection requires some spicy code due to engine limitations. AUTO will only use this code if it's been manually verified as working. Without advanced detection, a less-accurate fallback will be used."]
CameraDetectionMode useCameraDetection = CameraDetectionMode::Auto;

// NORMAL

[Setting category="Advanced" min=0 max=5000 drag name="Horizontal Distance" description="How far apart the left and right columns are"]
Expand Down
2 changes: 1 addition & 1 deletion info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "Diegetic Information Display"
author = "MisfitMaid"
category = "Overlay"
version = "0.5"
version = "0.5.1"
siteid = 311

[script]
Expand Down

0 comments on commit 0eb17fa

Please sign in to comment.