public static LightPatch GeneratePatch(MRELight _old, UnityLight _new)
        {
            if (_old == null && _new != null)
            {
                return(new LightPatch(_new));
            }
            else if (_new == null)
            {
                return(null);
            }

            var patch = new LightPatch()
            {
                Enabled   = _new.enabled,
                Type      = UtilMethods.ConvertEnum <Core.Interfaces.LightType, UnityEngine.LightType>(_new.type),
                Color     = new ColorPatch(_new.color),
                Range     = _new.range,
                Intensity = _new.intensity,
                SpotAngle = _new.spotAngle
            };

            if (patch.IsPatched())
            {
                return(patch);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
 internal LightPatch(UnityEngine.Light light)
 {
     Enabled   = light.enabled;
     Type      = UtilMethods.ConvertEnum <LightType, UnityEngine.LightType>(light.type);
     Color     = new ColorPatch(light.color);
     Range     = light.range;
     Intensity = light.intensity;
     SpotAngle = light.spotAngle;
 }
Beispiel #3
0
        public static RigidBodyPatch GeneratePatch(RigidBody _old, Rigidbody _new,
                                                   Transform sceneRoot, bool addVelocities)
        {
            if (_old == null && _new != null)
            {
                return(new RigidBodyPatch(_new, sceneRoot));
            }
            else if (_new == null)
            {
                return(null);
            }

            var patch = new RigidBodyPatch()
            {
                // Do not include Position or Rotation in the patch.

                // we add velocities only if there is an explicit subscription for it, since it might cause significant bandwidth
                Velocity = ((addVelocities) ?
                            GeneratePatch(_old.Velocity, sceneRoot.InverseTransformDirection(_new.velocity)) : null),
                AngularVelocity = ((addVelocities) ?
                                   GeneratePatch(_old.AngularVelocity, sceneRoot.InverseTransformDirection(_new.angularVelocity)) : null),

                CollisionDetectionMode = GeneratePatch(
                    _old.CollisionDetectionMode,
                    UtilMethods.ConvertEnum <MRECollisionDetectionMode, UnityCollisionDetectionMode>(_new.collisionDetectionMode)),
                ConstraintFlags = GeneratePatch(
                    _old.ConstraintFlags,
                    UtilMethods.ConvertEnum <MRERigidBodyConstraints, UnityRigidBodyConstraints>(_new.constraints)),
                DetectCollisions = GeneratePatch(_old.DetectCollisions, _new.detectCollisions),
                Mass             = GeneratePatch(_old.Mass, _new.mass),
                UseGravity       = GeneratePatch(_old.UseGravity, _new.useGravity),
            };

            if (patch.IsPatched())
            {
                return(patch);
            }
            else
            {
                return(null);
            }
        }
        public static RigidBodyPatch GeneratePatch(RigidBody _old, Rigidbody _new, Transform sceneRoot)
        {
            if (_old == null && _new != null)
            {
                return(new RigidBodyPatch(_new, sceneRoot));
            }
            else if (_new == null)
            {
                return(null);
            }

            var patch = new RigidBodyPatch()
            {
                // Do not include Position or Rotation in the patch.
                Velocity               = GeneratePatch(_old.Velocity, sceneRoot.InverseTransformDirection(_new.velocity)),
                AngularVelocity        = GeneratePatch(_old.AngularVelocity, sceneRoot.InverseTransformDirection(_new.angularVelocity)),
                CollisionDetectionMode = GeneratePatch(
                    _old.CollisionDetectionMode,
                    UtilMethods.ConvertEnum <MRECollisionDetectionMode, UnityCollisionDetectionMode>(_new.collisionDetectionMode)),
                ConstraintFlags = GeneratePatch(
                    _old.ConstraintFlags,
                    UtilMethods.ConvertEnum <MRERigidBodyConstraints, UnityRigidBodyConstraints>(_new.constraints)),
                DetectCollisions = GeneratePatch(_old.DetectCollisions, _new.detectCollisions),
                Mass             = GeneratePatch(_old.Mass, _new.mass),
                UseGravity       = GeneratePatch(_old.UseGravity, _new.useGravity),
            };

            if (patch.IsPatched())
            {
                return(patch);
            }
            else
            {
                return(null);
            }
        }