Page 1 of 1

BezierCurve:render() generating unnecessary points

Posted: Sat May 11, 2019 4:22 am
by Krunklehorn
LOVE's BezierCurve object creates unnecessary points when rendering out to a list of coordinates.

Code: Select all

curve = love.math.newBezierCurve(0, 0, 100, 0, 100, -100) -- A simple curve with only three points
...
if dirty then
	coordinates = curve:render() -- Always best to store the result and only update again when the control points change
	dirty = false
end
...
love.graphics.line(coordinates)
Here is this example rendered at a depth of 2, but this happens regardless of depth...

Image

The function uses De Casteljau's algorithm, but ends up generating extra mid points before returning the list. This is incredibly inefficient for drawing and wastes a good chunk of memory.

Was this intentional? Am I missing something?

Re: BezierCurve:render() generating unnecessary points

Posted: Fri Jun 14, 2019 4:52 am
by Krunklehorn