3D Level Editor - Performance issue
-
Share your code, let’s have a look :)
-
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!
-
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!
-
-
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
-
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..
-
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
-
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 :)
- 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
-
@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
-
Thanks @CasualTie5 - I'll give it a go, just need to find a way to unload everything now haha
-
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 -
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.
-
Nice, do you have any code you can share for how you're doing this?
-
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!
-
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..
-
How’s it going?
-
Have been flat out with work... should have a chance to get back into this on the weekend !