BezierCurve:render() generating unnecessary points

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Krunklehorn
Prole
Posts: 4
Joined: Sat May 11, 2019 3:46 am

BezierCurve:render() generating unnecessary points

Post by Krunklehorn » Sat May 11, 2019 4:22 am

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?

User avatar
Krunklehorn
Prole
Posts: 4
Joined: Sat May 11, 2019 3:46 am

Re: BezierCurve:render() generating unnecessary points

Post by Krunklehorn » Fri Jun 14, 2019 4:52 am


Post Reply

Who is online

Users browsing this forum: Google [Bot] and 5 guests