Skip to content
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

Rewriting the rendering System of Manim to a modern standard 💥 💯 #3112

Draft
wants to merge 123 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
8b345d9
Porting and drastical rewrite to reach compatibility with `3b1b/manim…
MrDiver Jan 3, 2023
31cebcc
replace manimlib import
behackl Jan 3, 2023
59ab392
removed checkpoint feature (for now)
behackl Jan 3, 2023
334f5d7
added ipython as dependency
behackl Jan 3, 2023
120db6f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2023
9f55388
fix imports: CLI works again (rendering doesn't yet)
behackl Jan 3, 2023
5ec1f25
Merge branch 'experimental' of github.com:ManimCommunity/manim into e…
behackl Jan 3, 2023
be45dca
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2023
e77e6c8
removed a bunch of config.renderer comparisons
behackl Jan 3, 2023
ed9e797
removed renderer argument from scene class call
behackl Jan 3, 2023
178778d
fix imports, again
behackl Jan 3, 2023
5569c9f
Merge branch 'experimental' of github.com:ManimCommunity/manim into e…
behackl Jan 3, 2023
3888d20
rendering a black screen works :-)
behackl Jan 3, 2023
67e1ca9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2023
6151860
tried to fix shaders added warning in camera if uniform does not exist
MrDiver Jan 4, 2023
eda8bb0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 4, 2023
d169cd5
addded relative import support for shaders and first working square (…
MrDiver Jan 4, 2023
068919e
Merge branch 'experimental' of github.com:ManimCommunity/manim into e…
MrDiver Jan 4, 2023
f90c9a2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 4, 2023
9c40838
camera.py -> cairo_camera.py; delete other cairo camera subclasses
behackl Jan 5, 2023
b411dbd
remove scenes depending on cairo camera subclasses
behackl Jan 5, 2023
5ae747e
opengl_renderer.py -> camera.py
behackl Jan 5, 2023
db7274e
fix a bunch of imports
behackl Jan 5, 2023
30dd07e
fix decorator issues in OpenGL(V)Mobject
behackl Jan 5, 2023
4231751
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 5, 2023
56e9914
Initial Renderer abstraction
jsonvillanueva Sep 3, 2023
1d4f0d9
changed Camera back to Renderer
jsonvillanueva Sep 4, 2023
520577d
Merge branch 'main' of github.com:ManimCommunity/manim into experimental
jsonvillanueva Sep 4, 2023
c2d1a40
small color fix openglvmobject
jsonvillanueva Sep 4, 2023
aa18dc4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 4, 2023
9904627
wip: copy data functions to opengl_renderer, preparing uniforms and s…
MrDiver Sep 10, 2023
76694e5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 10, 2023
5d8ea6a
Merge 3320-fix-antialiasing-opengl into experimental
MrDiver Sep 10, 2023
1e57fec
Something is rendering now but the relative manim units don't work Co…
MrDiver Sep 10, 2023
7dea044
Fixed frame_width and height usage, fix ibo to be i4
MrDiver Sep 10, 2023
d418acc
Basic Rendering Vmobject works!
MrDiver Sep 10, 2023
1a821d7
nothing rendering again
MrDiver Sep 10, 2023
9a94781
change dtype to f1 float 1 byte
MrDiver Sep 10, 2023
5a7da79
Working window rendering with events
MrDiver Sep 11, 2023
b7fe84d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 11, 2023
f73b35d
Working render to numpy array
MrDiver Sep 11, 2023
f82ec48
Merge
MrDiver Sep 11, 2023
d9dd887
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 11, 2023
388604b
Submobject rendering and further abstraction - WIP for stroke early drop
MrDiver Sep 12, 2023
603e712
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 12, 2023
389c1a1
Working Shading in 3D many many tries
MrDiver Sep 12, 2023
ab44633
Working Shading in 3D many many tries
MrDiver Sep 12, 2023
46ba43c
Almost working blending, stroke broken
MrDiver Sep 12, 2023
7a7ed42
Working Blending and Transparency in one direction
MrDiver Sep 12, 2023
115bcf9
Fixed affecting colors bug returns copy instead
MrDiver Sep 12, 2023
d8f261d
Make depth_testing default
MrDiver Sep 12, 2023
95f97b7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 12, 2023
df97462
Fix logo .set deprecated usage
MrDiver Sep 14, 2023
17f0204
Initializing Window before gl context
MrDiver Sep 14, 2023
8537fd6
Fixing svg mobject constructor
MrDiver Sep 14, 2023
7e97df4
experimental transparent stroke shadnig
MrDiver Sep 14, 2023
7f4b287
some formatting and removing unused variables
MrDiver Sep 14, 2023
bffbc22
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 14, 2023
e50b82f
add comment
MrDiver Sep 14, 2023
4fb492c
Merge branch 'experimental' of github.com:jsonvillanueva/manim into e…
MrDiver Sep 14, 2023
d98ba1c
Progress thus far on uniform block/buffer/layouts
jsonvillanueva Oct 3, 2023
feff6ba
Added YishiMichael's suggestion on missed declaration
jsonvillanueva Oct 3, 2023
985141f
Implemented a rudimentary UniformBufferObject compatible with the STD…
jsonvillanueva Oct 24, 2023
393c2a1
Small byte_offset bugfix for vec2
jsonvillanueva Oct 24, 2023
eb1ff92
Add some comments to the code, run black for formatting
jsonvillanueva Oct 25, 2023
9b98fe5
[EXPERIMENTAL] Mobject shader cleanup + Scene changes + Undo orientat…
chopan050 Nov 27, 2023
c6dfc15
Disable rendering doc examples for experimental branch (#3475)
behackl Dec 16, 2023
22844a2
Add rendering loop to experimental (#3707)
JasonGrace2282 May 2, 2024
69ddb0e
Rewrite Animation Loop (#3785)
JasonGrace2282 Jun 21, 2024
557784a
Merge branch 'main' of github.com:MrDiver/manim into experimental
MrDiver Jun 21, 2024
e550c55
Merge branch 'experimental' of github.com:ManimCommunity/manim into e…
MrDiver Jun 21, 2024
08264dc
Merge with main (#3815)
JasonGrace2282 Jun 25, 2024
5dcab4c
Bring in main's FileWriter into experimental (#3821)
JasonGrace2282 Jul 15, 2024
d6ea841
Merge branch 'main' of https://github.com/ManimCommunity/manim into e…
JasonGrace2282 Jul 15, 2024
51cf463
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2024
7a634dd
Fixes for pre-commit
JasonGrace2282 Jul 15, 2024
ce752bf
Fix window being internally None after hitting quit
JasonGrace2282 Jul 19, 2024
53f637b
Merge branch 'main' of https://github.com/ManimCommunity/manim into e…
JasonGrace2282 Jul 21, 2024
424cb27
Cleanup legacy code in experimental (#3874)
JasonGrace2282 Jul 25, 2024
d09b03b
Fix MathTex on experimental (#3871)
JasonGrace2282 Jul 31, 2024
7844c84
Implement sections for scenes (#3883)
JasonGrace2282 Aug 3, 2024
7e8c5c8
Merge branch 'main' of https://github.com/ManimCommunity/manim into e…
JasonGrace2282 Aug 3, 2024
3f431a1
Note changed families in some places, and fix colors (#3894)
JasonGrace2282 Aug 31, 2024
157ed6e
Merge branch 'main' of https://github.com/ManimCommunity/manim into e…
JasonGrace2282 Aug 31, 2024
793e853
Merge branch 'main' of https://github.com/ManimCommunity/manim into e…
JasonGrace2282 Sep 1, 2024
38fdaec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 1, 2024
9f0eafb
Little patch on memoryleaks in test scenarios. (#3928)
OliverStrait Sep 2, 2024
560ca7f
Drop support for python 3.9
JasonGrace2282 Sep 1, 2024
db26fe6
Use descriptors to bind SceneSections
JasonGrace2282 Sep 2, 2024
867ce8d
Merge branch 'main' of https://github.com/ManimCommunity/manim into e…
JasonGrace2282 Sep 8, 2024
11f1792
Better typing and doc strings
JasonGrace2282 Sep 8, 2024
f41b925
Revert changes to i18n
JasonGrace2282 Sep 8, 2024
bfaa900
Clean up the diff a little bit
JasonGrace2282 Sep 8, 2024
2304541
rename sections feature to groups
JasonGrace2282 Oct 25, 2024
d7fa8f0
Merge branch 'main' of https://github.com/ManimCommunity/manim into e…
JasonGrace2282 Oct 25, 2024
088d6be
remove debugging content
JasonGrace2282 Oct 25, 2024
7631878
Add docs for groups
JasonGrace2282 Oct 25, 2024
4e6af02
Experimental: fix 11 tests (#3979)
chopan050 Oct 30, 2024
97fedbc
Add a release method to OpenGLRenderer
JasonGrace2282 Nov 7, 2024
b830b7d
Fixed `fix_in_frame` refactored glsl files and deleted useless
MrDiver Nov 25, 2024
e18fdd2
Formatting shaders
MrDiver Nov 25, 2024
b51d3fe
Fixing another stray global variable
MrDiver Nov 25, 2024
0426552
Whops
MrDiver Nov 26, 2024
0dc1547
Fixing broken rendering when no window is present
MrDiver Nov 26, 2024
91a6bf0
Cone doesn't initialize OpenglVMobject
MrDiver Nov 26, 2024
b94eb15
Fixing test_vectorized_mobject to use OpenGLVMobject an port add func…
MrDiver Nov 26, 2024
85db7ac
Fixing test_vectorized_mobject to account for OpenGLMobject
MrDiver Nov 26, 2024
4ea40d2
Fixing AnimationGroup remover behavior
MrDiver Nov 27, 2024
2726a4d
Fix Updaters with Hacky solution
MrDiver Nov 27, 2024
23a9d40
Write to movie
JasonGrace2282 Dec 1, 2024
497deba
Merge branch 'main' of https://github.com/ManimCommunity/manim into e…
JasonGrace2282 Dec 1, 2024
89cb646
Fix circular import issue
JasonGrace2282 Dec 1, 2024
9fcf94f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2024
9360129
Fix `color` initialization in `OpenGLVMobject.__init__()` to prevent …
chopan050 Dec 13, 2024
9f72377
Improve rendering time by rewriting `STD140BufferFormat._write_padded…
chopan050 Dec 13, 2024
d984976
Simplify Manager creation
JasonGrace2282 Dec 13, 2024
f9e6090
Add missing AnimationProtocol method
JasonGrace2282 Dec 16, 2024
3911643
[Experimental] Start Migration Guide (#4060)
JasonGrace2282 Dec 16, 2024
19980e3
[EXPERIMENTAL] Remove `ThreeDScene` and rewrite `Camera` internals (#…
chopan050 Dec 17, 2024
620766e
Merge branch 'main' of https://github.com/JasonGrace2282/manim into e…
JasonGrace2282 Dec 17, 2024
7de544d
Merge branch 'main' of https://github.com/JasonGrace2282/manim into e…
JasonGrace2282 Dec 17, 2024
5be4c13
Remove missed cairo import
JasonGrace2282 Dec 17, 2024
9aef19f
Move validate_run_time to Scene and fix some tests in test_animation.py
chopan050 Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import configparser
import copy
import errno
import importlib
import inspect
import logging
import os
import re
Expand Down
3 changes: 3 additions & 0 deletions manim/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@
DEGREES: float = TAU / 360
"""The exchange rate between radians and degrees."""

RADIANS: float = 1.0
"""Just a default to select for camera."""

# Video qualities
QUALITIES: dict[str, dict[str, str | int | None]] = {
"fourk_quality": {
Expand Down
5 changes: 5 additions & 0 deletions manim/event_handler/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from manim.event_handler.event_dispatcher import EventDispatcher

# This is supposed to be a Singleton
# i.e., during runtime there should be only one object of Event Dispatcher
EVENT_DISPATCHER = EventDispatcher()
91 changes: 91 additions & 0 deletions manim/event_handler/event_dispatcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from __future__ import annotations

import numpy as np

from manim.event_handler.event_listener import EventListener
from manim.event_handler.event_type import EventType


class EventDispatcher:
def __init__(self):
self.event_listeners: dict[EventType, list[EventListener]] = {
event_type: [] for event_type in EventType
}
self.mouse_point = np.array((0.0, 0.0, 0.0))
self.mouse_drag_point = np.array((0.0, 0.0, 0.0))
self.pressed_keys: set[int] = set()
self.draggable_object_listeners: list[EventListener] = []

def add_listener(self, event_listener: EventListener):
assert isinstance(event_listener, EventListener)
self.event_listeners[event_listener.event_type].append(event_listener)
return self

def remove_listener(self, event_listener: EventListener):
assert isinstance(event_listener, EventListener)
try:
while event_listener in self.event_listeners[event_listener.event_type]:
self.event_listeners[event_listener.event_type].remove(event_listener)
except Exception:
# raise ValueError("Handler is not handling this event, so cannot remove it.")
pass
return self

def dispatch(self, event_type: EventType, **event_data):
if event_type == EventType.MouseMotionEvent:
self.mouse_point = event_data["point"]
elif event_type == EventType.MouseDragEvent:
self.mouse_drag_point = event_data["point"]
elif event_type == EventType.KeyPressEvent:
self.pressed_keys.add(event_data["symbol"]) # Modifiers?
elif event_type == EventType.KeyReleaseEvent:
self.pressed_keys.difference_update({event_data["symbol"]}) # Modifiers?
elif event_type == EventType.MousePressEvent:
self.draggable_object_listeners = [
listener
for listener in self.event_listeners[EventType.MouseDragEvent]
if listener.mobject.is_point_touching(self.mouse_point)
]
elif event_type == EventType.MouseReleaseEvent:
self.draggable_object_listeners = []

propagate_event = None

if event_type == EventType.MouseDragEvent:
for listener in self.draggable_object_listeners:
assert isinstance(listener, EventListener)
propagate_event = listener.callback(listener.mobject, event_data)
if propagate_event is not None and propagate_event is False:
return propagate_event

elif event_type.value.startswith("mouse"):
for listener in self.event_listeners[event_type]:
if listener.mobject.is_point_touching(self.mouse_point):
propagate_event = listener.callback(listener.mobject, event_data)
if propagate_event is not None and propagate_event is False:
return propagate_event

elif event_type.value.startswith("key"):
for listener in self.event_listeners[event_type]:
propagate_event = listener.callback(listener.mobject, event_data)
if propagate_event is not None and propagate_event is False:
return propagate_event

return propagate_event

def get_listeners_count(self) -> int:
return sum([len(value) for key, value in self.event_listeners.items()])

def get_mouse_point(self) -> np.ndarray:
return self.mouse_point

def get_mouse_drag_point(self) -> np.ndarray:
return self.mouse_drag_point

def is_key_pressed(self, symbol: int) -> bool:
return symbol in self.pressed_keys

__iadd__ = add_listener
__isub__ = remove_listener
__call__ = dispatch
__len__ = get_listeners_count
34 changes: 34 additions & 0 deletions manim/event_handler/event_listener.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Callable

import manim.mobject.opengl.opengl_mobject as glmob
from manim.event_handler.event_type import EventType


class EventListener:
def __init__(
self,
mobject: glmob.OpenGLMobject,
event_type: EventType,
event_callback: Callable[[glmob.OpenGLMobject, dict[str, str]], None],
):
self.mobject = mobject
self.event_type = event_type
self.callback = event_callback

def __eq__(self, o: object) -> bool:
return_val = False
if isinstance(o, EventListener):
try:
return_val = (
self.callback == o.callback
and self.mobject == o.mobject
and self.event_type == o.event_type
)
except Exception:
pass
return return_val
11 changes: 11 additions & 0 deletions manim/event_handler/event_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from enum import Enum


class EventType(Enum):
MouseMotionEvent = "mouse_motion_event"
MousePressEvent = "mouse_press_event"
MouseReleaseEvent = "mouse_release_event"
MouseDragEvent = "mouse_drag_event"
MouseScrollEvent = "mouse_scroll_event"
KeyPressEvent = "key_press_event"
KeyReleaseEvent = "key_release_event"
Loading