diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0c642d88..c42467d1f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - The 'Build Configuration' Inspector window will no longer report your Android SDK installation as missing if you have a completely fresh Unity installation with the bundled Android SDK. [#1441](https://github.com/spatialos/gdk-for-unity/pull/1441) - Fixed a bug where having spaces in the path to your project would cause the 'Local launch' and 'Launch standalone client' menu options to fail on MacOS. [#1442](https://github.com/spatialos/gdk-for-unity/pull/1442) - Fixed a faulty sync point caused by using `ComponentDataFromEntity` of the `WorkerSystem`. [#1430](https://github.com/spatialos/gdk-for-unity/pull/1430) +- Fixed a bug where the Transform Sync Feature Module would not correctly apply the `Is Kinematic` option. [#1456](https://github.com/spatialos/gdk-for-unity/pull/1456) ### Internal diff --git a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/DefaultApplyLatestTransformSystem.cs b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/DefaultApplyLatestTransformSystem.cs index 677746762a..896352ccc6 100644 --- a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/DefaultApplyLatestTransformSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/DefaultApplyLatestTransformSystem.cs @@ -4,6 +4,7 @@ using Improbable.Gdk.Core; using Unity.Entities; using UnityEngine; +using static Improbable.Gdk.TransformSynchronization.TransformUtils; namespace Improbable.Gdk.TransformSynchronization { @@ -32,7 +33,7 @@ protected override void OnCreate() internal void RegisterTransformSyncType(ITransformSync impl) where T : class { - var entityQuery = GetEntityQuery(TransformUtils.ConstructEntityQueryDesc(requireAuthority: false, baseComponentTypes)); + var entityQuery = GetEntityQuery(ConstructEntityQueryDesc(AuthorityRequirements.Exclude, baseComponentTypes)); applyLatestTransformActions.Add(typeof(T), () => Entities.With(entityQuery) @@ -42,7 +43,7 @@ internal void RegisterTransformSyncType(ITransformSync impl) private void UpdateTransformQuery() { - var transformQueryDesc = TransformUtils.ConstructEntityQueryDesc(requireAuthority: false, baseComponentTypes); + var transformQueryDesc = ConstructEntityQueryDesc(AuthorityRequirements.Exclude, baseComponentTypes); transformQueryDesc.None = transformQueryDesc.None .Union( applyLatestTransformActions.Keys diff --git a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/DefaultUpdateLatestTransformSystem.cs b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/DefaultUpdateLatestTransformSystem.cs index a9ed9da11e..e4c8e6b812 100644 --- a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/DefaultUpdateLatestTransformSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/DefaultUpdateLatestTransformSystem.cs @@ -4,6 +4,7 @@ using Improbable.Gdk.Core; using Unity.Entities; using UnityEngine; +using static Improbable.Gdk.TransformSynchronization.TransformUtils; namespace Improbable.Gdk.TransformSynchronization { @@ -32,7 +33,7 @@ protected override void OnCreate() internal void RegisterTransformSyncType(ITransformSync impl) where T : class { - var entityQuery = GetEntityQuery(TransformUtils.ConstructEntityQueryDesc(requireAuthority: true, baseComponentTypes)); + var entityQuery = GetEntityQuery(ConstructEntityQueryDesc(AuthorityRequirements.Require, baseComponentTypes)); updateLatestTransformActions.Add(typeof(T), () => Entities.With(entityQuery) @@ -43,7 +44,7 @@ internal void RegisterTransformSyncType(ITransformSync impl) private void UpdateTransformQuery() { - var transformQueryDesc = TransformUtils.ConstructEntityQueryDesc(requireAuthority: true, baseComponentTypes); + var transformQueryDesc = ConstructEntityQueryDesc(AuthorityRequirements.Require, baseComponentTypes); transformQueryDesc.None = updateLatestTransformActions.Keys .Select(ComponentType.ReadOnly) .ToArray(); diff --git a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/ResetForAuthorityGainedSystem.cs b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/ResetForAuthorityGainedSystem.cs index 33f3e29d8c..1d6ee282b5 100644 --- a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/ResetForAuthorityGainedSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/ResetForAuthorityGainedSystem.cs @@ -3,7 +3,7 @@ using System.Linq; using Improbable.Gdk.Core; using Unity.Entities; -using UnityEngine; +using static Improbable.Gdk.TransformSynchronization.TransformUtils; namespace Improbable.Gdk.TransformSynchronization { @@ -49,7 +49,7 @@ protected override void OnCreate() internal void RegisterTransformSyncType(ITransformSync impl) where T : class { - var componentQueryDesc = TransformUtils.ConstructEntityQueryDesc(requireAuthority: true, baseComponentTypes); + var componentQueryDesc = ConstructEntityQueryDesc(AuthorityRequirements.Require, baseComponentTypes); componentQueryDesc.None = baseExcludeComponentTypes; var entityQuery = GetEntityQuery(componentQueryDesc); @@ -81,7 +81,7 @@ internal void RegisterTransformSyncType(ITransformSync impl) private void UpdateTransformQuery() { - var transformQueryDesc = TransformUtils.ConstructEntityQueryDesc(requireAuthority: true, baseComponentTypes); + var transformQueryDesc = ConstructEntityQueryDesc(AuthorityRequirements.Require, baseComponentTypes); transformQueryDesc.None = resetAuthorityActions.Keys .Select(ComponentType.ReadOnly) .Concat(baseExcludeComponentTypes) diff --git a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/SetKinematicFromAuthoritySystem.cs b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/SetKinematicFromAuthoritySystem.cs index 6c1e1be70b..68d53e8a98 100644 --- a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/SetKinematicFromAuthoritySystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/Systems/SetKinematicFromAuthoritySystem.cs @@ -3,6 +3,7 @@ using System.Linq; using Improbable.Gdk.Core; using Unity.Entities; +using static Improbable.Gdk.TransformSynchronization.TransformUtils; namespace Improbable.Gdk.TransformSynchronization { @@ -55,7 +56,7 @@ internal void RegisterTransformSyncType(ITransformSync impl) private void CreateInitAction(EntityQueryBuilder.F_DC initFunc) where T : class { - var entityQuery = GetEntityQuery(TransformUtils.ConstructEntityQueryDesc(requireAuthority: false, initBaseComponentTypes)); + var entityQuery = GetEntityQuery(ConstructEntityQueryDesc(AuthorityRequirements.Exclude, initBaseComponentTypes)); initKinematicActions.Add(typeof(T), () => Entities.With(entityQuery).ForEach(initFunc)); } @@ -63,7 +64,7 @@ private void CreateInitAction(EntityQueryBuilder.F_DC(AuthChangeFunc authFunc) where T : class { - var componentQueryDesc = TransformUtils.ConstructEntityQueryDesc(requireAuthority: false, authBaseComponentTypes); + var componentQueryDesc = ConstructEntityQueryDesc(AuthorityRequirements.Ignore, authBaseComponentTypes); componentQueryDesc.None = componentQueryDesc.None .Append(ComponentType.ReadOnly()) .ToArray(); @@ -83,7 +84,8 @@ private void CreateAuthChangeAction(AuthChangeFunc authFunc) return; } - var auth = changes[changes.Count - 1]; + // The first element is actually the latest value! + var auth = changes[0]; authFunc(ref kinematicStateWhenAuth, auth, component); })); diff --git a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/TransformUtils.cs b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/TransformUtils.cs index 5644cefdd4..83185f0b08 100644 --- a/workers/unity/Packages/io.improbable.gdk.transformsynchronization/TransformUtils.cs +++ b/workers/unity/Packages/io.improbable.gdk.transformsynchronization/TransformUtils.cs @@ -70,13 +70,13 @@ public static CompressedQuaternion ToCompressedQuaternion(this Quaternion quater /// The base set of types. /// The type to add. /// An that is the union of and typeof() - internal static EntityQueryDesc ConstructEntityQueryDesc(bool requireAuthority, params ComponentType[] baseTypes) + internal static EntityQueryDesc ConstructEntityQueryDesc(AuthorityRequirements authorityRequirements, params ComponentType[] baseTypes) { var componentType = ComponentType.ReadOnly(); var includedComponentTypes = baseTypes .Append(componentType); - if (requireAuthority) + if (authorityRequirements == AuthorityRequirements.Require) { includedComponentTypes = includedComponentTypes .Append(ComponentType.ReadOnly()); @@ -87,7 +87,7 @@ internal static EntityQueryDesc ConstructEntityQueryDesc(bool requireAuthorit All = includedComponentTypes.ToArray(), }; - if (!requireAuthority) + if (authorityRequirements == AuthorityRequirements.Exclude) { componentQueryDesc.None = new[] { @@ -97,5 +97,12 @@ internal static EntityQueryDesc ConstructEntityQueryDesc(bool requireAuthorit return componentQueryDesc; } + + internal enum AuthorityRequirements + { + Exclude, + Ignore, + Require + } } }