I'm currently working on some procedural destruction code for objects in a space scene. The basic premise is to map the destructible object to a grid of destructible blocks that destroy when other objects make contact.
In the first iteration, I took an array of blocks and generated a body/shape/fixture for each. Using WeldJoints, each block was welded to other blocks it touched on its side's. This worked well except for the jitter seen in the weld joints when a high speed object made contact with the body group as a whole.
I've decided instead to map all of my object blocks to a single common body to stop the jitter. The only issue I have during destruction if the grid of blocks ever gets cut in half (high speed object cuts straight through) then both halfs float together with the same body.
I need help with a solver to detect when an array of blocks splits into two distinct groups. Example:
Starting Block Grid:
Code: Select all
objectBlocks = {
{{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK},{BLOCK}},
}
Code: Select all
objectBlocks = {
{{BLOCK},{BLOCK},{EMPTY},{EMPTY},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{EMPTY},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{EMPTY},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{EMPTY},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{EMPTY},{BLOCK},{BLOCK}},
{{BLOCK},{BLOCK},{BLOCK},{EMPTY},{EMPTY},{BLOCK}},
}
Thanks so much!