-
Notifications
You must be signed in to change notification settings - Fork 65
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
Tp3 network rewrite #646
Draft
NateTheGreatt
wants to merge
28
commits into
main
Choose a base branch
from
tp3_network_rewrite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Tp3 network rewrite #646
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
15181b3
networking rewrite stage 1:
250c44c
fixed voip
546c73e
added clear guards to outbound net system
8417a42
disable outbound net system when window is not focused
f9be17b
Revert "disable outbound net system when window is not focused"
dba623c
renamed inbound/outbound networking files
bbf2f93
added partial network message test coverage
ea917a7
fixed spawnable updates, created remaining replicators
314a1cb
lint
345d409
non-host spawnables guard & warning
acdc413
typecheck
a5e3612
remove node from replicator instances on despawn
91185f8
net replicator despawn error verbiage fix
cb05a70
outbound net system cleanup
737ba10
always remove entity if host on peer leave
0eb75bb
network/peerId count sync fix
1b9b784
add bytes written to updates for skipping
31b2985
interaction held/remove/release fix
e2eb176
getNetworkReplicator return type fix
ea60f51
host snapshot usage fix
c48da8f
added NetworkSpawnPeerAvatarSystem
0f1310c
only host does out of bounds floor handling
bada57a
out of bounds floor position fix
2381ca4
physics body handle mapping bugfix
9de4c5e
fixed physics body disposal bug
21a4f59
Merge branch 'physics-body-handle-mapping-bugfix' into tp3_network_re…
ed20511
fixed peer avatar despawns as host
af4095e
peerID refactor
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Avatar Network Schema | ||
|
||
```c | ||
struct Spawn { | ||
networkId: uint64 // The avatar's networkId | ||
authorIndex: uint64 // Who controls the avatar | ||
schemaId: uint32 // 1 (Reserved Avatar schema id) | ||
creationDataByteLength: uint32 // 0 | ||
creationData: uint8[] // not used | ||
updateData: AvatarUpdate | ||
} | ||
|
||
struct AvatarUpdate { | ||
changedBitmask: uint8_t // rigPosition, rigRotation, rigVelocity | ||
rigPosition: float_t[3] | ||
rigRotation: float_t[4] | ||
rigVelocity: float_t[3] | ||
} | ||
|
||
struct AvatarXRModeUpdate { | ||
xrMode: uint8_t | ||
} | ||
``` | ||
|
||
```js | ||
const avatarReplicator = createNetworkedReplicator({ | ||
spawn(world, { author, creationData, updateData, networked }) { | ||
// Create node in world | ||
// Should be controllable by author | ||
// Return node to spawn | ||
return avatarRoot; | ||
}, | ||
encode(node, buffer) { | ||
// Write to buffer, return number bytes written, buffer truncated to that length and written as updateData | ||
}, | ||
decode(node, buffer) { | ||
// Read from buffer and apply to node or interp buffer | ||
const interpBuffer = interpMap.get(node); | ||
interpBuffer.add(); | ||
}, | ||
}); | ||
|
||
// host | ||
if (host) { | ||
const node = avatarReplicator.spawn(creationData, { destroyOnLeave: true }); | ||
// Modify the node as needed and that update data will be sent with the first spawn message | ||
} | ||
|
||
avatarReplicator.despawn(node); | ||
|
||
for (const { node } of avatarReplicator.spawned()) { | ||
// Spawned nodes should have the latest update data applied to them if it exists, | ||
// not just the original spawn update data | ||
world.environment.addNode(node); | ||
} | ||
|
||
for (const node of avatarReplicator.despawned()) { | ||
world.environment.removeNode(node); | ||
} | ||
``` |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we explain what this struct is used for in this document? Is it an RPC?