Skip to content

Commit

Permalink
Beta 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilsnd committed Oct 13, 2020
1 parent 1e5e2d7 commit cd91c92
Show file tree
Hide file tree
Showing 20 changed files with 677 additions and 517 deletions.
15 changes: 15 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## Beta 1.1
* Bumped module and MCM version number to 10
* Added a compatibility patch for Immersive First Person View.
* Tweaked Improved Camera compatibility when on horseback.
* Remove dynamic casting for camera state method invocations, not really required.
* Config now reads fNearDistance, in case the player changes it - changing it isn't really advised though if you use Immersive First Person View (We check the expected near value against what it actually is, combined with a distance check, to try and figure out if we are in IFPV's hacked first person mode).
* Config now reads fMinCurrentZoom rather than use the hard coded value.
* Adjusted config defaults to no longer enable compat options - these should be opt-in.
* Using new raycasting method for the crosshair, dropped the jank custom intersection test.
* Fix arrow and magic projectiles spawning behind the player when using the archery patch with SSE Engine Fixes.
* Changed some of the interpolation math to FP64 to gain a bit more precision (might not end up being necessary).
* Switched to SKSE's ITimer over using naked qpc.
* Updated config defaults and added a new MCM option to restore default values.
* As some users have reported local space smoothing causing jitter, the local space smoothing rate now defaults to 1, making it opt-in. Jitter is mostly caused by a sub-60 frame rate, currently looking into options for correcting jitter in a later update.

## Beta 1
* Bumped module and MCM version number to 9
* Promoted to beta.
Expand Down
Binary file modified MCM/SmoothCamMCM.pex
Binary file not shown.
42 changes: 40 additions & 2 deletions MCM/mcm.psc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Function SmoothCam_SetIntConfig(string member, int value) global native
Function SmoothCam_SetStringConfig(string member, string value) global native
Function SmoothCam_SetBoolConfig(string member, bool value) global native
Function SmoothCam_SetFloatConfig(string member, float value) global native
Function SmoothCam_ResetConfig() global native

int Function SmoothCam_GetIntConfig(string member) global native
string Function SmoothCam_GetStringConfig(string member) global native
Expand Down Expand Up @@ -90,6 +91,27 @@ endFunction
}
}

#constexpr_struct ResetSetting {
real_int ref = 0
string displayName = ""
string desc = ""

MACRO implControl = {
this->ref = AddToggleOption(this->displayName, false)
}

MACRO implSelectHandler = {
if (ShowMessage("Are you sure? This will reset all settings to their default values."))
SmoothCam_ResetConfig()
ShowMessage("Settings reset.")
endIf
}

MACRO implDesc = {
SetInfoText(this->desc)
}
}

#constexpr_struct ListSetting {
real_int ref = 0
string settingName = ""
Expand Down Expand Up @@ -201,7 +223,7 @@ endFunction
}

ScriptMeta scriptMetaInfo -> {
version: 9
version: 10
}

; Presets
Expand Down Expand Up @@ -276,6 +298,17 @@ ToggleSetting disableDuringDialog -> {
displayName: "Disable During Dialog"
desc: "Disables SmoothCam when the dialog menu is open."
}
ToggleSetting ifpvCompat -> {
settingName: "IFPVCompat"
displayName: "Immersive First Person View"
desc: "Enable compat fixes for Improved First Person View."
}

; Reset
ResetSetting reset -> {
displayName: "Reset All Settings"
desc: "Set all settings back to their defual values."
}

; Following
ToggleSetting interpEnabled -> {
Expand Down Expand Up @@ -1370,6 +1403,9 @@ event OnPageReset(string a_page)
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
icFirstPersonHorse, icFirstPersonDragon, icFirstPersonSitting
})

AddHeaderOption("Immersive First Person View")
ifpvCompat->!implControl
elseIf (a_page == " Following")
AddHeaderOption("Interpolation")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
Expand Down Expand Up @@ -1406,7 +1442,7 @@ event OnPageReset(string a_page)

