Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Private/StaticLightingSystem/StaticLightingSystem.cpp
Matt Kuhlenschmidt e2ba04378b Copying //UE4/Dev-Editor to //UE4/Dev-Main (Source: //UE4/Dev-Editor @ 3133954)
#lockdown Nick.Penwarden
#rb none

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3077573 on 2016/08/04 by Nick.Darnell

	Removing some unused code, adding additional needed modules to editor tests.

	#rb none

Change 3077580 on 2016/08/04 by Nick.Darnell

	Removing the test plugins, going to be recreating them in EngineTest.

Change 3082659 on 2016/08/09 by Nick.Darnell

	Automation - Presets are now stored in json files stored in Config so they can be shared, and human readable.  Working on screenshot automation, getting it where it needs to be to permit us to have repeatable tests for comarison.  Removing the option to not take full size screenshots, that defeats the purpose of being able to compare them.

	#rb none

Change 3082766 on 2016/08/09 by Jamie.Dale

	Fixed crashes when dealing with code-points outside the BMP on platforms with UTF-32 FStrings

	ICU always deals with its offsets as UTF-16 (as it always uses UTF-16 internally with icu::UnicodeString), so there were a couple of places in code (break iteration, and bidi detection) where we needed to adjust those UTF-16 offsets to UTF-32 offsets in the case where FString is UTF-32.

	#jira UE-33971
	#rb James.Hopkin

Change 3083067 on 2016/08/09 by Nick.Darnell

	Automation - Working on screenshot support, system now allows a lot more customization in terms of how large the shot is.

	#rb none

Change 3084475 on 2016/08/10 by Richard.TalbotWatkin

	Fixed issue with ModelComponent replication in client/server PIE if BSP is rebuilt. ModelComponent now implements IsNameStableForNetworking and always returns true, as a level's model components will never be rebuilt during a game session. Brush poly normals are now only fixed up in Editor builds.
	#jira UE-34391 - No run animation on client that is not focused when running 2 player and dedicated server
	#codereview Matt.Kuhlenschmidt
	#rb none

Change 3084661 on 2016/08/10 by Matt.Kuhlenschmidt

	Added grayscale texture importing support

	#rb none

Change 3084774 on 2016/08/10 by Cody.Albert

	Adding controller support for ComboBox widget

	#jira UE-33826
	#rb nick.darnell

Change 3085716 on 2016/08/11 by Nick.Darnell

	UMG - Taking the Widget Component and Widget Interaction Components out of experimental.  Removed old importing support for upgrading ancient versions of widget components.  Removing parbola distortion, as users can now do whatever they want in their custom MID they can override the widget with.

	#rb none

Change 3085733 on 2016/08/11 by Nick.Darnell

	UMG - Documenting the meta parameters allowed on widgets, like we do for regular UObjects.  For binding widgets from blueprints you can now do BindWidget (unchanged), and to simplify binding widgets optionally, you can now just do (BindWidgetOptional), rather than the combination of BindWidget + OptionalWidget=true.  Made generating the Design time wrapper call a little more efficent, by optimizing it away by force inlining a noop.  Also added some additional checking when we forcefully set focus in UMG, to help people catch cases where they set focus, but didn't make the widget focusable.

	#rb none

Change 3085734 on 2016/08/11 by Nick.Darnell

	Texture - Making GetDefaultMipMapBias a bit more efficent in the common case.

	#rb none

Change 3085736 on 2016/08/11 by Nick.Darnell

	Static Lighting - Warning the user when they build lighting, but have bForceNoPrecomputedLighting set to true on the world settings.

	#rb none

Change 3085737 on 2016/08/11 by Nick.Darnell

	Editor - code organization.

	#rb none

Change 3085875 on 2016/08/11 by Nick.Darnell

	UMG - You can now use 'G' to toggle game mode on the designer so that you can disable and enable the dashed lines around containers.  The option in the settings is now used as the default when you startup a designer.

	#rb none

Change 3086209 on 2016/08/11 by Ben.Salem

	Make our automated test pass reporting more robust and pipe out to JSON in \saved\automation\logs\AutomationReport-{CL}-{Timestamp}.json format.
	#rb adric.worley, william.ewen

Change 3086515 on 2016/08/11 by Nick.Darnell

	Editor - Fixing a crash in the curve table customization.  If the row doesn't exist, it would crash, we now protect against that case.

	#rb Matt.Kuhlenschmidt

Change 3087216 on 2016/08/12 by Jamie.Dale

	Fixed an issue where re-scanning a package file may leave old assets in the asset registry

	We didn't used to clear out anything associated with the old package before scanning the file, which could result in old assets being left if they'd since been removed from the package.

	This also exposes a PackageDeleted function to allow people to manually clear anything associated with a package (if doing some custom asset work).

	#rb Andrew.Rodham

Change 3087219 on 2016/08/12 by Jamie.Dale

	Updated TextRenderComponent to support multiple font pages

	It used to use the correct UV data, but wouldn't set the correct texture page when rendering. It now creates MIDs for all of the texture pages used by the font, and will use these MIDs (which override the font page on the material) when rendering the text (batched on sequential index/vertex buffer data with the same texture page).

	#rb Matt.Kuhlenschmidt

Change 3087308 on 2016/08/12 by Alex.Delesky

	#jira UE-14727  - Support for editing TSet properties in the editor's Details panel has been added.

	#rb Matt.Kuhlenschmidt

Change 3089140 on 2016/08/15 by Jamie.Dale

	We now abort a directory watch if we lose access to the directory in question

	This prevents an infinite loop in the call to MsgWaitForMultipleObjectsEx if a watched directory is deleted.

	#jira UE-30172
	#rb Andrew.Rodham

Change 3089148 on 2016/08/15 by Alexis.Matte

	Allow fbx export of any actor type.
	#rb none
	#codereview dmitriy.dyomin

Change 3089211 on 2016/08/15 by Jamie.Dale

	Unified access to the parent window for external dialogs

	A lot of places used to ad-hoc use the MainFrame window, even when they had access to a widget that may be belong to a different window. This could cause issues where an external dialog could appear behind a modal UE4 window (as it would appear above the MainFrame), and be inaccessible.

	You can now use IMainFrameModule::GetBestParentWindowHandleForDialogs to get the best window handle to use for an external dialog. This will either be the parent window for the given widget (if known), or failing that, the MainFrame window.

	#rb Andrew.Rodham

Change 3089640 on 2016/08/15 by Jamie.Dale

	Wrapped UMaterialExpression::MenuCategories in WITH_EDITORONLY_DATA to avoid gathering it for game-only loc

	#rb none

Change 3089661 on 2016/08/15 by Nick.Darnell

	Editor - There's a new view option "Show C++ Classes" in the content browser.  Lets you hide all those C++ folders most folks probably don't care to see.

	#rb none

Change 3089667 on 2016/08/15 by Cody.Albert

	Updating RoutePointerUpEvent to call OnDrop for touch events when dragging

	#jira UE-34709
	#rb nick.darnell

Change 3089694 on 2016/08/15 by Jamie.Dale

	Applied a fix to the ExcludeClasses setting in the loc gather

	#rb none

Change 3089889 on 2016/08/15 by Nick.Darnell

	Automation - Continued work on the screenshot portion of the automation system.  Going to start using the adapter information in the screenshots taken, otherwise we can't accurately test a plethora of devices sharing the same OS, with different capabilities.

	#rb none

Change 3090256 on 2016/08/16 by Nick.Darnell

	Automation - working on screenshots.
	#rb none

Change 3090322 on 2016/08/16 by Nick.Darnell

	Automation - Adding modified screenshot function.

	#rb none

Change 3090335 on 2016/08/16 by Nick.Darnell

	Automation - The tests were determined to need to be shared afterall, but at least keeping them as plugins.  Moved to Engine plugins.

	#rb none

Change 3090881 on 2016/08/16 by Nick.Darnell

	Automation - Moving the content over and fixing up some code so that the AutoRimport tests work as expected.

	#rb none

Change 3090884 on 2016/08/16 by Nick.Darnell

	Plugins - There's now support for generating a Content Only plugin from the new plugin wizard.

	#rb none

Change 3090911 on 2016/08/16 by Nick.Darnell

	Feature Packs - If there's an error loading a manifest, it's now an error, not a warning.

	#rb none

Change 3090913 on 2016/08/16 by Jamie.Dale

	Optimization and usability improvements of the MemoryProfiler2 tool

	 - Optimized the processing of the Callgraph, Histogram, and Short lived allocations views.
	    - The callgraph view is now using a virtualized tree view mapped to our own internal tree. This allows us to amortize the cost of adding nodes to the TreeView as the user views the nodes in the tree. In my own test, this took callgraph generation from ~45 seconds to ~5 seconds.
	    - The Histogram view was vastly optimized via the use of a HashSet on the callstack filter, and the batch addition of unsorted callstacks that are sorted once at the end. In my own test, this took histogram generation from ~15 minutes to ~2 seconds.
	    - The Short lived allocations view was optimized by avoiding redundant sorting, including maintaining a sorted order while inserting items, and instead doing a final sort at the end. The column selection was also optimized by avoiding copying the entire dataset just to resort it. In my own test, this took short lived allocation generation from ~1 minute to ~3 seconds.

	 - Added a user-configurable list of allocator functions to trim (which now includes FMemory and operator new by default, and produces much cleaner callstacks).

	#jira UETOOL-948
	#jira UETOOL-949
	#rb James.Hopkin

Change 3090962 on 2016/08/16 by Jamie.Dale

	Fixed double assignment of filter functions

	#rb none

Change 3090989 on 2016/08/16 by Nick.Darnell

	Editor - Attempting to fix the build, non-unity issue I suspect.

	#rb none

Change 3091754 on 2016/08/17 by Nick.Darnell

	FbxAutomationTestBuilder is now a plugin.  Users won't see it unless they've enabled the plugin (so primarily internal QA).  Reorganized the automation tools and testing menu to be a bit lower in the main menu, and gave them a more test sounding name.  Additionally made some modifications to the workspace menu structure to allow generating just a subset of a workplace menu so that I could target where I wanted to insert all of the automation tool menu items, rather than just allowing the general placement of them under developer tools...etc.

	#rb none
	#codereview Alexis.Matte

Change 3091758 on 2016/08/17 by Nick.Darnell

	Slate / Editor - Trying to make the editor less focus greedy.  Now when there are notification popups and tabs attempt to grab your attention we now do a few activation ownership checks to ensure that it or a parent window actually owns activation.  Not doing this has the nasty side effect of things like notifications and message log errors that popup while playing the game (if the game is in new window PIE), causing the game to be hidden, and focus returned to the editor.  Ran into this a lot running the automation tests, the new PIE window that's launched to run tests is immediately hidden as soon as the tests log a warning or error or a notification about high res screenshots happens.

	#rb none

	#codereview Nick.Atamas,Matt.Kuhlenschmidt

Change 3091829 on 2016/08/17 by Nick.Darnell

	Build - Attempting to repair the build.

	#rb none

Change 3091920 on 2016/08/17 by Nick.Darnell

	Build - Another attempt at fixing the mac build.

	#rb none

Change 3093380 on 2016/08/18 by Matt.Kuhlenschmidt

	Ignore group actors when checking for references to other actors when deleting.  The check for references is designed for gameplay affecting references which groups are not.  Having this show up for groups is annoying

	#rb none

Change 3094474 on 2016/08/19 by Jamie.Dale

	Fixed PS4 error when building with USE_MALLOC_PROFILER, and optimized symbol name resolution for a build with USE_MALLOC_PROFILER enabled

	#jira UETOOL-951
	#rb James.Hopkin

Change 3094581 on 2016/08/19 by Jamie.Dale

	Added missing allocator filter needed by PS4 profiles

	#rb none

Change 3094681 on 2016/08/19 by Richard.TalbotWatkin

	Fixed issue where painting override vertex colors on a SpeedTree mesh would cause its wind animation to cease. The OverrideVertexColors vertex factory needed to be registered with the SpeedTree renderer.
	#jira UE-32762 - Custom VertexPaint on SpeedTrees interferes with wind animation
	#rb none

Change 3095163 on 2016/08/19 by Trung.Le

	#jira UE-20849: Added tooltips to the inputs of the Material final result node
	#rb matt.kuhlenschmidt

Change 3095285 on 2016/08/19 by Trung.Le

	#jira UE-20849 In SGraphNodeMaterialResult, renamed ToolTip to ToolTipWidget so we're not hiding class member
	#rb none

Change 3095344 on 2016/08/19 by Alexis.Matte

	#jira UE-34690 When using the optionnal matrix to change the scene root node, we have to flush the fbx evaluation engine.
	Add also a new option to allow the user to automatically convert the fbx scene to unreal unit (centimeter).

	#rb none
	#codereview matt.kuhlenschmidt

Change 3096162 on 2016/08/22 by Alexis.Matte

	#jira UE-34763 Remove offending no-action combo box entry when the json file is readonly. Also clean up other combo box menu.
	#rb none
	#codereview matt.kuhlenschmidt

Change 3096261 on 2016/08/22 by Alexis.Matte

	#jira UE-33121 Make sure re-import all and import all fix all the issue before starting the job. So it get not interrupt during the process.

	#rb lina.halper
	#codereview lina.halper

Change 3096344 on 2016/08/22 by Jamie.Dale

	NSString conversion fix for UTF-32 strings containing characters outside of the BMP

	#jira UE-33971
	#rb Peter.Sauerbrei, James.Hopkin

Change 3096605 on 2016/08/22 by Alex.Delesky

	#jira UE-34787 - Dropdown menus in standalone programs will now correctly display tooltips if they have any.

	#rb Matt.Kuhlenschmidt

Change 3096615 on 2016/08/22 by Alex.Delesky

	#jira UE-33334 - Scrolling up on the mouse wheel when using the orbit camera should no longer move away from the orbit point when the camera moves too close to the orbit origin.

	#rb Matt.Kuhlenschmidt

Change 3096619 on 2016/08/22 by Alex.Delesky

	#jira UE-34084 - Structs containing an enum with a value that contains a whitespace character will now serialize correctly when copied from the Details Panel.

	#rb Matt.Kuhlenschmidt

Change 3097644 on 2016/08/23 by Matt.Kuhlenschmidt

	PR #2729: Fix a typo in the comment (Contributed by adcentury)

	#rb none

Change 3097648 on 2016/08/23 by Matt.Kuhlenschmidt

	PR #2726: Undef unused macros (Contributed by shrimpy56)

	#rb none

Change 3097697 on 2016/08/23 by Matt.Kuhlenschmidt

	Guard against crash when details panels rebuild when their customizations have been torn down

	https://jira.ol.epicgames.net/browse/UE-35048

	#rb none

Change 3097757 on 2016/08/23 by Alex.Delesky

	#jira UE-14727  - Support for editing TMap properties in the editor's Details panel has been added. This change also removes the Duplicate option from TSet elements, and disallows entry of duplicates elements into a TSet or duplicate keys into a TMap

	#rb Matt.Kuhlenschmidt

Change 3098164 on 2016/08/23 by Alexis.Matte

	#jira UE-34686 Fbx importer bImportMeshesInBoneHierarchy is used also by the animation.
	#rb none
	#codereview matt.kuhlenschmidt

Change 3098502 on 2016/08/23 by Alexis.Matte

	#jira UE-30951 Fbx option dialog, we disable the option to bake pivot if transform vertex position is true
	#rb none
	#codereview matt.kuhlenschmidt

Change 3099986 on 2016/08/24 by Jamie.Dale

	Fixing non-editor builds

	#rb none

Change 3101138 on 2016/08/25 by Matt.Kuhlenschmidt

	Fixed viewport redraw callback not being called when certian property modifications occur in the details panel (reset to default, array size changes, etc)

	#rb none

Change 3101280 on 2016/08/25 by Jamie.Dale

	Fixed crash when counting memory over internationalization meta-data

	- The serialization code only used to handle loading or saving, now it handles loading or not loading.
	- The Type of the meta-data wasn't set by all constructors. For safety it has been removed and replaced with a virtual function that the derived types override.

	#rb James.Hopkin

Change 3101283 on 2016/08/25 by Jamie.Dale

	MProf2 platform and symbol parsing improvements

	 - Updated ISymbolParser to work with lazy symbol resolution (handled via the UI when looking at full callstacks).
	 - Added a PS4 symbol parser which handles performing full file/line resolution for symbols.
	 - Removed all the V3 file format support and legacy platform handling.
	 - Optimized FStreamInfo.GetNameIndex so it can be used by the lazy symbol fixup.

	#rb James.Hopkin

Change 3101586 on 2016/08/25 by Jamie.Dale

	Small code cleanup and path normalization

	#rb James.Hopkin

Change 3101837 on 2016/08/25 by Alexis.Matte

	#jira UE-35101 we now store the sourceanimationname to retrieve the correct animtrack when re-importing animations
	#rb none
	#codereview matt.kuhlenschmidt

Change 3102537 on 2016/08/26 by Jamie.Dale

	Fix for potential crash in FICUCamelCaseBreakIterator

	In platforms with UTF-32 strings, the index returned by FICUTextCharacterIterator may not be in the same range as FString, so we need to call InternalIndexToSourceIndex to ensure that it is.

	#rb James.Hopkin

Change 3102582 on 2016/08/26 by Matt.Kuhlenschmidt

	Log the freetype version when it starts up (for debugging purposes)

	#rb none

Change 3102657 on 2016/08/26 by Alexis.Matte

	#jira UE-29177 When re-importing a texture we want to notify materials using this texture so they can recompile the shader.
	#review-3101585 @uriel.doyon
	#rb matt.kuhlenschmidt

Change 3102704 on 2016/08/26 by Jamie.Dale

	Added symbol meta-data support to MProf2

	You can now define platform specific meta-data using FPlatformStackWalk::GetSymbolMetaData, which is then stored within the generated .mprof file.

	PS4 uses this meta-data to say where the original .self file can be found, so that MProf2 can usually automatically load the .self file without having to bother the user.

	#rb James.Hopkin

Change 3102878 on 2016/08/26 by Matt.Kuhlenschmidt

	Added support for outline fonts
	- An outline size (in slate units), optional material and optional fill color can be specified with each font info.
	- Outlines do not contribute to measurement directly so the text measuring and shaping methods have been modified to account for outlines
	- Fixed a bug where font materials do not work properly if part of the font's rendered glyphs were in a different atlas

	#rb jamie.dale

Change 3102879 on 2016/08/26 by Jamie.Dale

	Bumped the MProf2 version so we can tell which build of the tool can load v6 mprof files

	#rb none

Change 3102960 on 2016/08/26 by Alexis.Matte

	build fix
	#rb none

Change 3103032 on 2016/08/26 by Jamie.Dale

	Fixed SEditableText and SMultiLineEditableText not setting the correct foreground color when painting

	#jira UE-34936
	#rb Matt.Kuhlenschmidt

Change 3103278 on 2016/08/26 by Jamie.Dale

	Fixing Clang warnings

	#rb none

Change 3104211 on 2016/08/29 by Ben.Marsh

	Add build script for automated tests, and create settings file for Dev-Editor which adds an agent pool for running them.

	#rb none

Change 3104290 on 2016/08/29 by Alex.Delesky

	Adding additional documentation accessible from the editor for TSet and TMap properties, along with a quick clarification on container properties to let the user know what kind of container they're working with.

	#rb Matt.Kuhlenschmidt

Change 3104292 on 2016/08/29 by Alex.Delesky

	#jira UE-35039 - Command/Control user keybindings will no longer flip-flop when the editor is opened on Mac.

	#rb Matt.Kuhlenschmidt

Change 3104294 on 2016/08/29 by Alex.Delesky

	#jira UE-34952 - The user will no longer encounter an ensure when setting the value of Period equal to or less than 0 on the circular throbber widget

	#rb Matt.Kuhlenschmidt

Change 3104295 on 2016/08/29 by Matt.Kuhlenschmidt

	PR #2682: Remove unused bUseDesktopResolutionForFullscreen (Contributed by stfx)

	#rb none

Change 3104296 on 2016/08/29 by Alex.Delesky

	#jira UE-35160 - The Auto Distance Error for LOD meshes can now be set to any value larger than zero.

	#rb Matt.Kuhlenschmidt

Change 3104348 on 2016/08/29 by Matt.Kuhlenschmidt

	Added the ability to clear the preview mesh on a material instance.  Previously there was no way to null it out.

	#rb none

Change 3104355 on 2016/08/29 by Matt.Kuhlenschmidt

	Guard against crash with invalid path to the default physical material.  Just create a new one if it doesnt exist and warn about it.

	#rb none
	#jira UE-31865

Change 3104396 on 2016/08/29 by Ben.Marsh

	Fix incrorrect agent names for running automated tests

Change 3104610 on 2016/08/29 by Alex.Delesky

	Fix for AutomationTool compile editor from changes introduced today.

	#rb None

Change 3104611 on 2016/08/29 by Michael.Dupuis

	#jira UETOOL-253
	#rb Alexis.Matte

Change 3105826 on 2016/08/30 by Gareth.Martin

	Added console variables to discard grass and/or scalable foliage data on load
	#jira UE-35086
	#rb Benn

Change 3106126 on 2016/08/30 by Matt.Kuhlenschmidt

	Eliminated bad code duplication between retainer widgets and element batcher

	#rb none
	#codereview nick.darnell

Change 3106449 on 2016/08/30 by Michael.Dupuis

	#jira UETOOL-229 Added generic command icons used in Edit Menu (including contextual menu)
	#rb Alexis.Matte

Change 3106966 on 2016/08/30 by Jamie.Dale

	Fixed FApp::IsAuthorizedUser not considering the SessionOwner override

	#rb Max.Preussner

Change 3107687 on 2016/08/31 by Michael.Dupuis

	Checkout/Make Writable on proper config file

	#rb Matt Kuhlenschmidt

Change 3107736 on 2016/08/31 by Matt.Kuhlenschmidt

	Fixed mode typos in the lerp instruction

	#rb none

Change 3107830 on 2016/08/31 by Matt.Kuhlenschmidt

	Logging and guard against UEditorEngine::TeardownPlaySession crash.

	#rb none
	https://jira.ol.epicgames.net/browse/UE-35325

Change 3107912 on 2016/08/31 by Alex.Delesky

	#jira UE-35181 - Normalizing paths when retrieving absolute filenames for source control operations.

	#rb Matt.Kuhlenschmidt

Change 3107986 on 2016/08/31 by Matt.Kuhlenschmidt

	Removed PropertyTestObject.h out of UnrealEd.h so you dont have to compile the entire editor when changing this one file.

	#rb none

Change 3108027 on 2016/08/31 by Chris.Wood

	Re-added lost doc comment for analytics event "Engine.AbnormalShutdown".

	#rb none - just a comment in a cpp file
	#codereview wes.hunt

Change 3108580 on 2016/08/31 by Mike.Fricker

	Deleted the "Live Editor" plugins from UE4
	- These were undocumented, buggy and never finished, and we have no plans to complete them
	- Both the "LiveEditor" and "LiveEditorListenServer" plugins were deleted, along with related icon files

	#codereview matt.kuhlenschmidt
	#rb matt.kuhlenschmidt

Change 3108604 on 2016/08/31 by Mike.Fricker

	Added new "MIDI Device" plugin (disabled by default)

	- This is a simple MIDI interface that allows you to receive MIDI events from devices connected to your computer

	- Currently only input is supported.  In the future we might allow for output, as well.

	- In Blueprints, here's how to use it:
	        - Look for "MIDI Device Manager" in the Blueprint RMB menu
	        - Call "Find MIDI Devices" to choose your favorite device.  Break the "Found MIDI Device" struct to see what's available.
	        - Then call "Create MIDI Device Controller" for the device you want.  Store that in a variable.
	        - On your MIDI Device Controller, bind your own Event to the "On MIDI Event" event.  This will be called every game Tick when there is at least one new MIDI event to receive.
	        - Process the data passed into the Event to make your project do stuff!

	- This plugin makes use of the "PortMidi" third party library (which already existed in UE4 -- it was used by the now-deprecated 'LiveEditor' plugin)

	#codereview matt.kuhlenschmidt
	#rb none

Change 3108760 on 2016/08/31 by Alexis.Matte

	#jira UE-25840 Fbx export collision mesh, we now export collision: box, sphere, capsule and convex mesh. There is an option in the editor preference to enable the export of collisions, default value is false.
	#rb none
	#codereview matt.kuhlenschmidt

Change 3109006 on 2016/08/31 by Alex.Delesky

	#ignore Source Control rename test - initial commit

Change 3109044 on 2016/08/31 by Alex.Delesky

	#ignore Testing asset rename from P4 to observe correct behavior.

	#rb none

Change 3109048 on 2016/08/31 by Alex.Delesky

	#ignore Testing P4 rename to identify correct behavior

	#rb none

Change 3110044 on 2016/09/01 by Gareth.Martin

	Fixed painting foliage on blocking "query" actors not working
	#jira UE-33852
	#rb Allan.Bentham

Change 3110133 on 2016/09/01 by Alexis.Matte

	Fix crash in function GetForceRecompileTextureIdsHash
	#rb none
	#codereview jamie.dale

Change 3111848 on 2016/09/02 by Mike.Fricker

	MIDI Device plugin: Fixed compilation error on Clang compilers (Mac, Linux)
	- Fixed bad enum cast
	#rb none

Change 3111995 on 2016/09/02 by Michael.Dupuis

	#jira UE-35263

	Do not try selecting the actor if the actor is in the blueprint
	Properly Refresh the ToopTip & Hyper Link to take into account blueprint recreation process

	#rb Alexis Matte

Change 3112280 on 2016/09/02 by Michael.Dupuis

	Call MakeWritable if source control fail

	#rb Alexis Matte

Change 3112335 on 2016/09/02 by Cody.Albert

	Updating cursor hiding logic to not improperly hide cursor when left clicking in ortho mode

	#jira UE-35306
	#rb none

Change 3112478 on 2016/09/02 by Alexis.Matte

	#jira UE-20059 Use a base material to import fbx material.
	#rb uriel.doyon
	#codereview matt.kuhlenschmidt
	#1468 Github pull request number

Change 3113912 on 2016/09/06 by Michael.Dupuis

	#jira UE-32288 Fixed Console params display
	#rb Alexis Matte

Change 3114026 on 2016/09/06 by Alex.Delesky

	#jira UE-35123 - The Details panel in a Texture editor or Simple Asset editor window will no longer disappear when the inspected asset is imported again.

	#rb Matt.Kuhlenschmidt

Change 3114032 on 2016/09/06 by Alex.Delesky

	PR #2733: Improved the project launcher progress page (Contributed by projectgheist)

	#jira UE-34027
	#rb Matt.Kuhlenschmidt

Change 3114034 on 2016/09/06 by Alex.Delesky

	#jira UE-35265 - Copying a comment node from a Material Function and pasting it inside a Material will no longer render the Material unsaveable

	#rb Matt.Kuhlenschmidt

Change 3114071 on 2016/09/06 by Nick.Darnell

	[AUTOMATED TEST] Automatic checkin, testing functionality.

Change 3114109 on 2016/09/06 by Nick.Darnell

	[AUTOMATED TEST] Automatic checkin, testing functionality.

Change 3114562 on 2016/09/06 by Nick.Darnell

	Adding LevelEditor to the FbxAutomationTestBuilder to fix a compiler issue.

	#rb none

Change 3114701 on 2016/09/06 by Michael.Dupuis

	#jira UE-31988 add const to all usage of TArray<ItemType>* as it was done in SListView
	#rb Alexis Matte

Change 3114861 on 2016/09/06 by Matt.Kuhlenschmidt

	Prevent non-thread safe slate code from running on the slate loading thread

	#rb none

Change 3115698 on 2016/09/07 by Nick.Darnell

	Make sure the commands are available - during functional testing that was found to not always be the case.

	#rb none

Change 3115719 on 2016/09/07 by Nick.Darnell

	Adding an IsRegistered command to commands.

	#rb none

Change 3115721 on 2016/09/07 by Nick.Darnell

	Adding a new built VirtualReality feature pack, this new one contains the update manifest that will parse correctly.

	#rb none

Change 3115722 on 2016/09/07 by Nick.Darnell

	IsBindWidgetProperty now returns false if the property passed in is null.

	#rb none

Change 3115734 on 2016/09/07 by Alexis.Matte

	#jira UE-30166 Support fbx sdk 2017
	#rb none

Change 3115737 on 2016/09/07 by Nick.Darnell

	Adding an image comparer for screenshots.  Removing some content from EngineTest.

	#rb none

Change 3115743 on 2016/09/07 by Nick.Darnell

	Checkpointing a bunch of progress towards a screenshot comparison workflow that allows us to diff screenshots taken on various platforms and hardware.  Disabling many tests that are not passing.  Updating a few tests to log better errors, and fixed a few tests with easy bugs in them so they would start passing again.  All editor tests currently passing!

	#rb none

Change 3115748 on 2016/09/07 by Nick.Darnell

	Making the RuntimeTests plugin a Developer module, so that it doesn't get included in shipping builds.

	#rb none

Change 3115789 on 2016/09/07 by Jamie.Dale

	We now favor Traditional Chinese for Hong Kong and Macau

	#rb James.Hopkin

Change 3115799 on 2016/09/07 by Jamie.Dale

	Removed validity check on source cultures when remapping, as platforms may use invalid cultures that need to be remapped

	#rb James.Hopkin

Change 3115826 on 2016/09/07 by Nick.Darnell

	Adding missing files.

	#rb none

Change 3115838 on 2016/09/07 by Nick.Darnell

	Back out revision 6 from //UE4/Dev-Editor/Engine/Source/Runtime/UMG/Public/Components/WidgetInteractionComponent.h

	#rb none

Change 3116007 on 2016/09/07 by Alexis.Matte

	build fix
	#rb none

Change 3116057 on 2016/09/07 by Jamie.Dale

	Fixed widget snapshot messages so they appear in the message debugger

	#rb none

Change 3116112 on 2016/09/07 by Nick.Darnell

	Removing the FbxAutomationBuilder file that go recreated on a merge from main.

	#rb none

Change 3116365 on 2016/09/07 by Michael.Dupuis

	#jira UE-20765 Added missing class flag to test (CLASS_CONFIG) and change a bit how the checkout/make writable work.
	#codereview Matt.Kuhlenschmidt
	#rb Alexis.Matte

Change 3116622 on 2016/09/07 by Alexis.Matte

	#jira UE-35608 Use the same naming convention when trying to retrieve uv channel by name.
	#rb matt.kuhlenschmidt

Change 3116638 on 2016/09/07 by Jamie.Dale

	Ensured that manifests and archives don't try and load data that they can't parse

	#rb none

Change 3117397 on 2016/09/08 by Gareth.Martin

	Added rotate and blend support to the landscape mirror tool
	#jira UE-34829
	#rb Jack.Porter

Change 3117459 on 2016/09/08 by Gareth.Martin

	Fixed crash saving a hidden landscape level with an offset (cloned from 4.13.1)
	#jira UE-35301
	#rb Jack.Porter

Change 3117462 on 2016/09/08 by Gareth.Martin

	Fixed invisible landscape components and crashes when tessellation is enabled (cloned from 4.13.1)
	#jira UE-35494
	#rb Benn.Gallagher

Change 3117583 on 2016/09/08 by Nick.Darnell

	Continued work on automation support for screenshot comparison, stubbing in a commandlet that can be run after automation tests that would perform the diffing.  Need to finish rigging it up so that deltas and results can be dumped out somewhere and consumed by a tool to approve shots.

	#rb none

Change 3117595 on 2016/09/08 by Nick.Darnell

	Updating the build script for AutomatedTests, going to see if this works!

	#rb none

Change 3117808 on 2016/09/08 by Nick.Darnell

	Adding header includes for async.

	#rb none

Change 3117812 on 2016/09/08 by Matt.Kuhlenschmidt

	Partially taken from Pr 2381

	Fixed Array Properties to handle duplicates properly and fixed Material Parameter Collection duplicate Guid problem.

	#rb none

Change 3117851 on 2016/09/08 by Jamie.Dale

	Silenced some redundant P4 errors that could be generated when running a stat update on a file

	Some of the options produced errors when working with newly added files. These errors are now downgraded to infos like they are for the main stat command.

	#rb Ben.Marsh
	#codereview Thomas.Sarkanen

Change 3117853 on 2016/09/08 by Gareth.Martin

	Clean up landscape includes and PCH
	#rb steve.robb

Change 3117859 on 2016/09/08 by Alex.Delesky

	#jira UE-35321 - Minimized windows will no longer act like they are visible when determining what widgets are currently underneath the mouse.

	#rb Nick.Darnell

Change 3117997 on 2016/09/08 by Nick.Darnell

	Updating the automation tests build script to use Editor-Cmd

	#rb none

Change 3118005 on 2016/09/08 by Matt.Kuhlenschmidt

	Properly reference graph node on material expressions so they are not GC'd while an expression still uses them

	#jira UE-35362
	#rb none

Change 3118043 on 2016/09/08 by Alex.Delesky

	#jira UE-30649 - Removed unnecessary returns from UWidget API.

	PR #2377: fix widget bug. (Contributed by dorgonman)

	#rb none

Change 3118045 on 2016/09/08 by Matt.Kuhlenschmidt

	Guard against crash saving config during level editor shutdown

	#rb none
	#jira UE-35605

Change 3118074 on 2016/09/08 by Matt.Kuhlenschmidt

	PR #2783: Removed #pragme once from CPP files (Contributed by projectgheist)

	#rb none

Change 3118078 on 2016/09/08 by Michael.Dupuis

	#jira UE-32065 Removed the -windows that was added as a default option and add it simply if fullscreen is not specified
	#rb Alexis.Matte

Change 3118080 on 2016/09/08 by Michael.Dupuis

	#jira UE-31131 Do not show a contextual menu if the menu is empty
	#rb Alexis.Matte

Change 3118087 on 2016/09/08 by Matt.Kuhlenschmidt

	Constify this method

	#rb none

Change 3118166 on 2016/09/08 by Nick.Darnell

	Trying additional command options for the build machine for automation.

	#rb none

Change 3118222 on 2016/09/08 by Matt.Kuhlenschmidt

	Fix actor delete during mesh paint not working during undo

	#rb none
	#jira UE-35684

Change 3118298 on 2016/09/08 by Alexis.Matte

	#jira UE-35302 Export all LODs for static mesh when there is no force LOD
	#rb uriel.doyon

Change 3118325 on 2016/09/08 by Matt.Kuhlenschmidt

	Fixed reset to default not appearing for slate brushes

	#rb none
	#jira UE-34958

Change 3119321 on 2016/09/09 by Matt.Kuhlenschmidt

	Guard against crash with an invalid world trying to be opened from the content browser

	#rb none
	https://jira.ol.epicgames.net/browse/UE-35712

Change 3119433 on 2016/09/09 by Nick.Darnell

	Removing a hack added by Paragon that prevents applications from resizing in real time as the user drags the size of the window around.

	#rb Matt.Kuklenschmidt
	#jira UE-35789

Change 3119448 on 2016/09/09 by Alex.Delesky

	When simulating touch events using the mouse, clicking the mouse will no longer let a drag operation continue. This should also allow the finger that started a drag to continue dragging items until it is released from the surface.

	#rb Nick.Darnell

Change 3119522 on 2016/09/09 by Jamie.Dale

	Fixed FDetailCategoryImpl::ShouldBeExpanded not honoring bShouldBeInitiallyCollapsed when bRestoreExpansionState was true

	#rb Matt.Kuhlenschmidt

Change 3119528 on 2016/09/09 by Jamie.Dale

	Some UI re-work to the localization dashboard

	This makes a better use of the available space, and will make it easier to make some other planned changes in the future.

	#rb James.Hopkin

Change 3119861 on 2016/09/09 by Michael.Dupuis

	#jira UE-9284 Added the Play/Stop button on the thumbnail
	#rb Alexis.Matte

Change 3120027 on 2016/09/09 by Alexis.Matte

	incorporate some fixes from licensee for LOD group re-import workflow
	#jira UE-32268
	#rb uriel.doyon
	#codereview matt.kuhlenschmidt

Change 3120845 on 2016/09/12 by Gareth.Martin

	Fixed crash in landscape editor when "Early Z" is enabled (cloned from 4.13.1)
	#jira UE-35850
	#rb Allan.Bentham

Change 3120980 on 2016/09/12 by Nick.Darnell

	Adding a commandlet that is runnable for comparing screenshots.  Adding comparing and exporting capability to the screenshot manager.

	#rb none

Change 3120992 on 2016/09/12 by Alex.Delesky

	#jira UE-35575 - TScriptInterface UProperties now have asset picker support.

	#rb Matt.Kuhlenschmidt

Change 3121074 on 2016/09/12 by Michael.Dupuis

	#jira UE-30092
	Added path length in error message when typing
	Added display of current filepath lenght for cooking

	#rb Alexis.Matte

Change 3121113 on 2016/09/12 by Nick.Darnell

	Adding some placeholder examples to show people how to author tests in EngineTest.

	#rb none

Change 3121152 on 2016/09/12 by Gareth.Martin

	Added TElementType, TIsContiguousContainer traits
	Added GetData(), GetNum() generic functions
	#rb Steve.Robb

Change 3121702 on 2016/09/12 by Jamie.Dale

	Optimized a loop over a sorted list to instead use a binary search

	This speeds up the short-lived allocation view generation.

	We also now dump the exception information to the Trace log when in a non-debug build.

	#rb James.Hopkin

Change 3121721 on 2016/09/12 by Jamie.Dale

	We now set the window mode first when resizing the game viewport to ensure that the work area is correct

	Fullscreen windows can affect the available work area size, which can break centering when moving between fullscreen and windowed mode.

	#jira UE-32842
	#rb Matt.Kuhlenschmidt

Change 3122578 on 2016/09/13 by Jamie.Dale

	Small code clean up

	Removed a use of the placement new style array addition.

	#rb none

Change 3122634 on 2016/09/13 by Jamie.Dale

	We now immediately update DefaultConfigCheckOutNeeded when checking out/making writable the config file, rather than wait for the text tick

	#jira UE-34865
	#rb James.Hopkin

Change 3122656 on 2016/09/13 by Jamie.Dale

	Fixed array combo button not focusing its contents, which prevented the menu closing correctly

	#jira UE-33667
	#rb none

Change 3122661 on 2016/09/13 by Nick.Darnell

	Checkpointing additional work on the screenshot compare dialog, moving some Directory path picker widget into a more common area.  Moving some "Find the best top level window handle for this widget for dialogs' code out of the main frame module and into Slate Application where it probably belongs.

	#rb none

Change 3122678 on 2016/09/13 by Jamie.Dale

	Fixing CIS error on Clang

	CoreUObject needs to be included before USTRUCT can be used.

	#rb none

Change 3122686 on 2016/09/13 by Jamie.Dale

	Fixing CIS error on Clang

	CoreUObject needs to be included before UCLASS can be used.

	#rb none

Change 3122728 on 2016/09/13 by Nick.Darnell

	UMG - Exposing a trace channel for the WIC, defaults to Visibility.  Improving how the WIC handles the cursor moving off the widget, it now maintains the last hit location rather than 0,0 which would cause things like dragged Sliders to reset to the left.  Ideally - the WIC would know the underlying widget has capture and continue to fake collision against an imaginary plane to simulate a continuous surface.

	#jira UE-35167
	#rb none

Change 3122775 on 2016/09/13 by Nick.Darnell

	Automation - Fixing an error with the ScreenshotTools plugin, needed to add an the include for Engine.h to the PCH.

	#rb none

Change 3122779 on 2016/09/13 by Nick.Darnell

	Widgetnimation - Exposing more of the class to C++.

	#rb none

Change 3122793 on 2016/09/13 by Nick.Darnell

	Fixing a crash in UWidgetComponent::UpdateRenderTarget updating a null material instance.

	#jira UE-35796
	#rb none

Change 3122834 on 2016/09/13 by Matt.Kuhlenschmidt

	Fixed crash undoing moves after bsp creation

	https://jira.ol.epicgames.net/browse/UE-35880

	#rb none

Change 3122835 on 2016/09/13 by Nick.Darnell

	Reverting changes to WIdgetAnimation

	#rb none

Change 3122897 on 2016/09/13 by Matt.Kuhlenschmidt

	Fixed non-editor compile error
	#rb none

Change 3122988 on 2016/09/13 by Alexis.Matte

	Material workflow refactor
	#jira UETOOL-774
	#rb matt.kuhlenschmidt

Change 3123006 on 2016/09/13 by Jamie.Dale

	Fixed dynamic collections not returning anything

	#jira UE-35869
	#rb James.Hopkin

Change 3123145 on 2016/09/13 by Alexis.Matte

	Fix fbx automation test. The test found a regression cause by CL: 3120027. In the case where we dont have a LODGroup we dont want to add LODs before the build.
	#jira UE-32268
	#rb none
	#codereview matt.kuhlenschmidt

Change 3123148 on 2016/09/13 by Matt.Kuhlenschmidt

	Fix fortnite compile error

	#rb alexis.matte

Change 3123208 on 2016/09/13 by Jamie.Dale

	The 'find culprit' dialog now honors the user choice

	#rb RichTW

Change 3123545 on 2016/09/13 by Nick.Darnell

	Slate - Adjusting the window dialog host finding code to do a better job of searching for slate windows and excluding popups and non-regular windows.

	#rb none

Change 3124494 on 2016/09/14 by Jamie.Dale

	Added ~ to the list of invalid characters for object/package names

	#jira UE-12908
	#rb Matt.Kuhlenschmidt

Change 3124513 on 2016/09/14 by Gareth.Martin

	Implemented filter to allow painting foliage on other foliage
	- Altered foliage filters so it will no longer paint on object types which don't have a filter, e.g. skeletal meshes
	#rb Allan.Bentham
	#2472

Change 3124523 on 2016/09/14 by Jamie.Dale

	PR #2724: Fix ScrollBox right mouse/touch grab scrolling functionality (Contributed by aarmbruster)

	#jira UE-34811
	#jira UE-32082
	#rb none

Change 3124607 on 2016/09/14 by Nick.Darnell

	UMG - Adding BoundsScale support to the WidgetComponent's CalcBounds function.

	#jira UE-35667
	#rb none

Change 3124785 on 2016/09/14 by Gareth.Martin

	Made some foliage functions editor-only to fix non-editor build
	#rb none

Change 3124795 on 2016/09/14 by Gareth.Martin

	Saved/loaded the new foliage filter
	#rb Allan.Bentham
	#2472

Change 3124915 on 2016/09/14 by Michael.Dupuis

	#jira UE-19511
	Add support for Add to source control on DefaultEditorPerProjectUserSettings file
	Remove CheckoutNotice when not editing a DefaultXXXX.ini file
	Edit proper config file either we're modifying settings from a Default file or Local user file
	#codereview Matt.Kuhlenschmidt Max.Preussner
	#rb Alexis.Matte

Change 3125266 on 2016/09/14 by Jamie.Dale

	Fixed ULocalizationTarget::DeleteFiles not deleting cultures, and using SCC wrong

	#rb none

Change 3125385 on 2016/09/14 by Matt.Kuhlenschmidt

	Fix crash when using SaveAs to save over top of an existing level

	#rb none
	https://jira.ol.epicgames.net/browse/UE-35919
	https://jira.ol.epicgames.net/browse/UE-35921

Change 3125487 on 2016/09/14 by Alexis.Matte

	Fix cook content, regression induce by the material workflow refactor
	#rb matt.kuhlenschmidt

Change 3126217 on 2016/09/15 by Gareth.Martin

	Unset bHasPerInstanceHitProxies on landscape grass components, as they don't have individually editable instances
	#rb Allan.Bentham

Change 3126311 on 2016/09/15 by Jamie.Dale

	Placement mode fixes

	 - The display name is now cached correctly on construction, and the FPlaceableItem instance used with SPlacementAssetEntry is now const.
	 - Ensured that the ID used by FPlaceableItem could never overflow.
	 - Fixed some types being missing from the "All Classes" list.
	 - Fixed the escape key not cancelling the search.

	#jira UE-35972
	#rb James.Hopkin

Change 3126325 on 2016/09/15 by Jamie.Dale

	Made sure that UWorld::GetAssetRegistryTags called its Super function so that properties tagged as AssetRegistrySearchable will be added.

	#rb Andrew.Rodham

Change 3126403 on 2016/09/15 by Gareth.Martin

	Added Find and Contains functions to TBitArray
	#rb Steve.Robb

Change 3126405 on 2016/09/15 by Gareth.Martin

	Allowed instances of Hierarchical Instanced Mesh Components to be moved around with the transform widget in the blueprint editor
	- Just like regular instanced mesh components!
	Also fixed not being able to move instances of an instanced mesh component when it is the root component
	Also also fixed Hierarchical Instanced Mesh Components not flushing their async tree build on saving (this was causing log spam from PostLoad when dragging instances around as the blueprint would constantly reinstance the component before the async tree build had finished)
	#jira UE-29357
	#rb Allan.Bentham

Change 3126444 on 2016/09/15 by Jamie.Dale

	Fixed the loc dashboard configs not working with SCC

	This isn't a great solution, but the whole way the loc dashboard manages its config data is in need of an overhaul.

	#rb none

Change 3126446 on 2016/09/15 by Jamie.Dale

	Fixed loc dashboard game and engine targets sharing the same expansion settting

	#rb none

Change 3126555 on 2016/09/15 by Chris.Wood

	Removed WER from Windows crash handling. Crashes saved to log folder and passed to CRC with explicit path.
	[UE-34470] - Investigate WER settings and if they can conflict with CRC on Windows

	#rb Steve.Robb

Change 3126586 on 2016/09/15 by Gareth.Martin

	Fixed missing landscape components when using a LODBias (cloned from 4.13.1)
	#jira UE-35873
	#rb Jack.Porter

Change 3126610 on 2016/09/15 by Jamie.Dale

	Stopped PS4 from always staging all ICU data files

	#rb Marcus.Wassmer

Change 3126779 on 2016/09/15 by Michael.Dupuis

	#jira UE-32914 Improve the help text to provide usage examples and params
	#rb Alexis.Matte

Change 3126849 on 2016/09/15 by Matt.Kuhlenschmidt

	Fix font material and outline font material not being animatable in sequencer

	#rb frank.fella

Change 3126858 on 2016/09/15 by Matt.Kuhlenschmidt

	File not saved
	#rb none

Change 3127001 on 2016/09/15 by Matt.Kuhlenschmidt

	Fixed reset to default state still not appearing in all cases after changing a property.

	#rb none

Change 3127038 on 2016/09/15 by Nick.Darnell

	UMG - Improving focus setting for users on widgets.  If we're unable to set the focus immediately, possibly because the user is setting focus in the Construct callback before the widget is in the tree, we now update the SlateOperations FReply on LocalPlayer to set focus next frame when it's more likely the widget will become focusable.

	#rb none

Change 3127061 on 2016/09/15 by Nick.Darnell

	Slate - We now have a reentrancy guard in TPanelChildren to avoid the broad cases where users might attempt to remove children while all children are being removed.  Which is an easy case to engineer if you've got widgets spawning children managed by another widget, that all go away at the same time, thus causing the parent to attempt to cleanup children.  The end result is a delete while deleting.  So now TPanelChildren prevents adds/removes while emptying the list of children.

	#jira UE-35726
	#rb Matt.Kuchlenschmidt

Change 3127205 on 2016/09/15 by Alex.Delesky

	#jira UE-18013 - Users can now add Textures, Materials, or Sprites to a Widget Blueprint directly from the content browser. This also fixes a few issues with adding Widget Blueprints to another Widget BP from the content browser, such as adding a widget to itself or creating a circular dependency.

	#rb Nick.Darnell

Change 3127971 on 2016/09/16 by Matt.Kuhlenschmidt

	Fix crash in scene outliner if actors become invalid

	#rb none

	https://jira.ol.epicgames.net/browse/UE-35932

Change 3128011 on 2016/09/16 by Matt.Kuhlenschmidt

	Added guards for crashes accessing slate resources for deleted uobjects

	#rb nick.darnell

Change 3128067 on 2016/09/16 by Michael.Dupuis

	#jira UE-34158 Add an option to auto expand advanced details
	#rb Alexis.Matte

Change 3128073 on 2016/09/16 by Michael.Dupuis

	#jira UE-1145
	Set Save As to Ctrl + Alt + S
	Set Save All to Ctrl + Shift + S
	Set Save Current to Ctrl + S

	#rb Alexis.Matte

Change 3128117 on 2016/09/16 by Jamie.Dale

	Updated the pin-type filter combo to filter on both the localized and source type descriptions

	#jira UE-36081
	#rb none

Change 3128177 on 2016/09/16 by Alexis.Matte

	#jira UE-35946 Remove unnecessary GetReadValue call with bad parameter. The read value call is cache so subsequent call was returning the bad cache value.

	#rb michael.dupuis
	#codereview matt.kuhlenschmidt

Change 3128387 on 2016/09/16 by Gareth.Martin

	Fixed location and rotation of arrow widget in the landscape mirror tool when using one of the new "Rotate" modes
	#jira UE-36093
	#rb none

Change 3128445 on 2016/09/16 by Matt.Kuhlenschmidt

	Guard against scene outliner crash.  Print out tree when items appear twice.
	https://jira.ol.epicgames.net/browse/UE-35935

	#rb none

Change 3128454 on 2016/09/16 by Matt.Kuhlenschmidt

	Remove category for WindowTitleBarArea.  It is very custom for internal use and should not be a top level widget

	#rb none

Change 3128482 on 2016/09/16 by Michael.Dupuis

	Added new key binding for generic Save, Save As
	Added new key binding for Save All for the content browser

	#rb Alexis.Matte (approved by MattK)

Change 3128560 on 2016/09/16 by Matt.Kuhlenschmidt

	Fix build warning

	#codereview nick.darnell
	#rb none

Change 3128642 on 2016/09/16 by Alexis.Matte

	#jira UE-36047 We now convert the light color correctly when importing and exporting fbx files. UE4 is sRGB and FBX is linear
	#rb none
	#codereview matt.kuhlenschmidt

Change 3128733 on 2016/09/16 by Nick.Darnell

	UMG - Fixing a bad merge, some code was removed causing all BindWidget statements to fail to compile correctly.

	#jira UE-36105
	#rb none

Change 3128768 on 2016/09/16 by Matt.Kuhlenschmidt

	Fix selection outline showing around edges of all internal mesh sections of a component instead of around the entire actor

	#rb none

Change 3128779 on 2016/09/16 by Matt.Kuhlenschmidt

	Fix offset characters on some small fonts

	#rb none

Change 3130057 on 2016/09/19 by Jamie.Dale

	Fixing volatility and invalidation issues for text widgets

	#jira UE-33988
	#rb Nick.Darnell

Change 3130064 on 2016/09/19 by Jamie.Dale

	Changed mprof meta-data to allow unicode strings and updated ReadString to deal with them correctly

	#rb James.Hopkin

Change 3130233 on 2016/09/19 by Michael.Dupuis

	#jira UE-32914 Added missing args that the UI supported
	#rb Alexis.Matte

Change 3130265 on 2016/09/19 by Nick.Darnell

	Automation - Cleaning up some API items.

	#rb none

Change 3130378 on 2016/09/19 by Matt.Kuhlenschmidt

	Fix reentrancy saving assets while a prompt for checkout dialog is open

	#rb none

Change 3130398 on 2016/09/19 by Jamie.Dale

	Fixing UHT error when building

	#rb none

Change 3132101 on 2016/09/20 by Nick.Darnell

	UMG - Adding a toolbar option in the designer for the 'G' command, similar to 'Game View' in the level editor, it disables all the dashed lines / future editor visuals.

	#rb none

Change 3132110 on 2016/09/20 by Nick.Darnell

	PR #2792: ShowFlags for WidgetComponents (Contributed by projectgheist)

	#jira UE-13770

	#rb Nick.Darnell

Change 3132111 on 2016/09/20 by Nick.Darnell

	UMG - The retainer now embeds a virtual window into the focus path so that paths are resolved correctly.

	#rb none

Change 3132138 on 2016/09/20 by Michael.Dupuis

	#jira UE-30945 Added missing PostEditComponentMove after drag is finished
	#rb Alexis.Matte

Change 3132147 on 2016/09/20 by Michael.Dupuis

	#jira UE-30866 Fixed the filter to work properly
	#rb Alexis.Matte

Change 3132190 on 2016/09/20 by Matt.Kuhlenschmidt

	Fix static analysis warnings in this file

	#rb none

Change 3132231 on 2016/09/20 by Nick.Darnell

	Slate - Updating the material blend states to match what is expected of Slate rendering, which differs a lot from the scene renderer with the way it treats alpha.  This fixes translucent rendering with the retainer widget, users will need to set their materials to Alpha Composite though for it to behave as expected.

	#jira UE-33285
	#rb none

Change 3132255 on 2016/09/20 by Alex.Delesky

	#jira UE-36048 - TMap and TSet properties are now disallowed from adding more children through the Details panel when they contain the dfault value for a key or element. Reset to Default is also no longer allowed on a Map or Set child when it will result in a second default value existing within the container.

	#rb Matt.Kuhlenschmidt

Change 3132587 on 2016/09/20 by Mike.Fricker

	MIDI Plugin: Fixed a CIS error in shipping configuration (introduced in CL 3108604)
	#rb none
	#lockdown matt.kuhlenschmidt

Change 3132623 on 2016/09/20 by Matt.Kuhlenschmidt

	Fix crash opening the cooker settings

	https://jira.it.epicgames.net/browse/UE-36197

	#rb none
	#lockdown nick.darnell

Change 3133144 on 2016/09/20 by Nick.Darnell

	Build configuration for automation tests.

	#rb none
	#lockdown matt.kuhlenschmidt

Change 3133206 on 2016/09/20 by Matt.Kuhlenschmidt

	Fix default material on odin text

	#rb none
	#lockdown nick.darnell

Change 3133913 on 2016/09/21 by Nick.Darnell

	Back out revision 17 from //UE4/Dev-Editor/Engine/Source/Runtime/UMG/Private/Slate/SRetainerWidget.cpp

	#rb none
	#jira UE-36231
	#lockdown matt.kuhlenschmidt

[CL 3133983 by Matt Kuhlenschmidt in Main branch]
2016-09-21 10:07:18 -04:00

2369 lines
85 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
StaticLightingSystem.cpp: Bsp light mesh illumination builder code
=============================================================================*/
#include "UnrealEd.h"
FSwarmDebugOptions GSwarmDebugOptions;
#include "Lightmass/LightmassCharacterIndirectDetailVolume.h"
#include "LightingBuildOptions.h"
#include "StaticLightingPrivate.h"
#include "Database.h"
#include "Sorting.h"
#include "ModelLight.h"
#include "PrecomputedLightVolume.h"
#include "LevelUtils.h"
#include "CrashTracker.h"
#include "EngineModule.h"
#include "LightMap.h"
#include "ShadowMap.h"
#include "RendererInterface.h"
#include "EditorBuildUtils.h"
#include "ComponentRecreateRenderStateContext.h"
#include "Engine/LODActor.h"
DEFINE_LOG_CATEGORY(LogStaticLightingSystem);
// Don't compile the static lighting system on consoles.
#if WITH_EDITOR
#include "Toolkits/AssetEditorManager.h"
#include "../Lightmass/Lightmass.h"
#include "Editor/StatsViewer/Public/StatsViewerModule.h"
#include "MessageLog.h"
#include "SNotificationList.h"
#include "NotificationManager.h"
#include "Engine/GeneratedMeshAreaLight.h"
#include "Engine/LevelStreaming.h"
#include "Engine/Selection.h"
#include "Components/SkyLightComponent.h"
#include "Components/LightmassPortalComponent.h"
#include "Runtime/CoreUObject/Public/Misc/UObjectToken.h"
#define LOCTEXT_NAMESPACE "StaticLightingSystem"
/** The number of hardware threads to not use for building static lighting. */
#define NUM_STATIC_LIGHTING_UNUSED_THREADS 0
bool GbLogAddingMappings = false;
/** Counts the number of lightmap textures generated each lighting build. */
extern ENGINE_API int32 GLightmapCounter;
/** Whether to compress lightmaps. Reloaded from ini each lighting build. */
extern ENGINE_API bool GCompressLightmaps;
/** Whether to allow lighting builds to generate streaming lightmaps. */
extern ENGINE_API bool GAllowStreamingLightmaps;
// NOTE: We're only counting the top-level mip-map for the following variables.
/** Total number of texels allocated for all lightmap textures. */
extern ENGINE_API uint64 GNumLightmapTotalTexels;
/** Total number of texels used if the texture was non-power-of-two. */
extern ENGINE_API uint64 GNumLightmapTotalTexelsNonPow2;
/** Number of lightmap textures generated. */
extern ENGINE_API int32 GNumLightmapTextures;
/** Total number of mapped texels. */
extern ENGINE_API uint64 GNumLightmapMappedTexels;
/** Total number of unmapped texels. */
extern ENGINE_API uint64 GNumLightmapUnmappedTexels;
/** Whether to allow cropping of unmapped borders in lightmaps and shadowmaps. Controlled by BaseEngine.ini setting. */
extern ENGINE_API bool GAllowLightmapCropping;
/** Total lightmap texture memory size (in bytes), including GLightmapTotalStreamingSize. */
extern ENGINE_API uint64 GLightmapTotalSize;
/** Total memory size for streaming lightmaps (in bytes). */
extern ENGINE_API uint64 GLightmapTotalStreamingSize;
/** Largest boundingsphere radius to use when packing lightmaps into a texture atlas. */
extern ENGINE_API float GMaxLightmapRadius;
/** Total number of texels allocated for all shadowmap textures. */
extern ENGINE_API uint64 GNumShadowmapTotalTexels;
/** Number of shadowmap textures generated. */
extern ENGINE_API int32 GNumShadowmapTextures;
/** Total number of mapped texels. */
extern ENGINE_API uint64 GNumShadowmapMappedTexels;
/** Total number of unmapped texels. */
extern ENGINE_API uint64 GNumShadowmapUnmappedTexels;
/** Total shadowmap texture memory size (in bytes), including GShadowmapTotalStreamingSize. */
extern ENGINE_API uint64 GShadowmapTotalSize;
/** Total texture memory size for streaming shadowmaps. */
extern ENGINE_API uint64 GShadowmapTotalStreamingSize;
/** If non-zero, purge old lightmap data when rebuilding lighting. */
int32 GPurgeOldLightmaps=1;
static FAutoConsoleVariableRef CVarPurgeOldLightmaps(
TEXT("PurgeOldLightmaps"),
GPurgeOldLightmaps,
TEXT("If non-zero, purge old lightmap data when rebuilding lighting.")
);
TSharedPtr<FStaticLightingManager> FStaticLightingManager::StaticLightingManager;
TSharedPtr<FStaticLightingManager> FStaticLightingManager::Get()
{
if (!StaticLightingManager.IsValid())
{
StaticLightingManager = MakeShareable(new FStaticLightingManager);
}
return StaticLightingManager;
}
void FStaticLightingManager::ProcessLightingData(bool bDiscardResults)
{
auto StaticLightingSystem = FStaticLightingManager::Get()->StaticLightingSystem;
check(StaticLightingSystem);
FNavigationLockContext NavUpdateLock(StaticLightingSystem->GetWorld(), ENavigationLockReason::LightingUpdate);
if (!bDiscardResults)
{
bool bSuccessful = StaticLightingSystem->FinishLightmassProcess();
FEditorDelegates::OnLightingBuildKept.Broadcast();
if (!bSuccessful)
{
FStaticLightingManager::Get()->FailLightingBuild();
}
}
FStaticLightingManager::Get()->DestroyStaticLightingSystem();
FStaticLightingManager::Get()->ClearCurrentNotification();
}
void FStaticLightingManager::CancelLightingBuild()
{
if (FStaticLightingManager::Get()->StaticLightingSystem->IsAsyncBuilding())
{
GEditor->SetMapBuildCancelled( true );
FStaticLightingManager::Get()->ClearCurrentNotification();
FEditorDelegates::OnLightingBuildFailed.Broadcast();
}
else
{
FStaticLightingManager::Get()->FailLightingBuild();
}
}
void FStaticLightingManager::SendProgressNotification()
{
// Start the lightmass 'progress' notification
FNotificationInfo Info( LOCTEXT("LightBuildMessage", "Building lighting") );
Info.bFireAndForget = false;
Info.ButtonDetails.Add(FNotificationButtonInfo(
LOCTEXT("LightBuildCancel","Cancel"),
LOCTEXT("LightBuildCancelToolTip","Cancels the lighting build in progress."),
FSimpleDelegate::CreateStatic(&FStaticLightingManager::CancelLightingBuild)));
LightBuildNotification = FSlateNotificationManager::Get().AddNotification(Info);
if (LightBuildNotification.IsValid())
{
LightBuildNotification.Pin()->SetCompletionState(SNotificationItem::CS_Pending);
}
}
void FStaticLightingManager::ClearCurrentNotification()
{
if ( LightBuildNotification.IsValid() )
{
LightBuildNotification.Pin()->SetCompletionState(SNotificationItem::CS_None);
LightBuildNotification.Pin()->ExpireAndFadeout();
LightBuildNotification.Reset();
}
}
void FStaticLightingManager::SetNotificationText( FText Text )
{
if ( LightBuildNotification.IsValid() )
{
LightBuildNotification.Pin()->SetText( Text );
}
}
void FStaticLightingManager::SendBuildDoneNotification( bool AutoApplyFailed )
{
FNotificationInfo Info( LOCTEXT( "LightBuildDoneMessage", "Lighting build completed" ) );
Info.bFireAndForget = false;
Info.bUseThrobber = false;
FNotificationButtonInfo ApplyNow = FNotificationButtonInfo(
LOCTEXT( "LightBuildKeep", "Apply Now" ),
LOCTEXT( "LightBuildKeepToolTip", "Keeps and applies built lighting data." ),
FSimpleDelegate::CreateStatic( &FStaticLightingManager::ProcessLightingData, false ) );
ApplyNow.VisibilityOnSuccess = EVisibility::Collapsed;
FNotificationButtonInfo Discard = FNotificationButtonInfo(
LOCTEXT( "LightBuildDiscard", "Discard" ),
LOCTEXT( "LightBuildDiscardToolTip", "Ignores the built lighting data generated." ),
FSimpleDelegate::CreateStatic( &FStaticLightingManager::ProcessLightingData, true ) );
Discard.VisibilityOnSuccess = EVisibility::Collapsed;
Info.ButtonDetails.Add( ApplyNow );
Info.ButtonDetails.Add( Discard );
FEditorDelegates::OnLightingBuildSucceeded.Broadcast();
LightBuildNotification = FSlateNotificationManager::Get().AddNotification( Info );
if ( LightBuildNotification.IsValid() )
{
LightBuildNotification.Pin()->SetCompletionState( AutoApplyFailed ? SNotificationItem::CS_Pending : SNotificationItem::CS_Success );
}
}
void FStaticLightingManager::CreateStaticLightingSystem(const FLightingBuildOptions& Options)
{
#if WITH_EDITOR
if (StaticLightingSystem == NULL)
{
StaticLightingSystem = new FStaticLightingSystem(Options, GWorld);
bool bSuccess = StaticLightingSystem->BeginLightmassProcess();
if (bSuccess)
{
SendProgressNotification();
}
else
{
DestroyStaticLightingSystem();
}
}
else
{
// Tell the user that they must close their current build first.
FNotificationInfo Info( LOCTEXT("LightBuildInProgressWarning", "A lighting build is already in progress! Please cancel it before triggering a new build.") );
Info.ExpireDuration = 5.0f;
TSharedPtr<SNotificationItem> Notification = FSlateNotificationManager::Get().AddNotification(Info);
if (Notification.IsValid())
{
Notification->SetCompletionState(SNotificationItem::CS_Fail);
}
}
#endif
}
void FStaticLightingManager::UpdateBuildLighting()
{
if (StaticLightingSystem != NULL)
{
StaticLightingSystem->UpdateLightingBuild();
}
}
void FStaticLightingManager::FailLightingBuild( FText ErrorText)
{
FStaticLightingManager::Get()->ClearCurrentNotification();
if (GEditor->GetMapBuildCancelled())
{
ErrorText = LOCTEXT("LightBuildCanceledMessage", "Lighting build canceled.");
}
else
{
// Override failure message if one provided
if (ErrorText.IsEmpty())
{
ErrorText = LOCTEXT("LightBuildFailedMessage", "Lighting build failed.");
}
}
FNotificationInfo Info( ErrorText );
Info.ExpireDuration = 4.f;
FEditorDelegates::OnLightingBuildFailed.Broadcast();
LightBuildNotification = FSlateNotificationManager::Get().AddNotification(Info);
if (LightBuildNotification.IsValid())
{
LightBuildNotification.Pin()->SetCompletionState(SNotificationItem::CS_Fail);
}
UE_LOG(LogStaticLightingSystem, Warning, TEXT("Failed to build lighting!!! %s"),*ErrorText.ToString());
FMessageLog("LightingResults").Open();
DestroyStaticLightingSystem();
}
void FStaticLightingManager::DestroyStaticLightingSystem()
{
if (StaticLightingSystem != NULL)
{
delete StaticLightingSystem;
StaticLightingSystem = NULL;
}
}
bool FStaticLightingManager::IsLightingBuildCurrentlyRunning() const
{
return StaticLightingSystem != NULL;
}
bool FStaticLightingManager::IsLightingBuildCurrentlyExporting() const
{
return StaticLightingSystem != NULL && StaticLightingSystem->IsAmortizedExporting();
}
FStaticLightingSystem::FStaticLightingSystem(const FLightingBuildOptions& InOptions, UWorld* InWorld )
: Options(InOptions)
, bBuildCanceled(false)
, DeterministicIndex(0)
, NextVisibilityId(0)
, CurrentBuildStage(FStaticLightingSystem::NotRunning)
, bCrashTrackerOriginallyEnabled(false)
, World(InWorld)
, LightmassProcessor(NULL)
{
}
FStaticLightingSystem::~FStaticLightingSystem()
{
if (bCrashTrackerOriginallyEnabled)
{
// Re-enable the crash tracker if we ever disabled it
ICrashTrackerModule* CrashTracker = FModuleManager::LoadModulePtr<ICrashTrackerModule>("CrashTracker");
if (CrashTracker)
{
CrashTracker->SetCrashTrackingEnabled(true);
bCrashTrackerOriginallyEnabled = false;
}
}
if (LightmassProcessor)
{
delete LightmassProcessor;
}
}
bool FStaticLightingSystem::BeginLightmassProcess()
{
StartTime = FPlatformTime::Seconds();
CurrentBuildStage = FStaticLightingSystem::Startup;
bool bRebuildDirtyGeometryForLighting = true;
bool bForceNoPrecomputedLighting = false;
{
FLightmassStatistics::FScopedGather StartupStatScope(LightmassStatistics.StartupTime);
// Flip the results page
FFormatNamedArguments Arguments;
Arguments.Add(TEXT("TimeStamp"), FText::AsDateTime(FDateTime::Now()));
FText LightingResultsPageName(FText::Format(LOCTEXT("LightingResultsPageName", "Lighting Build - {TimeStamp}"), Arguments));
FMessageLog("LightingResults").NewPage(LightingResultsPageName);
FStatsViewerModule& StatsViewerModule = FModuleManager::Get().LoadModuleChecked<FStatsViewerModule>(TEXT("StatsViewer"));
StatsViewerModule.GetPage(EStatsPage::LightingBuildInfo)->Clear();
GLightmapCounter = 0;
GNumLightmapTotalTexels = 0;
GNumLightmapTotalTexelsNonPow2 = 0;
GNumLightmapTextures = 0;
GNumLightmapMappedTexels = 0;
GNumLightmapUnmappedTexels = 0;
GLightmapTotalSize = 0;
GLightmapTotalStreamingSize = 0;
GNumShadowmapTotalTexels = 0;
GNumShadowmapTextures = 0;
GNumShadowmapMappedTexels = 0;
GNumShadowmapUnmappedTexels = 0;
GShadowmapTotalSize = 0;
GShadowmapTotalStreamingSize = 0;
for( TObjectIterator<UPrimitiveComponent> It ; It ; ++It )
{
UPrimitiveComponent* Component = *It;
Component->VisibilityId = INDEX_NONE;
}
FString SkippedLevels;
for ( int32 LevelIndex=0; LevelIndex < World->GetNumLevels(); LevelIndex++ )
{
ULevel* Level = World->GetLevel(LevelIndex);
Level->LightmapTotalSize = 0.0f;
Level->ShadowmapTotalSize = 0.0f;
ULevelStreaming* LevelStreaming = NULL;
if ( World->PersistentLevel != Level )
{
LevelStreaming = FLevelUtils::FindStreamingLevel( Level );
}
if (!Options.ShouldBuildLightingForLevel(Level))
{
if (SkippedLevels.Len() > 0)
{
SkippedLevels += FString(TEXT(", "));
}
SkippedLevels += Level->GetName();
}
}
for( int32 LevelIndex = 0 ; LevelIndex < World->StreamingLevels.Num() ; ++LevelIndex )
{
ULevelStreaming* CurStreamingLevel = World->StreamingLevels[ LevelIndex ];
if (CurStreamingLevel && CurStreamingLevel->GetLoadedLevel() && !CurStreamingLevel->bShouldBeVisibleInEditor)
{
if (SkippedLevels.Len() > 0)
{
SkippedLevels += FString(TEXT(", ")) + CurStreamingLevel->GetWorldAssetPackageName();
}
else
{
SkippedLevels += CurStreamingLevel->GetWorldAssetPackageName();
}
}
}
if (SkippedLevels.Len() > 0 && !IsRunningCommandlet())
{
// Warn when some levels are not visible and therefore will not be built, because that indicates that only a partial build will be done,
// Lighting will still be unbuilt for some areas when playing through the level.
const FText SkippedLevelsWarning = FText::Format( LOCTEXT("SkippedLevels", "The following levels will not have the lighting rebuilt because of your selected lighting build options: {0}"), FText::FromString( SkippedLevels ) );
FSuppressableWarningDialog::FSetupInfo Info( SkippedLevelsWarning, LOCTEXT("SkippedLevelsDialogTitle", "Rebuild Lighting - Warning" ), "WarnOnHiddenLevelsBeforeRebuild" );
Info.ConfirmText = LOCTEXT("SkippedWarningConfirm", "Build");
FSuppressableWarningDialog WarnAboutSkippedLevels( Info );
WarnAboutSkippedLevels.ShowModal();
}
static const auto AllowStaticLightingVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.AllowStaticLighting"));
const bool bAllowStaticLighting = (!AllowStaticLightingVar || AllowStaticLightingVar->GetValueOnGameThread() != 0);
bForceNoPrecomputedLighting = World->GetWorldSettings()->bForceNoPrecomputedLighting || !bAllowStaticLighting;
GConfig->GetFloat( TEXT("TextureStreaming"), TEXT("MaxLightmapRadius"), GMaxLightmapRadius, GEngineIni );
GConfig->GetBool( TEXT("TextureStreaming"), TEXT("AllowStreamingLightmaps"), GAllowStreamingLightmaps, GEngineIni );
if (!bForceNoPrecomputedLighting)
{
// Begin the static lighting progress bar.
GWarn->BeginSlowTask( LOCTEXT("BeginBuildingStaticLightingTaskStatus", "Building lighting"), false );
}
else
{
UE_LOG(LogStaticLightingSystem, Warning, TEXT("WorldSettings.bForceNoPrecomputedLighting is true, Skipping Lighting Build!"));
}
FConfigCacheIni::LoadGlobalIniFile(GLightmassIni, TEXT("Lightmass"), NULL, true);
verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bUseBilinearFilterLightmaps"), GUseBilinearLightmaps, GLightmassIni));
verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bAllowCropping"), GAllowLightmapCropping, GLightmassIni));
verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bRebuildDirtyGeometryForLighting"), bRebuildDirtyGeometryForLighting, GLightmassIni));
verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bCompressLightmaps"), GCompressLightmaps, GLightmassIni));
GCompressLightmaps = GCompressLightmaps && World->GetWorldSettings()->LightmassSettings.bCompressLightmaps;
GAllowLightmapPadding = true;
FMemory::Memzero(&LightingMeshBounds, sizeof(FBox));
FMemory::Memzero(&AutomaticImportanceVolumeBounds, sizeof(FBox));
GLightingBuildQuality = Options.QualityLevel;
}
{
FLightmassStatistics::FScopedGather CollectStatScope(LightmassStatistics.CollectTime);
// Prepare lights for rebuild.
{
FLightmassStatistics::FScopedGather PrepareStatScope(LightmassStatistics.PrepareLightsTime);
if (!Options.bOnlyBuildVisibility)
{
// Delete all AGeneratedMeshAreaLight's, since new ones will be created after the build with updated properties.
USelection* EditorSelection = GEditor->GetSelectedActors();
for(TObjectIterator<AGeneratedMeshAreaLight> LightIt;LightIt;++LightIt)
{
if (EditorSelection)
{
EditorSelection->Deselect(*LightIt);
}
(*LightIt)->GetWorld()->DestroyActor(*LightIt);
}
for (TObjectIterator<ULightComponentBase> LightIt(RF_ClassDefaultObject, /** bIncludeDerivedClasses */ true, /** InternalExcludeFlags */ EInternalObjectFlags::PendingKill); LightIt; ++LightIt)
{
ULightComponentBase* const Light = *LightIt;
const bool bLightIsInWorld = Light->GetOwner()
&& World->ContainsActor(Light->GetOwner())
&& !Light->GetOwner()->IsPendingKill();
if(bLightIsInWorld
&& Light->bAffectsWorld
&& (Light->HasStaticShadowing() || Light->HasStaticLighting()))
{
// Make sure the light GUIDs are up-to-date.
Light->ValidateLightGUIDs();
// Add the light to the system's list of lights in the world.
Lights.Add(Light);
}
}
}
}
{
FLightmassStatistics::FScopedGather GatherStatScope(LightmassStatistics.GatherLightingInfoTime);
if (IsTexelDebuggingEnabled())
{
// Clear reference to the selected lightmap
GCurrentSelectedLightmapSample.Lightmap = NULL;
GDebugStaticLightingInfo = FDebugLightingOutput();
}
GatherStaticLightingInfo(bRebuildDirtyGeometryForLighting, bForceNoPrecomputedLighting);
}
// Sort the mappings - and tag meshes if doing deterministic mapping
if (GLightmassDebugOptions.bSortMappings)
{
struct FCompareNumTexels
{
FORCEINLINE bool operator()( const FStaticLightingMappingSortHelper& A, const FStaticLightingMappingSortHelper& B ) const
{
return B.NumTexels < A.NumTexels;
}
};
UnSortedMappings.Sort( FCompareNumTexels() );
for (int32 SortIndex = 0; SortIndex < UnSortedMappings.Num(); SortIndex++)
{
FStaticLightingMapping* Mapping = UnSortedMappings[SortIndex].Mapping;
Mappings.Add(Mapping);
if (Mapping->bProcessMapping)
{
if (Mapping->Mesh)
{
Mapping->Mesh->Guid = FGuid(0,0,0,DeterministicIndex++);
}
}
}
UnSortedMappings.Empty();
}
// Verify deterministic lighting setup, if it is enabled...
for (int32 CheckMapIdx = 0; CheckMapIdx < Mappings.Num(); CheckMapIdx++)
{
if (Mappings[CheckMapIdx]->bProcessMapping)
{
FGuid CheckGuid = Mappings[CheckMapIdx]->Mesh->Guid;
if ((CheckGuid.A != 0) ||
(CheckGuid.B != 0) ||
(CheckGuid.C != 0) ||
(CheckGuid.D >= (uint32)(Mappings.Num()))
)
{
UE_LOG(LogStaticLightingSystem, Warning, TEXT("Lightmass: Error in deterministic lighting for %s:%s"),
*(Mappings[CheckMapIdx]->Mesh->Guid.ToString()), *(Mappings[CheckMapIdx]->GetDescription()));
}
}
}
// if we are dumping binary results, clear up any existing ones
if (Options.bDumpBinaryResults)
{
FStaticLightingSystem::ClearBinaryDumps();
}
}
ProcessingStartTime = FPlatformTime::Seconds();
bool bLightingSuccessful = false;
if (!bForceNoPrecomputedLighting)
{
bool bSavedUpdateStatus_LightMap = FLightMap2D::GetStatusUpdate();
if (GLightmassDebugOptions.bImmediateProcessMappings)
{
FLightMap2D::SetStatusUpdate(false);
}
bLightingSuccessful = CreateLightmassProcessor();
if (bLightingSuccessful)
{
GatherScene();
bLightingSuccessful = InitiateLightmassProcessor();
}
if (GLightmassDebugOptions.bImmediateProcessMappings)
{
FLightMap2D::SetStatusUpdate(bSavedUpdateStatus_LightMap);
}
}
else
{
InvalidateStaticLighting();
ApplyNewLightingData(true);
}
if (!bForceNoPrecomputedLighting)
{
// End the static lighting progress bar.
GWarn->EndSlowTask();
}
return bLightingSuccessful;
}
void FStaticLightingSystem::InvalidateStaticLighting()
{
FLightmassStatistics::FScopedGather InvalidationScopeStat(LightmassStatistics.InvalidationTime);
for( int32 LevelIndex=0; LevelIndex<World->GetNumLevels(); LevelIndex++ )
{
bool bMarkLevelDirty = false;
ULevel* Level = World->GetLevel(LevelIndex);
const bool bBuildLightingForLevel = Options.ShouldBuildLightingForLevel( Level );
if (bBuildLightingForLevel)
{
if (!Options.bOnlyBuildVisibility)
{
Level->PrecomputedLightVolume->RemoveFromScene(World->Scene);
Level->PrecomputedLightVolume->InvalidateLightingCache();
}
if (Level == World->PersistentLevel)
{
Level->PrecomputedVisibilityHandler.Invalidate(World->Scene);
Level->PrecomputedVolumeDistanceField.Invalidate(World->Scene);
}
// Mark any existing cached lightmap data as transient. This allows the derived data cache to purge it more aggressively.
// It is safe to do so even if some of these lightmaps are needed. It just means compressed data will have to be retrieved
// from the network cache or rebuilt.
if (GPurgeOldLightmaps != 0)
{
for (TObjectIterator<ULightMapTexture2D> It; It; ++It)
{
ULightMapTexture2D* LightMapTexture = *It;
if (LightMapTexture->GetOutermost() == Level->GetOutermost())
{
LightMapTexture->MarkPlatformDataTransient();
}
}
}
}
// Invalidate static lighting info on BSP.
bool bBuildBSPLighting = bBuildLightingForLevel;
TArray<FNodeGroup*> NodeGroupsToBuild;
TArray<UModelComponent*> SelectedModelComponents;
if (bBuildBSPLighting && !Options.bOnlyBuildVisibility)
{
if (!Options.bOnlyBuildSelected)
{
// Invalidate it all
for (int32 i = 0; i < Level->ModelComponents.Num(); i++)
{
Level->ModelComponents[i]->InvalidateLightingCacheDetailed(false, false);
}
}
}
// Inavlidate static lighting info on actors.
for(int32 ActorIndex = 0;ActorIndex < Level->Actors.Num();ActorIndex++)
{
AActor* Actor = Level->Actors[ActorIndex];
if(Actor)
{
const bool bBuildActorLighting =
bBuildLightingForLevel &&
(!Options.bOnlyBuildSelected || Actor->IsSelected());
if (bBuildActorLighting)
{
if (!Options.bOnlyBuildVisibility)
{
TInlineComponentArray<UActorComponent*> Components;
Actor->GetComponents(Components);
for (int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++)
{
UActorComponent* ActorComponent = Components[ComponentIndex];
if (ActorComponent->IsRegistered())
{
ULightComponent* LightComponent = Cast<ULightComponent>(Components[ComponentIndex]);
if (LightComponent)
{
// Don't regenerate light guids, since that would modify the light,
// And cause hidden levels affected by this light to have uncached light interactions.
LightComponent->InvalidateLightingCacheInner(false);
}
else
{
UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(ActorComponent);
if (PrimitiveComponent)
{
PrimitiveComponent->InvalidateLightingCacheDetailed(false, false);
}
else
{
ActorComponent->InvalidateLightingCacheDetailed(false, false);
}
}
}
}
}
}
}
}
}
}
void FStaticLightingSystem::PostInvalidateStaticLighting()
{
FLightmassStatistics::FScopedGather InvalidationScopeStat(LightmassStatistics.InvalidationTime);
for( int32 LevelIndex=0; LevelIndex<World->GetNumLevels(); LevelIndex++ )
{
ULevel* Level = World->GetLevel(LevelIndex);
const bool bBuildLightingForLevel = Options.ShouldBuildLightingForLevel( Level );
// Inavlidate static lighting info on actors if they are NOT marked for enqueued rebuild
for(int32 ActorIndex = 0;ActorIndex < Level->Actors.Num();ActorIndex++)
{
AActor* Actor = Level->Actors[ActorIndex];
if(Actor)
{
const bool bBuildActorLighting =
bBuildLightingForLevel &&
(!Options.bOnlyBuildSelected || Actor->IsSelected());
if (bBuildActorLighting)
{
if (!Options.bOnlyBuildVisibility)
{
TInlineComponentArray<UPrimitiveComponent*> Components;
Actor->GetComponents(Components);
for (int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++)
{
UPrimitiveComponent* PrimitiveComponent = Components[ComponentIndex];
if (PrimitiveComponent->IsRegistered())
{
bool bShouldBuildLightmapsForThis = PrimitiveComponent->bStaticLightingBuildEnqueued;
if (!bShouldBuildLightmapsForThis)
{
PrimitiveComponent->InvalidateLightingCache();
}
}
}
}
}
}
}
}
}
void UpdateStaticLightingHLODTreeIndices(TMultiMap<AActor*, FStaticLightingMesh*>& ActorMeshMap, ALODActor* LODActor, uint32 HLODTreeIndex, uint32& HLODLeafIndex)
{
check(LODActor && HLODTreeIndex > 0);
uint32 LeafStartIndex = HLODLeafIndex;
++HLODLeafIndex;
for (AActor* SubActor : LODActor->SubActors)
{
if (ALODActor* LODSubActor = Cast<ALODActor>(SubActor))
{
UpdateStaticLightingHLODTreeIndices(ActorMeshMap, LODSubActor, HLODTreeIndex, HLODLeafIndex);
}
else
{
TArray<FStaticLightingMesh*> SubActorMeshes;
ActorMeshMap.MultiFind(SubActor,SubActorMeshes);
for (FStaticLightingMesh* SubActorMesh : SubActorMeshes)
{
if (SubActorMesh->HLODTreeIndex == 0)
{
SubActorMesh->HLODTreeIndex = HLODTreeIndex;
SubActorMesh->HLODChildStartIndex = HLODLeafIndex;
SubActorMesh->HLODChildEndIndex = HLODLeafIndex;
++HLODLeafIndex;
}
else
{
// Output error to message log containing tokens to the problematic objects
FMessageLog("LightingResults").Warning()
->AddToken(FUObjectToken::Create(SubActorMesh->Component->GetOwner()))
->AddToken(FTextToken::Create(LOCTEXT("LightmassError_InvalidHLODTreeIndex", "will not be correctly lit since it is part of another Hierarchical LOD cluster besides ")))
->AddToken(FUObjectToken::Create(LODActor));
}
}
}
}
TArray<FStaticLightingMesh*> LODActorMeshes;
ActorMeshMap.MultiFind(LODActor, LODActorMeshes);
for (FStaticLightingMesh* LODActorMesh : LODActorMeshes)
{
LODActorMesh->HLODTreeIndex = HLODTreeIndex;
LODActorMesh->HLODChildStartIndex = LeafStartIndex;
LODActorMesh->HLODChildEndIndex = HLODLeafIndex - 1;
check(LODActorMesh->HLODChildEndIndex >= LODActorMesh->HLODChildStartIndex);
}
}
void FStaticLightingSystem::GatherStaticLightingInfo(bool bRebuildDirtyGeometryForLighting, bool bForceNoPrecomputedLighting)
{
uint32 ActorsInvalidated = 0;
uint32 ActorsToInvalidate = 0;
for( int32 LevelIndex=0; LevelIndex<World->GetNumLevels(); LevelIndex++ )
{
ActorsToInvalidate += World->GetLevel(LevelIndex)->Actors.Num();
}
const int32 ProgressUpdateFrequency = FMath::Max<int32>(ActorsToInvalidate / 20, 1);
GWarn->StatusUpdate( ActorsInvalidated, ActorsToInvalidate, LOCTEXT("GatheringSceneGeometryStatus", "Gathering scene geometry...") );
bool bObjectsToBuildLightingForFound = false;
// Gather static lighting info from actor components.
for (int32 LevelIndex = 0; LevelIndex < World->GetNumLevels(); LevelIndex++)
{
bool bMarkLevelDirty = false;
ULevel* Level = World->GetLevel(LevelIndex);
// If the geometry is dirty and we're allowed to automatically clean it up, do so
if (Level->bGeometryDirtyForLighting)
{
UE_LOG(LogStaticLightingSystem, Warning, TEXT("WARNING: Lighting build detected that geometry needs to be rebuilt to avoid incorrect lighting (due to modifying a lighting property)."));
if (bRebuildDirtyGeometryForLighting)
{
// This will go ahead and clean up lighting on all dirty levels (not just this one)
UE_LOG(LogStaticLightingSystem, Warning, TEXT("WARNING: Lighting build automatically rebuilding geometry.") );
GEditor->Exec(World, TEXT("MAP REBUILD ALLDIRTYFORLIGHTING"));
}
}
const bool bBuildLightingForLevel = Options.ShouldBuildLightingForLevel(Level);
// Gather static lighting info from BSP.
bool bBuildBSPLighting = bBuildLightingForLevel;
TArray<FNodeGroup*> NodeGroupsToBuild;
TArray<UModelComponent*> SelectedModelComponents;
if (bBuildBSPLighting && !Options.bOnlyBuildVisibility)
{
if (Options.bOnlyBuildSelected)
{
UModel* Model = Level->Model;
GLightmassDebugOptions.bGatherBSPSurfacesAcrossComponents = false;
Model->GroupAllNodes(Level, Lights);
bBuildBSPLighting = false;
// Build only selected brushes/surfaces
TArray<ABrush*> SelectedBrushes;
for (int32 ActorIndex = 0; ActorIndex < Level->Actors.Num(); ActorIndex++)
{
AActor* Actor = Level->Actors[ActorIndex];
if (Actor)
{
ABrush* Brush = Cast<ABrush>(Actor);
if (Brush && Brush->IsSelected())
{
SelectedBrushes.Add(Brush);
}
}
}
TArray<int32> SelectedSurfaceIndices;
// Find selected surfaces...
for (int32 SurfIdx = 0; SurfIdx < Model->Surfs.Num(); SurfIdx++)
{
bool bSurfaceSelected = false;
FBspSurf& Surf = Model->Surfs[SurfIdx];
if ((Surf.PolyFlags & PF_Selected) != 0)
{
SelectedSurfaceIndices.Add(SurfIdx);
bSurfaceSelected = true;
}
else
{
int32 DummyIdx;
if (SelectedBrushes.Find(Surf.Actor, DummyIdx) == true)
{
SelectedSurfaceIndices.Add(SurfIdx);
bSurfaceSelected = true;
}
}
if (bSurfaceSelected == true)
{
// Find it's model component...
for (int32 NodeIdx = 0; NodeIdx < Model->Nodes.Num(); NodeIdx++)
{
const FBspNode& Node = Model->Nodes[NodeIdx];
if (Node.iSurf == SurfIdx)
{
UModelComponent* SomeModelComponent = Level->ModelComponents[Node.ComponentIndex];
if (SomeModelComponent)
{
SelectedModelComponents.AddUnique(SomeModelComponent);
for (int32 InnerNodeIndex = 0; InnerNodeIndex < SomeModelComponent->Nodes.Num(); InnerNodeIndex++)
{
FBspNode& InnerNode = Model->Nodes[SomeModelComponent->Nodes[InnerNodeIndex]];
SelectedSurfaceIndices.AddUnique(InnerNode.iSurf);
}
}
}
}
}
}
// Pass 2...
if (SelectedSurfaceIndices.Num() > 0)
{
for (int32 SSIdx = 0; SSIdx < SelectedSurfaceIndices.Num(); SSIdx++)
{
int32 SurfIdx = SelectedSurfaceIndices[SSIdx];
// Find it's model component...
for (int32 NodeIdx = 0; NodeIdx < Model->Nodes.Num(); NodeIdx++)
{
const FBspNode& Node = Model->Nodes[NodeIdx];
if (Node.iSurf == SurfIdx)
{
UModelComponent* SomeModelComponent = Level->ModelComponents[Node.ComponentIndex];
if (SomeModelComponent)
{
SelectedModelComponents.AddUnique(SomeModelComponent);
for (int32 InnerNodeIndex = 0; InnerNodeIndex < SomeModelComponent->Nodes.Num(); InnerNodeIndex++)
{
FBspNode& InnerNode = Model->Nodes[SomeModelComponent->Nodes[InnerNodeIndex]];
SelectedSurfaceIndices.AddUnique(InnerNode.iSurf);
}
}
}
}
}
}
if (SelectedSurfaceIndices.Num() > 0)
{
// Fill in a list of all the node group to rebuild...
bBuildBSPLighting = false;
for (TMap<int32, FNodeGroup*>::TIterator It(Model->NodeGroups); It; ++It)
{
FNodeGroup* NodeGroup = It.Value();
if (NodeGroup && (NodeGroup->Nodes.Num() > 0))
{
for (int32 GroupNodeIdx = 0; GroupNodeIdx < NodeGroup->Nodes.Num(); GroupNodeIdx++)
{
int32 CheckIdx;
if (SelectedSurfaceIndices.Find(Model->Nodes[NodeGroup->Nodes[GroupNodeIdx]].iSurf, CheckIdx) == true)
{
NodeGroupsToBuild.AddUnique(NodeGroup);
bBuildBSPLighting = true;
}
}
}
}
}
}
}
if (bBuildBSPLighting && !bForceNoPrecomputedLighting)
{
if (!Options.bOnlyBuildSelected || Options.bOnlyBuildVisibility)
{
// generate BSP mappings across the whole level
AddBSPStaticLightingInfo(Level, bBuildBSPLighting);
}
else
{
if (NodeGroupsToBuild.Num() > 0)
{
bObjectsToBuildLightingForFound = true;
AddBSPStaticLightingInfo(Level, NodeGroupsToBuild);
}
}
}
// Gather HLOD primitives
TMultiMap<AActor*, UPrimitiveComponent*> PrimitiveActorMap;
TMultiMap<UPrimitiveComponent*, UStaticMeshComponent*> PrimitiveSubStaticMeshMap;
for (int32 ActorIndex = 0; ActorIndex < Level->Actors.Num(); ActorIndex++)
{
AActor* Actor = Level->Actors[ActorIndex];
if (Actor)
{
ALODActor* LODActor = Cast<ALODActor>(Actor);
if (LODActor && LODActor->GetStaticMeshComponent())
{
UPrimitiveComponent* PrimitiveParent = LODActor->GetStaticMeshComponent()->GetLODParentPrimitive();
for (auto SubActor : LODActor->SubActors)
{
PrimitiveActorMap.Add(SubActor, LODActor->GetStaticMeshComponent());
if (PrimitiveParent)
{
PrimitiveActorMap.Add(SubActor, PrimitiveParent);
}
TArray<UStaticMeshComponent*> SubStaticMeshComponents;
SubActor->GetComponents<UStaticMeshComponent>(SubStaticMeshComponents);
for (auto SMC : SubStaticMeshComponents)
{
PrimitiveSubStaticMeshMap.Add(LODActor->GetStaticMeshComponent(), SMC);
}
}
}
}
}
TMultiMap<AActor*, FStaticLightingMesh*> ActorMeshMap;
TArray<ALODActor*> LODActors;
// Gather static lighting info from actors.
for (int32 ActorIndex = 0; ActorIndex < Level->Actors.Num(); ActorIndex++)
{
AActor* Actor = Level->Actors[ActorIndex];
if (Actor)
{
const bool bBuildActorLighting =
bBuildLightingForLevel &&
(!Options.bOnlyBuildSelected || Actor->IsSelected());
TInlineComponentArray<UPrimitiveComponent*> Components;
Actor->GetComponents(Components);
if (bBuildActorLighting)
{
bObjectsToBuildLightingForFound = true;
if (!Options.bOnlyBuildVisibility)
{
for (int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++)
{
Components[ComponentIndex]->bStaticLightingBuildEnqueued = true;
}
}
}
TArray<UPrimitiveComponent*> HLODPrimitiveParents;
PrimitiveActorMap.MultiFind(Actor, HLODPrimitiveParents);
ALODActor* LODActor = Cast<ALODActor>(Actor);
if (LODActor)
{
LODActors.Add(LODActor);
}
// Gather static lighting info from each of the actor's components.
for (int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++)
{
UPrimitiveComponent* Primitive = Components[ComponentIndex];
if (Primitive->IsRegistered() && !bForceNoPrecomputedLighting)
{
// Find the lights relevant to the primitive.
TArray<ULightComponent*> PrimitiveRelevantLights;
for (int32 LightIndex = 0; LightIndex < Lights.Num(); LightIndex++)
{
ULightComponentBase* LightBase = Lights[LightIndex];
ULightComponent* Light = Cast<ULightComponent>(LightBase);
// Only add enabled lights
if (Light && Light->AffectsPrimitive(Primitive))
{
PrimitiveRelevantLights.Add(Light);
}
}
// Query the component for its static lighting info.
FStaticLightingPrimitiveInfo PrimitiveInfo;
Primitive->GetStaticLightingInfo(PrimitiveInfo, PrimitiveRelevantLights, Options);
if (PrimitiveInfo.Meshes.Num() > 0 && (Primitive->Mobility == EComponentMobility::Static))
{
if (World->GetWorldSettings()->bPrecomputeVisibility)
{
// Make sure the level gets dirtied since we are changing the visibility Id of a component in it
bMarkLevelDirty = true;
}
PrimitiveInfo.VisibilityId = Primitive->VisibilityId = NextVisibilityId;
NextVisibilityId++;
}
TArray<UStaticMeshComponent*> LODSubActorSMComponents;
if (LODActor)
{
PrimitiveSubStaticMeshMap.MultiFind(Primitive, LODSubActorSMComponents);
}
for (auto Mesh : PrimitiveInfo.Meshes)
{
ActorMeshMap.Add(Actor, Mesh);
}
AddPrimitiveStaticLightingInfo(PrimitiveInfo, bBuildActorLighting);
}
}
}
ActorsInvalidated++;
if (ActorsInvalidated % ProgressUpdateFrequency == 0)
{
GWarn->UpdateProgress(ActorsInvalidated, ActorsToInvalidate);
}
}
// Recurse through HLOD trees, group actors and calculate child ranges
uint32 HLODTreeIndex = 1;
uint32 HLODLeafIndex;
for (ALODActor* LODActor : LODActors)
{
// Only process fully merged (root) HLOD nodes
if (LODActor->GetStaticMeshComponent() && !LODActor->GetStaticMeshComponent()->GetLODParentPrimitive())
{
HLODLeafIndex = 0;
UpdateStaticLightingHLODTreeIndices(ActorMeshMap, LODActor, HLODTreeIndex, HLODLeafIndex);
++HLODTreeIndex;
}
}
if (bMarkLevelDirty)
{
Level->MarkPackageDirty();
}
}
if (Options.bOnlyBuildSelected)
{
FMessageLog("LightingResults").Warning(LOCTEXT("LightmassError_BuildSelected", "Building selected actors only, lightmap memory and quality will be sub-optimal until the next full rebuild."));
if (!bObjectsToBuildLightingForFound)
{
FMessageLog("LightingResults").Error(LOCTEXT("LightmassError_BuildSelectedNothingSelected", "Building selected actors and BSP only, but no actors or BSP selected!"));
}
}
}
void FStaticLightingSystem::EncodeTextures(bool bLightingSuccessful)
{
// used to debug multithreaded issues (don't check in)
bool bEnableMultithreadedLightmapEncode = false;
bool bEnableMultithreadedShadowmapEncode = false;
UEditorExperimentalSettings* ExperimentalSettings = UEditorExperimentalSettings::StaticClass()->GetDefaultObject<UEditorExperimentalSettings>();
if (ExperimentalSettings)
{
bEnableMultithreadedLightmapEncode = ExperimentalSettings->bEnableMultithreadedLightmapEncoding;
bEnableMultithreadedShadowmapEncode = ExperimentalSettings->bEnableMultithreadedShadowmapEncoding;
}
FLightmassStatistics::FScopedGather EncodeStatScope(LightmassStatistics.EncodingTime);
FScopedSlowTask SlowTask(2);
{
FLightmassStatistics::FScopedGather EncodeStatScope2(LightmassStatistics.EncodingLightmapsTime);
// Flush pending shadow-map and light-map encoding.
SlowTask.EnterProgressFrame(1, LOCTEXT("EncodingImportedStaticLightMapsStatusMessage", "Encoding imported static light maps."));
FLightMap2D::EncodeTextures(World, bLightingSuccessful, bEnableMultithreadedLightmapEncode);
}
{
FLightmassStatistics::FScopedGather EncodeStatScope2(LightmassStatistics.EncodingShadowMapsTime);
SlowTask.EnterProgressFrame(1, LOCTEXT("EncodingImportedStaticShadowMapsStatusMessage", "Encoding imported static shadow maps."));
FShadowMap2D::EncodeTextures(World, bLightingSuccessful, bEnableMultithreadedShadowmapEncode);
}
}
void FStaticLightingSystem::ApplyNewLightingData(bool bLightingSuccessful)
{
{
FLightmassStatistics::FScopedGather ApplyStatScope(LightmassStatistics.ApplyTime);
// Now that the lighting is done, we can tell the model components to use their new elements,
// instead of the pre-lighting ones
UModelComponent::ApplyTempElements(bLightingSuccessful);
}
{
FLightmassStatistics::FScopedGather FinishStatScope(LightmassStatistics.FinishingTime);
// Mark lights of the computed level to have valid precomputed lighting.
for (int32 LevelIndex = 0; LevelIndex < World->GetNumLevels(); LevelIndex++)
{
ULevel* Level = World->GetLevel(LevelIndex);
if (World->PersistentLevel == Level)
{
Level->PrecomputedVisibilityHandler.UpdateScene(World->Scene);
Level->PrecomputedVolumeDistanceField.UpdateScene(World->Scene);
}
const bool bBuildLightingForLevel = Options.ShouldBuildLightingForLevel( Level );
uint32 ActorCount = Level->Actors.Num();
for (uint32 ActorIndex = 0; ActorIndex < ActorCount; ++ActorIndex)
{
AActor* Actor = Level->Actors[ActorIndex];
if (Actor && bLightingSuccessful && !Options.bOnlyBuildSelected)
{
TInlineComponentArray<ULightComponentBase*> Components;
Actor->GetComponents(Components);
for (int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++)
{
ULightComponentBase* LightComponent = Components[ComponentIndex];
if (LightComponent && (LightComponent->HasStaticShadowing() || LightComponent->HasStaticLighting()))
{
LightComponent->bPrecomputedLightingIsValid = true;
}
}
}
}
// Store off the quality of the lighting for the level if lighting was successful and we build lighting for this level.
if( bLightingSuccessful && bBuildLightingForLevel )
{
Level->GetWorldSettings()->LevelLightingQuality = Options.QualityLevel;
}
}
// Ensure all primitives which were marked dirty by the lighting build are updated.
// First clear all components so that any references to static lighting assets held
// by scene proxies will be fully released before any components are reregistered.
// We do not rerun construction scripts - nothing should have changed that requires that, and
// want to know which components were not moved during lighting rebuild
{
FGlobalComponentRecreateRenderStateContext RecreateRenderState;
}
// Clean up old shadow-map and light-map data.
CollectGarbage( GARBAGE_COLLECTION_KEEPFLAGS );
// Commit the changes to the world's BSP surfaces.
World->CommitModelSurfaces();
}
// Report failed lighting build (don't count cancelled builds as failure).
if ( !bLightingSuccessful && !bBuildCanceled )
{
FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("LightingBuildFailedDialogMessage", "The lighting build failed! See the log for more information!") );
}
}
/**
* Reports lighting build statistics to the log.
*/
void FStaticLightingSystem::ReportStatistics()
{
extern UNREALED_API bool GLightmassStatsMode;
if ( GLightmassStatsMode )
{
double TrackedTime =
LightmassStatistics.StartupTime
+ LightmassStatistics.CollectTime
+ LightmassStatistics.ProcessingTime
+ LightmassStatistics.ImportTime
+ LightmassStatistics.ApplyTime
+ LightmassStatistics.EncodingTime
+ LightmassStatistics.InvalidationTime
+ LightmassStatistics.FinishingTime;
double UntrackedTime = LightmassStatistics.TotalTime - TrackedTime;
UE_LOG(LogStaticLightingSystem, Log,
TEXT("Illumination: %s total\n")
TEXT(" %3.1f%%\t%8.1fs Untracked time\n")
, *FPlatformTime::PrettyTime(LightmassStatistics.TotalTime)
, UntrackedTime / LightmassStatistics.TotalTime * 100.0
, UntrackedTime
);
UE_LOG(LogStaticLightingSystem, Log,
TEXT("Breakdown of Illumination time\n")
TEXT(" %3.1f%%\t%8.1fs \tStarting up\n")
TEXT(" %3.1f%%\t%8.1fs \tCollecting\n")
TEXT(" %3.1f%%\t%8.1fs \t--> Preparing lights\n")
TEXT(" %3.1f%%\t%8.1fs \t--> Gathering lighting info\n")
TEXT(" %3.1f%%\t%8.1fs \tProcessing\n")
TEXT(" %3.1f%%\t%8.1fs \tImporting\n")
TEXT(" %3.1f%%\t%8.1fs \tApplying\n")
TEXT(" %3.1f%%\t%8.1fs \tEncoding\n")
TEXT(" %3.1f%%\t%8.1fs \tInvalidating\n")
TEXT(" %3.1f%%\t%8.1fs \tFinishing\n")
, LightmassStatistics.StartupTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.StartupTime
, LightmassStatistics.CollectTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.CollectTime
, LightmassStatistics.PrepareLightsTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.PrepareLightsTime
, LightmassStatistics.GatherLightingInfoTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.GatherLightingInfoTime
, LightmassStatistics.ProcessingTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.ProcessingTime
, LightmassStatistics.ImportTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.ImportTime
, LightmassStatistics.ApplyTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.ApplyTime
, LightmassStatistics.EncodingTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.EncodingTime
, LightmassStatistics.InvalidationTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.InvalidationTime
, LightmassStatistics.FinishingTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.FinishingTime
);
UE_LOG(LogStaticLightingSystem, Log,
TEXT("Breakdown of Processing time\n")
TEXT(" %3.1f%%\t%8.1fs \tCollecting Lightmass scene\n")
TEXT(" %3.1f%%\t%8.1fs \tExporting\n")
TEXT(" %3.1f%%\t%8.1fs \tLightmass\n")
TEXT(" %3.1f%%\t%8.1fs \tSwarm startup\n")
TEXT(" %3.1f%%\t%8.1fs \tSwarm callback\n")
TEXT(" %3.1f%%\t%8.1fs \tSwarm job open\n")
TEXT(" %3.1f%%\t%8.1fs \tSwarm job close\n")
TEXT(" %3.1f%%\t%8.1fs \tImporting\n")
TEXT(" %3.1f%%\t%8.1fs \tApplying\n")
, LightmassStatistics.CollectLightmassSceneTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.CollectLightmassSceneTime
, LightmassStatistics.ExportTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.ExportTime
, LightmassStatistics.LightmassTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.LightmassTime
, LightmassStatistics.SwarmStartupTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.SwarmStartupTime
, LightmassStatistics.SwarmCallbackTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.SwarmCallbackTime
, LightmassStatistics.SwarmJobOpenTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.SwarmJobOpenTime
, LightmassStatistics.SwarmJobCloseTime / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.SwarmJobCloseTime
, LightmassStatistics.ImportTimeInProcessing / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.ImportTimeInProcessing
, LightmassStatistics.ApplyTimeInProcessing / LightmassStatistics.TotalTime * 100.0
, LightmassStatistics.ApplyTimeInProcessing
);
UE_LOG(LogStaticLightingSystem, Log,
TEXT("Breakdown of Export Times\n")
TEXT(" %8.1fs\tVisibility Data\n")
TEXT(" %8.1fs\tLights\n")
TEXT(" %8.1fs\tModels\n")
TEXT(" %8.1fs\tStatic Meshes\n")
TEXT(" %8.1fs\tMaterials\n")
TEXT(" %8.1fs\tMesh Instances\n")
TEXT(" %8.1fs\tLandscape Instances\n")
TEXT(" %8.1fs\tMappings\n")
, LightmassStatistics.ExportVisibilityDataTime
, LightmassStatistics.ExportLightsTime
, LightmassStatistics.ExportModelsTime
, LightmassStatistics.ExportStaticMeshesTime
, LightmassStatistics.ExportMaterialsTime
, LightmassStatistics.ExportMeshInstancesTime
, LightmassStatistics.ExportLandscapeInstancesTime
, LightmassStatistics.ExportMappingsTime
);
UE_LOG(LogStaticLightingSystem, Log,
TEXT("Scratch counters\n")
TEXT(" %3.1f%%\tScratch0\n")
TEXT(" %3.1f%%\tScratch1\n")
TEXT(" %3.1f%%\tScratch2\n")
TEXT(" %3.1f%%\tScratch3\n")
, LightmassStatistics.Scratch0
, LightmassStatistics.Scratch1
, LightmassStatistics.Scratch2
, LightmassStatistics.Scratch3
);
float NumLightmapTotalTexels = float(FMath::Max<uint64>(GNumLightmapTotalTexels,1));
float NumShadowmapTotalTexels = float(FMath::Max<uint64>(GNumShadowmapTotalTexels,1));
float LightmapTexelsToMT = float(NUM_HQ_LIGHTMAP_COEF)/float(NUM_STORED_LIGHTMAP_COEF)/1024.0f/1024.0f; // Strip out the SimpleLightMap
float ShadowmapTexelsToMT = 1.0f/1024.0f/1024.0f;
UE_LOG(LogStaticLightingSystem, Log, TEXT("Lightmap textures: %.1f M texels (%.1f%% mapped, %.1f%% unmapped, %.1f%% wasted by packing, %.1f M non-pow2 texels)")
, NumLightmapTotalTexels * LightmapTexelsToMT
, 100.0f * float(GNumLightmapMappedTexels) / NumLightmapTotalTexels
, 100.0f * float(GNumLightmapUnmappedTexels) / NumLightmapTotalTexels
, 100.0f * float(GNumLightmapTotalTexels - GNumLightmapMappedTexels - GNumLightmapUnmappedTexels) / NumLightmapTotalTexels
, GNumLightmapTotalTexelsNonPow2 * LightmapTexelsToMT
);
UE_LOG(LogStaticLightingSystem, Log, TEXT("Shadowmap textures: %.1f M texels (%.1f%% mapped, %.1f%% unmapped, %.1f%% wasted by packing)")
, NumShadowmapTotalTexels * ShadowmapTexelsToMT
, 100.0f * float(GNumShadowmapMappedTexels) / NumShadowmapTotalTexels
, 100.0f * float(GNumShadowmapUnmappedTexels) / NumShadowmapTotalTexels
, 100.0f * float(GNumShadowmapTotalTexels - GNumShadowmapMappedTexels - GNumShadowmapUnmappedTexels) / NumShadowmapTotalTexels
);
for ( int32 LevelIndex=0; LevelIndex < World->GetNumLevels(); LevelIndex++ )
{
ULevel* Level = World->GetLevel(LevelIndex);
UE_LOG(LogStaticLightingSystem, Log, TEXT("Level %2d - Lightmaps: %.1f MB. Shadowmaps: %.1f MB."), LevelIndex, Level->LightmapTotalSize/1024.0f, Level->ShadowmapTotalSize/1024.0f );
}
}
else //if ( GLightmassStatsMode)
{
UE_LOG(LogStaticLightingSystem, Log, TEXT("Illumination: %s (%s encoding lightmaps, %s encoding shadowmaps)"), *FPlatformTime::PrettyTime(LightmassStatistics.TotalTime), *FPlatformTime::PrettyTime(LightmassStatistics.EncodingLightmapsTime), *FPlatformTime::PrettyTime(LightmassStatistics.EncodingShadowMapsTime));
}
UE_LOG(LogStaticLightingSystem, Log, TEXT("Lightmap texture memory: %.1f MB (%.1f MB streaming, %.1f MB non-streaming), %d textures"),
GLightmapTotalSize/1024.0f/1024.0f,
GLightmapTotalStreamingSize/1024.0f/1024.0f,
(GLightmapTotalSize - GLightmapTotalStreamingSize)/1024.0f/1024.0f,
GNumLightmapTextures);
UE_LOG(LogStaticLightingSystem, Log, TEXT("Shadowmap texture memory: %.1f MB (%.1f MB streaming, %.1f MB non-streaming), %d textures"),
GShadowmapTotalSize/1024.0f/1024.0f,
GShadowmapTotalStreamingSize/1024.0f/1024.0f,
(GShadowmapTotalSize - GShadowmapTotalStreamingSize)/1024.0f/1024.0f,
GNumShadowmapTextures);
}
void FStaticLightingSystem::CompleteDeterministicMappings(class FLightmassProcessor* InLightmassProcessor)
{
check(InLightmassProcessor != NULL);
if (InLightmassProcessor && GLightmassDebugOptions.bUseImmediateImport && GLightmassDebugOptions.bImmediateProcessMappings)
{
// Already completed in the Lightmass Run function...
return;
}
double ImportAndApplyStartTime = FPlatformTime::Seconds();
double ApplyTime = 0.0;
int32 CurrentStep = Mappings.Num();
int32 TotalSteps = Mappings.Num() * 2;
const int32 ProgressUpdateFrequency = FMath::Max<int32>(TotalSteps / 20, 1);
GWarn->StatusUpdate( CurrentStep, TotalSteps, LOCTEXT("CompleteDeterministicMappingsStatusMessage", "Importing and applying deterministic mappings...") );
// Process all the texture mappings first...
for (int32 MappingIndex = 0; MappingIndex < Mappings.Num(); MappingIndex++)
{
FStaticLightingTextureMapping* TextureMapping = Mappings[MappingIndex]->GetTextureMapping();
if (TextureMapping)
{
//UE_LOG(LogStaticLightingSystem, Log, TEXT("%32s Completed - %s"), *(TextureMapping->GetDescription()), *(TextureMapping->GetLightingGuid().ToString()));
if (!GLightmassDebugOptions.bUseImmediateImport)
{
InLightmassProcessor->ImportMapping(TextureMapping->GetLightingGuid(), true);
}
else
{
double ApplyStartTime = FPlatformTime::Seconds();
InLightmassProcessor->ProcessMapping(TextureMapping->GetLightingGuid());
ApplyTime += FPlatformTime::Seconds() - ApplyStartTime;
}
CurrentStep++;
if (CurrentStep % ProgressUpdateFrequency == 0)
{
GWarn->UpdateProgress(CurrentStep , TotalSteps);
}
}
}
LightmassStatistics.ImportTimeInProcessing += FPlatformTime::Seconds() - ImportAndApplyStartTime - ApplyTime;
LightmassStatistics.ApplyTimeInProcessing += ApplyTime;
}
struct FCompareByArrayCount
{
FORCEINLINE bool operator()( const TArray<ULightComponent*>& A, const TArray<ULightComponent*>& B ) const
{
// Sort by descending array count
return B.Num() < A.Num();
}
};
/**
* Generates mappings/meshes for all BSP in the given level
*
* @param Level Level to build BSP lighting info for
* @param bBuildLightingForBSP If true, we need BSP mappings generated as well as the meshes
*/
void FStaticLightingSystem::AddBSPStaticLightingInfo(ULevel* Level, bool bBuildLightingForBSP)
{
// For BSP, we aren't Component-centric, so we can't use the GetStaticLightingInfo
// function effectively. Instead, we look across all nodes in the Level's model and
// generate NodeGroups - which are groups of nodes that are coplanar, adjacent, and
// have the same lightmap resolution (henceforth known as being "conodes"). Each
// NodeGroup will get a mapping created for it
// cache the model
UModel* Model = Level->Model;
// reset the number of incomplete groups
Model->NumIncompleteNodeGroups = 0;
Model->CachedMappings.Empty();
Model->bInvalidForStaticLighting = false;
// create all NodeGroups
Model->GroupAllNodes(Level, Lights);
// now we need to make the mappings/meshes
bool bMarkLevelDirty = false;
for (TMap<int32, FNodeGroup*>::TIterator It(Model->NodeGroups); It; ++It)
{
FNodeGroup* NodeGroup = It.Value();
if (NodeGroup->Nodes.Num())
{
// get one of the surfaces/components from the NodeGroup
// @todo UE4: Remove need for GetSurfaceLightMapResolution to take a surfaceindex, or a ModelComponent :)
UModelComponent* SomeModelComponent = Level->ModelComponents[Model->Nodes[NodeGroup->Nodes[0]].ComponentIndex];
int32 SurfaceIndex = Model->Nodes[NodeGroup->Nodes[0]].iSurf;
// fill out the NodeGroup/mapping, as UModelComponent::GetStaticLightingInfo did
SomeModelComponent->GetSurfaceLightMapResolution(SurfaceIndex, true, NodeGroup->SizeX, NodeGroup->SizeY, NodeGroup->WorldToMap, &NodeGroup->Nodes);
// Make sure mapping will have valid size
NodeGroup->SizeX = FMath::Max(NodeGroup->SizeX, 1);
NodeGroup->SizeY = FMath::Max(NodeGroup->SizeY, 1);
NodeGroup->MapToWorld = NodeGroup->WorldToMap.InverseFast();
// Cache the surface's vertices and triangles.
NodeGroup->BoundingBox.Init();
TArray<int32> ComponentVisibilityIds;
for(int32 NodeIndex = 0;NodeIndex < NodeGroup->Nodes.Num();NodeIndex++)
{
const FBspNode& Node = Model->Nodes[NodeGroup->Nodes[NodeIndex]];
const FBspSurf& NodeSurf = Model->Surfs[Node.iSurf];
const FVector& TextureBase = Model->Points[NodeSurf.pBase];
const FVector& TextureX = Model->Vectors[NodeSurf.vTextureU];
const FVector& TextureY = Model->Vectors[NodeSurf.vTextureV];
const int32 BaseVertexIndex = NodeGroup->Vertices.Num();
// Compute the surface's tangent basis.
FVector NodeTangentX = Model->Vectors[NodeSurf.vTextureU].GetSafeNormal();
FVector NodeTangentY = Model->Vectors[NodeSurf.vTextureV].GetSafeNormal();
FVector NodeTangentZ = Model->Vectors[NodeSurf.vNormal].GetSafeNormal();
// Generate the node's vertices.
for(uint32 VertexIndex = 0;VertexIndex < Node.NumVertices;VertexIndex++)
{
const FVert& Vert = Model->Verts[Node.iVertPool + VertexIndex];
const FVector& VertexWorldPosition = Model->Points[Vert.pVertex];
FStaticLightingVertex* DestVertex = new(NodeGroup->Vertices) FStaticLightingVertex;
DestVertex->WorldPosition = VertexWorldPosition;
DestVertex->TextureCoordinates[0].X = ((VertexWorldPosition - TextureBase) | TextureX) / UModel::GetGlobalBSPTexelScale();
DestVertex->TextureCoordinates[0].Y = ((VertexWorldPosition - TextureBase) | TextureY) / UModel::GetGlobalBSPTexelScale();
DestVertex->TextureCoordinates[1].X = NodeGroup->WorldToMap.TransformPosition(VertexWorldPosition).X;
DestVertex->TextureCoordinates[1].Y = NodeGroup->WorldToMap.TransformPosition(VertexWorldPosition).Y;
DestVertex->WorldTangentX = NodeTangentX;
DestVertex->WorldTangentY = NodeTangentY;
DestVertex->WorldTangentZ = NodeTangentZ;
// Include the vertex in the surface's bounding box.
NodeGroup->BoundingBox += VertexWorldPosition;
}
// Generate the node's vertex indices.
for(uint32 VertexIndex = 2;VertexIndex < Node.NumVertices;VertexIndex++)
{
NodeGroup->TriangleVertexIndices.Add(BaseVertexIndex + 0);
NodeGroup->TriangleVertexIndices.Add(BaseVertexIndex + VertexIndex);
NodeGroup->TriangleVertexIndices.Add(BaseVertexIndex + VertexIndex - 1);
// track the source surface for each triangle
NodeGroup->TriangleSurfaceMap.Add(Node.iSurf);
}
UModelComponent* Component = Level->ModelComponents[Node.ComponentIndex];
if (Component->VisibilityId == INDEX_NONE)
{
if (World->GetWorldSettings()->bPrecomputeVisibility)
{
// Make sure the level gets dirtied since we are changing the visibility Id of a component in it
bMarkLevelDirty = true;
}
Component->VisibilityId = NextVisibilityId;
NextVisibilityId++;
}
ComponentVisibilityIds.AddUnique(Component->VisibilityId);
}
// Continue only if the component accepts lights (all components in a node group have the same value)
// TODO: If we expose CastShadow for BSP in the future, reenable this condition and make sure
// node grouping logic is updated to account for CastShadow as well
//if (SomeModelComponent->bAcceptsLights || SomeModelComponent->CastShadow)
{
// Create the object to represent the surface's mapping/mesh to the static lighting system,
// the model is now the owner, and all nodes have the same
FBSPSurfaceStaticLighting* SurfaceStaticLighting = new FBSPSurfaceStaticLighting(NodeGroup, Model, SomeModelComponent);
// Give the surface mapping the visibility Id's of all components that have nodes in it
// This results in fairly ineffective precomputed visibility with BSP but is necessary since BSP mappings contain geometry from multiple components
SurfaceStaticLighting->VisibilityIds = ComponentVisibilityIds;
Meshes.Add(SurfaceStaticLighting);
LightingMeshBounds += SurfaceStaticLighting->BoundingBox;
if (SomeModelComponent->CastShadow)
{
UpdateAutomaticImportanceVolumeBounds( SurfaceStaticLighting->BoundingBox );
}
FStaticLightingMapping* CurrentMapping = SurfaceStaticLighting;
if (GLightmassDebugOptions.bSortMappings)
{
int32 InsertIndex = UnSortedMappings.AddZeroed();
FStaticLightingMappingSortHelper& Helper = UnSortedMappings[InsertIndex];
Helper.Mapping = CurrentMapping;
Helper.NumTexels = CurrentMapping->GetTexelCount();
}
else
{
Mappings.Add(CurrentMapping);
if (bBuildLightingForBSP)
{
CurrentMapping->Mesh->Guid = FGuid(0,0,0,DeterministicIndex++);
}
}
if (bBuildLightingForBSP)
{
CurrentMapping->bProcessMapping = true;
}
// count how many node groups have yet to come back as complete
Model->NumIncompleteNodeGroups++;
// add this mapping to the list of mappings to be applied later
Model->CachedMappings.Add(SurfaceStaticLighting);
}
}
}
if (bMarkLevelDirty)
{
Level->MarkPackageDirty();
}
}
/**
* Generates mappings/meshes for the given NodeGroups
*
* @param Level Level to build BSP lighting info for
* @param NodeGroupsToBuild The node groups to build the BSP lighting info for
*/
void FStaticLightingSystem::AddBSPStaticLightingInfo(ULevel* Level, TArray<FNodeGroup*>& NodeGroupsToBuild)
{
// For BSP, we aren't Component-centric, so we can't use the GetStaticLightingInfo
// function effectively. Instead, we look across all nodes in the Level's model and
// generate NodeGroups - which are groups of nodes that are coplanar, adjacent, and
// have the same lightmap resolution (henceforth known as being "conodes"). Each
// NodeGroup will get a mapping created for it
// cache the model
UModel* Model = Level->Model;
// reset the number of incomplete groups
Model->NumIncompleteNodeGroups = 0;
Model->CachedMappings.Empty();
Model->bInvalidForStaticLighting = false;
// now we need to make the mappings/meshes
for (int32 NodeGroupIdx = 0; NodeGroupIdx < NodeGroupsToBuild.Num(); NodeGroupIdx++)
{
FNodeGroup* NodeGroup = NodeGroupsToBuild[NodeGroupIdx];
if (NodeGroup && NodeGroup->Nodes.Num())
{
// get one of the surfaces/components from the NodeGroup
// @todo UE4: Remove need for GetSurfaceLightMapResolution to take a surfaceindex, or a ModelComponent :)
UModelComponent* SomeModelComponent = Level->ModelComponents[Model->Nodes[NodeGroup->Nodes[0]].ComponentIndex];
int32 SurfaceIndex = Model->Nodes[NodeGroup->Nodes[0]].iSurf;
// fill out the NodeGroup/mapping, as UModelComponent::GetStaticLightingInfo did
SomeModelComponent->GetSurfaceLightMapResolution(SurfaceIndex, true, NodeGroup->SizeX, NodeGroup->SizeY, NodeGroup->WorldToMap, &NodeGroup->Nodes);
NodeGroup->MapToWorld = NodeGroup->WorldToMap.InverseFast();
// Cache the surface's vertices and triangles.
NodeGroup->BoundingBox.Init();
for(int32 NodeIndex = 0;NodeIndex < NodeGroup->Nodes.Num();NodeIndex++)
{
const FBspNode& Node = Model->Nodes[NodeGroup->Nodes[NodeIndex]];
const FBspSurf& NodeSurf = Model->Surfs[Node.iSurf];
const FVector& TextureBase = Model->Points[NodeSurf.pBase];
const FVector& TextureX = Model->Vectors[NodeSurf.vTextureU];
const FVector& TextureY = Model->Vectors[NodeSurf.vTextureV];
const int32 BaseVertexIndex = NodeGroup->Vertices.Num();
// Compute the surface's tangent basis.
FVector NodeTangentX = Model->Vectors[NodeSurf.vTextureU].GetSafeNormal();
FVector NodeTangentY = Model->Vectors[NodeSurf.vTextureV].GetSafeNormal();
FVector NodeTangentZ = Model->Vectors[NodeSurf.vNormal].GetSafeNormal();
// Generate the node's vertices.
for(uint32 VertexIndex = 0;VertexIndex < Node.NumVertices;VertexIndex++)
{
const FVert& Vert = Model->Verts[Node.iVertPool + VertexIndex];
const FVector& VertexWorldPosition = Model->Points[Vert.pVertex];
FStaticLightingVertex* DestVertex = new(NodeGroup->Vertices) FStaticLightingVertex;
DestVertex->WorldPosition = VertexWorldPosition;
DestVertex->TextureCoordinates[0].X = ((VertexWorldPosition - TextureBase) | TextureX) / UModel::GetGlobalBSPTexelScale();
DestVertex->TextureCoordinates[0].Y = ((VertexWorldPosition - TextureBase) | TextureY) / UModel::GetGlobalBSPTexelScale();
DestVertex->TextureCoordinates[1].X = NodeGroup->WorldToMap.TransformPosition(VertexWorldPosition).X;
DestVertex->TextureCoordinates[1].Y = NodeGroup->WorldToMap.TransformPosition(VertexWorldPosition).Y;
DestVertex->WorldTangentX = NodeTangentX;
DestVertex->WorldTangentY = NodeTangentY;
DestVertex->WorldTangentZ = NodeTangentZ;
// Include the vertex in the surface's bounding box.
NodeGroup->BoundingBox += VertexWorldPosition;
}
// Generate the node's vertex indices.
for(uint32 VertexIndex = 2;VertexIndex < Node.NumVertices;VertexIndex++)
{
NodeGroup->TriangleVertexIndices.Add(BaseVertexIndex + 0);
NodeGroup->TriangleVertexIndices.Add(BaseVertexIndex + VertexIndex);
NodeGroup->TriangleVertexIndices.Add(BaseVertexIndex + VertexIndex - 1);
// track the source surface for each triangle
NodeGroup->TriangleSurfaceMap.Add(Node.iSurf);
}
}
// Continue only if the component accepts lights (all components in a node group have the same value)
// TODO: If we expose CastShadow for BSP in the future, reenable this condition and make sure
// node grouping logic is updated to account for CastShadow as well
//if (SomeModelComponent->bAcceptsLights || SomeModelComponent->CastShadow)
{
// Create the object to represent the surface's mapping/mesh to the static lighting system,
// the model is now the owner, and all nodes have the same
FBSPSurfaceStaticLighting* SurfaceStaticLighting = new FBSPSurfaceStaticLighting(NodeGroup, Model, SomeModelComponent);
Meshes.Add(SurfaceStaticLighting);
LightingMeshBounds += SurfaceStaticLighting->BoundingBox;
if (SomeModelComponent->CastShadow)
{
UpdateAutomaticImportanceVolumeBounds( SurfaceStaticLighting->BoundingBox );
}
FStaticLightingMapping* CurrentMapping = SurfaceStaticLighting;
if (GLightmassDebugOptions.bSortMappings)
{
int32 InsertIndex = UnSortedMappings.AddZeroed();
FStaticLightingMappingSortHelper& Helper = UnSortedMappings[InsertIndex];
Helper.Mapping = CurrentMapping;
Helper.NumTexels = CurrentMapping->GetTexelCount();
}
else
{
Mappings.Add(CurrentMapping);
CurrentMapping->Mesh->Guid = FGuid(0,0,0,DeterministicIndex++);
}
CurrentMapping->bProcessMapping = true;
// count how many node groups have yet to come back as complete
Model->NumIncompleteNodeGroups++;
// add this mapping to the list of mappings to be applied later
Model->CachedMappings.Add(SurfaceStaticLighting);
}
}
}
}
void FStaticLightingSystem::AddPrimitiveStaticLightingInfo(FStaticLightingPrimitiveInfo& PrimitiveInfo, bool bBuildActorLighting)
{
// Verify a one to one relationship between mappings and meshes
//@todo - merge FStaticLightingMesh and FStaticLightingMapping
check(PrimitiveInfo.Meshes.Num() == PrimitiveInfo.Mappings.Num());
// Add the component's shadow casting meshes to the system.
for(int32 MeshIndex = 0;MeshIndex < PrimitiveInfo.Meshes.Num();MeshIndex++)
{
FStaticLightingMesh* Mesh = PrimitiveInfo.Meshes[MeshIndex];
if (Mesh)
{
Mesh->VisibilityIds.Add(PrimitiveInfo.VisibilityId);
if (!GLightmassDebugOptions.bSortMappings && bBuildActorLighting)
{
Mesh->Guid = FGuid(0, 0, 0, DeterministicIndex++);
}
Meshes.Add(Mesh);
LightingMeshBounds += Mesh->BoundingBox;
if (Mesh->bCastShadow)
{
UpdateAutomaticImportanceVolumeBounds(Mesh->BoundingBox);
}
}
}
// If lighting is being built for this component, add its mappings to the system.
for(int32 MappingIndex = 0;MappingIndex < PrimitiveInfo.Mappings.Num();MappingIndex++)
{
FStaticLightingMapping* CurrentMapping = PrimitiveInfo.Mappings[MappingIndex];
if (GbLogAddingMappings)
{
FStaticLightingMesh* SLMesh = CurrentMapping->Mesh;
if (SLMesh)
{
//UE_LOG(LogStaticLightingSystem, Log, TEXT("Adding %32s: 0x%08p - %s"), *(CurrentMapping->GetDescription()), (PTRINT)(SLMesh->Component), *(SLMesh->Guid.ToString()));
}
else
{
//UE_LOG(LogStaticLightingSystem, Log, TEXT("Adding %32s: 0x%08x - %s"), *(CurrentMapping->GetDescription()), 0, TEXT("NO MESH????"));
}
}
if (bBuildActorLighting)
{
CurrentMapping->bProcessMapping = true;
}
if (GLightmassDebugOptions.bSortMappings)
{
int32 InsertIndex = UnSortedMappings.AddZeroed();
FStaticLightingMappingSortHelper& Helper = UnSortedMappings[InsertIndex];
Helper.Mapping = CurrentMapping;
Helper.NumTexels = Helper.Mapping->GetTexelCount();
}
else
{
Mappings.Add(CurrentMapping);
}
}
}
bool FStaticLightingSystem::CreateLightmassProcessor()
{
FLightmassStatistics::FScopedGather SwarmStartStatScope(LightmassProcessStatistics.SwarmStartupTime);
GWarn->StatusForceUpdate( -1, -1, LOCTEXT("StartingSwarmConnectionStatus", "Starting up Swarm Connection...") );
if (Options.bOnlyBuildVisibility && !World->GetWorldSettings()->bPrecomputeVisibility)
{
FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "BuildFailed_VisibilityOnlyButVisibilityDisabled", "'Build Only Visibility' option was enabled but precomputed visibility is disabled! Aborting build."));
return false;
}
NSwarm::FSwarmInterface::Initialize(*(FString(FPlatformProcess::BaseDir()) + TEXT("..\\DotNET\\SwarmInterface.dll")));
// Create the processor
check(LightmassProcessor == NULL);
LightmassProcessor = new FLightmassProcessor(*this, Options.bDumpBinaryResults, Options.bOnlyBuildVisibility);
check(LightmassProcessor);
if (LightmassProcessor->IsSwarmConnectionIsValid() == false)
{
UE_LOG(LogStaticLightingSystem, Warning, TEXT("Failed to connect to Swarm."));
FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("FailedToConnectToSwarmDialogMessage", "Failed to connect to Swarm."));
delete LightmassProcessor;
LightmassProcessor = NULL;
return false;
}
return true;
}
void FStaticLightingSystem::GatherScene()
{
LightmassProcessStatistics = FLightmassStatistics();
GWarn->StatusUpdate( 0, Meshes.Num() + Mappings.Num(), LOCTEXT("GatherSceneStatusMessage", "Collecting the scene...") );
FLightmassStatistics::FScopedGather SceneStatScope(LightmassProcessStatistics.CollectLightmassSceneTime);
// Grab the exporter and fill in the meshes
//@todo. This should be exported to the 'processor' as it will be used on the input side as well...
FLightmassExporter* LightmassExporter = LightmassProcessor->GetLightmassExporter();
check(LightmassExporter);
// The Level settings...
AWorldSettings* WorldSettings = World->GetWorldSettings();
if (WorldSettings)
{
LightmassExporter->SetLevelSettings(WorldSettings->LightmassSettings);
}
else
{
FLightmassWorldInfoSettings TempSettings;
LightmassExporter->SetLevelSettings(TempSettings);
}
LightmassExporter->SetNumUnusedLocalCores(Options.NumUnusedLocalCores);
LightmassExporter->SetQualityLevel(Options.QualityLevel);
if (World->PersistentLevel && Options.ShouldBuildLightingForLevel( World->PersistentLevel ))
{
LightmassExporter->SetLevelName(World->PersistentLevel->GetPathName());
}
LightmassExporter->ClearImportanceVolumes();
for( TObjectIterator<ALightmassImportanceVolume> It ; It ; ++It )
{
ALightmassImportanceVolume* LMIVolume = *It;
if (World->ContainsActor(LMIVolume) && !LMIVolume->IsPendingKill())
{
LightmassExporter->AddImportanceVolume(LMIVolume);
}
}
for( TObjectIterator<ALightmassCharacterIndirectDetailVolume> It ; It ; ++It )
{
ALightmassCharacterIndirectDetailVolume* LMDetailVolume = *It;
if (World->ContainsActor(LMDetailVolume) && !LMDetailVolume->IsPendingKill())
{
LightmassExporter->AddCharacterIndirectDetailVolume(LMDetailVolume);
}
}
for( TObjectIterator<ULightmassPortalComponent> It ; It ; ++It )
{
ULightmassPortalComponent* LMPortal = *It;
if (LMPortal->GetOwner() && World->ContainsActor(LMPortal->GetOwner()) && !LMPortal->IsPendingKill())
{
LightmassExporter->AddPortal(LMPortal);
}
}
float MinimumImportanceVolumeExtentWithoutWarning = 0.0f;
verify(GConfig->GetFloat(TEXT("DevOptions.StaticLightingSceneConstants"), TEXT("MinimumImportanceVolumeExtentWithoutWarning"), MinimumImportanceVolumeExtentWithoutWarning, GLightmassIni));
// If we have no importance volumes, then we'll synthesize one now. A scene without any importance volumes will not yield
// expected lighting results, so it's important to have a volume to pass to Lightmass.
if (LightmassExporter->GetImportanceVolumes().Num() == 0)
{
FBox ReasonableSceneBounds = AutomaticImportanceVolumeBounds;
if (ReasonableSceneBounds.GetExtent().SizeSquared() > (MinimumImportanceVolumeExtentWithoutWarning * MinimumImportanceVolumeExtentWithoutWarning))
{
// Emit a serious warning to the user about performance.
FMessageLog("LightingResults").PerformanceWarning(LOCTEXT("LightmassError_MissingImportanceVolume", "No importance volume found and the scene is so large that the automatically synthesized volume will not yield good results. Please add a tightly bounding lightmass importance volume to optimize your scene's quality and lighting build times."));
// Clamp the size of the importance volume we create to a reasonable size
ReasonableSceneBounds = FBox(ReasonableSceneBounds.GetCenter() - MinimumImportanceVolumeExtentWithoutWarning, ReasonableSceneBounds.GetCenter() + MinimumImportanceVolumeExtentWithoutWarning);
}
else
{
// The scene isn't too big, so we'll use the scene's bounds as a synthetic importance volume
// NOTE: We don't want to pop up a message log for this common case when creating a new level, so we just spray a log message. It's not very important to a user.
UE_LOG(LogStaticLightingSystem, Warning, TEXT("No importance volume found, so the scene bounding box was used. You can optimize your scene's quality and lighting build times by adding importance volumes."));
float AutomaticImportanceVolumeExpandBy = 0.0f;
verify(GConfig->GetFloat(TEXT("DevOptions.StaticLightingSceneConstants"), TEXT("AutomaticImportanceVolumeExpandBy"), AutomaticImportanceVolumeExpandBy, GLightmassIni));
// Expand the scene's bounds a bit to make sure volume lighting samples placed on surfaces are inside
ReasonableSceneBounds = ReasonableSceneBounds.ExpandBy(AutomaticImportanceVolumeExpandBy);
}
LightmassExporter->AddImportanceVolumeBoundingBox(ReasonableSceneBounds);
}
const int32 NumMeshesAndMappings = Meshes.Num() + Mappings.Num();
const int32 ProgressUpdateFrequency = FMath::Max<int32>(NumMeshesAndMappings / 20, 1);
// Meshes
for( int32 MeshIdx=0; !GEditor->GetMapBuildCancelled() && MeshIdx < Meshes.Num(); MeshIdx++ )
{
Meshes[MeshIdx]->ExportMeshInstance(LightmassExporter);
if (MeshIdx % ProgressUpdateFrequency == 0)
{
GWarn->UpdateProgress( MeshIdx, NumMeshesAndMappings );
}
}
// Mappings
for( int32 MappingIdx=0; !GEditor->GetMapBuildCancelled() && MappingIdx < Mappings.Num(); MappingIdx++ )
{
Mappings[MappingIdx]->ExportMapping(LightmassExporter);
if (MappingIdx % ProgressUpdateFrequency == 0)
{
GWarn->UpdateProgress( Meshes.Num() + MappingIdx, NumMeshesAndMappings );
}
}
for (int32 LightIndex = 0; LightIndex < Lights.Num(); LightIndex++)
{
ULightComponentBase* LightBase = Lights[LightIndex];
USkyLightComponent* SkyLight = Cast<USkyLightComponent>(LightBase);
if (SkyLight && (SkyLight->Mobility == EComponentMobility::Static || SkyLight->Mobility == EComponentMobility::Stationary))
{
LightmassExporter->AddLight(SkyLight);
}
}
}
bool FStaticLightingSystem::InitiateLightmassProcessor()
{
// Run!
bool bSuccessful = false;
bool bOpenJobSuccessful = false;
if ( !GEditor->GetMapBuildCancelled() )
{
UE_LOG(LogStaticLightingSystem, Log, TEXT("Running Lightmass w/ ImmediateImport mode %s"), GLightmassDebugOptions.bUseImmediateImport ? TEXT("ENABLED") : TEXT("DISABLED"));
LightmassProcessor->SetImportCompletedMappingsImmediately(GLightmassDebugOptions.bUseImmediateImport);
UE_LOG(LogStaticLightingSystem, Log, TEXT("Running Lightmass w/ ImmediateProcess mode %s"), GLightmassDebugOptions.bImmediateProcessMappings ? TEXT("ENABLED") : TEXT("DISABLED"));
UE_LOG(LogStaticLightingSystem, Log, TEXT("Running Lightmass w/ Sorting mode %s"), GLightmassDebugOptions.bSortMappings ? TEXT("ENABLED") : TEXT("DISABLED"));
UE_LOG(LogStaticLightingSystem, Log, TEXT("Running Lightmass w/ Mapping paddings %s"), GLightmassDebugOptions.bPadMappings ? TEXT("ENABLED") : TEXT("DISABLED"));
UE_LOG(LogStaticLightingSystem, Log, TEXT("Running Lightmass w/ Mapping debug paddings %s"), GLightmassDebugOptions.bDebugPaddings ? TEXT("ENABLED") : TEXT("DISABLED"));
{
FLightmassStatistics::FScopedGather OpenJobStatScope(LightmassProcessStatistics.SwarmJobOpenTime);
bOpenJobSuccessful = LightmassProcessor->OpenJob();
}
if (bOpenJobSuccessful)
{
LightmassProcessor->InitiateExport();
bSuccessful = true;
CurrentBuildStage = FStaticLightingSystem::AmortizedExport;
if (!IsRunningCommandlet())
{
// Crash tracker interferes with performance during export only.
// Disable it only for export, for everything else it shouldn't matter.
// This is a very special case, and doing this sort of thing
// is almost never recommended, especially without profiling heavily.
// The reason it works here is because amortized export flushes the render
// commands every tick, which is highly detrimental to the crash tracker's operation.
// ALSO NOTE: The reason this is set here rather than be a common API in the crashtracker
// module is to discourage people from doing this sort of thing all over the place.
ICrashTrackerModule* CrashTracker = FModuleManager::LoadModulePtr<ICrashTrackerModule>("CrashTracker");
if (CrashTracker)
{
bCrashTrackerOriginallyEnabled = CrashTracker->IsCurrentlyCapturing();
CrashTracker->SetCrashTrackingEnabled(false);
}
}
}
}
return bSuccessful;
}
void FStaticLightingSystem::KickoffSwarm()
{
bool bSuccessful = LightmassProcessor->BeginRun();
if (bSuccessful)
{
CurrentBuildStage = FStaticLightingSystem::AsynchronousBuilding;
}
else
{
FStaticLightingManager::Get()->FailLightingBuild(LOCTEXT("SwarmKickoffFailedMessage", "Lighting build failed. Swarm failed to kick off."));
}
}
bool FStaticLightingSystem::FinishLightmassProcess()
{
bool bSuccessful = false;
GEditor->ResetTransaction( LOCTEXT("KeepLightingTransReset", "Applying Lighting") );
CurrentBuildStage = FStaticLightingSystem::Import;
double TimeWaitingOnUserToAccept = FPlatformTime::Seconds() - WaitForUserAcceptStartTime;
{
FScopedSlowTask SlowTask(7);
SlowTask.MakeDialog();
SlowTask.EnterProgressFrame(1, LOCTEXT("InvalidatingPreviousLightingStatus", "Invalidating previous lighting"));
InvalidateStaticLighting();
SlowTask.EnterProgressFrame(1, LOCTEXT("ImportingBuiltStaticLightingStatus", "Importing built static lighting"));
bSuccessful = LightmassProcessor->CompleteRun();
SlowTask.EnterProgressFrame();
if (bSuccessful)
{
CompleteDeterministicMappings(LightmassProcessor);
if (!Options.bOnlyBuildVisibility)
{
FLightmassStatistics::FScopedGather FinishStatScope(LightmassStatistics.FinishingTime);
ULightComponent::ReassignStationaryLightChannels(GWorld, true);
}
}
SlowTask.EnterProgressFrame(1, LOCTEXT("EncodingTexturesStaticLightingStatis", "Encoding textures"));
EncodeTextures(bSuccessful);
SlowTask.EnterProgressFrame();
{
FLightmassStatistics::FScopedGather CloseJobStatScope(LightmassProcessStatistics.SwarmJobCloseTime);
bSuccessful = LightmassProcessor->CloseJob() && bSuccessful;
}
{
FLightmassStatistics::FScopedGather FinishStatScope(LightmassStatistics.FinishingTime);
// Add in the time measurements from the LightmassProcessor
LightmassStatistics += LightmassProcessor->GetStatistics();
// A final update on the lighting build warnings and errors dialog, now that everything is finished
FMessageLog("LightingResults").Open();
// Check the for build cancellation.
bBuildCanceled = bBuildCanceled || GEditor->GetMapBuildCancelled();
bSuccessful = bSuccessful && !bBuildCanceled;
FStatsViewerModule& StatsViewerModule = FModuleManager::Get().LoadModuleChecked<FStatsViewerModule>(TEXT("StatsViewer"));
if (bSuccessful)
{
StatsViewerModule.GetPage(EStatsPage::LightingBuildInfo)->Refresh();
}
bool bShowLightingBuildInfo = false;
GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("ShowLightingBuildInfo"), bShowLightingBuildInfo, GEditorPerProjectIni );
if( bShowLightingBuildInfo )
{
StatsViewerModule.GetPage(EStatsPage::LightingBuildInfo)->Show();
}
}
SlowTask.EnterProgressFrame();
ApplyNewLightingData(bSuccessful);
SlowTask.EnterProgressFrame();
PostInvalidateStaticLighting();
// Finish up timing statistics
LightmassStatistics += LightmassProcessStatistics;
LightmassStatistics.TotalTime += FPlatformTime::Seconds() - StartTime - TimeWaitingOnUserToAccept;
GetRendererModule().UpdateMapNeedsLightingFullyRebuiltState(World);
GEngine->DeferredCommands.AddUnique(TEXT("MAP CHECK NOTIFYRESULTS"));
}
ReportStatistics();
if ( bSuccessful && World->Scene )
{
// Update reflection captures now that static lighting has changed
// Update sky light first because it's considered direct lighting, sky diffuse will be visible in reflection capture indirect specular
World->UpdateAllSkyCaptures();
World->UpdateAllReflectionCaptures();
}
return bSuccessful;
}
void FStaticLightingSystem::UpdateLightingBuild()
{
if (CurrentBuildStage == FStaticLightingSystem::AmortizedExport)
{
bool bCompleted = LightmassProcessor->ExecuteAmortizedMaterialExport();
FFormatNamedArguments Args;
Args.Add( TEXT("PercentDone"), FText::AsPercent( LightmassProcessor->GetAmortizedExportPercentDone() ) );
FText Text = FText::Format( LOCTEXT("LightExportProgressMessage", "Exporting lighting data: {PercentDone} Done"), Args );
FStaticLightingManager::Get()->SetNotificationText( Text );
if (bCompleted)
{
if (bCrashTrackerOriginallyEnabled)
{
// Re-enable the crash tracker if we disabled it
ICrashTrackerModule* CrashTracker = FModuleManager::LoadModulePtr<ICrashTrackerModule>("CrashTracker");
if (CrashTracker)
{
CrashTracker->SetCrashTrackingEnabled(true);
bCrashTrackerOriginallyEnabled = false;
}
}
CurrentBuildStage = FStaticLightingSystem::SwarmKickoff;
}
}
else if (CurrentBuildStage == FStaticLightingSystem::SwarmKickoff)
{
FText Text = LOCTEXT("LightKickoffSwarmMessage", "Kicking off Swarm");
FStaticLightingManager::Get()->SetNotificationText( Text );
KickoffSwarm();
}
else if (CurrentBuildStage == FStaticLightingSystem::AsynchronousBuilding)
{
bool bFinished = LightmassProcessor->Update();
FText Text = FText::Format(LOCTEXT("LightBuildProgressMessage", "Building lighting: {0}%"), FText::AsNumber(LightmassProcessor->GetAsyncPercentDone()));
FStaticLightingManager::Get()->SetNotificationText( Text );
if (bFinished)
{
LightmassStatistics.ProcessingTime += FPlatformTime::Seconds() - ProcessingStartTime;
WaitForUserAcceptStartTime = FPlatformTime::Seconds();
FStaticLightingManager::Get()->ClearCurrentNotification();
if (LightmassProcessor->IsProcessingCompletedSuccessfully())
{
CurrentBuildStage = FStaticLightingSystem::AutoApplyingImport;
}
else
{
// automatically fail lighting build (discard)
FStaticLightingManager::Get()->FailLightingBuild();
CurrentBuildStage = FStaticLightingSystem::NotRunning;
}
}
}
else if ( CurrentBuildStage == FStaticLightingSystem::AutoApplyingImport )
{
if ( CanAutoApplyLighting() || IsRunningCommandlet() )
{
bool bAutoApplyFailed = false;
FStaticLightingManager::Get()->SendBuildDoneNotification(bAutoApplyFailed);
FStaticLightingManager::ProcessLightingData( false );
CurrentBuildStage = FStaticLightingSystem::NotRunning;
}
else
{
bool bAutoApplyFailed = true;
FStaticLightingManager::Get()->SendBuildDoneNotification(bAutoApplyFailed);
CurrentBuildStage = FStaticLightingSystem::WaitingForImport;
}
}
}
void FStaticLightingSystem::UpdateAutomaticImportanceVolumeBounds( const FBox& MeshBounds )
{
// Note: skyboxes will be excluded if they are properly setup to not cast shadows
AutomaticImportanceVolumeBounds += MeshBounds;
}
bool FStaticLightingSystem::CanAutoApplyLighting() const
{
const bool bAutoApplyEnabled = GetDefault<ULevelEditorMiscSettings>()->bAutoApplyLightingEnable;
const bool bSlowTask = GIsSlowTask;
const bool bInterpEditMode = GLevelEditorModeTools().IsModeActive( FBuiltinEditorModes::EM_InterpEdit );
const bool bPlayWorldValid = GEditor->PlayWorld != nullptr;
const bool bAnyMenusVisible = (FSlateApplication::IsInitialized() && FSlateApplication::Get().AnyMenusVisible());
//const bool bIsInteratcting = false;// FSlateApplication::Get().GetMouseCaptor().IsValid() || GEditor->IsUserInteracting();
const bool bHasGameOrProjectLoaded = FApp::HasGameName();
return ( bAutoApplyEnabled && !bSlowTask && !bInterpEditMode && !bPlayWorldValid && !bAnyMenusVisible/* && !bIsInteratcting */&& !GIsDemoMode && bHasGameOrProjectLoaded );
}
/**
* Clear out all the binary dump log files, so the next run will have just the needed files for rendering
*/
void FStaticLightingSystem::ClearBinaryDumps()
{
IFileManager::Get().DeleteDirectory(*FString::Printf(TEXT("%sLogs/Lighting_%s"), *FPaths::GameDir(), TEXT("Lightmass")), false, true);
}
/** Marks all lights used in the calculated lightmap as used in a lightmap, and calls Apply on the texture mapping. */
void FStaticLightingSystem::ApplyMapping(
FStaticLightingTextureMapping* TextureMapping,
FQuantizedLightmapData* QuantizedData,
const TMap<ULightComponent*,FShadowMapData2D*>& ShadowMapData) const
{
TextureMapping->Apply(QuantizedData, ShadowMapData);
}
UWorld* FStaticLightingSystem::GetWorld() const
{
return World;
}
bool FStaticLightingSystem::IsAsyncBuilding() const
{
return CurrentBuildStage == FStaticLightingSystem::AsynchronousBuilding;
}
bool FStaticLightingSystem::IsAmortizedExporting() const
{
return CurrentBuildStage == FStaticLightingSystem::AmortizedExport;
}
#endif
void UEditorEngine::BuildLighting(const FLightingBuildOptions& Options)
{
// Forcibly shut down all texture property windows as they become invalid during a light build
FAssetEditorManager& AssetEditorManager = FAssetEditorManager::Get();
TArray<UObject*> EditedAssets = AssetEditorManager.GetAllEditedAssets();
for (int32 AssetIdx = 0; AssetIdx < EditedAssets.Num(); AssetIdx++)
{
UObject* EditedAsset = EditedAssets[AssetIdx];
if (EditedAsset->IsA(UTexture2D::StaticClass()))
{
IAssetEditorInstance* Editor = AssetEditorManager.FindEditorForAsset(EditedAsset, false);
if (Editor)
{
Editor->CloseWindow();
}
}
}
FEditorDelegates::OnLightingBuildStarted.Broadcast();
FStaticLightingManager::Get()->CreateStaticLightingSystem(Options);
}
void UEditorEngine::UpdateBuildLighting()
{
FStaticLightingManager::Get()->UpdateBuildLighting();
}
bool UEditorEngine::IsLightingBuildCurrentlyRunning() const
{
return FStaticLightingManager::Get()->IsLightingBuildCurrentlyRunning();
}
bool UEditorEngine::IsLightingBuildCurrentlyExporting() const
{
return FStaticLightingManager::Get()->IsLightingBuildCurrentlyExporting();
}
bool UEditorEngine::WarnIfLightingBuildIsCurrentlyRunning()
{
bool bFailure = IsLightingBuildCurrentlyRunning();
if (bFailure)
{
FNotificationInfo Info( LOCTEXT("LightBuildUnderwayWarning", "Static light is currently building! Please cancel it to proceed!") );
Info.ExpireDuration = 5.0f;
TSharedPtr<SNotificationItem> Notification = FSlateNotificationManager::Get().AddNotification(Info);
if (Notification.IsValid())
{
Notification->SetCompletionState(SNotificationItem::CS_Fail);
}
}
else if (FEditorBuildUtils::IsBuildCurrentlyRunning())
{
// Another, non-lighting editor build is running.
FNotificationInfo Info( LOCTEXT("EditorBuildUnderwayWarning", "A build process is currently underway! Please cancel it to proceed!") );
Info.ExpireDuration = 5.0f;
TSharedPtr<SNotificationItem> Notification = FSlateNotificationManager::Get().AddNotification(Info);
if (Notification.IsValid())
{
Notification->SetCompletionState(SNotificationItem::CS_Fail);
}
bFailure = true;
}
return bFailure;
}
#undef LOCTEXT_NAMESPACE