81 bool movedDuringThisStep =
false;
83 if (s->updateNeededAfterSetPosition)
85 movedDuringThisStep =
true;
86 *calculatedPosition = s->positionLastFrame;
87 s->updateNeededAfterSetPosition =
false;
92 movedDuringThisStep =
true;
93 VuoReal timeSinceLastFrame = time - s->timeLastFrame;
94 if (timeSinceLastFrame != 0)
96 double timeSinceTargetChanged =
MIN(time - s->timeWhenTargetChanged, s->duration);
97 double curviness = s->duration/(3.*timeSinceLastFrame);
98 VuoGenericType1 p1 = VuoGenericType1_add(s->positionWhenTargetChanged, VuoGenericType1_multiply(s->velocityWhenTargetChanged, timeSinceLastFrame*curviness));
99 *calculatedPosition = VuoGenericType1_bezier3(s->positionWhenTargetChanged, p1, s->target, s->target, timeSinceTargetChanged/s->duration);
101 s->velocity = VuoGenericType1_multiply(VuoGenericType1_subtract(*calculatedPosition, s->positionLastFrame), 1./timeSinceLastFrame);
102 s->positionLastFrame = *calculatedPosition;
104 if (time - s->timeWhenTargetChanged > s->duration)
107 s->velocity = VuoGenericType1_makeFromJson(NULL);
112 s->timeLastFrame = time;
114 return movedDuringThisStep;