allow an entity to pass thru a hole in a box

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
srk84
Posts: 2
Joined: Fri Jul 31, 2020 8:52 pm

allow an entity to pass thru a hole in a box

Post by srk84 »

I’m trying to build something with BEPUphysics1 but am stuck on how to proceed. I’d like to create a block with a hole thru it so that another cylinder could slid thru it while retaining the physics if the cylinder collides with the sides of the hole. I’ve had a few thoughts but haven’t been able to get very far building them:
  • Create a cylinder inside the block to represent the hole (turning off broadphase collision between them). Add a collision handler to the hole for the InitialCollisionDetected event. When an entity comes in contact with the top (or bottom) of the hole, the handler fires and disables broadphase collision detection between that entity and the hole. Now I’m left with figuring out the physics for the entity to move thru the hole, basically collisions between the outside of one cylinder and the inside of another _ it feels like an algorithm with a big “magic happens here” step.
  • Approximate the hole as a polygon with a bunch of boxes with faces on the tangent of the hole’s cylinder wall. I’ve used this to build a pipe or tube that I can drop an entity thru and it handles the physics nicely. Now I need to figure out how to overlay that tube on a block so an entity can pass thru the block. I’d need to somehow group the tube and block so they move together and selectively allow entities to pass through the block at the top or bottom of the tube.
I’m very new to this so I’m likely missing something obvious.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: allow an entity to pass thru a hole in a box

Post by Norbo »

Probably easiest to just make a compound of multiple simple convex shapes with a hole in it. Trying to dynamically adjust collision rules in response to contact events to dynamically make a hole in an existing convex object pretty much won't work.

The CompoundBodiesDemo shows how to create compounds: https://github.com/bepu/bepuphysics1/bl ... iesDemo.cs
srk84
Posts: 2
Joined: Fri Jul 31, 2020 8:52 pm

Re: allow an entity to pass thru a hole in a box

Post by srk84 »

Thank you. CompoundBody is much easier. I tried using that before but hadn't seen how to rotate a CompoundShapeEntry and gave up on it. Your answer to a different question pointed me to a RigidTransform and that solved the issue.
Post Reply