Skip to content

Conversation

@GuiCT
Copy link
Contributor

@GuiCT GuiCT commented Nov 17, 2025

Overview: What does this pull request change?

Change argument passing to the triangulate_float32 method, using an explicitly-created NumPy Array (with dtype=uint32).

meta_indices = earcut(verts[indices, :2], [len(indices)])

becomes

meta_indices = earcut(verts[indices, :2], np.array([len(indices)], dtype=np.uint32))

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

I was having problems trying to use the OpenGL Renderer. I investigated and a simple line fix corrected the behavior.

MWE:

from manim import *
from manim.opengl import *

class IntroScene(Scene):
    def construct(self):
        square = Square(color=RED).shift(LEFT * 2)
        circle = Circle(color=BLUE).shift(RIGHT * 2)

        self.play(Write(square), Write(circle))

        # moving objects
        self.play(
            square.animate.shift(UP * 0.5),
            circle.animate.shift(DOWN * 0.5)
        )

        # rotating and filling the square (opacity 80%)
        # scaling and filling the circle (opacity 80%)
        self.play(
            square.animate.rotate(PI / 2).set_fill(RED, 0.8),
            circle.animate.scale(2).set_fill(BLUE, 0.8),
        )

        # this is new!
        self.interactive_embed()

This yields:

TypeError: triangulate_float32(): incompatible function arguments. The following argument types are supported:
    1. triangulate_float32(arg0: ndarray[dtype=float32, shape=(*, 2), device='cpu'], arg1: ndarray[dtype=uint32, shape=(*), device='cpu'], /) ->
numpy.ndarray[dtype=uint32, shape=(*)]

Invoked with types: ndarray, list

When using mapbox-earcut=2.0.0 and manim=0.19.0

Links to added or changed documentation pages

Further Information and Comments

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

If a numpy array is not created, the following exception is raised:
```TypeError: triangulate_float32(): incompatible function arguments. The following argument types are supported:
    1. triangulate_float32(arg0: ndarray[dtype=float32, shape=(*, 2), device='cpu'], arg1: ndarray[dtype=uint32, shape=(*), device='cpu'], /) ->
numpy.ndarray[dtype=uint32, shape=(*)]

Invoked with types: ndarray, list```
Copy link
Contributor

@chopan050 chopan050 left a comment

Choose a reason for hiding this comment

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

The reason you're encountering this error is because you're using version 2.0.0 of mapbox_earcut which requires that the arguments are NumPy arrays. Manim requires mapbox_earcut>=1.0.0, so most people use version 1.X.X which doesn't have the requirement above, which is why I haven't seen anybody else reporting this problem.

Nevertheless, it's nice to have this change, so thanks!

@github-project-automation github-project-automation bot moved this from 🆕 New to 👍 To be merged in Dev Board Nov 20, 2025
@chopan050 chopan050 changed the title Simple fix to pass arguments to mapbox_earcut.triangulate_float32 method Pass ndarrays to mapbox_earcut.triangulate_float32() to fix TypeError in mapbox_earcut==2.0.0 Nov 20, 2025
@chopan050 chopan050 enabled auto-merge (squash) November 20, 2025 01:48
@chopan050 chopan050 merged commit 51377b5 into ManimCommunity:main Nov 20, 2025
22 checks passed
@github-project-automation github-project-automation bot moved this from 👍 To be merged to ✅ Done in Dev Board Nov 20, 2025
@GuiCT
Copy link
Contributor Author

GuiCT commented Nov 20, 2025

Yeah, i imagined that would be the case

Maybe a brainfart on my own by doing something wrong with uv xd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants