| 362 | } |
| 363 | |
| 364 | void NetInterpComp_SetLocation(struct NetInterpComp* interp, struct LocationUpdate* update, struct Entity* e) { |
| 365 | struct NetInterpAngles last = interp->CurAngles; |
| 366 | struct NetInterpAngles* cur = &interp->CurAngles; |
| 367 | struct NetInterpAngles mid; |
| 368 | cc_uint8 flags = update->flags; |
| 369 | cc_bool interpolate = flags & LU_ORI_INTERPOLATE; |
| 370 | |
| 371 | if (flags & LU_HAS_POS) { |
| 372 | NetInterpComp_SetPosition(interp, update, e, flags & LU_POS_MODEMASK); |
| 373 | } |
| 374 | if (flags & LU_HAS_ROTX) cur->RotX = Math_ClampAngle(update->rotX); |
| 375 | if (flags & LU_HAS_ROTZ) cur->RotZ = Math_ClampAngle(update->rotZ); |
| 376 | if (flags & LU_HAS_PITCH) cur->Pitch = Math_ClampAngle(update->pitch); |
| 377 | if (flags & LU_HAS_YAW) cur->Yaw = Math_ClampAngle(update->yaw); |
| 378 | |
| 379 | if (!interpolate) { |
| 380 | NetInterpAngles_Copy(e->prev, cur); e->prev.rotY = cur->Yaw; |
| 381 | NetInterpAngles_Copy(e->next, cur); e->next.rotY = cur->Yaw; |
| 382 | interp->RotYCount = 0; interp->AnglesCount = 0; |
| 383 | } else { |
| 384 | /* Smoother interpolation by also adding midpoint */ |
| 385 | mid.RotX = Math_LerpAngle(last.RotX, cur->RotX, 0.5f); |
| 386 | mid.RotZ = Math_LerpAngle(last.RotZ, cur->RotZ, 0.5f); |
| 387 | mid.Pitch = Math_LerpAngle(last.Pitch, cur->Pitch, 0.5f); |
| 388 | mid.Yaw = Math_LerpAngle(last.Yaw, cur->Yaw, 0.5f); |
| 389 | NetInterpComp_AddAngles(interp, mid); |
| 390 | NetInterpComp_AddAngles(interp, *cur); |
| 391 | |
| 392 | /* Body rotation lags behind head a tiny bit */ |
| 393 | InterpComp_AddRotY((struct InterpComp*)interp, Math_LerpAngle(last.Yaw, cur->Yaw, 0.33333333f)); |
| 394 | InterpComp_AddRotY((struct InterpComp*)interp, Math_LerpAngle(last.Yaw, cur->Yaw, 0.66666667f)); |
| 395 | InterpComp_AddRotY((struct InterpComp*)interp, Math_LerpAngle(last.Yaw, cur->Yaw, 1.00000000f)); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | void NetInterpComp_AdvanceState(struct NetInterpComp* interp, struct Entity* e) { |
| 400 | e->prev = e->next; |
no test coverage detected