protected override void OnDestroy() { base.OnDestroy(); try { if (this.m_scheduler != null) { this.m_scheduler.ShutingDown = true; this.m_scheduler.CancelAllTasks(); } if (this.m_conditionCache != null) { foreach (WaveSpectrumCondition current in this.m_conditionCache) { current.Release(); } this.m_conditionCache.Clear(); this.m_conditionCache = null; } this.Release(); } catch (Exception ex) { Ocean.LogError(ex.ToString()); base.WasError = true; base.enabled = false; } }
private void Awake() { m_tileStorage = GetComponents <TileStorage>(); m_producers = new Dictionary <int, TileProducer>(); m_usedTiles = new Dictionary <TId, Tile>(EqualityComparerTID.Instance); m_unusedTiles = new DictionaryQueue <TId, Tile>(EqualityComparerTID.Instance); }
void Awake() { TileStorage = GetComponents <TileStorage>(); Producers = new Dictionary <int, TileProducer>(); UsedTiles = new Dictionary <Tile.TId, Tile>(new Tile.EqualityComparerTID()); UnusedTiles = new DictionaryQueue <Tile.TId, Tile>(new Tile.EqualityComparerTID()); }
private void Start() { try { Shader.SetGlobalTexture("Ceto_SlopeMap0", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_SlopeMap1", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_DisplacementMap0", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_DisplacementMap1", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_DisplacementMap2", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_DisplacementMap3", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_FoamMap0", Texture2D.blackTexture); this.m_slopeCopyMat = new Material(this.slopeCopySdr); this.m_displacementCopyMat = new Material(this.displacementCopySdr); this.m_foamCopyMat = new Material(this.foamCopySdr); this.m_slopeInitMat = new Material(this.initSlopeSdr); this.m_displacementInitMat = new Material(this.initDisplacementSdr); this.m_foamInitMat = new Material(this.initJacobianSdr); this.m_conditionCache = new DictionaryQueue <WaveSpectrumConditionKey, WaveSpectrumCondition>(); this.m_scheduler = new Scheduler(); this.CreateBuffers(); this.CreateRenderTextures(); this.CreateConditions(); this.UpdateQueryScaling(); } catch (Exception ex) { Ocean.LogError(ex.ToString()); base.WasError = true; base.enabled = false; } }
public override void InitNode() { TileStorage = GetComponents <TileStorage>(); Producers = new Dictionary <int, TileProducer>(); UsedTiles = new Dictionary <Tile.TId, Tile>(new Tile.EqualityComparerTID()); UnusedTiles = new DictionaryQueue <Tile.TId, Tile>(new Tile.EqualityComparerTID()); TileTIDBuffer = new Tile.TId(-1, -1, 0, 0); }
public TileCache(int width, int height, int tileSize, int channels, int capacity = 20) { Width = width; Height = height; TileSize = tileSize; Channels = Mathf.Clamp(channels, 1, 4); Capacity = capacity; Cache = new DictionaryQueue <int, Tile>(); }
public override void InitNode() { base.InitNode(); OldLocalCamera = Vector3d.zero; NeedsReadBackDictionary = new Dictionary <Tile.Id, QuadTreeZ>(new Tile.EqualityComparerID()); ElevationsDicionary = new DictionaryQueue <Tile.Id, ElevationInfo>(new Tile.EqualityComparerID()); var size = Producer.GetTileSize(0); ElevationsBuffer = new ComputeBuffer(size * size, sizeof(float)); GroundBuffer = new ComputeBuffer(1, 4 * sizeof(float)); }
public override void Start() { base.Start(); m_oldLocalCamera = Vector3d2.Zero(); m_needReadBack = new Dictionary <Tile.Id, QuadTreeZ>(new Tile.EqualityComparerID()); m_elevations = new DictionaryQueue <Tile.Id, ElevationInfo>(new Tile.EqualityComparerID()); int size = GetProducer().GetTileSize(0); m_elevationsBuffer = new ComputeBuffer(size * size, sizeof(float)); m_groundBuffer = new ComputeBuffer(1, sizeof(float)); }
protected virtual void Start() { if (TileSize <= 0) { throw new InvalidParameterException("Tile size must be greater than 0!"); } if (Width % TileSize != 0) { throw new InvalidParameterException("Tile size must be divisable by width!"); } if (Height % TileSize != 0) { throw new InvalidParameterException("Tile size must be divisable by height!"); } Cache = new DictionaryQueue <Id, Tile>(new EqualityComparerID()); }
public PackedSprite(int spriteSize, bool halfPrecision = false, int width = 1024, int height = 1024) { TextureFormat format; if (halfPrecision && SystemInfo.SupportsTextureFormat(TextureFormat.RGBA4444)) { format = TextureFormat.RGBA4444; } else { format = TextureFormat.RGBA32; } m_packTexture = new Texture2D(width, height, format, false) { wrapMode = TextureWrapMode.Clamp, filterMode = FilterMode.Bilinear, name = $"Packed Sprite Texture : {spriteSize}" }; m_spriteSize = spriteSize; var sizeWithPadding = spriteSize + DEFAULT_PADDING; var columnCount = width / sizeWithPadding; var rowCount = height / sizeWithPadding; var totalCount = columnCount * rowCount; m_notInUsed = new List <SpriteElement>(totalCount); m_freeList = new DictionaryQueue <string, SpriteElement>(totalCount); m_inUsed = new Dictionary <string, SpriteElement>(totalCount); for (int i = 0; i < totalCount; i++) { var x = i % columnCount; var y = i / columnCount; var rect = new Rect(sizeWithPadding * x, sizeWithPadding * y, spriteSize, spriteSize); m_notInUsed.Add(new SpriteElement(this) { Sprite = Sprite.Create(m_packTexture, rect, Vector2.one * 0.5f, 100, 1, SpriteMeshType.Tight) }); } }
protected virtual void Awake() { if (TileSize.x <= 0 || TileSize.y <= 0) { throw new InvalidParameterException("Tile size must be greater than 0!"); } if (!IgnoreSizeRatio) { if (Width % (int)TileSize.x != 0) { throw new InvalidParameterException(string.Format("Tile size must be divisable by width! W:{0}; S:{1}; W%S:{2}", Width, TileSize, Width % TileSize.x)); } if (Height % (int)TileSize.y != 0) { throw new InvalidParameterException(string.Format("Tile size must be divisable by height! H:{0}; S:{1}; H%S:{2}", Height, TileSize, Height % TileSize.y)); } } Cache = new DictionaryQueue <Id, Tile>(new EqualityComparerID()); }
private float[] GetTile(int tx, int ty) { var key = new Id(tx, ty); // TODO : Cache initialization... if (Cache == null) { Cache = new DictionaryQueue <Id, Tile>(new EqualityComparerID()); } if (!Cache.ContainsKey(key)) { var data = GetValues(tx * (int)TileSize.x, ty * (int)TileSize.y); if (Cache.Count() == Capacity) { // Evict least recently used tile if cache is full Cache.RemoveFirst(); } // Create tile, put it at the end of tileCache var tile = new Tile(tx, ty, data); Cache.AddLast(key, tile); return(data); } else { var tile = Cache.Get(key); Cache.Remove(key); Cache.AddLast(key, tile); return(tile.Data); } }
/// <summary> /// BOT初期化 /// * 設定読み込み /// * タイマー設定 /// </summary> /// <param name="output">ログ出力先</param> public KamatteBot(logOutput output = null) { LogOutput = output; Settings = Properties.Settings.Default.Kamatte; if (Settings == null) { Settings = new KamatteSettings(); Settings.WaitTime = 5; Settings.GlobalFilter = ""; Settings.Targets = new List<TargetUser>(); var t = new TargetUser(); t.Id = 0; t.Name = "null"; t.Filter = "*"; Settings.Targets.Add(t); } Log(Settings.ToString()); watchingList = new DictionaryQueue<decimal, TwitterStatus>(); /* Set timer */ countClearTimer = TimerUtil.DailyTimer(CountClearTask); }
void Awake() { m_tileStorage = GetComponents<TileStorage>(); m_producers = new Dictionary<int, TileProducer>(); m_usedTiles = new Dictionary<Tile.TId, Tile>(new Tile.EqualityComparerTID()); m_unusedTiles = new DictionaryQueue<Tile.TId, Tile>(new Tile.EqualityComparerTID()); }
protected override void OnDestroy() { base.OnDestroy(); try { if (m_scheduler != null) { m_scheduler.ShutingDown = true; m_scheduler.CancelAllTasks(); } //Clear the cache before releasing other resources. if(m_conditionCache != null) { //Release all conditions and mark cache as null //so current conditions are not cached. foreach(var condition in m_conditionCache) condition.Release(); m_conditionCache.Clear(); m_conditionCache = null; } Release(); } catch(Exception e) { Ocean.LogError(e.ToString()); WasError = true; enabled = false; } }
void Start() { try { //Zero all textures Shader.SetGlobalTexture("Ceto_SlopeMap0", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_SlopeMap1", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_DisplacementMap0", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_DisplacementMap1", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_DisplacementMap2", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_DisplacementMap3", Texture2D.blackTexture); Shader.SetGlobalTexture("Ceto_FoamMap0", Texture2D.blackTexture); m_slopeCopyMat = new Material(slopeCopySdr); m_displacementCopyMat = new Material(displacementCopySdr); m_foamCopyMat = new Material(foamCopySdr); m_slopeInitMat = new Material(initSlopeSdr); m_displacementInitMat = new Material(initDisplacementSdr); m_foamInitMat = new Material(initJacobianSdr); m_conditionCache = new DictionaryQueue<WaveSpectrumConditionKey, WaveSpectrumCondition>(); m_scheduler = new Scheduler(); CreateBuffers(); CreateRenderTextures(); CreateConditions(); UpdateQueryScaling(); } catch(Exception e) { Ocean.LogError(e.ToString()); WasError = true; enabled = false; } }
public override void Start () { base.Start(); m_oldLocalCamera = Vector3d2.Zero(); m_needReadBack = new Dictionary<Tile.Id, QuadTreeZ>(new Tile.EqualityComparerID()); m_elevations = new DictionaryQueue<Tile.Id, ElevationInfo>(new Tile.EqualityComparerID()); int size = GetProducer().GetTileSize(0); m_elevationsBuffer = new ComputeBuffer(size*size, sizeof(float)); m_groundBuffer = new ComputeBuffer(1, sizeof(float)); }