-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,107 additions
and
952 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
set -eu | ||
cd "$(dirname $0)/.." | ||
|
||
NAME="$1" | ||
VALUE="$2" | ||
|
||
VALUE_ESCAPED=$(printf '%s\n' "$VALUE" | sed -e 's/[&/\]/\\&/g') | ||
|
||
FILENAME="MelonPreferences.cfg" | ||
PREFS_PATH="/sdcard/Android/data/com.StressLevelZero.BONELAB/files/UserData/$FILENAME" | ||
CATEGORY="HandTracking" | ||
LINE_TO_INSERT="$NAME = $VALUE_ESCAPED" | ||
|
||
adb pull "$PREFS_PATH" | ||
|
||
if grep -q "^$NAME = .*\$" "$FILENAME"; then | ||
sed -i '' "s/^$NAME = .*\$/$LINE_TO_INSERT/" "$FILENAME" | ||
elif grep -q "^\[$CATEGORY\]$" "$FILENAME"; then | ||
sed -i '' -e "/^\[$CATEGORY\]$/a\\ | ||
$LINE_TO_INSERT" "$FILENAME" | ||
else | ||
echo "Error: No category with name \"$CATEGORY\" found in $FILENAME" | ||
exit 1 | ||
fi | ||
|
||
adb shell run-as com.StressLevelZero.BONELAB sh -c " | ||
cat > '$PREFS_PATH' <<'EOF' | ||
$(cat "$FILENAME") | ||
EOF | ||
" | ||
rm "$FILENAME" | ||
|
||
./scripts/build-and-start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
- Tracking quality | ||
- Sleeves block tracking/make hand movement choppy | ||
- Hand mapping | ||
- Different bones in Oculus hand tracking API vs Bonelab | ||
- Movement | ||
- Hand running | ||
- Nimsony head bobbing | ||
- Jumping | ||
- Force pull | ||
- Vehicles | ||
- UI | ||
- Inventory | ||
- Guns | ||
- Aiming is hard to be accurate with, but not unusable | ||
- Two handed gun aiming is hard | ||
- Hard for cameras to see trigger finger when aiming | ||
- Added weapon rotation offset to help the headset see the trigger finger better while aiming down sights | ||
- Struggling with auto sight | ||
- Minor tweaks | ||
- Noose auto-attach | ||
- Future improvements | ||
- Wife tried grabbing avatar selector with fingers (make different types of grips allow different hand shapes to grip?) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
using System; | ||
using UnityEngine; | ||
using SLZ.Bonelab; | ||
using SLZ.Interaction; | ||
using Sst.Utilities; | ||
using SLZ.Rig; | ||
using HarmonyLib; | ||
using SLZ.VRMK; | ||
|
||
namespace Sst.HandTracking; | ||
|
||
public class AutoSight { | ||
private const float ROTATION_SIMILARITY_ACTIVATION_THRESHOLD = 0.95f; | ||
private const float ROTATION_SIMILARITY_DEACTIVATION_THRESHOLD = 0.9f; | ||
private const float ROTATION_FACTOR = 0.1f; | ||
// Sights have a slightly different offset depending on the gun but finding | ||
// the specific value per gun is a lot of manual effort and won't work for | ||
// modded guns whereas hardcoding it works well enough | ||
private static Vector3 SIGHT_OFFSET = new Vector3(0f, 0.03f, 0f); | ||
|
||
public HandTracker Tracker; | ||
public HandTracker OtherTracker; | ||
public InteractableHost Weapon; | ||
public bool IsActive; | ||
public Quaternion TargetHandRotation; | ||
|
||
public AutoSight(HandTracker tracker, HandTracker otherTracker) { | ||
Tracker = tracker; | ||
OtherTracker = otherTracker; | ||
} | ||
|
||
public void UpdateHand() { | ||
// TODO: More efficient way to get held gun and cache all this stuff? | ||
var hand = Tracker.GetPhysicalHand(); | ||
if (hand == null) | ||
return; | ||
|
||
var host = hand?.AttachedReceiver?.TryCast<TargetGrip>() | ||
?.Host?.TryCast<InteractableHost>(); | ||
var gun = host?.GetComponent<Gun>(); | ||
if (gun?.firePointTransform == null || host?.Rb == null) | ||
return; | ||
|
||
var eye = LevelHooks.RigManager.controllerRig.TryCast<OpenControllerRig>() | ||
?.cameras?[0]; | ||
if (eye == null) | ||
return; | ||
|
||
var sightRot = gun.firePointTransform.rotation; | ||
var sightPos = gun.firePointTransform.position + sightRot * SIGHT_OFFSET; | ||
|
||
var targetRotation = | ||
Quaternion.LookRotation(sightPos - eye.transform.position); | ||
var rotationSimilarity = Quaternion.Dot(targetRotation, sightRot); | ||
|
||
if (IsActive) { | ||
if (rotationSimilarity < ROTATION_SIMILARITY_DEACTIVATION_THRESHOLD) { | ||
Dbg.Log("Auto-sight deactivated"); | ||
IsActive = false; | ||
return; | ||
} | ||
} else if (rotationSimilarity >= ROTATION_SIMILARITY_ACTIVATION_THRESHOLD) { | ||
Dbg.Log("Auto-sight activated"); | ||
IsActive = true; | ||
} else { | ||
return; | ||
} | ||
|
||
var handToSightPos = sightPos - host.Rb.transform.position - | ||
hand.joint.connectedAnchor + hand.joint.anchor; | ||
var handToSightRot = sightRot * | ||
Quaternion.Inverse(host.Rb.transform.rotation) * | ||
Quaternion.Inverse(hand.joint.targetRotation); | ||
var sightToHandRot = | ||
sightRot * host.Rb.transform.rotation * hand.joint.targetRotation; | ||
|
||
TargetHandRotation = targetRotation * sightToHandRot; | ||
} | ||
|
||
// TODO: Get this working | ||
// [HarmonyPatch( | ||
// typeof(GameWorldSkeletonRig), | ||
// nameof(GameWorldSkeletonRig.OnFixedUpdate) | ||
// )] | ||
// internal static class GameWorldSkeletonRig_OnFixedUpdate { | ||
// // [HarmonyPrefix] | ||
// // private static bool Prefix(GameWorldSkeletonRig __instance) { | ||
// [HarmonyPostfix] | ||
// private static void Postfix(GameWorldSkeletonRig __instance) { | ||
// __instance.m_handLf.localPosition = | ||
// new Vector3(Mathf.Sin(Time.time) * 0.25f, 1.5f, 0.2f); | ||
// __instance.m_handLf.localRotation = Quaternion.identity; | ||
// // __instance.m_elbowLf.localPosition = new Vector3(0.2f, 1.2f, 0.2f); | ||
// // __instance.m_elbowLf.localRotation = Quaternion.identity; | ||
// // __instance.bodyPose = __instance._basePose; | ||
// // return false; | ||
// } | ||
// } | ||
|
||
// [HarmonyPatch( | ||
// typeof(GameWorldSkeletonRig), nameof(GameWorldSkeletonRig.OnUpdate) | ||
// )] | ||
// internal static class GameWorldSkeletonRig_OnUpdate { | ||
// [HarmonyPostfix] | ||
// private static void Postfix(GameWorldSkeletonRig __instance) { | ||
// __instance.m_handLf.localPosition = | ||
// new Vector3(Mathf.Sin(Time.time) * 0.25f, 1.5f, 0.2f); | ||
// __instance.m_handLf.localRotation = Quaternion.identity; | ||
// } | ||
// } | ||
|
||
// [HarmonyPatch(typeof(PhysHand), nameof(PhysHand.UpdateArmTargets))] | ||
// internal static class PhysHand_UpdateArmTargets { | ||
// [HarmonyPrefix] | ||
// private static bool Prefix(PhysHand __instance) { | ||
// var tracker = | ||
// Mod.Instance.GetTrackerOfHand(__instance.hand.handedness); | ||
// tracker.AutoSight.UpdateHand(); | ||
// if (!tracker.AutoSight.IsActive) | ||
// return; | ||
|
||
// tracker.LogSpam("maxTor", maxTor); | ||
// var delta = Quaternion.Inverse(targetRotation) * | ||
// tracker.AutoSight.TargetHandRotation; | ||
|
||
// targetRotation = tracker.AutoSight.TargetHandRotation * | ||
// Quaternion.Slerp(Quaternion.identity, delta, ROTATION_FACTOR); | ||
// } | ||
// } | ||
} |
Oops, something went wrong.