Skip to content

Commit

Permalink
Merge branch 'fix/linux-hard-crash' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed Aug 31, 2021
2 parents 10e9e20 + 58ee8e6 commit 77d133f
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 15 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ name: build
on:
push:
branches:
- main
- develop
tags:
- '*'
pull_request:

jobs:
Expand Down
6 changes: 6 additions & 0 deletions Source/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
root = true

[*.bsml]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
tab_width = 2

[*.cs]

# In general, the format for this file has the dotnet_diagnostic directive immediately preceding what it affects
Expand Down
3 changes: 2 additions & 1 deletion Source/CustomAvatar/Configuration/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ internal class Settings
public bool calibrateFullBodyTrackingOnStart { get; set; }
public ObservableValue<bool> enableLocomotion { get; } = new ObservableValue<bool>(true);
public ObservableValue<float> cameraNearClipPlane { get; } = new ObservableValue<float>(0.1f);
public bool showAvatarInSmoothCamera { get; set; } = true;
public ObservableValue<bool> showAvatarInSmoothCamera { get; } = new ObservableValue<bool>(true);
public bool showAvatarInMirrors { get; set; } = true;
public Lighting lighting { get; } = new Lighting();
public Mirror mirror { get; } = new Mirror();
public AutomaticFullBodyCalibration automaticCalibration { get; } = new AutomaticFullBodyCalibration();
Expand Down
12 changes: 11 additions & 1 deletion Source/CustomAvatar/HarmonyPatches/MirrorRendererSO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using CustomAvatar.Avatar;
using CustomAvatar.Configuration;
using HarmonyLib;
using UnityEngine;

Expand All @@ -23,9 +24,18 @@ namespace CustomAvatar.HarmonyPatches
[HarmonyPatch(typeof(MirrorRendererSO), "CreateOrUpdateMirrorCamera")]
internal static class MirrorRendererSO_CreateOrUpdateMirrorCamera
{
internal static Settings settings { get; set; }

public static void Postfix(Camera ____mirrorCamera)
{
____mirrorCamera.cullingMask |= AvatarLayers.kAllLayersMask;
if (settings.showAvatarInMirrors)
{
____mirrorCamera.cullingMask |= AvatarLayers.kAllLayersMask;
}
else
{
____mirrorCamera.cullingMask &= ~AvatarLayers.kAllLayersMask;
}
}
}
}
2 changes: 1 addition & 1 deletion Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class GameEnvironmentObjectManager : IInitializable, IDisposable
{
private static readonly int kReflectionProbeTexture1PropertyId = Shader.PropertyToID("_ReflectionProbeTexture1");
private static readonly int kReflectionProbeTexture2PropertyId = Shader.PropertyToID("_ReflectionProbeTexture2");
private static readonly Cubemap kBlackCubemap = new Cubemap(0, TextureFormat.DXT1, false);
private static readonly Cubemap kBlackCubemap = new Cubemap(0, TextureFormat.DXT1Crunched, false);

private readonly DiContainer _container;
private readonly ILogger<GameEnvironmentObjectManager> _logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ public void Start()
}

_settings.cameraNearClipPlane.changed += OnCameraNearClipPlaneChanged;
_settings.showAvatarInSmoothCamera.changed += OnShowAvatarInSmoothCameraChanged;
_mainSettingsModel.smoothCameraThirdPersonEnabled.didChangeEvent += OnSmoothCameraThirdPersonEnabled;

UpdateSmoothCamera();
}

public void OnDestroy()
{
if (_settings != null) _settings.cameraNearClipPlane.changed -= OnCameraNearClipPlaneChanged;
if (_settings != null)
{
_settings.cameraNearClipPlane.changed -= OnCameraNearClipPlaneChanged;
_settings.showAvatarInSmoothCamera.changed -= OnShowAvatarInSmoothCameraChanged;
}

if (_mainSettingsModel) _mainSettingsModel.smoothCameraThirdPersonEnabled.didChangeEvent -= OnSmoothCameraThirdPersonEnabled;
}

Expand All @@ -73,6 +79,11 @@ private void OnCameraNearClipPlaneChanged(float value)
UpdateSmoothCamera();
}

private void OnShowAvatarInSmoothCameraChanged(bool value)
{
UpdateSmoothCamera();
}

private void OnSmoothCameraThirdPersonEnabled()
{
UpdateSmoothCamera();
Expand Down
20 changes: 20 additions & 0 deletions Source/CustomAvatar/UI/GeneralSettingsHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ public bool visibleInFirstPerson
}
}

public bool showAvatarInSmoothCamera
{
get => _settings.showAvatarInSmoothCamera;
set
{
_settings.showAvatarInSmoothCamera.value = value;
NotifyPropertyChanged();
}
}

public bool showAvatarInMirrors
{
get => _settings.showAvatarInMirrors;
set
{
_settings.showAvatarInMirrors = value;
NotifyPropertyChanged();
}
}

