## Destructable Meshes with patterns

Post and discuss features you'd like to see in the BEPUphysics library.
Mindrage
Posts: 11
Joined: Mon Oct 24, 2011 8:16 pm

### Destructable Meshes with patterns

This is a mere unthought concept but.
Lets say you have certain "destruction patterns"
Like wood breaks towards thier fibers, Why not make some polygon modifications laws for certain materials

Lets say that the contact area or destruction area depends on a materials solidity and force of impulse.

But to simulate tree and fibers you need a solidity value for height,width and depth. where a lower value on the height will make the "crack" longer at that direction.
Then ofc these cracks are stored within the "cracks" in the model so they can futher increase in length and spread until they break and form a new object when it has reached the outer polygon lines.
each crack can have thier direction which draws towards the shortest range to a line and bends thier path even more. depending on the force.
And adding a quality value from 0 to 100 to depend on how many cracks there are in the object you can reduse cpu usage i think...

So
1: Crack points spawn at a random position within the destruction area in the polygon. A value from 1 to 100 determine how many cracks there should be.
2: The cracks gets a point tree or array to expand the crack wit ha new point when a certain distance.
3. when one of the cracks trees reaches ouside the polygon, it will connect all crackpoints to surrounding vectors and create a new object and leave the second object wit ha hole.

4 expanding it more these cracks" can also be point to where objects deform if they arent massive, otherwise it could also have a detail level of how many points that are used to deform.
I dont know the math here, but isnt there some kind of law that tells how long all points of a polygon together can tell the volume of the polygon?
In that case, cant you make some kind of equivilence to make the total outer polygon get deformed with balance of volume?

Norbo
Posts: 4816
Joined: Tue Jul 04, 2006 4:45 am

### Re: Destructable Meshes with patterns

A good thing to remember about things that look fancy in games, especially if they involve the CPU: It's all tricks

Unfortunately, the approach you describe would be very expensive if you intend for there to be any physical simulation describing the cracking process and its results. A game only has so long to compute a frame (usually around 16 milliseconds), and only so much of that frame is reserved for physics.

Speeding it up significantly would involve making all the cracking a purely graphical effect with no changes to collision geometry until post-break, at which point highly simplified physical entities are created with many more noninteractive debris objects and particles. Another approach would be 'prebreaking' the mesh so that it always gets destroyed along the same cracks.

You may have seen some deformable-destructible game simulations where plywood gets bent and splinters into pieces. Such simulations as applied to games are usually deceptive. The plywood might have a couple dozen 'pieces' which simulate the deformation physics. This is quick enough to be used for a game. On top of that, many tiny graphical chunks are parented to this deforming tetrahedral mesh. This gives the appearance of extremely detailed simulation, since the little pieces have so many tiny features- like the jagged points of splintered wood.

Deformation anisotropy, like wood splintering along certain directions, can be faked quite well and quite speedily by making sure the graphical pieces align with the grain. On top of that, the tetrahedral elements can be stretched out. The simulation tends to behave a bit as you might expect by doing so.

With this clever fakery, you can get away with whole walls of bricks that can be seemingly blown apart with relatively low cost. Even people familiar with deformation techniques can be captured by the illusion- it works very well.

All that said, deformable materials aren't currently high on the to-do list right now. I've made prototypes of it in the past, but there's a lot of work between a prototype and making it public. If I do jump back into it, it will probably be something like I described- specialized in handling fast, relatively small groups of elements for a convincing back-end simulation on top of which graphics can be layered.

A type of speedy rigid fracturing without deformation, on the other hand, is high on the to-do list (and is basically done).

Mindrage
Posts: 11
Joined: Mon Oct 24, 2011 8:16 pm

### Re: Destructable Meshes with patterns

Awesome ;D

Im currently myself trying to integrate some kind of multilayer terrain in the system with liquid and gas objects, Trying to make a game where the entire worlds is interactive from air to water to ground.
So im basically making my own periodic table somehow XD.Though i am editing some code where friction increases temprature of a certain terrain sector.

Love the preformance so far ;D. tried 30000 objects with the planet simulation. got around 80 ms with two gravitational fields!

oh and i wonder, How does the engine act with wide areas, Can you have many objects in "sleep". if you are using some kind of tree system?

Norbo
Posts: 4816
Joined: Tue Jul 04, 2006 4:45 am

### Re: Destructable Meshes with patterns

How does the engine act with wide areas
Generally well. You can modify some of the BEPUphysicsDemos to start thousands of units away from the origin to investigate it directly.

All collision detection takes place in local space, so it's fairly resilient. Running a simulation 100,000 units away from the origin introduces some wobbliness that wouldn't otherwise be there, but it's still quite stable and usable most of the time. Going 1,000,000 units out is a different story- there's not enough precision in floating point numbers to even render the graphics properly, let alone do robust physics.

If you have a simulation that spans many tens of thousands of units with the expectation of perfect simulation in every area, you will have to take some precautions. If you're a single person walking around the world, you can adaptively recenter the space on your character's area. Depending on the game there are different 'best' ways to do this.

Another possibility is changing the engine to use all doubles. This can complicate certain interactions, and would most likely require that you use the DependencyFree version of BEPUphysics which comes with its own math library (and so allows you to switch the core math to doubles instead of floats, which isn't possible with the prebuilt XNA libraries). This approach will lead to some inconvenience, but it will make things more robust much further out.
Can you have many objects in "sleep". if you are using some kind of tree system?
Yes.

The main cost associated with sleeping objects is the broad phase acceleration structure which is required to figure out whether or not it's time to wake up an object yet. It's speedy, but you'll still feel it if there's many thousands of objects. If you don't want any cost at all, you'll have to do some pruning such that only relevant areas of the world are actually in the Space, or, if you have multiple Spaces, only the relevant Spaces are updated.

Mindrage
Posts: 11
Joined: Mon Oct 24, 2011 8:16 pm

### Re: Destructable Meshes with patterns

Basically what i've tried in an own 2d physics engine i was trying to do, i had about 100000 objects in sleep which where stored in memory.
But then i had a quadtree that stored a list of active objects that moved around, they only checked the areas arounds its own objects and redused the number of collisions.
I had a increased memory usage but the preformace was pretty good. Im mainly using this as a server simulation of physics.then sending packets to the clients when an impulse happens affected from the players/ingame things.
otherwise the simulation should be the same, except that i have to update positions of the pbjects according to the servers to not make the local time be a problem.

What i wanted to ask is if i can have large amount of meshes in sleep without affecting the active objects preformance?

Norbo