Not great, but adding an alternate implementation of make_smooth in as a comment just because it's unclear what's best right now

This commit is contained in:
Grant Sanderson 2020-07-22 18:18:29 -07:00
parent 93f7671732
commit 5ee4b94ec3

View file

@ -10,6 +10,7 @@ from manimlib.mobject.mobject import Mobject
from manimlib.mobject.mobject import Point from manimlib.mobject.mobject import Point
from manimlib.utils.bezier import bezier from manimlib.utils.bezier import bezier
from manimlib.utils.bezier import get_smooth_quadratic_bezier_handle_points from manimlib.utils.bezier import get_smooth_quadratic_bezier_handle_points
from manimlib.utils.bezier import get_smooth_cubic_bezier_handle_points
from manimlib.utils.bezier import get_quadratic_approximation_of_cubic from manimlib.utils.bezier import get_quadratic_approximation_of_cubic
from manimlib.utils.bezier import interpolate from manimlib.utils.bezier import interpolate
from manimlib.utils.bezier import set_array_by_interpolation from manimlib.utils.bezier import set_array_by_interpolation
@ -27,7 +28,7 @@ from manimlib.utils.space_ops import earclip_triangulation
from manimlib.utils.space_ops import get_norm from manimlib.utils.space_ops import get_norm
from manimlib.utils.space_ops import get_unit_normal from manimlib.utils.space_ops import get_unit_normal
from manimlib.utils.space_ops import z_to_vector from manimlib.utils.space_ops import z_to_vector
from manimlib.utils.shaders import ShaderWrapper from manimlib.shader_wrapper import ShaderWrapper
class VMobject(Mobject): class VMobject(Mobject):
@ -521,6 +522,8 @@ class VMobject(Mobject):
new_subpath = np.array(subpath) new_subpath = np.array(subpath)
if mode == "smooth": if mode == "smooth":
new_subpath[1::nppc] = get_smooth_quadratic_bezier_handle_points(anchors) new_subpath[1::nppc] = get_smooth_quadratic_bezier_handle_points(anchors)
# h1, h2 = get_smooth_cubic_bezier_handle_points(anchors)
# new_subpath = get_quadratic_approximation_of_cubic(anchors[:-1], h1, h2, anchors[1:])
elif mode == "jagged": elif mode == "jagged":
new_subpath[1::nppc] = 0.5 * (anchors[:-1] + anchors[1:]) new_subpath[1::nppc] = 0.5 * (anchors[:-1] + anchors[1:])
submob.append_points(new_subpath) submob.append_points(new_subpath)
@ -1059,7 +1062,7 @@ class VMobject(Mobject):
data["point"] = points data["point"] = points
data["unit_normal"] = unit_normal data["unit_normal"] = unit_normal
data["color"] = rgbas data["color"] = rgbas
data["vert_index"][:, 0] = self.saved_triangulation[:n_points] data["vert_index"][:, 0] = range(n_points)
return data return data
def get_fill_shader_vert_indices(self): def get_fill_shader_vert_indices(self):