public void UpdateHeightmap() { _ring1Tree.UpdateLod(FovData.FromCamera(_camera)); }
public void Start() { InitializeWelding(); /// /// VISIBILITY TEXTURE var visibilityTextureSideLength = 16; var visibilityTexture = new Texture2D(visibilityTextureSideLength, visibilityTextureSideLength, TextureFormat.RFloat, false); visibilityTexture.filterMode = FilterMode.Point; var visibilityTextureProcessorProxy = new Ring1VisibilityTextureProcessorUTProxy(new Ring1VisibilityTextureProcessor(visibilityTexture)); _ultraUpdatableContainer.Add(visibilityTextureProcessorProxy); var visibilityTextureChangeGrabber = new Ring1VisibilityTextureChangeGrabber(); var terrainParentGameObject = new GameObject("TerrainParent"); terrainParentGameObject.transform.localPosition = new Vector3(0, 0, 0); var globalSideLength = _gRingConfiguration.Ring1GlobalSideLength; var globalSize = new Vector2(globalSideLength, globalSideLength); var unityCoordsCalculator = new UnityCoordsCalculator(globalSize); var orderGrabber = new Ring1PaintingOrderGrabber(); var painterProxy = new RingTerrainPainterUTProxy(new RingTerrainPainter(_gRingConfiguration.MakeTerrainVisible)); _ultraUpdatableContainer.Add(painterProxy); painterProxy.Update(); var mainRespondingProxy = new Ring1NodeEventMainRespondingProxy(new Ring1NodeEventMainResponder()); _ultraUpdatableContainer.AddOtherThreadProxy(new OtherThreadProxyWithPerPostAction() { OtherThreadProxy = mainRespondingProxy, PerPostAction = () => { var delta = visibilityTextureChangeGrabber.RetriveVisibilityChanges(); if (delta.AnyChange) { var visibilityTextureChagnes = visibilityTextureChangeGrabber.RetriveVisibilityChanges(); visibilityTextureProcessorProxy.AddOrder(visibilityTextureChagnes); } if (orderGrabber.IsAnyOrder) { painterProxy.AddOrder(orderGrabber.RetriveOrderAndClear()); } } }); var stainTerrainResourceCreatorUtProxy = new StainTerrainResourceCreatorUTProxy(new StainTerrainResourceCreator()); _ultraUpdatableContainer.Add(stainTerrainResourceCreatorUtProxy); var stainTerrainServiceProxy = new StainTerrainServiceProxy( new StainTerrainService( new FromFileStainTerrainResourceGenerator(_configuration.StainTerrainServicePath, _gameInitializationFields.Retrive <CommonExecutorUTProxy>()), //new ComputationStainTerrainResourceGenerator( // new StainTerrainResourceComposer( // _stainTerrainResourceCreatorUtProxy // ), // new StainTerrainArrayMelder(), // new DummyStainTerrainArrayFromBiomesGenerator( // new DebugBiomeContainerGenerator().GenerateBiomesContainer(new BiomesContainerConfiguration()), // new StainTerrainArrayFromBiomesGeneratorConfiguration() // )), _gRingConfiguration.Ring1GenerationArea)); _ultraUpdatableContainer.AddOtherThreadProxy(stainTerrainServiceProxy); var ring1Tree = new Ring1Tree(_gRingConfiguration.Ring1TreeConfiguration); var ring1TreeProxy = new Ring1TreeProxy(ring1Tree); _gameInitializationFields.Retrive <LateAssignBox <Ring1TreeProxy> >().Set(ring1TreeProxy); _ultraUpdatableContainer.AddOtherThreadProxy(ring1TreeProxy); var terrainShapeDbInitialization = new FETerrainShapeDbInitialization(_ultraUpdatableContainer, _gameInitializationFields, _configuration, new FilePathsConfiguration()); terrainShapeDbInitialization.Start(); var gRing0NodeTerrainCreator = new GRing0NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), unityCoordsCalculator, _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); var gRing1NodeTerrainCreator = new GRing1NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), stainTerrainServiceProxy, unityCoordsCalculator, _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); var gRing2PatchesCreatorProxy = _gameInitializationFields.Retrive <GRing2PatchesCreatorProxy>(); var gRing2NodeTerrainCreator = new GRing2NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), unityCoordsCalculator, gRing2PatchesCreatorProxy, _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); var gDebugNodeTerrainCreator = new GDebugLodNodeTerrainCreator( orderGrabber, terrainParentGameObject, unityCoordsCalculator, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>() ); var gDebugTerrainedNodeTerrainCreator = new GDebugTerrainedLodNodeTerrainCreator( orderGrabber, terrainParentGameObject, unityCoordsCalculator, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gameInitializationFields.Retrive <GRingSpotUpdater>() ); var gStampedRing2NodeTerrainCreator = new GStampedRing2NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), unityCoordsCalculator, gRing2PatchesCreatorProxy, _gameInitializationFields.Retrive <Ring2PatchStamplingOverseerFinalizer>(), _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); var gCompositeRing2NodeTerrainCreator = new GCompositeRing2NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), unityCoordsCalculator, gRing2PatchesCreatorProxy, _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gameInitializationFields.Retrive <Ring2PatchStamplingOverseerFinalizer>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); //var gCompositeRing2NodeTerrainCreator = new GCompositeRing2NodeTerrainCreator( // new List<INewGRingListenersCreator>() // { // gRing2NodeTerrainCreator, // gStampedRing2NodeTerrainCreator, // }); var subCreator = new SupremeGRingNodeTerrainCreator(new List <NewListenersCreatorWithLimitation>() { //new NewListenersCreatorWithLimitation() //{ // Creator = gDebugTerrainedNodeTerrainCreator, // MaximumLod = new FlatLod(14), // //PositionLimiter = new NewListenersCreatorPositionLimiter(new Vector2(0.5f, 0.6f), 0.025f) //}, //new NewListenersCreatorWithLimitation() //{ // Creator = gRing0NodeTerrainCreator, // MaximumLod = new FlatLod(5), //}, new NewListenersCreatorWithLimitation() { Creator = new GVoidNodeTerrainCreator(), MaximumLod = new FlatLod(5), //IsFallthroughCreator = true }, new NewListenersCreatorWithLimitation() { Creator = gRing1NodeTerrainCreator, MaximumLod = new FlatLod(10) }, new NewListenersCreatorWithLimitation() { Creator = gRing2NodeTerrainCreator, MaximumLod = new FlatLod(14) }, new NewListenersCreatorWithLimitation() { Creator = gStampedRing2NodeTerrainCreator, MaximumLod = new FlatLod(13) }, new NewListenersCreatorWithLimitation() { Creator = gCompositeRing2NodeTerrainCreator, MaximumLod = new FlatLod(14) } //new NewListenersCreatorWithLimitation() //{ // Creator = gDebugNodeTerrainCreator, // MaximumLod = new FlatLod(11) //}, }); var eventCollector = new Ring1NodeEventCollector( new DynamicFlatLodGRingNodeTerrainCreator(subCreator, new FlatLodCalculator(unityCoordsCalculator, _gRingConfiguration.FlatLodConfiguration))); _ultraUpdatableContainer.AddOtherThreadProxy( new OtherThreadProxyWithPerPostAction() { OtherThreadProxy = ring1TreeProxy, PerPostAction = () => { if (eventCollector.Any) { mainRespondingProxy.AddOrder(eventCollector.RetriveOrderAndClear()); } } } ); var repositioner = _gameInitializationFields.Retrive <Repositioner>(); _ultraUpdatableContainer.AddUpdatableElement(new FieldBasedUltraUpdatable() { UpdateCameraField = (camera) => { if (_configuration.UpdateRingTree) { ring1TreeProxy.UpdateCamera(FovData.FromCamera(camera, repositioner)); } } }); _ultraUpdatableContainer.AddUpdatableElement(new FieldBasedUltraUpdatable() { StartCameraField = (camera) => { ring1TreeProxy.CreateHeightmap( new Ring1Tree.RootNodeCreationParameters() { InitialCameraPosition = repositioner.InvMove(camera.Position), NodeListener = eventCollector, PrecisionDistances = _gRingConfiguration.QuadLodPrecisionDistances, UnityCoordsCalculator = unityCoordsCalculator }); } }); }