-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Movement] Rubberbanding movement and Interpolation #94
Comments
Oh, nice find, so it seems that entities rotation is borked :) |
Looking at this, if I change the number of bits passed to AngleQuantized() here to
Even with this change, the server is not updating the client for rotations of other character models. That is, spinning in a circle doesn't affect your model on another players screen. |
What you can experiment with is forcing the rotation values to the ones we get from client: void World::physicsStep(Entity *e,uint32_t msec)
{
if(glm::length2(e->inp_state.pos_delta)) {
// todo: take into account time between updates
glm::mat3 za = static_cast<glm::mat3>(e->inp_state.direction); // quat to mat4x4 conversion
/// add the line below
e->qrot = e->inp_state.direction;
/// add the line above
e->pos += ((za*e->inp_state.pos_delta)*float(msec))/50.0f;
}
} |
If that does something interesting, but still wrong You might consider sending the same values the client sends to us by replacing the: e->qrot = e->inp_state.direction; with e->qrot.x = e->inp_state.camera_pyr.x;
e->qrot.y = e->inp_state.camera_pyr.y;
e->qrot.z = e->inp_state.camera_pyr.z; |
This is getting close, but we need to discard x,z, as we really only care about he horizontal plane (otherwise the entity will tilt up or down as you look around) First to correct the spawn direction, I changed
I added the following to EntitiesResponse instead of World::physicsStep, as it updates immediately upon spawning, and continues to update as you move. The effect is not perfect, rotation only works 180deg, and rotates the opposite direction. I'm sure this is because I'm misunderstanding the math in qrot.
Any ideas on why it's rotating in reverse? Why it'll only work 180deg? Also, I tried to play with |
Ok, the fact that you had to rotate by 15 degrees tells me something wonky is going on, maybe the client expects a PYR angles, so we'll have to convert quaternion to euler angles. static void toEulerAngle(const glm::quat& q, float& roll, float& pitch, float& yaw)
{
// roll (x-axis rotation)
float sinr = +2.0 * (q.w * q.x + q.y * q.z);
float cosr = +1.0 - 2.0 * (q.x * q.x + q.y * q.y);
roll = atan2(sinr, cosr);
// pitch (y-axis rotation)
float sinp = +2.0 * (q.w * q.y - q.z * q.x);
if (fabs(sinp) >= 1)
pitch = copysign(M_PI / 2, sinp); // use 90 degrees if out of range
else
pitch = asin(sinp);
// yaw (z-axis rotation)
float siny = +2.0 * (q.w * q.z + q.x * q.y);
float cosy = +1.0 - 2.0 * (q.y * q.y + q.z * q.z);
yaw = atan2(siny, cosy);
} On my side I can look over the client and check the logic on that side. |
Ok, looking over the client side, i'm pretty sure it's using PYR during transmission, so converting from quaternion to PYR is a must :/ |
Let me try |
Please try the latest commit, it might have fixed this, if it did, feel free to close this issue :) |
Also, You have my heartfelt thanks for investigating and working on this |
Of course. I'll let you know my results. |
Yup, we have to do some float twiddling to fix this: void World::physicsStep(Entity *e,uint32_t msec)
{
if(glm::length2(e->inp_state.pos_delta)) {
// todo: take into account time between updates
glm::mat3 za = static_cast<glm::mat3>(e->inp_state.direction); // quat to mat4x4 conversion
glm::vec3 pyr;
toEulerAngle(e->inp_state.direction, pyr);
pyr.y = 0;
pyr.z = 0;
toQuat(pyr,e->qrot);
e->pos += ((za*e->inp_state.pos_delta)*float(msec))/50.0f;
}
} I'm starting to think we should store all rotations in PYR format, and convert to quaternions/transform matrices only as needed :/ |
This would make sense, as most mobs and players will default to an upright position. In fact, if we're not doing any real rotational math on entities, then I don't see any reason to use quats. PYR is going to be more intuitive. I'm assuming that flying and jumping animations would not be affected. |
Tried this, but had no effect?
Obviously copying the |
Working on this from another angle (bad pun, sorry). I'm getting an error with this line that I don't understand.
I don't understand. I think
|
inp_state.direction is a quaternion not a pitch-yaw-roll triple , it's converted from the pyr here:
|
Oh weird. Then wouldn't When trying that before it only worked 180deg, and the rotation was reverse direction from input. Is it possible that inp_state.direction is storing the Quat in the wrong order? |
It might be in wrong order, since there are waaay to many ways of converting Euler angles to quaternions :) |
Yeah, looks like we could just call glm::eularAngles() instead of using our own solution. |
Continued testing on this. Adding to SetOrientation in EntityUpdateCodec.cpp
Results of rotating in place in the output below, which reveals that our
This would actually make sense since you begin facing south (presumably 0,0,0 orientation), but performing a translation on that does not produce desired results.
Results in the following, and produces the undesired effect of rotating the entity in all kinds of weird directions.
All of this makes me wonder though, if the client is already handling all of this logic on it's end to show you what your character is doing when you move (which works as expected), then why doesn't it pass this info back directly to the server? Is it possible that the client is already telling the server "I'm turning this way" and we can simply store those packets and pass them back to other clients? Isn't this how ParagonChat works over XMPP? How can I see what the client sends the server when I'm pressing |
I'll take a closer look at this after I return home ( should be 2 days since the date of this post, I'm at code::dive conference right now ) |
Fun! Enjoy your trip! |
Leaving myself a note:
|
Am I understanding this correctly? Does the client send the server a packet saying simply "this is the direction I'm facing"? The reason I ask this is because if SetOrientation derives it's value from pyr_camera. So panning the camera around your character without rotating your model would result in your model rotating on other clients. |
note: i'm at work atm, can look into orientation stuff closer on the weekend As for panning: yup, and that's the use-case for first-person third-person camera switching ( in first person camera orientation should influence entity orientation, not so much in 3rd person ) |
No problem at all. I know you're busy and traveling. Thank you so much for helping me understand this. |
Changed branch to https://github.com/broxen/Segs/tree/interp-v2 As you can see progress is limited. Velocity and PosUpdates need to be properly calculated. |
Updated branch address: https://github.com/broxen/Segs/tree/movement |
Moving to v7 as this needs a lot more work and some testing. |
Per our discord conversation |
When I move forward with mouseview facing downward, the other client sees me move downward into the ground. With mouseview facing upward, the other client sees me moving upward. The more extreme the angle of mouseview relative to the horizontal plane, the move vertical movement is produced. |
Both clients did a /stuck and the one moved toward Flint. The server is not computing jump properly, it only thinks you are going up and not down. The server thinks you are always flying, even if you clip into something. After an afk, found blue floating where brown sees him, |
Ahhh my old pal Movement... Closing this out, as SEGS Engine will correct these issues. |
This issue began with work on orientation, which was not being updated correctly. The scope has since expanded to include all movement
This will need
physicsStep(...)
)storeUnknownBinTree(...)
)Bonus
Useful testing commands (require Access Level 9)
/controldebug 1
- outputs to client console and shows markers in the world with position deltas/entdebugclient 1
- displays GUI window that shows active data, and displays reticle on entity/moveto {x} {y} {z}
- moves entity to position/postest
- Outputs server values for position. Only available on my broxen/segs/interp-v2 branch/interp
- Runs an interpolation test. Only available on my broxen/segs/interp-v2 branchSEGS version
78c7fd5 and later
Tracking
Progress taking place in https://github.com/broxen/Segs/tree/movement
The text was updated successfully, but these errors were encountered: