Commit Graph

19 Commits (5b44ea9b9ab99b5f285158afe88fca35219c33c5)

Author SHA1 Message Date
Mike Balfour 71c6b3e506
Refresh cached transforms before saving. (#1858)
If the prefab template saves default values for a cached transform, but *shouldn't* have default values, it will get patch application errors at runtime due to missing cached transform fields.

Signed-off-by: mbalfour <mbalfour@amazon.com>
5 years ago
Mike Balfour d34d088191
Miscellaneous prefab/converter bugfixes to support TrackView (#1701)
This has a small bundle of bugfixes and improvements all based around improving prefab TrackView support:

* JsonMerger - improved the error message when patch remove operations fail to make the specific failure more obvious
Instance - swapped the order of destroying entities vs clearing the lookup tables so that lookups still produce valid results during destruction. (This could happen while creating undo caches)
* InstanceEntityIdMapper - in the case where an id isn't found, it now returns an invalid id instead of an "attempted-valid" one that still generally turned out to be not-valid
* PrefabUndo - downgraded a potential crash to an error message if for some reason the patch contains changes to an entity that doesn't currently have an alias. (This case can be caused occasionally by other bugs and error conditions)
* EditorSequenceComponent - downgraded a potential crash to an assert for the times when it tries to remove components, fails, but thinks it succeeded. (This case can currently be caused by using Maestro with Prefabs enabled)
* EditorSequenceAgentComponent - added an undo cache refresh whenever the component deletes itself, so that deleting itself during an EditorSequenceComponent destruction chain of events leaves the undo cache in the correct state.
* SliceConverter - fixed the conversion of entity references in top-level slice instance entities that refer down to nested slice entities. There was a chicken-and-egg problem in terms of which entities need to be created first to make the references and the prefab patching & serialization happy. This was worked around by creating placeholder top-level entities, then the nested slice entities, then replacing the top-level entities with the fully-realized ones.

Specific changes:
* Added more informative error message.

Signed-off-by: mbalfour <mbalfour@amazon.com>
(cherry picked from commit 672608a6c833c07295996cd9b3449825222b74d0)

* Changed the error condition to produce a "valid" invalid id instead of a deterministic but not-valid id

Signed-off-by: mbalfour <mbalfour@amazon.com>
(cherry picked from commit 3673950c949de8e067b32ddafaffd07e648a13d8)

* Guard against invalid reference assert/crash

Signed-off-by: mbalfour <mbalfour@amazon.com>
(cherry picked from commit 268d4ef3447f268a1372d07e028b9e67bac5c64e)

* Downgrade an invalid reference crash to an assert

Signed-off-by: mbalfour <mbalfour@amazon.com>
(cherry picked from commit 38c9303770845f4e863273dd6fb8fc7e83380425)

* Improved logic for handling entity references across nested slices.

Signed-off-by: mbalfour <mbalfour@amazon.com>
(cherry picked from commit 7e89a016d95fb72cb5f119e1e3768daa60e6bfb4)

* Changed order of entities.clear() call so that instance lookups are still valid during entity destruction.

Signed-off-by: mbalfour <mbalfour@amazon.com>

* Add undo cache notification when removing Maestro components.

Signed-off-by: mbalfour <mbalfour@amazon.com>
5 years ago
Steve Pham b4a2edec6a
Final update copyright headers to reference license files at the repo root (#1693)
* Final update copyright headers to reference license files at the repo root

Signed-off-by: spham <spham@amazon.com>

* Fix copyright validator unit tests to support the stale O3DE header scenario

Signed-off-by: spham <spham@amazon.com>
5 years ago
Steve Pham 70042fcdcd
O3DE Copyright Updates for Linux Foundation (#1504) 5 years ago
Mike Balfour ab3aa904f0
Fixed misc slice conversion bugs
* Fixed crash caused by nesting the same slice twice
If the same slice is nested at multiple levels in the same slice hierarchy, the second conversion would reregister the prefab and crash.  Now that case is detected and the slice isn't reconverted.

* Fixed json array patches where multiple elements are removed.
The patches now generate removals from back to front, instead of front to back, so that the indices remain valid as each patch is applied.
5 years ago
Mike Balfour 6f61454be4
Added support for remapping entity refs across slice instances (#1284)
* Fixed memory assert on shutdown.
Cleaned up the entity pointers on serialization, so that they no longer leak themselves, their asset references, or anything else within them.

* Added support for remapping entity refs across slice instances.
Slice instances can have components with entity references that have been modified to reference entities in other slice instances, or even in the parent.  This change detects and remaps those references so that they work correctly.
5 years ago
Mike Balfour ffe913a2d6
Added ability to convert multiply-nested slices (#1239) (#1245)
* Addressed feedback from previous PR
* Change missing entity aliases to be deterministic.
When converting slices, this helps produce the same results on multiple reconversions of the same data.
* Exposed the asset filter callback.
This allows the slice converter to specifically load nested slices as opposed to not loading *any* referenced assets.
* Added support for multiply-nested slice instance conversion.

(cherry picked from commit 86136ddfa6)
5 years ago
Mike Balfour d90a3d46a7
Support for nested slice conversions (#1121)
This set of changes enables conversions for singly-nested slices. Multiple nesting hierarchies are only partially supported at this point. Conversion is also significantly more deterministic, which makes it easier to convert single slices without needing to reconvert every slice or level that relies on it as well.
Changes:

- Added version of Instance::AddInstance() that takes in an alias to allow for deterministic aliases
- Added a "SliceConverterEditorEntityContextComponent" that's used to specifically disable entity activation on creation. The disabling is done this way vs adding a new public API, because the disable shouldn't be required in any normal case outside of this tool.
- Disabled more AWS gems for the SliceConverter, as they're unneeded and cause issues if they're around in the tool.
- Added a small null check to the Camera Controller.
- Added the actual support for slice instance conversion. This instantiates the entities, applies the data patches, turns them into a prefab instance, and generates a JSON patch out of the changes.
5 years ago
Mike Balfour 96905a26d7
Add support for AP-compliant relative paths (#998)
The method "PrefabLoader::GetRelativePathToProject" has been changed to "PrefabLoader::GenerateRelativePath", and reworked to get a correct relative path.  GetFullPath has also been modified to get correct relative paths too.  This requires an Asset Processor connection - if one isn't available (like during unit tests), the methods have fallback logic to produce project-relative paths.

With this change, SliceConverter can't use SaveTemplate() to save the file any more, because GetFullPath now expects to find an existing path, which doesn't work for not-yet-created files.  Instead, it now has to use the same technique as the Editor and call SaveTemplateToString then save the string out as a file.
5 years ago
Chris Galvan b68b9000a3 Fixed extra qualification causing compile error on Mac. 5 years ago
Mike Balfour 0be75732cc
Added initial support for nested slices to slice-prefab converter (#881)
Nested slices are now detected, converted into prefabs, and the top-level prefab will get linked to the nested prefabs with the proper number of instances.  However, the nested prefabs won't retain any of the slice override values or parent entity hierarchy.  That will (hopefully) be added in a separate PR.

This also adds support for better relative source paths for nested prefabs.  To support this, the tool now needs to connect/disconnect with the AssetProcessor to be able to turn a slice asset ID into a relative source path, so that nested templates can be looked up and converted correctly.
5 years ago
Aaron Ruiz Mora 87ec96fbf4
Fix compilation errors in windows release 5 years ago
Mike Balfour d084027b6e
Bugfixes to enable slice-to-prefab conversion to run with less warnings/errors/crashes (#768)
While trying to process all slices and levels in Automated Testing, a few bugs came up that needed to be addressed:
- [LYN-3832] TransformComponent had a field removed without updating the version number and converter, which caused a lot of excessive warnings
- SliceComponent would crash in debug builds on instantiation failures due to a null dereference that was guarded against in most but not all places
- SliceConverter now detects when nested slices exist and gracefully warns about it.
- InstanceUpdateExecutor / TemplateInstanceMapper will now immediately remove instances that are unregistered, so that any in the queue don't get processed on a subsequent tick.  This was causing crashes when the instance was destroyed before the processing occurred.  It also has a side benefit of preventing the same instance from executing multiple times.
- Minor logic bugfix to the pack close warning, the boolean check was flipped.

Also added an early-out on SetTemplateId, since this was causing some unnecessary instance queue entries.
5 years ago
Mike Balfour 77278a0329
First version of the slice-to-prefab converter
It converts .slice and .ly files to .prefab files, but doesn't handle nested or complicated slices correctly yet.
5 years ago
mbalfour ae9b36c135 PR feedback - now allows for multiple specializations on the command-line, and changed the switch name to "specializations" to reflect that. 5 years ago
mbalfour b5e87d3601 Change SerializeContextTools into a ToolsApplication so that it can correctly read in slice data:
- Uses ToolsApplication instead of ComponentApplication so that built-in Editor components are recognized and read in correctly
- Starts up all the DynamicModules immediately so that the System Components are activated, which registers asset handlers and allows asset references to serialize in correctly
- Adds a -specialization command-line flag to specify which project specialization to use (editor, game, etc)
- Removes the filter to ignore unknown classes since they should all now be "known"
- Adds a few gem autoload flags and a null thumbnail service so that Qt and Python systems can be skipped, as they aren't needed for the data conversions and would bring additional overhead and complications
5 years ago
Chris Burel 28170ffe41 Add newlines to the end of all files 5 years ago
alexpete 36c4e827bd Integrating latest from github/staging
Integrating up through commit 5e1bdae
5 years ago
alexpete a10351f38d Initial commit 5 years ago