Static Group can get smaller but not bigger

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
S0nix
Posts: 4
Joined: Sat Nov 24, 2018 12:30 pm

Static Group can get smaller but not bigger

Post by S0nix » Sat Nov 24, 2018 2:03 pm

Hi
I am currently trying to integrate Bepu into our engine. It works pretty well so far but I face a problem with static objects.
Short about my setup.
The engine is component based where each entity can have multiple components. A space object is represented by one engine Entity(let me call them actors to differentiate between the physics entities).
Each Actor can have multiple colliders which are represented by components. With all of the collider components an actor has I create a Compound Body for a dynamic object or a StaticGroup for a static object which I add afterwards to the space.
If I want to resize a collider for example this already works well with dynamic objects as I just need to change the properties of the collider which will update the shape.
Now the problem with static objects is that this does only seam to work when making a shape smaller but not bigger compared to the size they were added to the space.
If I remove the object from the space and add it again it works but I thought you can change the shape of a static collidable without readding it to the space or is my assumption wrong here?
I would be grateful for any help.
PS I am using bepu v1

Norbo
Site Admin
Posts: 4558
Joined: Tue Jul 04, 2006 4:45 am

Re: Static Group can get smaller but not bigger

Post by Norbo » Sat Nov 24, 2018 9:33 pm

I'd assume this is related to the fact that StaticGroups do not automatically refit their acceleration hierarchies when children are changed. You should be able to fix the issue by calling:

Code: Select all

staticGroup.Shape.CollidableTree.Refit();
staticGroup.UpdateBoundingBox();
after you make modifications. You can call refit a single time after a batch of changes to save some time.

Refit does not update the topology of the acceleration structure, though- if the collider changes dramatically, the tree may no longer be a good fit and performance might suffer. If this happens, you can instead call:

Code: Select all

staticGroup.Shape.CollidableTree.Reconstruct(setOfCollidablesInStaticGroup);
staticGroup.UpdateBoundingBox();
which will rebuild the entire acceleration structure for the current state. This is a much more expensive operation, but it can handle large changes in the children.

Both of these rely on the bounding boxes stored in the staticGroup's child CollisionInformations. Some types require explicitly calling UpdateBoundingBox on the modified child to update the cached bounding box; that would have to be done prior to calling refit or reconstruct.

S0nix
Posts: 4
Joined: Sat Nov 24, 2018 12:30 pm

Re: Static Group can get smaller but not bigger

Post by S0nix » Mon Nov 26, 2018 11:00 am

Thanks for the quick reply.
This did the trick. My static groups are now updating correctly :D

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests