Destroying spaces and Various

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
d3x0r
Posts: 4
Joined: Wed Nov 18, 2015 3:11 am

Destroying spaces and Various

Post by d3x0r »

I don't see an immediate way to like Space.Dispose() to have it cleanup all of its entites and allow itself to be garbage collected? (restart game)

I found the VoxelGrid demo; and that will mostly work, but it doesn't show up in Space.Entities. What I would like to do is foreach( Space.Entities) DrawBoundingBox(); for debugging.... but it only gets the few extra box shapes I created, not the voxel grids.... is it possible to like get the list of broadphase bounding boxes?

How do I trigger an update for bounding box? As I add/remove voxels it would have a new boundary. Also when I initially create the shape I assume it's entirely solid, later when I figure out that its actually all Empty I'd like to either set it's bounding shape with min>max or probably I'll remove the sector from the space and re-add it later when it gets content. But as I add/remove content the extents should change.

Also; I think since it's 'StaticCollidable' that I will need a different entity that is just 'Collidable' for movable voxel bodies?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Destroying spaces and Various

Post by Norbo »

I don't see an immediate way to like Space.Dispose() to have it cleanup all of its entites and allow itself to be garbage collected? (restart game)
There's no explicit cleanup required; just drop all references to it and its occupants and let the GC eat it. There is no 'remove everything from the space to ensure no objects are referencing the space', though, because:
I found the VoxelGrid demo; and that will mostly work, but it doesn't show up in Space.Entities. What I would like to do is foreach( Space.Entities) DrawBoundingBox(); for debugging.... but it only gets the few extra box shapes I created, not the voxel grids.... is it possible to like get the list of broadphase bounding boxes?
The engine never has to explicitly track a list of non-entities while running, so it doesn't. It's technically possible to extract it from the broad phase tree, but it's generally faster and easier to just maintain your own list externally.
How do I trigger an update for bounding box? As I add/remove voxels it would have a new boundary. Also when I initially create the shape I assume it's entirely solid, later when I figure out that its actually all Empty I'd like to either set it's bounding shape with min>max or probably I'll remove the sector from the space and re-add it later when it gets content. But as I add/remove content the extents should change.
Call (Collidable).UpdateBoundingBox(), and make sure the logic it's executing takes into account whatever you want. Or really anything else that sets the BroadPhaseEntry.boundingBox to the desired value.
Also; I think since it's 'StaticCollidable' that I will need a different entity that is just 'Collidable' for movable voxel bodies?
If you want a collision representation for use with an Entity, it'll need to be an EntityCollidable. (The conceptual division between EntityCollidables and StaticCollidables is one of the things that will likely get removed in v2.)
d3x0r
Posts: 4
Joined: Wed Nov 18, 2015 3:11 am

Re: Destroying spaces and Various

Post by d3x0r »

Alright I was always paranoid about circular references keeping things that shouldn't be kept so I try to at least unwind 1 of the links; but I see that it shouldn't matter after a little research.

Finally got some boxes to fall on a flat voxel terrain and react nicely :) Suppose I should move to a more interesting area but I'd guess it would work well enough there too...


'bouyancy' is not found in any posts :/

So... any advice/hints on how to handle water-voxel collisions? I guess maybe figuring out these custom collision rules....

https://bepuphysics.codeplex.com/wikipa ... umentation

Or maybe it's just defining a Material? With at least linear/angular damping?

hmm.. I guess I want to eventually displace the voxels... given a certain force exerted on them (needs some more thought since mobile grids are smaller than world grids, they'd have to occupy a certain amount of space before displacement would really work)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Destroying spaces and Various

Post by Norbo »

Buoyancy is usually handled with the FluidVolume. Check out the BuoyancyDemo for an example. It relies on a bunch of ray casts to approximate the submerged depth (FluidVolume.GetSubmergedHeight). To make a custom type work with it, the custom type will need to have a working ray cast.

Note that this isn't always a correct approximation for concave objects. Also, the FluidVolume is extremely old and not very fast. Depending on your needs, creating a custom analytic version might be better.

(At some point in the post-v2 future, I'll probably redo buoyancy mechanics.)
Post Reply