You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -245,11 +246,34 @@ public void SampleIfChanged(double time)
245
246
varvalue=plan.Sample(tr);
246
247
if(value==null||(valueisObjecto&&!o))
247
248
return;
248
-
if(!value.Equals(lastSample))
249
-
{
250
-
samples[time]=value;
251
-
lastSample=value;
249
+
// As a memory optimization we want to be able to skip identical samples.
250
+
// But, we cannot always skip samples when they are identical to the previous one - otherwise cases like this break:
251
+
// - First assume an object is invisible at first (by having a scale of (0,0,0))
252
+
// - At some point in time, it is instantaneously set "visible" by updating its scale from (0,0,0) to (1,1,1)
253
+
// If we simply skip identical samples on insert, instead of a instantaneous
254
+
// visibility/scale changes we get a linearly interpolated scale change because only two samples will be recorded:
255
+
// - one (0,0,0) at the start of time
256
+
// - (1,1,1) at the time of the visibility change
257
+
// What we want to get is
258
+
// - one sample with (0,0,0) at the start,
259
+
// - one with the same value right before the instantaneous change,
260
+
// - and then at the time of the change, we need a sample with (1,1,1)
261
+
// With this setup, now the linear interpolation only has an effect in the very short duration between the last two samples and we get the animation we want.
262
+
263
+
// How do we achieve both?
264
+
// Always sample & record and then on adding the next sample(s) we check
265
+
// if the *last two* samples were identical to the current sample.
266
+
// If that is the case we can remove/overwrite the middle sample with the new value.
0 commit comments