[Experimental] Use OpenGLMobject as Mobject and similar imports everywhere
#4578
+941
−439
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when importing
Mobjects, there are three different situations:OpenGLMobjectand use it directly.OpenGLMobject as Mobject: they useMobjectinstead, but it points toOpenGLMobjectbehind the scenes.Mobject.Something similar happens with
VMobjects and other classes. In particular, using the classicVMobjectinstead ofOpenGLVMobjectis causing multiple tests to fail withRecursionErrorbecause of an infinite recursion bug when setting colors.This PR changes this situation by always importing
OpenGLMobject as Mobject. In my opinion, this is a better approach compared to simply importingOpenGLMobjectbecause it reduces the amount of changes around the code.Now all the
RecursionErrors related to colors are gone. There are still some fewRecursionErrors which are for different reasons.In the future, when we get rid of the classic
Mobject, renameOpenGLMobjectas simplyMobject, and have to revert the imports, doing so should be simple:from manim.mobject.opengl.opengl_mobject import OpenGLMobject as Mobjectwithfrom manim.mobject.mobject import Mobject. Do the same withGroupandPoint.from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject as VMobjectwithfrom manim.mobject.types.vectorized_mobject import VMobject. Do the same withVGroup,VDictandVectorizedPoint.Some other changes done by this PR:
isinstance(mob_or_point, (Mobject, OpenGLMobject))are simplified toisinstance(mob_or_point, Mobject)implemented the animation override from(edit: I had to comment some code inMobjectintoOpenGLVMobjectin order to keep theexample_scenes/test_new_rendering.py::Testscene working__init_subclass__()temporarily)OpenGLVDictbecauseCoordinateSystemand its subclasses needed aVDictmetaclass=ConvertToOpenGLuses, except for the ones inmobject.pyandvectorized_mobject.py(those files are untouched)test_opengl_metaclass.py