Any way to handle large masses of cubes in game

So my game consists of levels completely made of mostly individual rooms made of entirely cubes floor walls ceiling everything well at least in the sandbox mode it does but in the normal levels there are some flat plane pieces but for the sandbox rooms is there anyway of making the game run faster buy maybe combining any touching blocks that are touching into one object but still keep there appearance like there color and beveled edge and then when a block is switched they get changed back to a single block and then back to a whole object when they touch another block again. I know this sounds confusing but is there anyway possible to do this?

It is indeed confusing.
What is a sandbox mode?
What part of the BGE eats most processing time (switch on profiling in game menu)?

In general you need to keep the number of objects as low as possible.
Physical objects eat more performance as non-physical objects.
Objects with logic eat more performance as objects without.
As more faces are visible at the screen as more time needs the render.
Alpha increases render time.

You can’t join meshes at runtime but in render. You can add and remove objects in runtime. This is usually done with LOD.
You can use occluder objects to hide objects (exclude the objects behind the occluder from render).

A sandbox in my game shere the whole room is made of cubes and you can basically have no limitations.

I tried the ocluder thing on all the cubes but they then dont have any collision with the player so i just fall right threw.

also what did you mean by the third question?

There a few solutions:
Since a cube has 6 faces, when making a wall, you convert the cubes (use replaceMesh) to objects having only one side. So the it’s also good to have “roof” cubes that make an end to the wall. These cubes wont be searching for blocks around them…
you can also use a ‘Tetris no justsu’. Once you have a specific block with the cubes, replace all cubes with a single optimized object (bigger wall), then change back to the cubes once you want to move the cubes again.

To achieve that, I suggest you use complex python location calculation script to determine if a cube has neighbors or not and do the replacing part. That will allow you to be able to have 1000’s of cubes without using collisions or expensive easier techniques such as RayCast or radar.

I also thought I might be a solution similar (LOD… LOGIC)

I meant you should switch on the profile messages. With that it displayes what part of the BGE eats most processing. The switch was in the game menu in 2.49. I do not know where it is in 2.5.

Torak: thats what i was thinking but i have no clue how to script that do you know of an exsisting script or .blend out there?

Monster: I found what you are talking about and ya its the cubes.

No, tell monster what it is exactly: and how many ms it takes

Tora’s correct - you would convert the cubes as much as possible. I once tried something with voxels that really didn’t work well, mainly because Blender doesn’t work well with a lot of objects, though many polygons in a single object isn’t so much of a problem. If moerdn continues to work on and fixes up the rasterizer code to optimize it, I would think that his work would be extreeeeemely helpful for cases like this.

EDIT: By the way, Tora’s idea of using the ‘Tetris technique’ sounds like a good idea - merge objects that are close together. That would be probably the most advantageous to your FPS and drawing, though that’s a pretty tough function to write.

Torak: thats what i was thinking but i have no clue how to script that do you know of an exsisting script or .blend out there?

No, This is as I mentioned a complex LOD system. And as SolarLune mentioned, it’s tought to write. However, it’s not impossible, means, that if you don’t find a script for that, you’ll have to write it… with our help…

From what I learned, from the help I got for me game, the following are a few steps to take to make that:

  1. Split your scene into spaces (dictionary, with tuples as keys and lists of lists).
  2. If the all spaces (list of n cubes) are full in section, convert that section into one object.
  3. If various sectors(list of lists) are full, replace them with a bigger block.
  4. Process one space at the time, the one the player is occupying.

Well, you need to plan this out, and think of how this is all going to work, like, how are the cubes added, how you move them, how they interact with the environment, etc.

I think i figured out a way of doing this soly with just logic bricks ill post something later if it works.

So i relized after tinkerying with the idea i had that monster’s object swapping system allready oriented objects correctly when they were switched, so if you swap a plane on a wall with on on the ground they allready rotate the the position that the oposite plane was, now i just have to make it so that the planes switch to full cubes when swaped with spring blocks or other blocks that are in full 3d view.