Skip to content

Conversation

@chopan050
Copy link
Contributor

@chopan050 chopan050 commented Feb 9, 2026

Currently, when importing Mobjects, there are three different situations:

  • Some files import OpenGLMobject and use it directly.
  • Some files import OpenGLMobject as Mobject: they use Mobject instead, but it points to OpenGLMobject behind the scenes.
  • Some files still import the classic, non-OpenGL Mobject.

Something similar happens with VMobjects and other classes. In particular, using the classic VMobject instead of OpenGLVMobject is causing multiple tests to fail with RecursionError because 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 importing OpenGLMobject because it reduces the amount of changes around the code.

Now all the RecursionErrors related to colors are gone. There are still some few RecursionErrors which are for different reasons.

In the future, when we get rid of the classic Mobject, rename OpenGLMobject as simply Mobject, and have to revert the imports, doing so should be simple:

  • search for all occurrences of from manim.mobject.opengl.opengl_mobject import OpenGLMobject as Mobject with from manim.mobject.mobject import Mobject. Do the same with Group and Point.
  • search for all occurrences of from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject as VMobject with from manim.mobject.types.vectorized_mobject import VMobject. Do the same with VGroup, VDict and VectorizedPoint.
  • let Ruff autocorrect the imports

Some other changes done by this PR:

  • conditionals like isinstance(mob_or_point, (Mobject, OpenGLMobject)) are simplified to isinstance(mob_or_point, Mobject)
  • implemented the animation override from Mobject into OpenGLVMobject in order to keep the example_scenes/test_new_rendering.py::Test scene working (edit: I had to comment some code in __init_subclass__() temporarily)
  • created OpenGLVDict because CoordinateSystem and its subclasses needed a VDict
  • removed almost all metaclass=ConvertToOpenGL uses, except for the ones in mobject.py and vectorized_mobject.py (those files are untouched)
  • deleted test_opengl_metaclass.py

@chopan050 chopan050 changed the title [Experimental] Use 'OpenGLMobject as Mobject' and similar imports everywhere [Experimental] Use OpenGLMobject as Mobject and similar imports everywhere Feb 9, 2026
@chopan050 chopan050 marked this pull request as draft February 9, 2026 00:23
@chopan050 chopan050 marked this pull request as ready for review February 9, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants