Merge pull request #1964 from 3b1b/video-work

Fix index buffer bug
This commit is contained in:
Grant Sanderson 2023-01-15 21:08:25 -08:00 committed by GitHub
commit afbc624ac4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View file

@ -415,7 +415,7 @@ class Camera(object):
if indices is None: if indices is None:
ibo = None ibo = None
elif single_use: elif single_use:
ibo = self.ctx.buffer(indices) ibo = self.ctx.buffer(indices.astype(np.uint32))
else: else:
# The vao.render call is strangely longer # The vao.render call is strangely longer
# when an index buffer is used, so if the # when an index buffer is used, so if the

View file

@ -238,7 +238,7 @@ class Mobject(object):
self.resize_points(0) self.resize_points(0)
def get_num_points(self) -> int: def get_num_points(self) -> int:
return len(self.data["points"]) return len(self.get_points())
def get_all_points(self) -> Vect3Array: def get_all_points(self) -> Vect3Array:
if self.submobjects: if self.submobjects:
@ -247,7 +247,7 @@ class Mobject(object):
return self.get_points() return self.get_points()
def has_points(self) -> bool: def has_points(self) -> bool:
return self.data["points"].size > 0 return len(self.get_points()) > 0
def get_bounding_box(self) -> Vect3Array: def get_bounding_box(self) -> Vect3Array:
if self.needs_new_bounding_box: if self.needs_new_bounding_box:

View file

@ -111,12 +111,12 @@ class DecimalNumber(VMobject):
num_string = num_string.replace("-", "") num_string = num_string.replace("-", "")
return num_string return num_string
def init_data(self) -> None: def init_uniforms(self) -> None:
super().init_data() super().init_uniforms()
self.data["font_size"] = np.array([self.font_size], dtype=float) self.uniforms["font_size"] = self.font_size
def get_font_size(self) -> int: def get_font_size(self) -> int:
return int(self.data["font_size"][0]) return int(self.uniforms["font_size"])
def get_formatter(self, **kwargs) -> str: def get_formatter(self, **kwargs) -> str:
""" """
@ -167,7 +167,7 @@ class DecimalNumber(VMobject):
return self return self
def _handle_scale_side_effects(self, scale_factor: float) -> None: def _handle_scale_side_effects(self, scale_factor: float) -> None:
self.data["font_size"] *= scale_factor self.uniforms["font_size"] *= scale_factor
def get_value(self) -> float | complex: def get_value(self) -> float | complex:
return self.number return self.number

View file

@ -720,7 +720,7 @@ class VMobject(Mobject):
return bezier(self.get_nth_curve_points(n)) return bezier(self.get_nth_curve_points(n))
def get_num_curves(self) -> int: def get_num_curves(self) -> int:
return len(self.data["points"]) // 2 return self.get_num_points() // 2
def quick_point_from_proportion(self, alpha: float) -> Vect3: def quick_point_from_proportion(self, alpha: float) -> Vect3:
# Assumes all curves have the same length, so is inaccurate # Assumes all curves have the same length, so is inaccurate