Building levels

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
lastlinkx
Posts: 7
Joined: Mon Jan 16, 2012 3:37 pm

Building levels

Post by lastlinkx »

Ok, first of all let me say, bepu is amazing! It fulfills all my needs.

I just have a couple of questions:

1 - Is it best to make levels out of static meshes or out of the collision primitives?
ex: I could make the entire level (walls, ceiling, floors) in my 3d model editor, and load that mesh into bepu, then have static objects representing all the stuff,
Of course I'd be loading a simplified version for collision detection, and would have the Map cut up into sections (see next part)
or should each wall/ ceiling be a static box?

2 - I've implemented a "portal" system in my game, where only the active part of the map needs to be updated / drawn. Is there any way I should tie this into bepu.
ex: You move from room A to B, so tell bepu that room A and it's contents no longer need to be updated.

Thanks in advance!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Building levels

Post by Norbo »

1 - Is it best to make levels out of static meshes or out of the collision primitives?
If the geometry is supposed to be static, a StaticMesh is a good option. Having a bunch of separated primitives puts extra stress on the BroadPhase that a StaticMesh avoids. Similarly, having a bunch of separate smallish StaticMeshes is not as efficient as having fewer, bigger StaticMeshes.

If the primitive representation is preferred, the primitives can be put into a kinematic compound shape. This avoids most of the overhead associated with tons of primitives in the broad phase.
2 - I've implemented a "portal" system in my game, where only the active part of the map needs to be updated / drawn. Is there any way I should tie this into bepu.
The engine already has a deactivation system which avoids doing a lot of work. It's not totally free since the broad phase still has to consider the object, but it's pretty cheap. I would recommend not worrying about it to begin with. Chances are, this kind of system would only be useful when there were thousands (perhaps hundreds on the Xbox) of inactive objects at a time.

If, later on, testing shows that it's worth it, you could remove objects from the Space as they go out of scope to prevent them from taking any more time. Removing isn't a free operation, though, so it wouldn't be a good idea to remove 100+ objects all in one frame. Distributing the removes over multiple frames would avoid performance spikes.
lastlinkx
Posts: 7
Joined: Mon Jan 16, 2012 3:37 pm

Re: Building levels

Post by lastlinkx »

Awesome! So I can get modelling now.

I guess I'm going the "Several Huge static meshes per level" approach.

Thanks!
Post Reply