Esempio n. 1
0
        void CheckFrameTicking()
        {
            if (Time.frameCount != lastFrameCount)
            {
                framePassed              = true;
                lastFrameCount           = Time.frameCount;
                previousFrameRedrawScope = gizmos.frameRedrawScope;
                gizmos.frameRedrawScope  = new RedrawScope(gizmos);
                Draw.builder.Dispose();
                Draw.builder = gizmos.GetBuilder();
            }
            else if (framePassed && Application.isPlaying)
            {
                // Rendered frame passed without a game frame passing!
                // This might mean the game is paused.
                // Redraw gizmos while the game is paused.
                // It might also just mean that we are rendering with multiple cameras.
                previousFrameRedrawScope.Draw();
            }

            if (framePassed)
            {
                gizmos.TickFrame();
                builtGizmos = false;
                framePassed = false;
            }
        }
Esempio n. 2
0
            public void Init(Hasher hasher, RedrawScope frameRedrawScope, RedrawScope customRedrawScope, bool isGizmos)
            {
                if (state != State.Reserved)
                {
                    throw new System.InvalidOperationException();
                }

                meta = new Meta {
                    hasher       = hasher,
                    redrawScope1 = frameRedrawScope,
                    redrawScope2 = customRedrawScope,
                    isGizmos     = isGizmos,
                    version      = 0,                // Will be filled in later
                };

                if (meshes == null)
                {
                    meshes = new List <Mesh>();
                }
                if (!commandBuffers.IsCreated)
                {
                    commandBuffers = new NativeArray <UnsafeAppendBuffer>(JobsUtility.MaxJobThreadCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
                    for (int i = 0; i < commandBuffers.Length; i++)
                    {
                        commandBuffers[i] = new UnsafeAppendBuffer(0, 4, Allocator.Persistent);
                    }
                }

                state = State.Initialized;
            }
Esempio n. 3
0
            public bool SetCustomScope(Hasher hasher, RedrawScope scope)
            {
                if (data == null)
                {
                    return(false);
                }
                bool found = false;

                for (int i = 0; i < data.Length; i++)
                {
                    if (data[i].isValid && data[i].meta.hasher.Hash == hasher.Hash)
                    {
                        data[i].meta.redrawScope2 = scope;
                        found = true;
                    }
                }
                return(found);
            }
Esempio n. 4
0
            public bool SetVersion(RedrawScope scope, int version)
            {
                if (data == null)
                {
                    return(false);
                }
                bool found = false;

                for (int i = 0; i < data.Length; i++)
                {
                    if (data[i].isValid && (data[i].meta.redrawScope1.id == scope.id || data[i].meta.redrawScope2.id == scope.id))
                    {
                        data[i].meta.version = version;
                        found = true;
                    }
                }
                return(found);
            }
Esempio n. 5
0
 /// <summary>
 /// Get an empty builder for queuing drawing commands.
 /// TODO: Example usage.
 ///
 /// See: <see cref="Drawing.CommandBuilder"/>
 /// </summary>
 /// <param name="hasher">Hash of whatever inputs you used to generate the drawing data.</param>
 /// <param name="redrawScope">Scope for this command builder. See #GetRedrawScope.</param>
 /// <param name="renderInGame">If true, this builder will be rendered in standalone games and in the editor even if gizmos are disabled.</param>
 public static CommandBuilder GetBuilder(DrawingData.Hasher hasher, RedrawScope redrawScope = default, bool renderInGame = false)
 {
     return(instance.gizmos.GetBuilder(hasher, redrawScope, renderInGame));
 }
Esempio n. 6
0
 /// <summary>
 /// Get an empty builder for queuing drawing commands.
 ///
 /// See: <see cref="Drawing.CommandBuilder"/>
 /// </summary>
 /// <param name="redrawScope">Scope for this command builder. See #GetRedrawScope.</param>
 /// <param name="renderInGame">If true, this builder will be rendered in standalone games and in the editor even if gizmos are disabled.
 /// If false, it will only be rendered in the editor when gizmos are enabled.</param>
 public static CommandBuilder GetBuilder(RedrawScope redrawScope, bool renderInGame = false)
 {
     return(instance.gizmos.GetBuilder(redrawScope, renderInGame));
 }