AddHeaderOption("Misc")
IMPL_STRUCT_MACRO_INVOKE_GROUP(implControl, {
shoulderSwapKey, swapDistanceClampXAxis, zoomMul, disableDeltaTime
shoulderSwapKey, swapDistanceClampXAxis, zoomMul, disableDeltaTime, reset
})
elseIf (a_page == " Crosshair")
AddHeaderOption("3D Crosshair Settings")
Expand Down Expand Up @@ -1657,6 +1693,7 @@ endEvent
event OnOptionSelect(int a_option)
IMPL_IFCHAIN_MACRO_INVOKE(a_option, ref, implSelectHandler, {
IMPL_ALL_IMPLS_OF_STRUCT(ToggleSetting),
IMPL_ALL_IMPLS_OF_STRUCT(ResetSetting),
IMPL_ALL_IMPLS_OF_STRUCT(LoadPresetSetting)
})
endEvent
Expand Down Expand Up @@ -1693,6 +1730,7 @@ event OnOptionHighlight(int a_option)
IMPL_IFCHAIN_MACRO_INVOKE(a_option, ref, implDesc, {
IMPL_ALL_IMPLS_OF_STRUCT(SliderSetting),
IMPL_ALL_IMPLS_OF_STRUCT(ToggleSetting),
IMPL_ALL_IMPLS_OF_STRUCT(ResetSetting),
IMPL_ALL_IMPLS_OF_STRUCT(ListSetting),
IMPL_ALL_IMPLS_OF_STRUCT(SavePresetSetting),
IMPL_ALL_IMPLS_OF_STRUCT(LoadPresetSetting),
Expand Down
16 changes: 14 additions & 2 deletions SmoothCam/include/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ namespace Camera {
const auto UNIT_FORWARD = glm::vec3(1.0f, 0.0f, 0.0f);
const auto UNIT_RIGHT = glm::vec3(0.0f, 1.0f, 0.0f);
const auto UNIT_UP = glm::vec3(0.0f, 0.0f, 1.0f);
constexpr auto SKYRIM_MIN_ZOOM_FRACTION = 0.2f;

class SmoothCamera {
public:
Expand All @@ -50,6 +49,8 @@ namespace Camera {
~SmoothCamera() = default;

public:
// Runs before the internal game camera logic
void PreGameUpdate(PlayerCharacter* player, CorrectedPlayerCamera* camera);
// Selects the correct update method and positions the camera
void UpdateCamera(PlayerCharacter* player, CorrectedPlayerCamera* camera);
// Called when the player toggles the POV
Expand All @@ -72,6 +73,9 @@ namespace Camera {
const bool UpdateCameraPOVState(const PlayerCharacter* player, const CorrectedPlayerCamera* camera) noexcept;

/// Camera state updates
// Check if the camera is near the player's head (for first person mods)
bool CameraNearHead(const PlayerCharacter* player, const CorrectedPlayerCamera* camere, float cutOff = 32.0f);
bool IFPV_InFirstPersonState(const PlayerCharacter* player, const CorrectedPlayerCamera* camera);
// Returns the current camera state for use in selecting an update method
const GameState::CameraState GetCurrentCameraState(const PlayerCharacter* player, const CorrectedPlayerCamera* camera);
// Returns the current camera action state for use in the selected update method
Expand Down Expand Up @@ -109,7 +113,7 @@ namespace Camera {
// Returns the full local-space camera offset for the current player state
glm::vec3 GetCurrentCameraOffset(PlayerCharacter* player, const CorrectedPlayerCamera* camera) const noexcept;
// Returns the current smoothing scalar to use for the given distance to the player
float GetCurrentSmoothingScalar(const float distance, ScalarSelector method = ScalarSelector::Normal) const;
double GetCurrentSmoothingScalar(const float distance, ScalarSelector method = ScalarSelector::Normal) const;
// Returns the user defined distance clamping vector pair
std::tuple<glm::vec3, glm::vec3> GetDistanceClamping() const noexcept;
// Returns true if interpolation is allowed in the current state
Expand All @@ -132,6 +136,8 @@ namespace Camera {
void SetCrosshairEnabled(bool enabled) const;

/// Camera getters
// Update the internal rotation
void UpdateInternalRotation(CorrectedPlayerCamera* camera) noexcept;
// Returns the camera's yaw
float GetCameraYawRotation(const CorrectedPlayerCamera* camera) const noexcept;
// Returns the camera's pitch
Expand Down Expand Up @@ -196,11 +202,17 @@ namespace Camera {
CameraActionState lastActionState = CameraActionState::Unknown;
mmath::NiMatrix44 worldToScreen = {};

float lastNearPlane = 0.0f;
glm::vec3 gameInitialWorldPosition = { 0.0f, 0.0f, 0.0f };
glm::vec3 gameLastActualPosition = { 0.0f, 0.0f, 0.0f };
glm::vec3 lastPosition = { 0.0f, 0.0f, 0.0f };
glm::vec3 currentPosition = { 0.0f, 0.0f, 0.0f };
glm::vec3 lastLocalPosition = { 0.0f, 0.0f, 0.0f };
glm::vec3 lastWorldPosition = { 0.0f, 0.0f, 0.0f };

glm::vec2 currentRotation = { 0.0f, 0.0f };
glm::quat currentQuat = glm::identity<glm::quat>();

template<typename T>
struct TransitionGroup {
T lastPosition = {};
Expand Down
20 changes: 12 additions & 8 deletions SmoothCam/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ namespace Config {
typedef struct gameConf {
float f3PArrowTiltUpAngle = 2.5f;
float f3PBoltTiltUpAngle = 2.5f;
float fNearDistance = 15.0f;
float fMinCurrentZoom = -0.200000003;
} GameConfig;

typedef struct offsetGroup {
Expand Down Expand Up @@ -127,9 +129,10 @@ namespace Config {

// Comapt
bool disableDuringDialog = false;
bool comaptIC_FirstPersonHorse = true;
bool comaptIC_FirstPersonDragon = true;
bool compatIC_FirstPersonSitting = true;
bool comaptIC_FirstPersonHorse = false;
bool comaptIC_FirstPersonDragon = false;
bool compatIC_FirstPersonSitting = false;
bool compatIFPV = false;

// Primary interpolation
bool enableInterp = true;
Expand All @@ -142,15 +145,15 @@ namespace Config {

// Separate local space interpolation
bool separateLocalInterp = true;
ScalarMethods separateLocalScalar = ScalarMethods::CIRC_IN;
float localScalarRate = 0.75f;
ScalarMethods separateLocalScalar = ScalarMethods::EXP_IN;
float localScalarRate = 1.0f;

// Separate Z
bool separateZInterp = true;
ScalarMethods separateZScalar = ScalarMethods::SINE_IN;
float separateZMaxSmoothingDistance = 60.0f;
float separateZMinFollowRate = 0.15f;
float separateZMaxFollowRate = 0.4f;
float separateZMinFollowRate = 0.2f;
float separateZMaxFollowRate = 0.6f;

// Offset interpolation
bool enableOffsetInterpolation = true;
Expand All @@ -168,7 +171,7 @@ namespace Config {
float cameraDistanceClampXMax = 35.0f;
bool cameraDistanceClampYEnable = true;
float cameraDistanceClampYMin = -100.0f;
float cameraDistanceClampYMax = 20.0f;
float cameraDistanceClampYMax = 10.0f;
bool cameraDistanceClampZEnable = true;
float cameraDistanceClampZMin = -60.0f;
float cameraDistanceClampZMax = 60.0f;
Expand Down Expand Up @@ -198,6 +201,7 @@ namespace Config {
void ReadConfigFile();
void SaveCurrentConfig();
UserConfig* GetCurrentConfig() noexcept;
void ResetConfig();

// Returns "" if ok, otherwise has an error message
BSFixedString SaveConfigAsPreset(int slot, const BSFixedString& name);
Expand Down
Loading

0 comments on commit cd91c92

Please sign in to comment.