public AvatarResizeMode resizeMode
{
get => _settings.resizeMode;
Expand Down
16 changes: 9 additions & 7 deletions Source/CustomAvatar/UI/Views/Settings.bsml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
<settings-container anchor-pos-y="0" size-delta-y="0">
<macro.as-host host="generalSettingsHost">
<toggle-setting text="Visible in First Person" value="visibleInFirstPerson" bind-value="true" apply-on-change="true"/>
<toggle-setting text="Show in Smooth Camera" value="showAvatarInSmoothCamera" bind-value="true" apply-on-change="true"/>
<toggle-setting text="Show in Mirrors" value="showAvatarInMirrors" bind-value="true" apply-on-change="true"/>
<dropdown-list-setting text="Resize Mode" value="resizeMode" bind-value="true" apply-on-change="true" options="resizeModeOptions" formatter="ResizeModeFormatter"></dropdown-list-setting>
<horizontal pref-width="90" active="~showHeightAdjustWarning">
<text color="#FFFF88FF" text="You are using Automatic Player Height; please disable it in Player Settings and set your height manually." font-size="2.5" italics="true" />
</horizontal>
<dropdown-list-setting text="Floor Height Adjust" hover-hint="Move the floor/environment so the avatar is standing at full height even if it is taller or shorter than the player." value="floorHeightAdjustMode" bind-value="true" apply-on-change="true" options="floorHeightAdjustOptions" formatter="FloorHeightAdjustFormatter"/>

<horizontal pref-height="7">
<text text="Arm Span" font-size="4" align="Left" italics="true"></text>
<slider value="armSpan" step="0.01" minimum="0" formatter="ArmSpanFormatter" interactable="~isHeightAdjustInteractable"/>
<button text="~measureButtonText" interactable="~isMeasureButtonEnabled" hover-hint="~measureButtonHoverHintText" on-click="OnMeasureArmSpanButtonClicked"></button>
<text text="Arm Span" font-size="4" align="Left" italics="true"></text>
<slider value="armSpan" step="0.01" minimum="0" formatter="ArmSpanFormatter" interactable="~isHeightAdjustInteractable"/>
<button text="~measureButtonText" interactable="~isMeasureButtonEnabled" hover-hint="~measureButtonHoverHintText" on-click="OnMeasureArmSpanButtonClicked"></button>
</horizontal>

<horizontal pref-width="90" pad-top="2">
<text color="#808080" text="Advanced" font-size="4" italics="true" align="Baseline" />
</horizontal>

<toggle-setting value="moveFloorWithRoomAdjust" bind-value="true" apply-on-change="true" text="Move Floor with Room Adjust" hover-hint="Move the floor/environment along with the game's built-in vertical room adjust."/>
<toggle-setting value="moveFloorWithRoomAdjust" bind-value="true" apply-on-change="true" text="Move Floor with Room Adjust" hover-hint="Move the floor/environment along with the game's built-in vertical room adjust."/>
<toggle-setting value="enableLocomotion" bind-value="true" apply-on-change="true" text="Enable locomotion" hover-hint="Allow feet and waist to be moved automatically to follow your head/body when not using dedicated trackers. Only affects full body avatars."/>
<increment-setting value="cameraNearClipPlane" bind-value="true" apply-on-change="true" text="Camera Near Clip Plane" hover-hint="Distance from the eyes at which objets start being visible." min="0.01" max="0.3" increment="0.01"/>
</macro.as-host>
Expand All @@ -48,8 +50,8 @@

<tab tags="avatar-tabs" tab-name="Current Avatar" anchor-max-y="0.8">
<macro.as-host host="avatarSpecificSettingsHost">
<loading-indicator active="~isLoaderActive" />
<loading-indicator active="~isLoaderActive" />
<settings-container anchor-pos-y="0" size-delta-y="0">
<toggle-setting text="Ignore first person exclusions" value="ignoreExclusions" bind-value="true" apply-on-change="true" interactable="~isAvatarSpecificSettingsAvailable" hover-hint="Show the entire model in first person, even if some parts were configured to be hidden in first person. This may cause issues on certain avatars."/>
<toggle-setting text="Bypass calibration" value="bypassCalibration" bind-value="true" apply-on-change="true" interactable="~isAvatarSpecificSettingsAvailable" hover-hint="Disable the need for calibration before full body tracking is applied."/>
Expand All @@ -67,7 +69,7 @@
<macro.as-host host="interfaceSettingsHost">
<settings-container anchor-pos-y="0" size-delta-y="0">
<increment-setting text="Mirror Render Scale" value="renderScale" bind-value="true" apply-on-change="true" min="0.5" max="2" increment="0.1" />
<list-setting text="Mirror Anti Aliasing" value="antiAliasingLevel" bind-value="true" apply-on-change="true" options="antiAliasingLevelOptions" formatter="AntiAliasingLevelFormatter" />
<list-setting text="Mirror Anti Aliasing" value="antiAliasingLevel" bind-value="true" apply-on-change="true" options="antiAliasingLevelOptions" formatter="AntiAliasingLevelFormatter" />
</settings-container>
</macro.as-host>
</tab>
Expand Down
5 changes: 4 additions & 1 deletion Source/CustomAvatar/Zenject/CustomAvatarsInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Linq;
using CustomAvatar.Avatar;
using CustomAvatar.Configuration;
using CustomAvatar.HarmonyPatches;
using CustomAvatar.Lighting;
using CustomAvatar.Logging;
using CustomAvatar.Player;
Expand Down Expand Up @@ -55,7 +56,9 @@ public override void InstallBindings()
Container.Bind(typeof(ILogger<>)).FromMethodUntyped(CreateLogger).AsTransient().When(ShouldCreateLogger);

// settings
Container.Bind<Settings>().FromInstance(LoadSettings());
Settings settings = LoadSettings();
MirrorRendererSO_CreateOrUpdateMirrorCamera.settings = settings;
Container.Bind<Settings>().FromInstance(settings);
Container.BindInterfacesAndSelfTo<CalibrationData>().AsSingle();

if (XRSettings.loadedDeviceName.Equals("openvr", StringComparison.InvariantCultureIgnoreCase) &&
Expand Down

0 comments on commit 77d133f

Please sign in to comment.