/// <summary> /// Update cached transforms based on the owning game thing and /// any controlling bones. /// </summary> public virtual void UpdateTransforms() { Matrix rootToWorld = Owner != null ? Owner.Movement.LocalMatrix : Matrix.Identity; Matrix worldToRoot = Matrix.Invert(rootToWorld); if (parentBone != null) { Matrix localToRoot = animator != null ? animator.LocalToWorld(parentBone.Index) : parentBone.Transform; if (Owner != null) { localToRoot = localToRoot * Matrix.CreateScale(Owner.ReScale); } Matrix rootToLocal = Matrix.Invert(localToRoot); LocalToWorld = localToRoot * rootToWorld; WorldToLocal = worldToRoot * rootToLocal; worldToLocalRadius = WorldToLocal.Right.Length(); } else { if (Owner != null) { LocalToWorld = Matrix.CreateScale(Owner.ReScale) * rootToWorld; WorldToLocal = worldToRoot * Matrix.CreateScale(1.0f / Owner.ReScale); worldToLocalRadius = WorldToLocal.Right.Length(); } else { LocalToWorld = rootToWorld; WorldToLocal = worldToRoot; } } worldSphere.Radius = localSphere.Radius / worldToLocalRadius; worldSphere.Center = Vector3.Transform(localSphere.Center, LocalToWorld); }