Re:Annotated code: Circles bouncing off lines
by qznc on Monday February 09, 2015 @07:34AM
(#9020835)
I do not understand. Since this is executed in a loop, for the circle it looks like ...-penetration-integration-penetration-integration-penetration-integration-... in either version. Why does it matter between which steps the circle is rendered?
[ Parent
| on HN ]
Re:Annotated code: Circles bouncing off lines
by sago on Monday February 09, 2015 @07:45AM
(#9020869)
(Edit: I can be clearer, using your approach - more verbose explanation trimmed)
In the linked version we are doing
... move, draw, de-overlap, move, draw, de-overlap ...
So the move might cause an overlap, which we'd draw on screen. Having objects routinely interpenetrating a little (by a frame's worth) can appear springy, as if they aren't made of rigid material.
Better would be
... move, de-overlap, draw, move, de-overlap, draw ...
Re:Annotated code: Circles bouncing off lines
by nightcracker on Monday February 09, 2015 @08:37AM
(#9021049)
In the original version it's possible that a penetrating object gets drawn, in the modified version penetrating objects are always resolved before the drawing happens.