ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
25.85k stars 1.78k forks source link

Items added to VDict don't respect z-index #901

Open wurmfood opened 3 years ago

wurmfood commented 3 years ago

Description of bug / unexpected behavior

Create a VDict. Add item to VDict with no z-index Add item2 to VDict with z-index=-1 Item2 is rendered on top of item.

Expected behavior

Items should respect the z-index. I think this may be related to the other issue I just submitted (#900) where items are added on their own.

How to reproduce the issue

Code for reproducing the problem ```py class DictTest(Scene): def construct(self): my_dict = VDict() d = Dot().scale(3) my_dict.add([("dot", d)]) self.play(ShowCreation(my_dict)) L = Line(start=UP+LEFT, end=RIGHT+DOWN).set_z_index(-1).set_color(BLUE) self.wait() my_dict.add([("line", L)]) self.wait() ```

Additional media files

Images/GIFs ![DictTest](https://user-images.githubusercontent.com/319384/103468507-756eab00-4d0e-11eb-87e3-6c1c58a5f69f.png)

Logs

Terminal output ``` ~/Documents/manim  manim library/myclasses.py DictTest -ql -s -v DEBUG   master ●  .manimenv [01/02/21 15:24:40] DEBUG Hashing ... hashing.py:239 DEBUG Hashing done in 0.008970 s. hashing.py:254 DEBUG Hash generated : 3070002022_1141029821_2772380660 hashing.py:258 DEBUG List of the first few animation hashes of the scene: caching.py:48 ['3070002022_1141029821_2772380660'] DEBUG Hashing ... hashing.py:239 DEBUG Hashing done in 0.005218 s. hashing.py:254 DEBUG Hash generated : 628362505_2959719147_2880318718 hashing.py:258 DEBUG List of the first few animation hashes of the scene: caching.py:48 ['3070002022_1141029821_2772380660', '628362505_2959719147_2880318718'] DEBUG Hashing ... hashing.py:239 DEBUG Hashing done in 0.004248 s. hashing.py:254 DEBUG Hash generated : 628362505_2959719147_3713024570 hashing.py:258 DEBUG List of the first few animation hashes of the scene: caching.py:48 ['3070002022_1141029821_2772380660', '628362505_2959719147_2880318718', '628362505_2959719147_3713024570'] INFO scene_file_writer.py:562 File ready at /home/wurmfood/Documents/manim/media/images/myclasses/DictTest.png INFO Rendered DictTest scene.py:95 Played 3 animations ```

System specifications

System Details - OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)): - RAM: - Python version (`python/py/python3 --version`): - Installed modules (provide output from `pip list`): ``` ~/Documents/manim  uname -a   master ●  .manimenv Linux minibaka 5.8.0-7630-generic #32~1609174078~20.04~4b8d17c-Ubuntu SMP Tue Dec 29 20:38:40 UTC x86_64 x86_64 x86_64 GNU/Linux ~/Documents/manim  free -h   master ●  .manimenv total used free shared buff/cache available Mem: 15Gi 3.3Gi 2.0Gi 669Mi 10Gi 11Gi Swap: 4.0Gi 0B 4.0Gi ~/Documents/manim  python -V   master ●  .manimenv Python 3.8.5 ~/Documents/manim  pip list   master ●  .manimenv Package Version ----------------- ---------- appdirs 1.4.4 attrs 20.3.0 black 20.8b1 cairocffi 1.2.0 cffi 1.14.4 click 7.1.2 colorama 0.4.4 colour 0.1.5 commonmark 0.9.1 iniconfig 1.1.1 manimce 0.1.1 mypy-extensions 0.4.3 numpy 1.19.4 packaging 20.8 pangocairocffi 0.4.0 pangocffi 0.8.0 pathspec 0.8.1 Pillow 8.0.1 pip 20.3.3 pkg-resources 0.0.0 pluggy 0.13.1 progressbar 2.5 py 1.10.0 pycairo 1.20.0 pycparser 2.20 pydocstyle 5.1.1 pydub 0.24.1 Pygments 2.7.3 pyparsing 2.4.7 pytest 6.2.1 regex 2020.11.13 rich 6.2.0 scipy 1.6.0 setuptools 44.0.0 snowballstemmer 2.0.0 toml 0.10.2 tqdm 4.55.0 typed-ast 1.4.2 typing-extensions 3.7.4.3 ```
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): + Installed LaTeX packages: texlive-full
FFMPEG Output of `ffmpeg -version`: ``` ~/Documents/manim  ffmpeg -version   master ●  .manimenv ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 ```

Additional comments

leotrs commented 3 years ago

Thanks for reporting. We plan to remove the z-index and just use the z-coordinate of mobjects to determine on-screen order, so unless that has changed in the past few weeks, I'd say this is a wontfix. cc @behackl @eulertour

wurmfood commented 3 years ago

Sorry for the delay in getting back to you on this. I haven't had a chance to look at this in a while.

When I try to use the z-coordinate to change the behavior, it doesn't seem to work. Am I doing something wrong? I just changed the set_z_index to set_z, which seems like it should work.

class DictTest(Scene):
    def construct(self):
        my_dict = VDict()
        d = Dot().scale(2)
        my_dict.add([("dot", d)])
        self.play(ShowCreation(my_dict))
        L = Line(start=UP + LEFT, end=RIGHT + DOWN).set_z(-1).set_color(BLUE)
        self.wait()
        my_dict.add([("line", L)])
        self.wait()
leotrs commented 3 years ago

You are not doing anything wrong. I wasn't clear enough. Using the z-coordinate to specify the rendering order in 2D scenes is what we want to have, but is not currently implemented :sweat_smile: