-
Notifications
You must be signed in to change notification settings - Fork 461
feat: quaternion synchronization, delta position, and NetworkTransform bandwidth optimizations #2388
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
Merged
NoelStephensUnity
merged 138 commits into
develop
from
feat/quaternion-synchronization-network-transform
Mar 10, 2023
Merged
feat: quaternion synchronization, delta position, and NetworkTransform bandwidth optimizations #2388
Changes from 133 commits
Commits
Show all changes
138 commits
Select commit
Hold shift + click to select a range
5571be6
update
NoelStephensUnity a7cde50
update
NoelStephensUnity 343e52b
update
NoelStephensUnity 2932d5d
update
NoelStephensUnity 44b03cb
update
NoelStephensUnity 6be04c5
update
NoelStephensUnity 64855d6
update
NoelStephensUnity 0168cc9
Merge branch 'develop' into refactor/quaternion-synchronization-netwo…
NoelStephensUnity a093a06
update
NoelStephensUnity 0a03b9f
update
NoelStephensUnity 877acc1
update
NoelStephensUnity 73c73db
test manual
NoelStephensUnity e3dc079
update
NoelStephensUnity 7183d38
update
NoelStephensUnity ce145ce
update
NoelStephensUnity 220e30a
update
NoelStephensUnity 09359bd
update
NoelStephensUnity d782c85
update
NoelStephensUnity 1f10e44
fix
NoelStephensUnity 360a267
test fix
NoelStephensUnity 2b254f1
test updates
NoelStephensUnity fe68e84
update
NoelStephensUnity d232e7e
update
NoelStephensUnity 419010d
update
NoelStephensUnity b71f7d2
tests update
NoelStephensUnity 466bbaa
update
NoelStephensUnity bcc5f8f
update
NoelStephensUnity 9ec0e4c
Test
NoelStephensUnity fd3dcd1
update and test
NoelStephensUnity a96d12b
update
NoelStephensUnity 924644c
test manual
NoelStephensUnity 756c77f
test
NoelStephensUnity 89acab4
update
NoelStephensUnity a4822ac
update
NoelStephensUnity b25d582
fix
NoelStephensUnity 7d3d313
test manual
NoelStephensUnity 3bd4807
test
NoelStephensUnity dc1ab6d
test
NoelStephensUnity 63f9169
update
NoelStephensUnity 1e58592
test manual
NoelStephensUnity 3435165
update
NoelStephensUnity a9df8a6
update
NoelStephensUnity b76d835
test manual
NoelStephensUnity cf23afd
update - wip
NoelStephensUnity 5151180
update
NoelStephensUnity b894b8c
test manual
NoelStephensUnity 0829500
test
NoelStephensUnity c7ea4c0
update
NoelStephensUnity 29269ca
style and minor update
NoelStephensUnity 03aca55
update - precision adjustment
NoelStephensUnity 576e3be
test manual
NoelStephensUnity 28cc889
update
NoelStephensUnity 1809fee
tests manual
NoelStephensUnity b76a455
test manual
NoelStephensUnity 89fec61
test
NoelStephensUnity 50a664d
test
NoelStephensUnity b674ac3
update - remove
NoelStephensUnity 27608a0
update - tick replacing sent time
NoelStephensUnity 87396d5
update
NoelStephensUnity 543c7e8
test manual
NoelStephensUnity 27da0c2
update - synchronize transform
NoelStephensUnity 84d3961
update - quaternion compression
NoelStephensUnity 0d53a97
test - manual Bandwidth Test
NoelStephensUnity ec0eda4
update
NoelStephensUnity efdb3be
update
NoelStephensUnity e7f0517
update
NoelStephensUnity 7c25236
update
NoelStephensUnity e045bc2
update
NoelStephensUnity f248e37
test
NoelStephensUnity 50f4d68
update
NoelStephensUnity a40ca24
update
NoelStephensUnity f8551c8
update
NoelStephensUnity 12864ef
test
NoelStephensUnity 0b69779
update
NoelStephensUnity 7676b57
test
NoelStephensUnity a7f545c
update
NoelStephensUnity 3bbf8a7
test
NoelStephensUnity 34795f5
test manual
NoelStephensUnity ba5444c
Merge branch 'develop' into refactor/quaternion-synchronization-netwo…
NoelStephensUnity 8d27739
style
NoelStephensUnity 85f0ec5
style
NoelStephensUnity 877dffd
test
NoelStephensUnity 79f44f3
style
NoelStephensUnity c02b81f
update
NoelStephensUnity af27d8f
style
NoelStephensUnity b4777a8
update
NoelStephensUnity 28b996c
fix
NoelStephensUnity 90d6ddb
fix
NoelStephensUnity c76d797
style
NoelStephensUnity 55697ac
update
NoelStephensUnity 1aedc03
update
NoelStephensUnity 2b2ab9b
update
NoelStephensUnity 23af3b7
Merge branch 'develop' into refactor/quaternion-synchronization-netwo…
NoelStephensUnity cf93c82
update
NoelStephensUnity 6dc3b42
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 922999d
update
NoelStephensUnity 10032f1
update
NoelStephensUnity 1f16c44
test manual
NoelStephensUnity f7a0e09
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 9569e00
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity cb42fe5
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity cd4a5f2
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity a06cc6c
fix - merging parent dynamic under in scene placed
NoelStephensUnity 049d6f5
update
NoelStephensUnity 3666fde
Test Manual
NoelStephensUnity bd02a59
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 348d949
update
NoelStephensUnity 53f2172
update
NoelStephensUnity 4705932
style
NoelStephensUnity 68e1f15
test
NoelStephensUnity 221fa44
update
NoelStephensUnity 0d9709a
update and style
NoelStephensUnity 5813345
update
NoelStephensUnity 8454f9d
test
NoelStephensUnity 906a3ab
update
NoelStephensUnity 3649e6c
test
NoelStephensUnity e97320b
update
NoelStephensUnity 19bbfad
test manual
NoelStephensUnity d550f61
update and style
NoelStephensUnity 484edc4
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 177fad4
changelog fix
NoelStephensUnity d616c0c
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 5c8a2ab
update
NoelStephensUnity c4f74c5
update
NoelStephensUnity 5c31ae5
test
NoelStephensUnity 24ebf6d
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 5d7cf3b
fix
NoelStephensUnity 2308eb5
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 1798926
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 06de0f2
update
NoelStephensUnity 7957230
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 2b7822b
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 3a906ae
revert
NoelStephensUnity 505ed65
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity 57588e8
update
NoelStephensUnity 144a4b8
Merge branch 'develop' into feat/quaternion-synchronization-network-t…
NoelStephensUnity a76c804
style
NoelStephensUnity 70b4f65
style
NoelStephensUnity 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 hidden or 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
114 changes: 114 additions & 0 deletions
114
com.unity.netcode.gameobjects/Components/HalfVector3.cs
This file contains hidden or 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,114 @@ | ||
| using System.Runtime.CompilerServices; | ||
| using UnityEngine; | ||
|
|
||
| namespace Unity.Netcode.Components | ||
| { | ||
| /// <summary> | ||
| /// Half float precision <see cref="Vector3"/> | ||
| /// </summary> | ||
| public struct HalfVector3 : INetworkSerializable | ||
| { | ||
| /// <summary> | ||
| /// The half float precision value of the x-axis as a <see cref="ushort"/> | ||
| /// </summary> | ||
| public ushort X => Axis[0]; | ||
| /// <summary> | ||
| /// The half float precision value of the y-axis as a <see cref="ushort"/> | ||
| /// </summary> | ||
| public ushort Y => Axis[1]; | ||
| /// <summary> | ||
| /// The half float precision value of the z-axis as a <see cref="ushort"/> | ||
| /// </summary> | ||
| public ushort Z => Axis[2]; | ||
|
|
||
| public ushort[] Axis; | ||
|
ShadauxCat marked this conversation as resolved.
Outdated
|
||
|
|
||
| private HalfVector3AxisToSynchronize m_HalfVector3AxisToSynchronize; | ||
|
|
||
| /// <summary> | ||
| /// The serialization implementation of <see cref="INetworkSerializable"/> | ||
| /// </summary> | ||
| /// <typeparam name="T"></typeparam> | ||
| /// <param name="serializer"></param> | ||
| public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter | ||
| { | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| if (m_HalfVector3AxisToSynchronize.SyncAxis[i]) | ||
| { | ||
| var axisValue = Axis[i]; | ||
| serializer.SerializeValue(ref axisValue); | ||
|
NoelStephensUnity marked this conversation as resolved.
|
||
| if (serializer.IsReader) | ||
| { | ||
| Axis[i] = axisValue; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Converts the <see cref="HalfVector3"/> to a full precision <see cref="Vector3"/> | ||
| /// </summary> | ||
| /// <param name="vector3">the <see cref="Vector3"/> to store the full precision values in</param> | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public void ToVector3(ref Vector3 vector3) | ||
| { | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| if (m_HalfVector3AxisToSynchronize.SyncAxis[i]) | ||
| { | ||
| vector3[i] = Mathf.HalfToFloat(Axis[i]); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Converts a <see cref="Vector3"/> full precision to a <see cref="HalfVector3"/> | ||
| /// </summary> | ||
| /// <param name="vector3">the <see cref="Vector3"/> to convert to a half precision <see cref="Vector3"/></param> | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public void FromVector3(ref Vector3 vector3) | ||
|
ShadauxCat marked this conversation as resolved.
Outdated
|
||
| { | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| if (m_HalfVector3AxisToSynchronize.SyncAxis[i]) | ||
| { | ||
| Axis[i] = Mathf.FloatToHalf(vector3[i]); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Constructor that initializes the HalfVector3 along with its precision adjustment | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Note about decimal precision: | ||
| /// If you know that all components (x, y, and z) of a Vector3 will not exceed a specific threshold, then you | ||
| /// can increase the decimal precision of a Vector3 by increasing the decimalPrecision value. The decimal precision | ||
| /// valid values range from 0 to 4 decimal places to adjust up and back down (1000 to 1 : 1 to 0.001). | ||
| /// </remarks> | ||
| /// <param name="vector3">the vector3 to initialize the HalfVector3 with</param> | ||
| public HalfVector3(Vector3 vector3, HalfVector3AxisToSynchronize halfVector3AxisToSynchronize) | ||
|
ShadauxCat marked this conversation as resolved.
Outdated
|
||
| { | ||
| Axis = new ushort[3]; | ||
| m_HalfVector3AxisToSynchronize = halfVector3AxisToSynchronize; | ||
| FromVector3(ref vector3); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Constructor that initializes the HalfVector3 along with its precision adjustment | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Note about decimal precision: | ||
| /// If you know that all components (x, y, and z) of a Vector3 will not exceed a specific threshold, then you | ||
| /// can increase the decimal precision of a Vector3 by increasing the decimalPrecision value. The decimal precision | ||
| /// valid values range from 0 to 4 decimal places to adjust up and back down (1000 to 1 : 1 to 0.001). | ||
| /// </remarks> | ||
| /// <param name="x">x component to initialize the HalfVector3 with</param> | ||
| /// <param name="y">y component of initialize the HalfVector3 with</param> | ||
| /// <param name="z">z component of initialize the HalfVector3 with</param> | ||
| public HalfVector3(float x, float y, float z, HalfVector3AxisToSynchronize halfVector3AxisToSynchronize) : this(new Vector3(x, y, z), halfVector3AxisToSynchronize) | ||
| { | ||
| } | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
com.unity.netcode.gameobjects/Components/HalfVector3.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
com.unity.netcode.gameobjects/Components/HalfVector3AxisToSynchronize.cs
This file contains hidden or 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,41 @@ | ||
|
|
||
| namespace Unity.Netcode.Components | ||
| { | ||
| /// <summary> | ||
| /// Structure that defines which axis of a <see cref="HalfVector3"/> | ||
| /// and <see cref="HalfVector3DeltaPosition"/> will be serialized. | ||
| /// </summary> | ||
| public struct HalfVector3AxisToSynchronize | ||
| { | ||
| /// <summary> | ||
| /// When enabled, serialize the X axis | ||
| /// </summary> | ||
| public bool X => SyncAxis[0]; | ||
|
|
||
| /// <summary> | ||
| /// When enabled, serialize the Y axis | ||
| /// </summary> | ||
| public bool Y => SyncAxis[1]; | ||
|
|
||
| /// <summary> | ||
| /// When enabled, serialize the Z axis | ||
| /// </summary> | ||
| public bool Z => SyncAxis[2]; | ||
|
|
||
| public bool[] SyncAxis; | ||
|
|
||
| /// <summary> | ||
| /// Constructor to preinitialize the x, y, and z values | ||
| /// </summary> | ||
| /// <param name="x">when <see cref="true"/> the x-axis will be serialized</param> | ||
| /// <param name="y">when <see cref="true"/> the y-axis will be serialized</param> | ||
| /// <param name="z">when <see cref="true"/> the z-axis will be serialized</param> | ||
| public HalfVector3AxisToSynchronize(bool x = true, bool y = true, bool z = true) | ||
| { | ||
| SyncAxis = new bool[3]; | ||
|
ShadauxCat marked this conversation as resolved.
Outdated
|
||
| SyncAxis[0] = x; | ||
| SyncAxis[1] = y; | ||
| SyncAxis[2] = z; | ||
| } | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
com.unity.netcode.gameobjects/Components/HalfVector3AxisToSynchronize.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.