예제 #1
0
        public void Process(ProcessMode processMode, AnimationClip prioritize, EePreviewAvatar previewSetup)
        {
            var clipDictionary    = GatherAnimations(processMode);
            var animationPreviews = ToPrioritizedList(clipDictionary, prioritize);

            _eeRenderingCommands.GenerateSpecific(animationPreviews, previewSetup);
        }
        public Action GenerateSpecificFastMode(
            List <EeRenderingSample> animationsPreviews,
            EePreviewAvatar previewSetup,
            int cameraIndex,
            EeDummyAutoHide autoHide = EeDummyAutoHide.Default,
            EePriority priority      = EePriority.Normal)
        {
            List <EeRenderingJob> jobs = new List <EeRenderingJob>();

            for (int startIndex = 0; startIndex < animationsPreviews.Count; startIndex += 15)
            {
                var finalIndex = startIndex;
                var job        = new EeRenderingJob(previewSetup, cameraIndex, animationsPreviews.GetRange(finalIndex, Math.Min(15, animationsPreviews.Count - finalIndex)), false, OnQueueTaskComplete, autoHide);
                jobs.Add(job);
                _priorityQueues[priority].Add(() => job.Capture());
            }
            WakeQueue();

            // FIXME: Obscure drop callback
            return(() =>
            {
                foreach (var job in jobs)
                {
                    job.Drop();
                }
            });
        }
        private void RenderEditables(EePreviewAvatar dummy)
        {
            if (_state.EditableBlendshapes.Count == 0)
            {
                return;
            }
            if (_state.Maintain && _state.ScenePreviewMode == EeAnimationEditorScenePreviewMode.Never)
            {
                return;
            }

            _renderingCommands.GenerateSpecificFastMode(
                _state.EditableBlendshapes.Select(current =>
                                                  new EeRenderingSample(
                                                      CreateAnimationClipForBinding(_state.CurrentClip, current.Binding),
                                                      BufferTexture2D(),
                                                      preview =>
            {
                EnsureBasedInitialized();
                EeRenderingSupport.MutateMultilevelHighlightDifferences(current.BoundaryTexture, preview.RenderTexture, BasedTexture(current.Property));
                EeAnimationEditorWindow.Obtain().Repaint();
            }
                                                      )).ToList(),
                dummy,
                _state.CameraIndex
                );
        }
        private void RenderMain(EePreviewAvatar dummy)
        {
            EnsureActivePreviewInitialized();
            var clipBeingGenerated = _state.CurrentClip;

            _renderingCommands.GenerateSpecificFastMode(
                new List <EeRenderingSample> {
                new EeRenderingSample(AnimationUtility.GetCurveBindings(clipBeingGenerated).Length == 0 ? NothingClip() : clipBeingGenerated, _bufferActive, preview =>
                {
                    _state.ActivePreview.SetPixels(preview.RenderTexture.GetPixels());
                    _state.ActivePreview.Apply();
                    EeAnimationEditorWindow.Obtain().Repaint();

                    Ee.Get().Hooks.PushOnMainRendered(new EeHookOnMainRendered
                    {
                        Clip          = clipBeingGenerated,
                        OutputTexture = preview.RenderTexture
                    });
                })
            },
                dummy,
                _state.CameraIndex,
                EeRenderingCommands.EeDummyAutoHide.Default,
                EeRenderingCommands.EePriority.High
                );
        }
        private void RenderBased(EePreviewAvatar dummy)
        {
            EnsureBasedInitialized();

            var smr = dummy.TempCxSmr;

            _renderingCommands.GenerateSpecificFastMode(
                new List <EeRenderingSample>
            {
                new EeRenderingSample(NothingClip(), BufferTexture2D(), preview =>
                {
                    _based.SetPixels(preview.RenderTexture.GetPixels());
                    _based.Apply();
                })
            }.Concat(_basedOnSomething.Select(basedToTexture => new EeRenderingSample(BlendShapeClip(new EditorCurveBinding()
            {
                path         = ResolveRelativePath(dummy.Dummy.transform, smr.transform),
                propertyName = basedToTexture.Key,
                type         = typeof(SkinnedMeshRenderer)
            }), BufferTexture2D(),
                                                                                      preview =>
            {
                basedToTexture.Value.SetPixels(preview.RenderTexture.GetPixels());
                basedToTexture.Value.Apply();
            }))).ToList(),
                dummy,
                _state.CameraIndex
                );
        }
 private void Maintain(EePreviewAvatar dummy)
 {
     dummy.Dummy.gameObject.SetActive(true);
     AnimationMode.StartAnimationMode();
     AnimationMode.BeginSampling();
     AnimationMode.SampleAnimationClip(dummy.Dummy.gameObject, _state.CurrentClip, 1 / 60f);
     AnimationMode.EndSampling();
 }
 public void GenerateSpecific(
     List <EeRenderingSample> animationsPreviews,
     EePreviewAvatar previewSetup,
     EeDummyAutoHide autoHide = EeDummyAutoHide.Default,
     EePriority priority      = EePriority.Normal)
 {
     _priorityQueues[priority].Add(() => new EeRenderingJob(previewSetup, 0, animationsPreviews, true, OnQueueTaskComplete, autoHide).Capture());
     WakeQueue();
 }
 public EeRenderingJob(EePreviewAvatar previewSetup, int cameraIndex, List <EeRenderingSample> renderingSamples, bool includeTransformsMode, Action onQueueTaskComplete = null, EeRenderingCommands.EeDummyAutoHide autoHide = EeRenderingCommands.EeDummyAutoHide.Default)
 {
     _previewSetup          = previewSetup;
     _cameraIndex           = cameraIndex;
     _renderingSamples      = renderingSamples;
     _includeTransformsMode = includeTransformsMode;
     _autoHide            = autoHide;
     _onQueueTaskComplete = onQueueTaskComplete ?? (() => {});
 }
        private void GeneratePreviewsFromCurrentClipForced(EePreviewAvatar dummy)
        {
            if (_state.CurrentClip == null)
            {
                return;
            }

            RenderMain(dummy);
            RenderBased(dummy);
            RenderEditables(dummy);
        }
        private void GeneratePreviewsFromCurrentClip(EePreviewAvatar dummy)
        {
            if (_state.CurrentClip == null)
            {
                return;
            }

            if (!_state.Maintain || _state.ScenePreviewMode != EeAnimationEditorScenePreviewMode.Never)
            {
                RenderMain(dummy);
                RenderBased(dummy);
            }
            RenderEditables(dummy);
        }
            private Transform MaybeTraversePathInDummy(string path, EePreviewAvatar dummy)
            {
                var pathing  = path.Split('/');
                var visiting = dummy.Dummy.transform;

                foreach (var subPath in pathing)
                {
                    visiting = visiting.Find(subPath);
                    if (visiting == null)
                    {
                        return(null);
                    }
                }

                return(visiting);
            }
 private Action RenderBlendshapes(EePreviewAvatar dummy, Func <EeExplorerBlendshape, bool> predicate)
 {
     return(_renderingCommands.GenerateSpecificFastMode(
                _state.ExplorerBlendshapes.Where(predicate).Select(info => new EeRenderingSample(
                                                                       CreateBlendShapeClipForBinding(info.Binding),
                                                                       BufferTexture2D(),
                                                                       preview =>
     {
         EnsureBasedInitialized();
         EeRenderingSupport.MutateHighlightHotspots(info.HotspotTexture, preview.RenderTexture, BasedTexture(info.Property));
         EeRenderingSupport.MutateMultilevelHighlightDifferences(info.BoundaryTexture, preview.RenderTexture, BasedTexture(info.Property));
         EePropertyExplorerWindow.Obtain().Repaint();
     }
                                                                       )).ToList(),
                dummy,
                _state.CameraIndex,
                EeRenderingCommands.EeDummyAutoHide.Default,
                EeRenderingCommands.EePriority.Low
                ));
 }
 private void GeneratePreviewsFromSubjectNamesAssignments(EePreviewAvatar dummy, List <string> subjects)
 {
     RenderBased(dummy);
     RenderBlendshapes(dummy, info => subjects.Contains(info.Property));
 }
 private void GeneratePreviewsFromPropertyExplorer(EePreviewAvatar dummy)
 {
     _generatePreviewsFromPropertyExplorerDropPrevious?.Invoke();
     RenderBased(dummy);
     _generatePreviewsFromPropertyExplorerDropPrevious = RenderBlendshapes(dummy, info => true);
 }