Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

27. May 2012, 03:42:12 am
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Wierd physics issue
Pages: [1]
Print
Author Topic: Wierd physics issue  (Read 1195 times)
AotFSteven
developers
Enjoying the stay
***
Offline Offline

Posts: 63


View Profile
« on: 23. April 2008, 07:48:29 pm »

I am having a problem with the avatar dropping partially through the ground and then getting flung through the wall.  This appears to happen when the frame rate drops dramatically.  Right now I am working on my senior project that allows multiple clients to connect to a server.  When they do the server lets the other clients know that the character has entered the game and the character's model is added to the other client's Xith environment.  I have noticed that on my laptop it occasionally stutters when adding the avatar.  After the pause finishes, the avatar is about halfway through the ground and then it is flung through wall.  I think that this has something to do with the physics engine and the pause, however, I am not sure and I don't think that I will really have the time do dive into this problem to see if I can figure it out so I was hoping that someone might have a solution or a work around for it.  Also, occasionally when I am debugging in eclipse or when I have given focus to a different window upon coming back to my application I will find that my avatar has fallen through the floor.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 23. April 2008, 08:08:07 pm »

You might be able to fix that by disabling the model's body's gravity responsiveness (setGravityEnabled( false )) when it is added the the scene. Then after it has been rendered one frame you enable the gravity.

As a general practice you might want to decrease the simulation engine's step size. Don't know, if that helps.

Marvin
Logged
AotFSteven
developers
Enjoying the stay
***
Offline Offline

Posts: 63


View Profile
« Reply #2 on: 23. April 2008, 08:31:44 pm »

You might be able to fix that by disabling the model's body's gravity responsiveness (setGravityEnabled( false )) when it is added the the scene. Then after it has been rendered one frame you enable the gravity.

The avatar attached to the FPIH is the one that is dropping, are you suggesting stopping its gravity while loading the new model in?  The only model that has physics applied to it is the avatar attached to the FPIH because the server just sends each application the exact coordinates of the other characters.

As a general practice you might want to decrease the simulation engine's step size. Don't know, if that helps.

I will try this and hopefully it will fix the problem.  I will post my results.

As usual, thanks for the quick response Marvin.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 23. April 2008, 08:52:51 pm »

The avatar attached to the FPIH is the one that is dropping, are you suggesting stopping its gravity while loading the new model in?  The only model that has physics applied to it is the avatar attached to the FPIH because the server just sends each application the exact coordinates of the other characters.

Well, yes, that was, what I was suggesting. Though I didn't completely think this through. Maybe there's a conflict between the sent coordinates and the local physics. I don't know your system.

Do I understand you correctly, that your own avatar is dropping trough the floor when a foreign client's model is added to the scene? Wouldn't that mean, that (possibly) all models drop, since all the other clients will have the same problem?

Marvin
Logged
AotFSteven
developers
Enjoying the stay
***
Offline Offline

Posts: 63


View Profile
« Reply #4 on: 23. April 2008, 10:12:31 pm »

Well, yes, that was, what I was suggesting. Though I didn't completely think this through. Maybe there's a conflict between the sent coordinates and the local physics. I don't know your system.

I don't think that this is the problem because the avatar is fine until another player connects.  Also, the client is the master for that character so it sends the coordinates (rotation, etc.) and state (animation) to the server and the server application just broadcasts this information to the other players.

Do I understand you correctly, that your own avatar is dropping trough the floor when a foreign client's model is added to the scene? Wouldn't that mean, that (possibly) all models drop, since all the other clients will have the same problem?

Yes, I guess this could possibly happen, however the avatar dropping through the floor does not happen all of the time and it only happens when the foreign players connect after the current player has already been in the game.

I tried changing the step size and it didn't seem to fix anything.  I will try toggling the gravity during the connecting of a foreign player to see if that helps.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #5 on: 23. April 2008, 10:53:54 pm »

Another solution could be to load all possible models once at startup and render them once, so that the display lists or VBOs are generated. Then the time gap should be negligible when the new model is inserted. Or are the models all of the same type (same/shared geometry and textures)? In this case, this shouldn't be necessary and I would not understand, why there could be a time gap.

Marvin
Logged
AotFSteven
developers
Enjoying the stay
***
Offline Offline

Posts: 63


View Profile
« Reply #6 on: 23. April 2008, 11:05:26 pm »

Right now I am using the same model, so I was going to try to just reuse it, but I am still getting the problem at other times if the system slows down.  I tried changing the setGravityEnabled and this worked, however when the foreign character moved (on my desktop) the avatar dropped through the ground as the client (my laptop) was updating the foreign character's position.  I think that for now I am just going to completely disable gravity and I will just make sure that my level is completely flat.

I have a theory of what is going on:

Because of the behavior that I am seeing I think that when the system slows down and the physics engine gets the CPU again, it tries to make up for lost time by applying the gravity to any and all objects that have gravity enabled.  During this time something is going wrong with the collision checking, either the object is being moved too much so the collision checking does not catch it, or something to that effect is happening.

Marvin, please let me know what you think.

EDIT:
By the way, I also noticed that the same things happens if I try inserting the avatar at the y location that it is supposed to be when creating and loading the Xith environment.  I am basically using the BSPLoaderTest and I had to add to the y coordinate so that the avatar would not fall through the floor.
« Last Edit: 23. April 2008, 11:08:43 pm by AotFSteven » Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #7 on: 24. April 2008, 12:27:19 am »

I will try to check that next week. Unfortunately I don't have time for this this week.

Marvin
Logged
AotFSteven
developers
Enjoying the stay
***
Offline Offline

Posts: 63


View Profile
« Reply #8 on: 24. April 2008, 12:33:14 am »

No problem.  Thanks, I appreciate it Marvin.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic