//this is the native companion type to com.eegeo.examples.PlaceJumpMenu.java // ShowJavaPlaceJumpUIExample::ShowJavaPlaceJumpUIExample( AndroidNativeState& nativeState, Eegeo::Camera::GlobeCamera::GlobeCameraController& cameraController, Eegeo::Camera::ICameraJumpController& cameraJumpController ) : m_nativeState(nativeState) , m_cameraJumpController(cameraJumpController) , m_pTargetLocation(NULL) , m_globeCameraStateRestorer(cameraController) { m_locations["NYC"] = ViewLocation(40.703762, -74.013733, 0, 240.0f, 1800.0f); m_locations["London"] = ViewLocation(51.506172,-0.118915, 0, 351.0f, 2731.0f); m_locations["SF"] = ViewLocation(37.7858,-122.401, 0.0, 0.0, 1781.0); m_locations["Kyoto"] = ViewLocation(34.9977166,135.755402, 0, 0.0f, 1500.0f); m_locations["Melbourne"] = ViewLocation(-37.815005, 144.964415, 0, 0.0f, 1500.0f); }
/** * Issues level streaming load/unload requests based on whether * players are inside/outside level streaming volumes. */ void UWorld::ProcessLevelStreamingVolumes(FVector* OverrideViewLocation) { // if we are delaying using streaming volumes, return now if( StreamingVolumeUpdateDelay > 0 ) { StreamingVolumeUpdateDelay--; return; } // Option to skip indefinitely. else if( StreamingVolumeUpdateDelay == INDEX_NONE ) { return; } SCOPE_CYCLE_COUNTER( STAT_VolumeStreamingTickTime ); // Begin by assembling a list of kismet streaming objects that have non-EditorPreVisOnly volumes associated with them. // @todo DB: Cache this, e.g. level startup. TArray<ULevelStreaming*> LevelStreamingObjectsWithVolumes; TMap<ULevelStreaming*,bool> LevelStreamingObjectsWithVolumesOtherThanBlockingLoad; for( int32 LevelIndex = 0 ; LevelIndex < StreamingLevels.Num() ; ++LevelIndex ) { ULevelStreaming* LevelStreamingObject = StreamingLevels[LevelIndex]; if( LevelStreamingObject ) { for ( int32 i = 0 ; i < LevelStreamingObject->EditorStreamingVolumes.Num() ; ++i ) { ALevelStreamingVolume* StreamingVolume = LevelStreamingObject->EditorStreamingVolumes[i]; if( StreamingVolume && !StreamingVolume->bEditorPreVisOnly && !StreamingVolume->bDisabled ) { LevelStreamingObjectsWithVolumes.Add( LevelStreamingObject ); if( StreamingVolume->StreamingUsage != SVB_BlockingOnLoad ) { LevelStreamingObjectsWithVolumesOtherThanBlockingLoad.Add( LevelStreamingObject, true ); } break; } } } } // The set of levels with volumes whose volumes current contain player viewpoints. TMap<ULevelStreaming*,FVisibleLevelStreamingSettings> VisibleLevelStreamingObjects; // Iterate over all players and build a list of level streaming objects with // volumes that contain player viewpoints. bool bStreamingVolumesAreRelevant = false; for( FConstPlayerControllerIterator Iterator = GetPlayerControllerIterator(); Iterator; ++Iterator ) { APlayerController* PlayerActor = *Iterator; if (PlayerActor->bIsUsingStreamingVolumes) { bStreamingVolumesAreRelevant = true; FVector ViewLocation(0,0,0); // let the caller override the location to check for volumes if (OverrideViewLocation) { ViewLocation = *OverrideViewLocation; } else { FRotator ViewRotation(0,0,0); PlayerActor->GetPlayerViewPoint( ViewLocation, ViewRotation ); } TMap<AVolume*,bool> VolumeMap; // Iterate over streaming levels with volumes and compute whether the // player's ViewLocation is in any of their volumes. for( int32 LevelIndex = 0 ; LevelIndex < LevelStreamingObjectsWithVolumes.Num() ; ++LevelIndex ) { ULevelStreaming* LevelStreamingObject = LevelStreamingObjectsWithVolumes[ LevelIndex ]; // StreamingSettings is an OR of all level streaming settings of volumes containing player viewpoints. FVisibleLevelStreamingSettings StreamingSettings; // See if level streaming settings were computed for other players. FVisibleLevelStreamingSettings* ExistingStreamingSettings = VisibleLevelStreamingObjects.Find( LevelStreamingObject ); if ( ExistingStreamingSettings ) { // Stop looking for viewpoint-containing volumes once all streaming settings have been enabled for the level. if ( ExistingStreamingSettings->AllSettingsEnabled() ) { continue; } // Initialize the level's streaming settings with settings that were computed for other players. StreamingSettings = *ExistingStreamingSettings; } // For each streaming volume associated with this level . . . for ( int32 i = 0 ; i < LevelStreamingObject->EditorStreamingVolumes.Num() ; ++i ) { ALevelStreamingVolume* StreamingVolume = LevelStreamingObject->EditorStreamingVolumes[i]; if ( StreamingVolume && !StreamingVolume->bEditorPreVisOnly && !StreamingVolume->bDisabled ) { bool bViewpointInVolume; bool* bResult = VolumeMap.Find(StreamingVolume); if ( bResult ) { // This volume has already been considered for another level. bViewpointInVolume = *bResult; } else { // Compute whether the viewpoint is inside the volume and cache the result. bViewpointInVolume = StreamingVolume->EncompassesPoint( ViewLocation ); VolumeMap.Add( StreamingVolume, bViewpointInVolume ); INC_DWORD_STAT( STAT_VolumeStreamingChecks ); } if ( bViewpointInVolume ) { // Copy off the streaming settings for this volume. StreamingSettings |= FVisibleLevelStreamingSettings( (EStreamingVolumeUsage) StreamingVolume->StreamingUsage ); // Update the streaming settings for the level. // This also marks the level as "should be loaded". VisibleLevelStreamingObjects.Add( LevelStreamingObject, StreamingSettings ); // Stop looking for viewpoint-containing volumes once all streaming settings have been enabled. if ( StreamingSettings.AllSettingsEnabled() ) { break; } } } } } // for each streaming level } // bIsUsingStreamingVolumes } // for each PlayerController // do nothing if no players are using streaming volumes if (bStreamingVolumesAreRelevant) { // Iterate over all streaming levels and set the level's loading status based // on whether it was found to be visible by a level streaming volume. for( int32 LevelIndex = 0 ; LevelIndex < LevelStreamingObjectsWithVolumes.Num() ; ++LevelIndex ) { ULevelStreaming* LevelStreamingObject = LevelStreamingObjectsWithVolumes[LevelIndex]; // Figure out whether level should be loaded and keep track of original state for notifications on change. FVisibleLevelStreamingSettings* NewStreamingSettings= VisibleLevelStreamingObjects.Find( LevelStreamingObject ); bool bShouldAffectLoading = LevelStreamingObjectsWithVolumesOtherThanBlockingLoad.Find( LevelStreamingObject ) != NULL; bool bShouldBeLoaded = (NewStreamingSettings != NULL); bool bOriginalShouldBeLoaded = LevelStreamingObject->bShouldBeLoaded; bool bOriginalShouldBeVisible = LevelStreamingObject->bShouldBeVisible; bool bOriginalShouldBlockOnLoad = LevelStreamingObject->bShouldBlockOnLoad; int32 bOriginalLODIndex = LevelStreamingObject->LevelLODIndex; if( bShouldBeLoaded || bShouldAffectLoading ) { if( bShouldBeLoaded ) { // Loading. LevelStreamingObject->bShouldBeLoaded = true; LevelStreamingObject->bShouldBeVisible = NewStreamingSettings->ShouldBeVisible( bOriginalShouldBeVisible ); LevelStreamingObject->bShouldBlockOnLoad = NewStreamingSettings->ShouldBlockOnLoad(); } // Prevent unload request flood. The additional check ensures that unload requests can still be issued in the first UnloadCooldownTime seconds of play. else if( TimeSeconds - LevelStreamingObject->LastVolumeUnloadRequestTime > LevelStreamingObject->MinTimeBetweenVolumeUnloadRequests || LevelStreamingObject->LastVolumeUnloadRequestTime < 0.1f ) { //UE_LOG(LogLevel, Warning, TEXT("Unloading") ); if( GetPlayerControllerIterator() ) { LevelStreamingObject->LastVolumeUnloadRequestTime = TimeSeconds; LevelStreamingObject->bShouldBeLoaded = false; LevelStreamingObject->bShouldBeVisible = false; } } // Notify players of the change. if( bOriginalShouldBeLoaded != LevelStreamingObject->bShouldBeLoaded || bOriginalShouldBeVisible != LevelStreamingObject->bShouldBeVisible || bOriginalShouldBlockOnLoad != LevelStreamingObject->bShouldBlockOnLoad || bOriginalLODIndex != LevelStreamingObject->LevelLODIndex) { for( FConstPlayerControllerIterator Iterator = GetPlayerControllerIterator(); Iterator; ++Iterator ) { APlayerController* PlayerController = *Iterator; PlayerController->LevelStreamingStatusChanged( LevelStreamingObject, LevelStreamingObject->bShouldBeLoaded, LevelStreamingObject->bShouldBeVisible, LevelStreamingObject->bShouldBlockOnLoad, LevelStreamingObject->LevelLODIndex); } } } } } }