Ejemplo n.º 1
0
    internal void RegisterCamera(AmplifyMotionCamera camera)
    {
        Camera actual = camera.GetComponent <Camera>();

        if ((actual.cullingMask & (1 << gameObject.layer)) != 0 && !m_states.ContainsKey(actual))
        {
            AmplifyMotion.MotionState state = null;
            switch (m_type)
            {
            case AmplifyMotion.ObjectType.Solid:
                state = new AmplifyMotion.SolidState(camera, this); break;

            case AmplifyMotion.ObjectType.Skinned:
                state = new AmplifyMotion.SkinnedState(camera, this); break;

            case AmplifyMotion.ObjectType.Cloth:
                state = new AmplifyMotion.ClothState(camera, this); break;

                        #if !UNITY_PRE_5_3
            case AmplifyMotion.ObjectType.Particle:
                state = new AmplifyMotion.ParticleState(camera, this); break;
                        #endif
            default:
                throw new Exception("[AmplifyMotion] Invalid object type.");
            }

            camera.RegisterObject(this);

            m_states.Add(actual, state);
        }
    }
 internal void OnRenderVectors(Camera camera, float scale, AmplifyMotion.Quality quality)
 {
     AmplifyMotion.MotionState state = null;
     if (m_states.TryGetValue(Camera.current, out state))
     {
         if (!state.Error)
         {
             state.RenderVectors(camera, scale, quality);
         }
     }
 }
Ejemplo n.º 3
0
    void TryInitializeStates()
    {
        var enumerator = m_states.GetEnumerator();

        while (enumerator.MoveNext())
        {
            AmplifyMotion.MotionState state = enumerator.Current.Value;
            if (state.Owner.Initialized && !state.Error && !state.Initialized)
            {
                state.Initialize();
            }
        }
    }
Ejemplo n.º 4
0
        private static void AsyncUpdateThread(object obj)
        {
        #if !NETFX_CORE && !UNITY_WEBGL
            KeyValuePair <object, int> pair = (KeyValuePair <object, int>)obj;
            WorkerThreadPool           pool = ( WorkerThreadPool )pair.Key;
            int id = ( int )pair.Value;

            while (true)
            {
                try
                {
                    pool.m_threadPoolContinueSignals[id].WaitOne();

                    if (pool.m_threadPoolTerminateSignal.WaitOne(0))
                    {
                        break;
                    }

                    while (true)
                    {
                        MotionState state = null;

                        lock (pool.m_threadStateQueueLocks[id])
                        {
                            if (pool.m_threadStateQueues[id].Count > 0)
                            {
                                state = pool.m_threadStateQueues[id].Dequeue();
                            }
                        }

                        if (state != null)
                        {
                            state.AsyncUpdate();
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                catch (System.Exception e)
                {
                    if (e.GetType() != typeof(ThreadAbortException))
                    {
                        Debug.LogWarning(e);
                    }
                }
            }
        #endif
        }
Ejemplo n.º 5
0
        internal void EnqueueAsyncUpdate( MotionState state )
        {
            #if NETFX_CORE
            Task.Run( () => AsyncUpdateCallback( state ) );
            #else
            lock ( m_threadStateQueueLocks[ m_threadPoolIndex ] )
            {
            m_threadStateQueues[ m_threadPoolIndex ].Enqueue( state );
            }

            m_threadPoolContinueSignals[ m_threadPoolIndex ].Set();

            m_threadPoolIndex++;
            if ( m_threadPoolIndex >= m_threadPoolSize )
            m_threadPoolIndex = 0;
            #endif
        }
Ejemplo n.º 6
0
        private static void AsyncUpdateThread(object obj)
        {
            KeyValuePair <object, int> keyValuePair     = (KeyValuePair <object, int>)obj;
            WorkerThreadPool           workerThreadPool = (WorkerThreadPool)keyValuePair.Key;
            int value = keyValuePair.Value;

            for (;;)
            {
                try
                {
                    workerThreadPool.m_threadPoolContinueSignals[value].WaitOne();
                    if (!workerThreadPool.m_threadPoolTerminateSignal.WaitOne(0))
                    {
                        for (;;)
                        {
                            MotionState motionState = null;
                            object      obj2        = workerThreadPool.m_threadStateQueueLocks[value];
                            lock (obj2)
                            {
                                if (workerThreadPool.m_threadStateQueues[value].Count > 0)
                                {
                                    motionState = workerThreadPool.m_threadStateQueues[value].Dequeue();
                                }
                            }
                            if (motionState == null)
                            {
                                break;
                            }
                            motionState.AsyncUpdate();
                        }
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    if (ex.GetType() != typeof(ThreadAbortException))
                    {
                        Debug.LogWarning(ex);
                    }
                    continue;
                }
                break;
            }
        }
Ejemplo n.º 7
0
        // Token: 0x06001FBF RID: 8127 RVA: 0x00187634 File Offset: 0x00185834
        private void UpdateVerticesBone2()
        {
            Vector3 zero = Vector3.zero;

            for (int i = 0; i < this.m_vertexCount; i++)
            {
                int   num  = i * 2;
                int   num2 = num + 1;
                int   num3 = this.m_boneIndices[num];
                int   num4 = this.m_boneIndices[num2];
                float num5 = this.m_boneWeights[num2];
                MotionState.MulPoint3x4_XYZW(ref zero, ref this.m_bones[num3], this.m_baseVertices[num]);
                if (num5 != 0f)
                {
                    MotionState.MulAddPoint3x4_XYZW(ref zero, ref this.m_bones[num4], this.m_baseVertices[num2]);
                }
                this.m_currVertices[i] = zero;
            }
        }
Ejemplo n.º 8
0
        internal void EnqueueAsyncUpdate(MotionState state)
        {
        #if NETFX_CORE
            Task.Run(() => AsyncUpdateCallback(state));
        #else
            lock (m_threadStateQueueLocks[m_threadPoolIndex])
            {
                m_threadStateQueues[m_threadPoolIndex].Enqueue(state);
            }

            m_threadPoolContinueSignals[m_threadPoolIndex].Set();

            m_threadPoolIndex++;
            if (m_threadPoolIndex >= m_threadPoolSize)
            {
                m_threadPoolIndex = 0;
            }
        #endif
        }
Ejemplo n.º 9
0
 internal void EnqueueAsyncUpdate(MotionState state)
 {
     if (!this.m_threadPoolFallback)
     {
         object obj = this.m_threadStateQueueLocks[this.m_threadPoolIndex];
         lock (obj)
         {
             this.m_threadStateQueues[this.m_threadPoolIndex].Enqueue(state);
         }
         this.m_threadPoolContinueSignals[this.m_threadPoolIndex].Set();
         this.m_threadPoolIndex++;
         if (this.m_threadPoolIndex >= this.m_threadPoolSize)
         {
             this.m_threadPoolIndex = 0;
         }
     }
     else
     {
         ThreadPool.QueueUserWorkItem(new WaitCallback(WorkerThreadPool.AsyncUpdateCallback), state);
     }
 }
Ejemplo n.º 10
0
 internal void EnqueueAsyncUpdate(MotionState state)
 {
     if (!this.m_threadPoolFallback)
     {
         object obj = this.m_threadStateQueueLocks[this.m_threadPoolIndex];
         lock (obj)
         {
             this.m_threadStateQueues[this.m_threadPoolIndex].Enqueue(state);
         }
         this.m_threadPoolContinueSignals[this.m_threadPoolIndex].Set();
         this.m_threadPoolIndex++;
         if (this.m_threadPoolIndex >= this.m_threadPoolSize)
         {
             this.m_threadPoolIndex = 0;
         }
     }
     else
     {
         ThreadPool.QueueUserWorkItem(new WaitCallback(WorkerThreadPool.AsyncUpdateCallback), state);
     }
 }
Ejemplo n.º 11
0
 internal override void UpdateTransform(CommandBuffer updateCB, bool starting)
 {
     if (!this.m_initialized)
     {
         this.Initialize();
         return;
     }
     if (!starting && this.m_wasVisible)
     {
         this.m_prevLocalToWorld = this.m_currLocalToWorld;
     }
     this.m_currLocalToWorld = this.m_transform.localToWorldMatrix;
     this.m_moved            = true;
     if (!this.m_owner.Overlay)
     {
         this.m_moved = (starting || MotionState.MatrixChanged(this.m_currLocalToWorld, this.m_prevLocalToWorld));
     }
     if (starting || !this.m_wasVisible)
     {
         this.m_prevLocalToWorld = this.m_currLocalToWorld;
     }
     this.m_wasVisible = this.m_meshRenderer.isVisible;
 }
Ejemplo n.º 12
0
        private static void AsyncUpdateCallback(object obj)
        {
            MotionState motionState = (MotionState)obj;

            motionState.AsyncUpdate();
        }
Ejemplo n.º 13
0
 internal override void UpdateTransform(CommandBuffer updateCB, bool starting)
 {
     if (!this.m_initialized)
     {
         this.Initialize();
         return;
     }
     if (!starting && this.m_wasVisible)
     {
         this.m_prevLocalToWorld = this.m_currLocalToWorld;
     }
     this.m_moved = true;
     if (!this.m_owner.Overlay)
     {
         Vector3    position   = this.m_transform.position;
         Quaternion rotation   = this.m_transform.rotation;
         Vector3    lossyScale = this.m_transform.lossyScale;
         this.m_moved = (starting || MotionState.VectorChanged(position, this.m_lastPosition) || MotionState.RotationChanged(rotation, this.m_lastRotation) || MotionState.VectorChanged(lossyScale, this.m_lastScale));
         if (this.m_moved)
         {
             this.m_lastPosition = position;
             this.m_lastRotation = rotation;
             this.m_lastScale    = lossyScale;
         }
     }
     this.m_currLocalToWorld = this.m_transform.localToWorldMatrix;
     if (starting || !this.m_wasVisible)
     {
         this.m_prevLocalToWorld = this.m_currLocalToWorld;
     }
     this.m_wasVisible = this.m_meshRenderer.isVisible;
 }