Page 1 of 1

Problems with BEPU in windows phone

Posted: Sat Oct 30, 2010 6:59 am
by jbosch
Hi,

I published a game based on bepu physics engine in the windows phone 7 marketplace. The game runs smoothly in the emulator, but in the real device, some "strange" things happen: the ball changes its direction suddenly, the performance decreases a lot when the ball hits the first pin, even sometimes the ball crosses the ground and falls under it... I feel frustrate because I can't debug this behaviour in the emulator. Any idea?

http://www.youtube.com/watch?v=_76CCogvxDk

Re: Problems with BEPU in windows phone

Posted: Sat Oct 30, 2010 9:02 am
by Danthekilla
Well the first problem is that you need to test it on a device as the emulator can be up to 25 times faster than a device.

Re: Problems with BEPU in windows phone

Posted: Sat Oct 30, 2010 4:30 pm
by Norbo
You might want to verify that the vertices and indices that the collision mesh is being made from matches between platforms. Strange behavior with the content loading has been reported before on the device that doesn't appear in the emulator, although I have no idea what would cause it.

The BEPUphysicsDrawer can draw the TriangleMesh object used to construct your model. It will draw whatever the collision mesh is; this might reveal something wonky.

Re: Problems with BEPU in windows phone

Posted: Sat Nov 06, 2010 4:10 pm
by jbosch
I can't find any way to speed up the game when the ball hits the pins. Any idea?

thanks

Re: Problems with BEPU in windows phone

Posted: Sat Nov 06, 2010 5:54 pm
by Norbo
Is it a performance problem, or are you just trying to make the actual simulation appear to move faster? If it's the latter, you could try increasing the gravity some until it feels right (careful, if you go too high, you can introduce instability which may require more iterations or a smaller timestep to fix).

For performance, you can try messing with the collision response setting's iteration count. Very low counts (1-4) will be quicker than the default (10), but you'll have to test to see how low you can go before the lack of accuracy becomes apparent.

If I remember right, you're using cylinders for the pins, which should be fine. If I remember wrong and you're actually using ConvexHulls, you might try simplifying the collision mesh some or using cylinders.

However, 10 pins and a ball should really run fine, even on a phone. If there are performance problems, it's probably something less obvious.

Re: Problems with BEPU in windows phone

Posted: Sun Nov 14, 2010 10:47 am
by jbosch
Hi, after many tests with the device, I've seen two main things:

-I cant undersrand the differences in the behavior.
-My pins are set to kynematic before each launch.When the ball is in a short distance, I make them dynamic, and it seems that causes problems. But if I dont do this, some pins start dancing and some fall. Is there a better solution for this?
-I also create new instances of ball and pins each turn. This probably generates garbage, but I need to do so because if not I cant find the way to "reset" the physical properties of the entities.

Can you sugest something better? Thanks.

Re: Problems with BEPU in windows phone

Posted: Sun Nov 14, 2010 12:14 pm
by jbosch
Norbo wrote:Is it a performance problem, or are you just trying to make the actual simulation appear to move faster? If it's the latter, you could try increasing the gravity some until it feels right (careful, if you go too high, you can introduce instability which may require more iterations or a smaller timestep to fix).

For performance, you can try messing with the collision response setting's iteration count. Very low counts (1-4) will be quicker than the default (10), but you'll have to test to see how low you can go before the lack of accuracy becomes apparent.

If I remember right, you're using cylinders for the pins, which should be fine. If I remember wrong and you're actually using ConvexHulls, you might try simplifying the collision mesh some or using cylinders.

However, 10 pins and a ball should really run fine, even on a phone. If there are performance problems, it's probably something less obvious.
By the way, how do we change the collision detection settings? Thanks

Re: Problems with BEPU in windows phone

Posted: Sun Nov 14, 2010 8:30 pm
by Norbo
I also create new instances of ball and pins each turn. This probably generates garbage, but I need to do so because if not I cant find the way to "reset" the physical properties of the entities.
That does create garbage, but it's 'rare' (once every several seconds) and a pretty small amount of garbage so it might not even be something to be worried about. If you do want to get rid of it, the only thing you should have to do to reset them is set the position, orientation, linear velocity, and angular velocity back to their starting values. Linear/angular velocity's initial values are both zero vectors.
My pins are set to kynematic before each launch.When the ball is in a short distance, I make them dynamic, and it seems that causes problems. But if I dont do this, some pins start dancing and some fall. Is there a better solution for this?
Does the dancing happen on Windows/WP7 emulator? If it's only happening on an actual device, the best solution (and the only one guaranteed to work, unfortunately) is to try and figure out what's up with the device. Making them dynamic shouldn't really cause issues either.

If the dancing happens on the emulator as well, then it's more likely related to the size ratios of cylinders/triangles involved. I'd have to see the exact behavior in action to know, but the size ratio issue is pretty common.
By the way, how do we change the collision detection settings? Thanks
Collision detection settings can be found in the space.SimulationSettings.CollisionDetection class. Collision response settings (including the iteration count) can be found in the space.SimulationSettings.CollisionResponse class.

Re: Problems with BEPU in windows phone

Posted: Wed Nov 17, 2010 5:57 pm
by jbosch
Hi there,

I followed your recommendations,and the performance has improved a 300%

Now I created a new problem, and it is that the ball does not move very reallistically. It seems like it is not being affected by the gravity or something similar. Please have a look at this video:

http://www.easy-share.com/1913001082/Sc ... 17-11-2010 18.49.49.wmv

Do you know which could be the reason for that behaviour and how to solve it?

Thanks in advance.

Re: Problems with BEPU in windows phone

Posted: Wed Nov 17, 2010 9:20 pm
by Norbo
I can't really tell for sure, but it almost looks like the ball is kinematic.

By the way, are you using a content processor to collect collision mesh data? If not, I would recommend it.