MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / LocalInterpComp_SetLocation

Function LocalInterpComp_SetLocation

src/EntityComponents.c:445–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445void LocalInterpComp_SetLocation(struct InterpComp* interp, struct LocationUpdate* update, struct Entity* e) {
446 struct EntityLocation* prev = &e->prev;
447 struct EntityLocation* next = &e->next;
448 cc_uint8 flags = update->flags;
449 cc_bool interpolate = flags & LU_ORI_INTERPOLATE;
450
451 if (flags & LU_HAS_POS) {
452 LocalInterpComp_SetPosition(e, update, flags & LU_POS_MODEMASK);
453 }
454 if (flags & LU_HAS_PITCH) {
455 LocalInterpComp_Angle(&prev->pitch, &next->pitch, update->pitch, interpolate);
456 }
457 if (flags & LU_HAS_ROTX) {
458 LocalInterpComp_Angle(&prev->rotX, &next->rotX, update->rotX, interpolate);
459 }
460 if (flags & LU_HAS_ROTZ) {
461 LocalInterpComp_Angle(&prev->rotZ, &next->rotZ, update->rotZ, interpolate);
462 }
463 if (flags & LU_HAS_YAW) {
464 LocalInterpComp_Angle(&prev->yaw, &next->yaw, update->yaw, interpolate);
465
466 if (!interpolate) {
467 next->rotY = next->yaw;
468 interp->RotYCount = 0;
469 } else {
470 /* Body Y rotation lags slightly behind */
471 InterpComp_AddRotY(interp, Math_LerpAngle(prev->yaw, next->yaw, 0.33333333f));
472 InterpComp_AddRotY(interp, Math_LerpAngle(prev->yaw, next->yaw, 0.66666667f));
473 InterpComp_AddRotY(interp, Math_LerpAngle(prev->yaw, next->yaw, 1.00000000f));
474
475 e->next.rotY = interp->RotYStates[0];
476 }
477 }
478 Entity_LerpAngles(e, 0.0f);
479}
480
481void LocalInterpComp_AdvanceState(struct InterpComp* interp, struct Entity* e) {
482 e->prev = e->next;

Callers 1

LocalPlayer_SetLocationFunction · 0.85

Calls 5

LocalInterpComp_AngleFunction · 0.85
InterpComp_AddRotYFunction · 0.85
Math_LerpAngleFunction · 0.85
Entity_LerpAnglesFunction · 0.85

Tested by

no test coverage detected