oomek / attractplus

Attract-Mode Plus
GNU General Public License v3.0
49 stars 16 forks source link

Artwork creation during tick fails if index_offset zero #58

Open Chadnaut opened 9 months ago

Chadnaut commented 9 months ago

Appears to be a bug since other offsets work (also occurs in AM vanilla)

local a, b, c;

function on_tick(tick_time) {
    if (!a) {
        a = fe.add_artwork("snap", 110, 0, 100, 100);
        a.index_offset = 0; // zero doesn't work?
    }
    if (!b) {
        b = fe.add_artwork("snap", 220, 0, 100, 100);
        b.rawset_index_offset(-1); // rawset to a different offset...
        b.index_offset = 0; // ...then set zero, works
    }
    if (!c) {
        c = fe.add_artwork("snap", 330, 0, 100, 100);
        c.index_offset = 1; // non-zero always works
    }
}

fe.add_artwork("snap", 0, 0, 100, 100);
fe.add_ticks_callback("on_tick");
oomek commented 9 months ago

There are many reasons why drawables should not be added in tick, but I believe you know what you are doing and there is no way to achieve what you need when drawables are added in transitions or in the main layout body. I've checked the code and AM+ behaviour is consistent with AM 2.7.0, same bug. It is even worse with Vid.ImagesOnly flag. a,b,c don't show up at all until you navigate. To be honest it's not what I would jump onto and investigate immediately, but will keep this issue open until I finish the new transition model.

Chadnaut commented 9 months ago

I have a create/animate/update pipeline that runs on tick (no leaks). video_flags does work, but only if it's set before index_offset. The rawset workaround does the job, so this quirk is not a show-stopper.

oomek commented 1 month ago

Easy fix by commenting https://github.com/oomek/attractplus/blob/6b2fec55e7b8b4cc15af6d036ea211093e15043b/src/fe_image.cpp#L672 But if the index_offset is set on each tick it will be a performance hog. Still trying to figure out a solution for this.