Question about an optimization system

I have a build battle game and players are placing individual parts but how I could optimize the builds like in the image below

The first image is the building without this optimization.
And second is with the optimization.
I do have an idea how to do this but I better hear from someone with more experience.

1 Like

There is probably a much better way to do this, but here is what I would do

When a block is placed:
• Get all touching parts
If one of these parts is the same class as the origin:
Calculate a ‘combined’ size from the two parts, as well as a median position.
Then, create a new part which inherits the new size & position, as well as the colours materials etc from the origin

some words I used, and their meaning

origin: The part that was placed.
class: If these bricks are just an example, then the class would be what was placed.
(chair, table, door etc)

Hope this helps! (Even if it isn’t the solution you were looking for)

The concept in this thread might help you out: Consume everything - how greedy meshing works

I decided to take advantage of the table my builds were creating. But still your solution is very good. It can easily give an idea to others how they could manage something like this.