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

Merged
merged 2 commits into from
Jul 25, 2025

Conversation

nubDotDev
Copy link
Contributor

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.

Copy link
Member

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, this looks good to me!

@github-project-automation github-project-automation bot moved this from 🆕 New to 👍 To be merged in Dev Board Jul 25, 2025
@JasonGrace2282 JasonGrace2282 enabled auto-merge (squash) July 25, 2025 15:24
@JasonGrace2282 JasonGrace2282 merged commit b65b0f2 into ManimCommunity:main Jul 25, 2025
21 checks passed
@github-project-automation github-project-automation bot moved this from 👍 To be merged to ✅ Done in Dev Board Jul 25, 2025
@JasonGrace2282 JasonGrace2282 added the pr:bugfix Bug fix for use in PRs solving a specific issue:bug label Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:bugfix Bug fix for use in PRs solving a specific issue:bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants