Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    3D Level Editor - Performance issue

    Help
    3
    18
    783
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Tratax
      Tratax F last edited by Tratax

      Hey All,

      I've been working on a 3D JRPG for a few weeks now and find i'm stuck at properly handling object and wall collision from multiple angles

      To try work this out, i've built a 3D Level Editor that has full save and load functionality so that I can experiment with various detection techniques (may turn into a Wolf3D clone!)

      In 2D, this works with no issues but in 3D i'm getting severe performance issues, fairly sure it's to do with how i'm creating and managing objects.. @pianofire @Martin @Jonboy any thoughts? :)

      Share ID: HT943MNDNX

      and

      1 Reply Last reply Reply Quote 1
      • PickleCatStars
        PickleCatStars F last edited by

        Share your code, let’s have a look :)

        1 Reply Last reply Reply Quote 1
        • PickleCatStars
          PickleCatStars F last edited by

          It’ll take a while to become public (you did also ’submit’ it for public share, right?), so I can make a few guesses/suggestions for now.

          Your walls all look like they’re using the same model. You should only have to ’yourvariable = loadmodel()’ once, and then use that same yourvariable every time you placeobject(). Don’t keep loading the same model over and over is what I’m saying.

          Also, you shouldn’t placeobject() every object every frame. You place a wall piece once to put it in the game world. I hope you’re not layering objects over and over on top of each other all the time.

          They’re the main two things I can think of. Fuze can definitely handle what it seems like you’re going for, so there’s something wrong with your code somewhere. Double-Check your loops, too. Once I had a setup function that was taking way too long because I was doing everything 64 times instead of just once! I also set a struct property .exists to ’true’ when I place an object and false after I remove one, and have if.. then checks. You can do the same with separate arrays though if you prefer. Good luck for now!

          1 Reply Last reply Reply Quote 1
          • Tratax
            Tratax F last edited by

            Hey, thanks - I'll check now if I've shared this up properly

            So I have two variables for two models (the floor and the wall objects)

            For the wall objects, I'm attempting to use a for loop to create an instance of each object = loadmodel however I dont know if that's possible.. my goal is to have each object be modifable once placed.. I've done this no issues in other 3D work but i've done it by manually assigning and incrementing each placeObject

            For the game loop, I'm attempting for it to place a new object only when a modification happens via pressing A

            Just checked my share settings and can't see a public option? I've shared from Friends and from the game itself.. I havent been on fuze in months so i'm probably missing something here

            Thanks!

            1 Reply Last reply Reply Quote 0
            • Tratax
              Tratax F last edited by Tratax

              Here's the code - haven't included the 2D drawbox function as its fairly basic and working fine




              1 Reply Last reply Reply Quote 0
              • PickleCatStars
                PickleCatStars F last edited by PickleCatStars

                Line 185. Set environment should just be used once when you’re setting up your lights and stuff. Try putting that outside of your loop :) fingers crossed

                1 Reply Last reply Reply Quote 0
                • PickleCatStars
                  PickleCatStars F last edited by

                  For public share, go to ’friends’, press r for ’my shared programs’, pick your program and press ’a’, then pick ’submit’. 2 people from the fuze team have to approve it, so it won’t happen instantly..

                  1 Reply Last reply Reply Quote 0
                  • Tratax
                    Tratax F last edited by

                    Nice, good one - Moved both setenvironment and the ground placeobject before the game loop and its running much better... still losing memory but i can now place more blocks!

                    Thanks, I've just submitted it for review

                    1 Reply Last reply Reply Quote 2
                    • Tratax
                      Tratax F last edited by Tratax

                      Quick update that I believe Ive found the cause of the memory issue!

                      The setup3D function runs each time the map has been loaded into memory and on each user input of the A button

                      At Line 178, I'm saying to read the entire array and place an object even if it already exists, so each time this function is called it's just creating whole replication of these objects filling up the map and memory quite quickly

                      So here's what I'm thinking...

                      • Create another array that stores if 3D objects have been placed or not and test / update that locations reference on each button push ONLY redrawing objects that do not yet exist
                        or
                      • Unload all objects, if this is possible.. and then just read from the array and redraw everything everytime something changes

                      Option one seems like the better choice.. option two seems like the faster lazier route.. Solving this will also allow me to remote objects from the scene which will be needed as a map editor

                      keen for any thoughts / input :)

                      CasualTie5 1 Reply Last reply Reply Quote 2
                      • CasualTie5
                        CasualTie5 F @Tratax last edited by

                        @Tratax the second option doesn't appear lazy to me at all - I would argue that always removing unnecessary data is a very effective procedure

                        1 Reply Last reply Reply Quote 0
                        • Tratax
                          Tratax F last edited by

                          Thanks @CasualTie5 - I'll give it a go, just need to find a way to unload everything now haha

                          1 Reply Last reply Reply Quote 0
                          • Tratax
                            Tratax F last edited by

                            Ok, have had a go at removing the objects and have realised that the objects might not be created properly at the moment as removal is saying the object is invalid

                            Does anyone know the correct way to use a for loop to create multiple individually managable 3D objects?

                            Here's my current version:
                            obj = []

                            for i = 0 to len(level01) loop
                            obj[i] = placeObject( model.wall, scale, pos )
                            repeat

                            1 Reply Last reply Reply Quote 0
                            • PickleCatStars
                              PickleCatStars F last edited by

                              The problem you’re encountering now is the bane of my life. I solved it by making sure my array is global, and doing it outside of a function. It will be fixed in the upcoming patch, I do believe.

                              1 Reply Last reply Reply Quote 3
                              • Tratax
                                Tratax F last edited by

                                Nice, do you have any code you can share for how you're doing this?

                                1 Reply Last reply Reply Quote 1
                                • PickleCatStars
                                  PickleCatStars F last edited by

                                  I downloaded yours and had a look. If you change the line

                                  Obj = []

                                  To

                                  Array obj[len(level01)]

                                  That’ll fix it. I also noticed in your setup3d function, you say ’float scale = {1,1,1}’ - that works, but only because Fuze is so forgiving. {1,1,1} is a vector, as I’m sure you know.

                                  It’s looking pretty good so far! The saving and loading works. Super cool!

                                  1 Reply Last reply Reply Quote 2
                                  • PickleCatStars
                                    PickleCatStars F last edited by

                                    I actually didn’t have to change anything else. Seems your problem isn’t the same as the one I’ve been having, and was just solved by setting up your array the way I just said..

                                    1 Reply Last reply Reply Quote 3
                                    • PickleCatStars
                                      PickleCatStars F last edited by

                                      How’s it going?

                                      1 Reply Last reply Reply Quote 1
                                      • Tratax
                                        Tratax F last edited by

                                        Have been flat out with work... should have a chance to get back into this on the weekend !

                                        1 Reply Last reply Reply Quote 1
                                        • First post
                                          Last post