Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ class Tracker @JvmOverloads constructor(

/**
* Tells the tracker that it received new data
* NOTE: Use only when rotation is received
*/
fun dataTick() {
timer.update()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,13 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
tracker.dataTick()
}

is UDPPacket27Position -> {
tracker = connection?.getTracker(packet.sensorId)
if (tracker == null) return
tracker.position = packet.position
// dont call dataTick here as this is just position update
Copy link
Member

Choose a reason for hiding this comment

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

Why we don't do data tick here? We need to update stuff based on new position though?

We also should probably have a PositionRotation packet that has both to save on a bit of data

Copy link
Author

@SummerSigh SummerSigh Sep 21, 2025

Choose a reason for hiding this comment

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

me and butter talked about this a bit. essentially data tick has filtering stuff (specific to rotation data) that happens when it's called and is otherwise only really used to calculate TPS. PositionRotation is something that could be added for sure, but i was just going to use packet bundling anyway to do rot + pos in a single packet. Can add to this PR if needed
CC @ButterscotchV

}

is UDPPacket200ProtocolChange -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,20 @@ data class UDPPacket26FlexData(
}
}

data class UDPPacket27Position(
var position: Vector3 = Vector3.NULL,
) : UDPPacket(27),
SensorSpecificPacket {
override var sensorId = 0
override fun readData(buf: ByteBuffer) {
sensorId = buf.get().toInt() and 0xFF
val x = UDPUtils.getSafeBufferFloat(buf)
val y = UDPUtils.getSafeBufferFloat(buf)
val z = UDPUtils.getSafeBufferFloat(buf)
position = Vector3(x, y, z)
}
}

data class UDPPacket200ProtocolChange(
var targetProtocol: Int = 0,
var targetProtocolVersion: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class UDPProtocolParser {
PACKET_FEATURE_FLAGS -> UDPPacket22FeatureFlags()
PACKET_ACK_CONFIG_CHANGE -> UDPPacket24AckConfigChange()
PACKET_FLEX_DATA -> UDPPacket26FlexData()
PACKET_POSITION -> UDPPacket27Position()
PACKET_PROTOCOL_CHANGE -> UDPPacket200ProtocolChange()
else -> null
}
Expand Down Expand Up @@ -152,6 +153,7 @@ class UDPProtocolParser {
const val PACKET_ACK_CONFIG_CHANGE = 24
const val PACKET_SET_CONFIG_FLAG = 25
const val PACKET_FLEX_DATA = 26
const val PACKET_POSITION = 27
const val PACKET_BUNDLE = 100
const val PACKET_BUNDLE_COMPACT = 101
const val PACKET_PROTOCOL_CHANGE = 200
Expand Down
Loading