public override void InitNode() { base.InitNode(); if (ElevationProducerGameObject != null) { if (ElevationProducer == null) { ElevationProducer = ElevationProducerGameObject.GetComponent <TileProducer>(); } } var tileSize = Cache.GetStorage(0).TileSize; var elevationTileSize = ElevationProducer.Cache.GetStorage(0).TileSize; if (tileSize != elevationTileSize) { throw new InvalidParameterException("Tile size must equal elevation tile size" + string.Format(": {0}-{1}", tileSize, elevationTileSize)); } if (GetBorder() != ElevationProducer.GetBorder()) { throw new InvalidParameterException("Border size must be equal to elevation border size"); } if (!(Cache.GetStorage(0) is GPUTileStorage)) { throw new InvalidStorageException("Storage must be a GPUTileStorage"); } }
protected override void Start() { base.Start(); if (TerrainNode == null) { TerrainNode = transform.parent.GetComponent <TerrainNode>(); } if (TerrainNode.ParentBody == null) { TerrainNode.ParentBody = transform.parent.GetComponentInParent <Body>(); } if (NormalsProducer == null) { NormalsProducer = NormalsProducerGameObject.GetComponent <TileProducer>(); } if (NormalsProducer.Cache == null) { NormalsProducer.InitCache(); } if (ElevationProducer == null) { ElevationProducer = ElevationProducerGameObject.GetComponent <TileProducer>(); } if (ElevationProducer.Cache == null) { ElevationProducer.InitCache(); } var tileSize = Cache.GetStorage(0).TileSize; var normalsTileSize = NormalsProducer.Cache.GetStorage(0).TileSize; var elevationTileSize = ElevationProducer.Cache.GetStorage(0).TileSize; if (tileSize != normalsTileSize) { throw new InvalidParameterException("Tile size must equal normals tile size" + string.Format(": {0}-{1}", tileSize, normalsTileSize)); } if (tileSize != elevationTileSize) { throw new InvalidParameterException("Tile size must equal elevation tile size" + string.Format(": {0}-{1}", tileSize, elevationTileSize)); } if (GetBorder() != NormalsProducer.GetBorder()) { throw new InvalidParameterException("Border size must be equal to normals border size"); } if (GetBorder() != ElevationProducer.GetBorder()) { throw new InvalidParameterException("Border size must be equal to elevation border size"); } if (!(Cache.GetStorage(0) is GPUTileStorage)) { throw new InvalidStorageException("Storage must be a GPUTileStorage"); } }
public override void InitNode() { base.InitNode(); if (SourceProducerGameObject != null) { if (SourceProducer == null) { SourceProducer = SourceProducerGameObject.GetComponent <TileProducer>(); } } if (TargetProducerGameObject != null) { if (TargetProducer == null) { TargetProducer = TargetProducerGameObject.GetComponent <TileProducer>(); } } if (SourceProducer == null) { throw new NullReferenceException("Source producer is null!"); } if (TargetProducer == null) { throw new NullReferenceException("Target producer is null!"); } var targetSize = TargetProducer.Cache.GetStorage(0).TileSize; var sourceSize = SourceProducer.Cache.GetStorage(0).TileSize; if (targetSize != sourceSize && targetSize != sourceSize - 1) { throw new InvalidParameterException("Target tile size must equal source tile size or source tile size-1"); } if (TargetProducer.GetBorder() != SourceProducer.GetBorder()) { throw new InvalidParameterException("Target border size must be equal to source border size"); } var storage = TargetProducer.Cache.GetStorage(0) as GPUTileStorage; if (storage == null) { throw new InvalidStorageException("Target storage must be a GPUTileStorage"); } storage = SourceProducer.Cache.GetStorage(0) as GPUTileStorage; if (storage == null) { throw new InvalidStorageException("Source storage must be a GPUTileStorage"); } }