Inverting a Box's Collission? And walls?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
theneonirvana
Posts: 24
Joined: Wed Aug 17, 2011 9:20 pm

Inverting a Box's Collission? And walls?

Post by theneonirvana »

My title may not be very descriptive... i apologize,


Basically i would like to create a prefab box entity, and have other entity within its co-ordinates like a container, and have those objects bounce within it,

picture a bunch of boxes bouncing in a box.

Now an obvious solution to this is to make 6 rectangular boxes like walls in that represent a cubes 6 sides and just have the items bounce inside all 6 prefab entities,

but, seems the more i add to the physics engine( entities) im at about 169 now, the slower my project gets, minimizing draw calls and items that do not require physics is a must, so 1 instead of 6 is ideal.

--------------

Second part question... i am playing with basic walls, lets call them north south east and west walls, we can include the ground in this question because it seems to be following the same principals.

if i were to decrease the Y position of my player so they move down in altitude, my player goes right through the floor and begins falling in empty space untill oblivion.

the same principal happens with my walls, if i walk into a wall it will push right through, if i tap my walk forward key, it seems to push me back a bit, so it seems to me my character movement variable is to large? and its moving the charter through the wall to fast? or, is there a way to make entites, "Rock Hard" or stiffer? or do i literally make it thicker, when i make my entity, so that the user may go into the surface but its so thick BEPU sees to collission and pushes the player out of the wall.

ive looked through the demo games, i cant find the code for the danm walls, lol.... u would think that would be easy, ive tried to use examples from basic objects being drawn there, and i do not see any parameters for entities made that would do this.

Thanks!
Shout out to Norbo, for all his hard work, and concerns with the forums! Thanks for you time, alot of us would be LOST :D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Inverting a Box's Collission? And walls?

Post by Norbo »

Basically i would like to create a prefab box entity, and have other entity within its co-ordinates like a container, and have those objects bounce within it,
There are a few options. The demos I refer to below are in the BEPUphysicsDemos project in the main source download.

-If it's not moving, you could use a StaticMesh to represent it. That single mesh could also contain the rest of your level geometry. This is how most games handle environmental geometry. The StaticMeshDemo shows how to use it.
-You can also use 6 kinematic boxes.
-If it's dynamic you could use 6 box shapes in a CompoundBody. Check out the CompoundBodiesDemo or EntityConstructionDemo for examples.
but, seems the more i add to the physics engine( entities) im at about 169 now, the slower my project gets, minimizing draw calls and items that do not require physics is a must, so 1 instead of 6 is ideal.
169 entities, particularly 169 nonmoving kinematic entitites, should not be slowing anything down noticeably (unless you're not targeting the PC, perhaps). Also, you can draw the objects however you want. A common approach is to use instancing. If your objects are a bunch of boxes, this is particularly useful. An example can be found on the XNA site: http://create.msdn.com/en-US/education/ ... instancing

Of course, if you make your level into a single environment mesh, then things are a lot simpler.
if i were to decrease the Y position of my player so they move down in altitude, my player goes right through the floor and begins falling in empty space untill oblivion.
Setting the position of an entity teleports it. Collision response cannot stop teleportation because there is no velocity to correct. If you tell an entity to teleport into a wall, it will happily do so.

The reason why collision response appears 'squishy' as opposed to completely absent is, despite the fact that there is no velocity to correct, there is still penetration error to correct. Penetration is resolved over multiple frames to prevent jerks and jumps in normal simulation, but when velocity is totally removed from the picture, it's usually too slow to stop entities from going through walls.

The proper way to control entity motion is using velocities or forces by setting LinearVelocity, AngularVelocity, using ApplyImpulse, etc.
Shout out to Norbo, for all his hard work, and concerns with the forums! Thanks for you time, alot of us would be LOST
You're welcome :)
Post Reply