Clearworld

Blitz3D Forums/Blitz3D Programming/Clearworld

stayne(Posted 2012) [#1]
ClearWorld [entities][,brushes][,textures]


I am aware of what it does in general - but how does it know the handles of all entities, brushes and textures? Does it do a complete wipe and does it affect everything else in memory in regards to other apps (clipboard, currently open apps, etc)? Perhaps those with the SDK can answer this. Is it truly clearing just Blitz3D-related memory hogs?

Last edited 2012


Zethrax(Posted 2012) [#2]
Well it's not going to be clearing anything in memory that the Blitz3D app doesn't have permission to access. It doesn't go rampaging through your system like Godzilla after a nuclear power plant.

It just clears the Blitz3D 3d world stuff. Your Blitz3D app keeps track of all the relevant resources under the hood so this command can easily delete them. Things involved with game logic, such as variables, type objects, arrays, banks, etc, are not deleted as that would be silly.

Last edited 2012


Adam Novagen(Posted 2012) [#3]
Things involved with game logic, such as variables, type objects, arrays, banks, etc, are not deleted as that would be silly.
Plus "World" is a term in Blitz3D relating specifically to the 3D scene, and thus wouldn't cover those other elements.

Also, it's worth noting that if you have Types for some entities or what have you, like:

For Enemy.Enemy = Each Enemy
    MoveEntity Enemy\Entity,0,0,1.5
ClearWorld() will delete the entity held in Enemy\Entity, but it won't delete the Enemy Type itself. That, you'd need to do manually; just a thought.


Kryzon(Posted 2012) [#4]
Think of it as an automated way to call FreeEntity for every entity, FreeTexture for every texture and FreeBrush for every brush currently in the scene.


Zethrax(Posted 2012) [#5]
It's probably worth mentioning that ClearWorld is pretty useless in most real-world gaming contexts because it clears ALL the 3D world resources. There's no way of telling it, "Hey buddy, clear up all that other 3D world stuff for me, but leave THIS and THIS and THIS individual resource alone thanks. I need those to render the 3D Gui, the HUD, the main menu, and to copy from when the player starts a new game. And I don't really want to be wasting the player's time by reloading those resources.".


Yasha(Posted 2012) [#6]
...especially since it clears the world objects but leaves your logical objects alone. In most games of any complexity the two will be pretty heavily entwined.


vinnicius(Posted 2017) [#7]
After "FreeEntity level", is important to change the value of the variable to 0. This way you will avoid errors while checking if the level exists or not: "scene > 0 then..."