neurogears / vestibular-vr

Closed-loop VR setup for Rancz Lab
2 stars 0 forks source link

Properly calculate wrapped index values from motion inputs #90

Closed RoboDoig closed 4 weeks ago

RoboDoig commented 4 weeks ago

This PR fixes issue #89

It was observed previously that sometimes an out of error index would be encountered when looking up a texture frame for motion clouds. This was because the WrapValue operator was not implemented correctly and when the input was equal to the negative of the number of texture frames, the calculated wrapped value would be out of bounds.

This PR updates the WrapValue operator to perform index wrapping properly.

One realisation here was that the % operator in C# does not behave as a modulus (as in Python) but instead does the remainder operation. A modulus function is also implemented in the WrapValue operator with the same behaviour as the Python % operator.