Exemple #1
0
        public static ScaledTransformPatch GenerateLocalTransformPatch(MWScaledTransform _old, Transform _new)
        {
            if (_old == null && _new != null)
            {
                return(new ScaledTransformPatch()
                {
                    Position = GeneratePatch(null, _new.localPosition),
                    Rotation = GeneratePatch(null, _new.localRotation),
                    Scale = GeneratePatch(null, _new.localScale)
                });
            }
            else if (_new == null)
            {
                return(null);
            }

            ScaledTransformPatch transform = new ScaledTransformPatch()
            {
                Position = GeneratePatch(_old.Position, _new.localPosition),
                Rotation = GeneratePatch(_old.Rotation, _new.localRotation),
                Scale    = GeneratePatch(_old.Scale, _new.localScale)
            };

            return(transform.IsPatched() ? transform : null);
        }
Exemple #2
0
        public static ScaledTransformPatch GenerateLocalTransformPatch(MWScaledTransform _old, Spatial _new)
        {
            if (_old == null && _new != null)
            {
                return(new ScaledTransformPatch()
                {
                    Position = GeneratePatch(null, _new.Transform.origin),
                    Rotation = GeneratePatch(null, new Quat(_new.Transform.basis)),
                    Scale = GeneratePatch(null, _new.Scale)
                });
            }
            else if (_new == null)
            {
                return(null);
            }

            ScaledTransformPatch transform = new ScaledTransformPatch()
            {
                Position = GeneratePatch(_old.Position, _new.Transform.origin),
                Rotation = GeneratePatch(_old.Rotation, new Quat(_new.Transform.basis)),
                Scale    = GeneratePatch(_old.Scale, _new.Scale)
            };

            return(transform.IsPatched() ? transform : null);
        }
Exemple #3
0
        public static void ApplyLocalPatch(this Transform _this, MWScaledTransform current, ScaledTransformPatch patch)
        {
            if (patch.Position != null)
            {
                _this.localPosition = _this.localPosition.GetPatchApplied(current.Position.ApplyPatch(patch.Position));
            }

            if (patch.Rotation != null)
            {
                _this.localRotation = _this.localRotation.GetPatchApplied(current.Rotation.ApplyPatch(patch.Rotation));
            }

            if (patch.Scale != null)
            {
                _this.localScale = _this.localScale.GetPatchApplied(current.Scale.ApplyPatch(patch.Scale));
            }
        }