lags in the update

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
User avatar
alakryon
Posts: 6
Joined: Fri Nov 21, 2008 8:41 am
Location: Miskolc, Hungary

lags in the update

Post by alakryon »

Hi!

I want to put a barell model (and a lot of other models of course) into my game. It looks like an ellipsoid, with the two ends cutted down, so none of the premade entities are acceptable to this model. So I try to make a StaticTriangleGroup from the model, and use the generatePositionList method to make a ConvexHull from the vertex list. Then I add this ConvexHull to the space with 'noDisplayObject' tag, so it will not get into the entityRenderer. Then I made a DisplayModel, and set the entity property to the ConvexHull, so the real barell model with the DisplayModel will be visible, and the physic modelling will be done width the ConvexHull.
This idea is working, but there is a problem, when the barell starting to move on the screen. There is a lag in its moving, sometimes it is freezing for a few moments, and then continue to move. The interesting thing is, that the other models in my scene, made of the Box premade entity, are working snoothly at the same time, there aren't any lag in their moving. How can I take rid of the lag? Please help...
Here is my code of setting up the barell (the model named 'Hordo' in the code):

Code: Select all

StaticTriangleGroup HordoTriangleGroup = new StaticTriangleGroup(.5f, 1, 0, 0, .4f, 0);
HordoTriangleGroup.initializeData(Hordo);
List<Vector3> Hordovertexlist = new List<Vector3>();
HordoTriangleGroup.generatePositionList(Hordovertexlist, false);          
ConvexHull HordoHull = new ConvexHull(new Vector3(0,5,0),Hordovertexlist,20f);
HordoHull.tag = "noDisplayObject";
space.add(HordoHull);
DisplayModel HordoDisplayModel = new DisplayModel(Hordo);
HordoDisplayModel.entity = HordoHull;
entityRenderer.displayModels.Add(HordoDisplayModel);
And there is a picture from this barell in the scene:
Image

Thanks for any help...
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: lags in the update

Post by Norbo »

That is pretty odd. Does it jig when its floating through the air ever, or does it only do it when its colliding with something or at least in contact with another entity? How large is the object approximately? Does it still happen if you change the space.simulationSettings.collisionDetectionType to CollisionDetectionType.discreteMPRGJK or CollisionDetectionType.linearContinuous?

Could you post or send me some sample code with it happening, the model itself, or the just a list of the vertices in the model?

Right now I'm trying to to determine if its an issue within the engine itself or just some oddity with the display. I'm not sure what part of the display could be causing it considering how simple the DisplayModel is.
User avatar
alakryon
Posts: 6
Joined: Fri Nov 21, 2008 8:41 am
Location: Miskolc, Hungary

Re: lags in the update

Post by alakryon »

:)
Thanks for the solution...
Setting space.simulationSettings.collisionDetectionType to CollisionDetectionType.linearContinuous solved the problem!
Thanks again... :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: lags in the update

Post by Norbo »

Oof, bad news for me. Glad it worked out; is there a chance I could get you to send me the list of vertices on that barrel anyway? Looks like I need to do some debugging.
User avatar
alakryon
Posts: 6
Joined: Fri Nov 21, 2008 8:41 am
Location: Miskolc, Hungary

Re: lags in the update

Post by alakryon »

There is a link for a zip file with the .fbx file (ASCII mode) of the model, so there is the list of the vertices in it, and the texture too, so you can experiment with it:
http://esztyaly.thgs.hu/barell.zip
I will be happy if this little thing could help you make the engine better... :)
Post Reply