Ejemplo n.º 1
0
        /// <summary>
        /// Revives instance without acquiring it.
        /// </summary>
        private void Revive()
        {
            // Return if already revived.
            if (IsRevived)
            {
                return;
            }


            // Return if no bytes are available.
            if (Bytes == null)
            {
                return;
            }


            // Allocate and initialize memory (returning if allocation failed).
            var memory = CubismMemory.AllocateUnmanaged(Bytes.Length, csmAlignofMoc);


            if (memory == IntPtr.Zero)
            {
                return;
            }


            CubismMemory.Write(Bytes, memory);


            // Try revive.
            UnmanagedMoc = csmReviveMocInPlace(memory, (uint)Bytes.Length);
        }
        /// <summary>
        /// Initializes instance.
        /// </summary>
        /// <param name="moc">Moc unmanaged model was instantiated from.</param>
        public CubismTaskableModel(CubismMoc moc)
        {
            Moc = moc;


            // Allocate unmanaged memory and instantiate unmanaged model.
            var unmanagedMoc = moc.AcquireUnmanagedMoc();
            var size         = csmGetSizeofModel(unmanagedMoc);
            var memory       = CubismMemory.AllocateUnmanaged((int)size, csmAlignofModel);


            UnmanagedModel = csmInitializeModelInPlace(unmanagedMoc, memory, size);


            Lock  = new object();
            State = TaskState.Idle;
            DynamicDrawableData    = CubismDynamicDrawableData.CreateData(UnmanagedModel);
            ShouldReleaseUnmanaged = false;
        }