fenix-hub / godot-engine.easy-charts

A Godot Engine addon for plotting general purpose charts. A collection of Control, 2D and 3D Nodes to plot every chart possible.
MIT License
647 stars 48 forks source link

[BUG] Samples are retained in `Function` objects, despite `max_samples` being set. #83

Closed addmix closed 1 year ago

addmix commented 1 year ago

Samples omitted by ChartProperties.max_samples are not freed from memory.

image

Values should also be removed from the Function objects as well.

fenix-hub commented 1 year ago

Although freeing the arrays would make memory more stable, removing values from the x and y arrays in the Chart script will make you lose all your first n values inside the Function object you are plotting. x and y values are passed from the Function object to the Chart and FunctionPlotter classes by reference, as well as when you provide your x and y arrays to the Function object without cloning. So removing at any step a value from those array would make you lose them in your own data in your own arrays. Since I don't want to interfere with user's data, if you care more about performances than losing your runtime data I would suggest instead to achieve the same goal by calling the Function.remove_point(0) method before/after adding a new point. The goal of "sampling" is to not display older values in the plot, although they are still in your data. You could always remove them manually from your own Functions. Does it make sense to you?

addmix commented 1 year ago

Makes sense.