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

Function NetInterpComp_SetPosition

src/EntityComponents.c:325–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325static void NetInterpComp_SetPosition(struct NetInterpComp* interp, struct LocationUpdate* update, struct Entity* e, int mode) {
326 Vec3 lastPos = interp->CurPos;
327 Vec3* curPos = &interp->CurPos;
328 Vec3 midPos;
329
330 if (mode == LU_POS_ABSOLUTE_INSTANT || mode == LU_POS_ABSOLUTE_SMOOTH) {
331 *curPos = update->pos;
332 } else {
333 Vec3_AddBy(curPos, &update->pos);
334 }
335
336 if (mode == LU_POS_ABSOLUTE_INSTANT) {
337 e->prev.pos = *curPos;
338 e->next.pos = *curPos;
339 interp->PositionsCount = 0;
340 } else {
341 /* Smoother interpolation by also adding midpoint */
342 Vec3_Lerp(&midPos, &lastPos, curPos, 0.5f);
343 NetInterpComp_AddPosition(interp, midPos);
344 NetInterpComp_AddPosition(interp, *curPos);
345 }
346}
347
348static void NetInterpComp_RemoveOldestAngles(struct NetInterpComp* interp) {
349 int i;

Callers 1

Calls 2

Vec3_LerpFunction · 0.85

Tested by

no test coverage detected