Announcement

Collapse
No announcement yet.

Prefabricator - Open Source Prefab Plugin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Thanks for the continued updates Ali. I'll have a check next time I'm on that bit of my project and let you know if there are problems after updating the assets.

    Comment


      Originally posted by merkaba48 View Post

      I too am very interested in this functionality! I can store and retrieve a soft-object reference, but creating a prefab instance results in logic referring to the original object in the scene.

      I see the primary focus of Prefabricator is for visual elements, but being able to retain hard object references to actors/scene components also in the prefab would be incredibly useful.
      I have recently found some spare time and got back to the project where I needed this functionality. I have modified Ali Akbar's code in such a way that it now preserves the reference to the actors inside the prefab. Here is pretty much what I did:
      • I modified FPrefabricatorPropertyAssetMapping structure to store ItemID for the referenced actor (the ID is obtained from UPrefabricatorAssetUserData)
      • I store this ItemID inside UPrefabricatorProperty::SaveReferencedAssetValues()
      • I modified method FPrefabTools::LoadStateFromPrefabAsset such that it first spawns all the actors as placeholders and only restores their properties after all are spawned.
      • I take the list of spawned actors and forward it all the way to UPrefabricatorProperty::LoadReferencedAssetValues(TArray<AActor*> ChildActors)
      • Inside this method, I use the previously stored ItemID to identify the correct actor and change the ReferencedPath accordingly.
      I am willing to share the code if anyone is interested (and if Ali agrees), but I have not yet tested it properly so I may have broken something else along the way.

      Comment


        Originally posted by Jan Byška View Post

        I have recently found some spare time and got back to the project where I needed this functionality. I have modified Ali Akbar's code in such a way that it now preserves the reference to the actors inside the prefab. Here is pretty much what I did:
        • I modified FPrefabricatorPropertyAssetMapping structure to store ItemID for the referenced actor (the ID is obtained from UPrefabricatorAssetUserData)
        • I store this ItemID inside UPrefabricatorProperty::SaveReferencedAssetValues()
        • I modified method FPrefabTools::LoadStateFromPrefabAsset such that it first spawns all the actors as placeholders and only restores their properties after all are spawned.
        • I take the list of spawned actors and forward it all the way to UPrefabricatorProperty::LoadReferencedAssetValues(TArray<AActor*> ChildActors)
        • Inside this method, I use the previously stored ItemID to identify the correct actor and change the ReferencedPath accordingly.
        I am willing to share the code if anyone is interested (and if Ali agrees), but I have not yet tested it properly so I may have broken something else along the way.
        If Ali is ok Im very interested in your code.

        Comment


          Originally posted by Jan Byška View Post

          I have recently found some spare time and got back to the project where I needed this functionality. I have modified Ali Akbar's code in such a way that it now preserves the reference to the actors inside the prefab. Here is pretty much what I did:
          • I modified FPrefabricatorPropertyAssetMapping structure to store ItemID for the referenced actor (the ID is obtained from UPrefabricatorAssetUserData)
          • I store this ItemID inside UPrefabricatorProperty::SaveReferencedAssetValues()
          • I modified method FPrefabTools::LoadStateFromPrefabAsset such that it first spawns all the actors as placeholders and only restores their properties after all are spawned.
          • I take the list of spawned actors and forward it all the way to UPrefabricatorProperty::LoadReferencedAssetValues(TArray<AActor*> ChildActors)
          • Inside this method, I use the previously stored ItemID to identify the correct actor and change the ReferencedPath accordingly.
          I am willing to share the code if anyone is interested (and if Ali agrees), but I have not yet tested it properly so I may have broken something else along the way.
          Thank you Jan Byška.

          Originally posted by Jan Byška View Post
          (and if Ali agrees),
          This is an open source project, you can do what ever you want with it

          I'd love to incorporate this into the plugin. You can share the code (preferably as a pull request in github) and I'll test and integrate it
          Last edited by Ali Akbar; 02-04-2020, 11:24 AM.
          Dungeon Architect | Prefabricator

          Discord Support

          Comment


            I've made some major performance improvements to prefabricator and I'll push a new update tomorrow. It does the following:
            • Reduce the generation time of prefabs during creation and randomization. This is noticeable with larger nested prefab with thousands of children
            • Optimized the thumbnail Renderer. The thumbs are no longer realtime. They are instead rendered once and cached so this will not slow you editor down with larger prefabs

            Dungeon Architect | Prefabricator

            Discord Support

            Comment


              Originally posted by Ali Akbar View Post
              I've made some major performance improvements to prefabricator and I'll push a new update tomorrow. It does the following:
              • Reduce the generation time of prefabs during creation and randomization. This is noticeable with larger nested prefab with thousands of children
              • Optimized the thumbnail Renderer. The thumbs are no longer realtime. They are instead rendered once and cached so this will not slow you editor down with larger prefabs
              Good to hear about the performance improvements.

              Comment


                Originally posted by Ali Akbar View Post

                I'd love to incorporate this into the plugin. You can share the code (preferably as a pull request in github) and I'll test and integrate it
                I have cleaned up the code, updated it to the newest version and created two pull requests.

                The first one is dealing with the local actor references. As I said before I use ItemID to lookup the correct actor when restoring the actor state. However, it is way from perfect/finished and I don't think you want to pull it as is. The known limitations are:
                1. it does not support nested prefabs
                2. soft references are kept unchanged - but I consider this feature as it allows you to reference the same actor from all prefabs while hard references are prefab specific
                The second pull request is dealing with another issue I have run into recently. If I try to spawn a huge amount of prefabs at runtime that contains components with collisions set to Query and Physics the game starts to choke and eats up all the memory. Upon investigations, I found out that all the components are spawned on top of each other which causes PhysX to deal with the overlaps when the component is registered (or at least I think so) and significantly slows down. Therefore, I have disabled serialization of RelativeLocation for root components. The relative location of the root component is redundant anyway as it equals to the actor location. Restoring the relative location will essentially put all spawned components (from different prefabs instances) on top of each other even if the prefabs are spawned at different places.

                Both pull requests were tested separately and in combination on a limited number of prefabs in my project. It works for all of them but it may break something else, so please feel free to reject the pull requests. I just hope it will give you a starting point to improve the already very handy plugin.

                Comment


                  Hi Ali,
                  I have found another bug (two closely related actually). It appears that changes made to properties of prefab actors are sometimes not stored nor propagated to the other prefabs already spawned in the editor. I have tested it mainly on the master branch, but I believe that it also appears in older versions.

                  The root of the problem of both bugs is that you are serializing only those properties that are different from class default object (CDO).

                  The first issue with this approach is that the user can set a different default value for the component variable inside an actor (e.g., true while CDO would have false). Then modify this value in an actor instance inside a prefab such that it is equal to the component CDO (i.e., false). In such a case, the value will not be serialized since HasDefaultValue method will return true. However, when spawning the prefab, the (wrong) default value from the actor (i.e., true) will be used. Therefore you need to use a CDO object of the component's owner to retrieve the correct default values. This approach, however, works only for native C++ classes as the blueprint classes do not have a correct CDO available. Therefore, I spawn a copy of the actor and delete it later in such cases. Maybe you (or someone else) can point me towards a better solution for blueprint actors as I am not familiar with how exactly CDOs works in this case.

                  Now on the second problem. When you change a property of an actor inside a prefab from anything back to the default value, this change is not propagated to existing prefabs. The problem is that you are reusing existing actors in the spawned prefabs. Since the value is not stored (being the default one), this spawned actor will not be updated correctly. The solution I come up with is to change the actor PrefabItemID inside the ActorData array in case the actor was modified when saving the prefab. This forces the plugin not to reuse the existing actor if it was modified, and it spawns a new one instead.

                  Another straight forward (but perhaps suboptimal) solution would be setting HasDefaultValue to always return false.
                  I have created another pull request to your git with the modification described above if you are interested.

                  Comment


                    Thank you Jan Byška . I looked into the first bug but couldn't get it into the next update (1.4.0) I'll fix this in the next update. I'll have a look at the second one too

                    Dungeon Architect | Prefabricator

                    Discord Support

                    Comment


                      I've submitted a new update. Lots of new improvements and bug fixes. It should show up in the marketplace in a few days


                      Version 1.4.0
                      • Fix: Massive improvements to runtime prefab spawning. Spawn thousands of prefabs at runtime with minimal overhead
                      • New: Procedural Platformer Level sample: Build a platformer level by assembling small building blocks and using those to build more complex nested prefabs, eventually building one nested layout prefab with thousands of valid playable layout randomizations. [Video](https://www.youtube.com/watch?v=RZaYUf_H8fI)
                      • New: Construction System - Enable your players to build their own worlds by assembling floors, walls, ramps corrdiors. There's a game sample demonstrating this. [Video](https://www.youtube.com/watch?v=jM0IItlTxjg)
                      • New: Rewrote the thumbnail renderer, drastically improving the performance. The thumbs are rendered and cached only while saving the prefab. This avoid performance issues in the content browser for larger prefabs where they were previously rendered on demand
                      • New: Prefabs hold soft references to child prefab assets. This avoids breaking reference issues on child prefabs when their location was changed in the content browser
                      • Fix: Fixed a crash issue when prefab settings were changed from other editor windows (like Dungeon Architect's theme editor window)
                      • Fix: Prefabricator loads correctly in custom viewports (like Dungeon Architect's theme editor viewport)
                      • Fix: Deep nested prefabs sometimes had their mobility incorrectly set to movable (when they were static). This also fixes the actor hierarchy unlinking issues where the actors were moved out of the prefab hierarchy
                      • New: Added a new samples submodule under Content/Samples. All sample content reside in this submodule to avoid increasing the main code repository's size
                      • New: Prefab Randomizer actor has a delegate to notify when randomization finishes
                      • Fix: Collision profiles are now saved correctly (Doesn't work in some cases and is still an open issue)
                      • New: Updated the prefab toolbar icon in the editor window and the prefab actor icon
                      • New: Moved the documentation to sphinx-docs for cleaner organization and maintainance. Updated the docs with the new construction system feature. [Link](https://docs.prefabricator.io)
                      • New: Disabled Undo / Redo transactions on creating prefabs to improve performance while mass creating prefabs. This might be restored in the future versions

                      Dungeon Architect | Prefabricator

                      Discord Support

                      Comment


                        Originally posted by Ali Akbar View Post
                        I've submitted a new update. Lots of new improvements and bug fixes. It should show up in the marketplace in a few days


                        Version 1.4.0[LIST]
                        (...)[*]New: Construction System - Enable your players to build their own worlds by assembling floors, walls, ramps corrdiors. There's a game sample demonstrating this. [Video](https://www.youtube.com/watch?v=jM0IItlTxjg)
                        (...)
                        what can I say.. 50 points for ravenclaw dude!

                        Comment


                          Ali Akbar Wow. I just found this. You are amazing.
                          Developing realtime biomolecular illustrative simulations in Unreal: Twitter - Youtube - GitHub

                          Comment


                            timtimmy Thank you Please consider joining our discord channel if you have any queries, we have an active community there: https://discord.gg/dRewTSU
                            Dungeon Architect | Prefabricator

                            Discord Support

                            Comment


                              Submitted a new update

                              Version 1.5.2
                              • New: Added engine 4.25 support
                              • New: Project settings has default thumbnail settings which will be used while saving the prefab asset

                              It should show up in the launcher in a few days

                              Grab this build (Win64) from github
                              Dungeon Architect | Prefabricator

                              Discord Support

                              Comment

                              Working...
                              X