Skip to content

Fixed surface animations in OpenGL #4286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nubDotDev
Copy link

Overview: What does this pull request change?

Previously, there was an error whenever animating a Surface object with OpenGL. Now there is no longer!

Motivation and Explanation: Why and how do your changes improve the library?

The bug occurred because the stroke and fill data of a Surface was not passed to the super class. This caused the conversion to an OpenGL object to create an entry in the data dictionary whose datatype is a float instead of the expected array.

Here is a scene to recreate the bug when rendered with --renderer=opengl:

class Test3D(ThreeDScene):
    def construct(self):
        s = Sphere(resolution=(8, 8))
        self.add(s)
        self.play(s.animate.move_to(UP))

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@henrikmidtiby
Copy link
Contributor

I have tried to run the example code that triggered the issue and can confirm that it prevented the scene from rendering.
By placing a few checks on when certain values are floats I was able to navigate around the problem

# Line 2383 in manim/mobject/opengl/opengl_mobject.py
if isinstance(arr1, float):
    arr1 = [[arr1]]
if isinstance(arr2, float):
    arr2 = [[arr2]]

I think that the PR solve the problem in a much cleaner way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

2 participants