Skip to content

Commit fb0c201

Browse files
committed
cleaned up the authoredmotionsystem
1 parent 836c128 commit fb0c201

9 files changed

Lines changed: 34 additions & 21 deletions

File tree

Basis/Packages/com.basis.framework/Avatar/BasisAvatarFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ private static void SetupPlayerAvatar(BasisPlayer Player, BasisAvatar avatar, bo
417417
? loadHarvest.Renderers.ToArray()
418418
: avatar.GetComponentsInChildren<Renderer>(true);
419419
Player.BasisAvatar.SkinnedMeshRenderers = loadHarvest.SkinnedMeshRenderers?.ToArray();
420+
Player.BasisAvatar.AuthoredMotions = loadHarvest.AuthoredMotions != null
421+
? loadHarvest.AuthoredMotions.ToArray()
422+
: avatar.GetComponentsInChildren<BasisAuthoredMotion>(true);
420423
avatar.Harvest = null;
421424
Player.BasisAvatar.IsOwnedLocally = Player.IsLocal;
422425

Basis/Packages/com.basis.framework/Drivers/AuthoredMotion/BasisAuthoredMotionSystem.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ static float Wave(int waveform, float phase, float pulseWidth)
231231
/// networked humanoid skeleton, so there's no write contention with the bone pipeline.
232232
///
233233
/// <para>Registration is calibration-driven (no scene discovery): the local/remote avatar drivers
234-
/// call <see cref="Register"/> for each <see cref="BasisAuthoredMotion"/> on the avatar and
235-
/// <see cref="Unregister"/> on teardown/recalibration. Authoritative state lives in managed
234+
/// call <see cref="Register"/> for each <see cref="BasisAuthoredMotion"/> on the avatar at calibration;
235+
/// recalibration re-registers (dedup drops the stale record) and a torn-down avatar's slots are
236+
/// reclaimed by the next <see cref="Schedule"/> rebuild. Authoritative state lives in managed
236237
/// <c>Registration</c> records (rest poses captured once at registration); a structural change
237238
/// rebuilds the native containers from them.</para>
238239
/// </summary>

Basis/Packages/com.basis.framework/Drivers/Local/BasisLocalAvatarDriver.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,13 @@ public void InitialLocalCalibration(BasisLocalPlayer player, List<BasisHeadChop.
150150
}
151151

152152
// Register authored motion (drives non-humanoid transforms IK doesn't touch); rest captured at the current TPose.
153-
var authoredMotions = player.BasisAvatar.GetComponentsInChildren<BasisAuthoredMotion>(true);
154-
for (int i = 0; i < authoredMotions.Length; i++)
153+
var authoredMotions = player.BasisAvatar.AuthoredMotions;
154+
if (authoredMotions != null)
155155
{
156-
BasisAuthoredMotionSystem.Register(authoredMotions[i]);
156+
for (int i = 0; i < authoredMotions.Length; i++)
157+
{
158+
BasisAuthoredMotionSystem.Register(authoredMotions[i]);
159+
}
157160
}
158161

159162
player.LocalRigDriver.Builder = BasisHelpers.GetOrAddComponent<RigBuilder>(AvatarAnimatorParent);

Basis/Packages/com.basis.framework/Drivers/Remote/BasisRemoteAvatarDriver.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,13 @@ public void RemoteCalibration(BasisRemotePlayer RemotePlayer)
139139
}
140140

141141
// Register authored motion (drives non-humanoid transforms the bone job / IK don't touch); rest captured at the current TPose.
142-
var authoredMotions = RemotePlayer.BasisAvatar.GetComponentsInChildren<BasisAuthoredMotion>(true);
143-
for (int i = 0; i < authoredMotions.Length; i++)
142+
var authoredMotions = RemotePlayer.BasisAvatar.AuthoredMotions;
143+
if (authoredMotions != null)
144144
{
145-
BasisAuthoredMotionSystem.Register(authoredMotions[i]);
145+
for (int i = 0; i < authoredMotions.Length; i++)
146+
{
147+
BasisAuthoredMotionSystem.Register(authoredMotions[i]);
148+
}
146149
}
147150

148151
// Face visibility setup

Basis/Packages/com.basis.framework/Players/Remote/BasisRemotePlayer.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -529,17 +529,6 @@ public void OnDestroy()
529529

530530
OnRemotePlayerDestroying?.Invoke();
531531

532-
// Unregister authored motion while the avatar transforms are still alive, so the
533-
// TransformAccessArray entries drop cleanly before Unity destroys them.
534-
if (BasisAvatar != null)
535-
{
536-
var authoredMotions = BasisAvatar.GetComponentsInChildren<BasisAuthoredMotion>(true);
537-
for (int i = 0; i < authoredMotions.Length; i++)
538-
{
539-
BasisAuthoredMotionSystem.Unregister(authoredMotions[i]);
540-
}
541-
}
542-
543532
RemoveFromBoneDriver();
544533
}
545534

Basis/Packages/com.basis.sdk/Scripts/Basis Components/BasisAvatar.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ public bool TryGetLinkedPlayer(out ushort Id)
121121
[System.NonSerialized]
122122
public SkinnedMeshRenderer[] SkinnedMeshRenderers;
123123

124+
[System.NonSerialized]
125+
public BasisAuthoredMotion[] AuthoredMotions;
126+
124127
/// <summary>
125128
/// Humanoid bone transforms captured at build time, indexed by HumanBodyBones, so
126129
/// runtime calibration can skip the per-bone Animator.GetBoneTransform lookups.

Basis/Packages/com.basis.sdk/Scripts/Basis Components/BasisContentHarvest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public sealed class BasisContentHarvest
7272
public BasisComponentKind[] Kinds;
7373
public List<Renderer> Renderers;
7474
public List<SkinnedMeshRenderer> SkinnedMeshRenderers;
75+
public List<BasisAuthoredMotion> AuthoredMotions;
7576

7677
/// <summary>
7778
/// Maps a component to its <see cref="BasisComponentKind"/>. Single source of truth for the
@@ -149,6 +150,7 @@ public static BasisContentHarvest BuildFrom(GameObject root, bool includeInactiv
149150
Kinds = new BasisComponentKind[count],
150151
Renderers = new List<Renderer>(),
151152
SkinnedMeshRenderers = new List<SkinnedMeshRenderer>(),
153+
AuthoredMotions = new List<BasisAuthoredMotion>(),
152154
};
153155
for (int i = 0; i < count; i++)
154156
{
@@ -162,6 +164,10 @@ public static BasisContentHarvest BuildFrom(GameObject root, bool includeInactiv
162164
harvest.SkinnedMeshRenderers.Add(skinned);
163165
}
164166
}
167+
if (component is BasisAuthoredMotion authored)
168+
{
169+
harvest.AuthoredMotions.Add(authored);
170+
}
165171
}
166172
return harvest;
167173
}

Basis/Packages/com.basis.sdk/Scripts/Content Police/ContentPoliceControl.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public static GameObject ContentControl(GameObject DisabledGameobject, GameObjec
4949
// so shader prewarm runs without paying for a second GetComponentsInChildren.
5050
List<Renderer> renderersForPrewarm = new List<Renderer>();
5151
List<SkinnedMeshRenderer> skinnedForHarvest = harvest != null ? new List<SkinnedMeshRenderer>() : null;
52+
List<BasisAuthoredMotion> authoredForHarvest = harvest != null ? new List<BasisAuthoredMotion>() : null;
5253
BasisComponentKind[] kinds = harvest != null ? new BasisComponentKind[count] : null;
5354

5455
// BasisHeadChop is harvested during this walk so the local avatar driver
@@ -77,6 +78,9 @@ public static GameObject ContentControl(GameObject DisabledGameobject, GameObjec
7778
GameObject.DestroyImmediate(headChop);
7879
if (kinds != null) kinds[Index] = BasisComponentKind.Removed;
7980
break;
81+
case BasisAuthoredMotion authoredMotion:
82+
authoredForHarvest?.Add(authoredMotion);
83+
break;
8084
case Animator animator:
8185
// AnimationEvents dispatch via SendMessage(methodName, arg),
8286
// which invokes any method of that name on any component on
@@ -172,6 +176,7 @@ public static GameObject ContentControl(GameObject DisabledGameobject, GameObjec
172176
harvest.Kinds = kinds;
173177
harvest.Renderers = renderersForPrewarm;
174178
harvest.SkinnedMeshRenderers = skinnedForHarvest;
179+
harvest.AuthoredMotions = authoredForHarvest;
175180
}
176181

177182
if (MaterialCorrectionEnabled)

Basis/Packages/dev.hai-vr.basis.comms/Scripts/Systems/Runtime/Vixxy/Internal/HVR_VixxyPermitted.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public static class HVR_VixxyPermitted
1818
typeof(GameObject),
1919
typeof(ParticleSystem),
2020
typeof(Cloth),
21+
// Authored motion
22+
typeof(BasisAuthoredMotion),
2123
// Renderers
2224
typeof(MeshRenderer), // NOTE: MeshRenderer and SkinnedMeshRenderer have hard-coded leniency on material properties. If a property recursively affects a SkinnedMeshRenderer, then it will also affect a MeshRenderer.
2325
typeof(SkinnedMeshRenderer),
@@ -53,8 +55,6 @@ public static class HVR_VixxyPermitted
5355
"UnityEngine.Rendering.Universal.DecalProjector",
5456
// Jiggle
5557
"GatorDragonGames.JigglePhysics.JiggleRig",
56-
// Authored motion (toggle the component's enabled state per movement group)
57-
"BasisAuthoredMotion",
5858
// UI
5959
"TMPro.TextMeshPro",
6060
"TMPro.TextMeshProUGUI",

0 commit comments

Comments
 (0)