Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try removing kotlin warnings #941

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions server/core/src/main/java/dev/slimevr/autobone/AutoBone.kt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot assume that humanPoseManager is not null, as it may be initialized before AutoBone in VRServer. It could technically be considered safe since I moved the initialization lower in VRServer, so it could be changed... Idk, I guess I won't block it over this, but technically it is not assured to be safe, I'd left it in before despite the warnings because of this reason.

Copy link
Member Author

@ImUrX ImUrX Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats an interesting thing, what I'm curious about is that it's not a lateinit and kotlin is sure that it's not null, is something wrong in the parser maybe?

Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,9 @@ class AutoBone(server: VRServer) {
// Remove all previous values
offsets.clear()

// Get current or default skeleton configs
val skeleton = server.humanPoseManager
// Still compensate for a null skeleton, as it may not be initialized yet
val getOffset: Function<SkeletonConfigOffsets, Float> =
if (skeleton != null) {
Function { key: SkeletonConfigOffsets -> skeleton.getOffset(key) }
} else {
val defaultConfig = SkeletonConfigManager(false)
Function { config: SkeletonConfigOffsets ->
defaultConfig.getOffset(config)
}
}
// Get current skeleton configs
for (bone in adjustOffsets) {
val offset = getOffset.apply(bone)
val offset = server.humanPoseManager.getOffset(bone)
if (offset > 0f) {
offsets[bone] = offset
}
Expand Down Expand Up @@ -154,18 +143,15 @@ class AutoBone(server: VRServer) {
val targetHeight: Float
// Get the current skeleton from the server
val humanPoseManager = server.humanPoseManager
// Still compensate for a null skeleton, as it may not be initialized yet
if (config.useSkeletonHeight && humanPoseManager != null) {
// If there is a skeleton available, calculate the target height
// from its configs
if (config.useSkeletonHeight) {
// calculate the target height from the skeleton configs
targetHeight = humanPoseManager.userHeightFromConfig
LogManager
.warning(
"[AutoBone] Target height loaded from skeleton (Make sure you reset before running!): $targetHeight",
)
} else {
// Otherwise if there is no skeleton available, attempt to get the
// max HMD height from the recording
// Otherwise, attempt to get the max HMD height from the recording
val hmdHeight = frames.maxHmdHeight
if (hmdHeight <= 0.4f) {
LogManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PositionError : IAutoBoneError {
val position = trackerFrame.tryGetPosition() ?: continue
val trackerRole = trackerFrame.tryGetTrackerPosition()?.trackerRole ?: continue

val computedTracker = skeleton.getComputedTracker(trackerRole) ?: continue
val computedTracker = skeleton.getComputedTracker(trackerRole)

offset += (position - computedTracker.position).len()
offsetCount++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class PositionOffsetError : IAutoBoneError {
val position2 = trackerFrame2.tryGetPosition() ?: continue
val trackerRole2 = trackerFrame2.tryGetTrackerPosition()?.trackerRole ?: continue

val computedTracker1 = skeleton1.getComputedTracker(trackerRole1) ?: continue
val computedTracker2 = skeleton2.getComputedTracker(trackerRole2) ?: continue
val computedTracker1 = skeleton1.getComputedTracker(trackerRole1)
val computedTracker2 = skeleton2.getComputedTracker(trackerRole2)

val dist1 = (position1 - computedTracker1.position).len()
val dist2 = (position2 - computedTracker2.position).len()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class RPCAutoBoneHandler(

private fun onAutoBoneApplyRequest(
conn: GenericConnection,
messageHeader: RpcMessageHeader,
@Suppress("UNUSED_PARAMETER")messageHeader: RpcMessageHeader,
) {
api.server.autoBoneHandler.applyValues()

Expand All @@ -160,15 +160,15 @@ class RPCAutoBoneHandler(
}

private fun onAutoBoneStopRecordingRequest(
conn: GenericConnection,
messageHeader: RpcMessageHeader,
@Suppress("UNUSED_PARAMETER")conn: GenericConnection,
@Suppress("UNUSED_PARAMETER")messageHeader: RpcMessageHeader,
) {
api.server.autoBoneHandler.stopRecording()
}

private fun onAutoBoneCancelRecordingRequest(
conn: GenericConnection,
messageHeader: RpcMessageHeader,
@Suppress("UNUSED_PARAMETER") conn: GenericConnection,
@Suppress("UNUSED_PARAMETER") messageHeader: RpcMessageHeader,
) {
api.server.autoBoneHandler.cancelRecording()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RPCTrackingPause(private val rpcHandler: RPCHandler, private val api: Prot
return fbb.dataBuffer()
}

private fun onTrackingPauseStateRequest(conn: GenericConnection, messageHeader: RpcMessageHeader) {
private fun onTrackingPauseStateRequest(conn: GenericConnection, @Suppress("UNUSED_PARAMETER") messageHeader: RpcMessageHeader) {
conn.send(getPauseStateResponse(currentPauseState))
}

Expand Down
Loading