From 58dc8f2f0dd9616bf9a16d1a3d4bff12a7d6ce68 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Tue, 6 Feb 2018 12:23:33 -0800 Subject: [PATCH] Going back and forth on how I want objects to be ordered in the 3d camera --- topics/three_dimensions.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/topics/three_dimensions.py b/topics/three_dimensions.py index 026ccd13..a7314d2e 100644 --- a/topics/three_dimensions.py +++ b/topics/three_dimensions.py @@ -83,22 +83,22 @@ class ThreeDCamera(CameraWithPerspective): *self.get_spherical_coords() ) def z_cmp(*vmobs): - #Compare to three dimensional mobjects based on - #how close they are to the camera - return cmp(*[ - -np.linalg.norm(vm.get_center()-camera_point) - for vm in vmobs - ]) - # three_d_status = map(should_shade_in_3d, vmobs) - # has_points = [vm.get_num_points() > 0 for vm in vmobs] - # if all(three_d_status) and all(has_points): - # cmp_vect = self.get_unit_normal_vect(vmobs[1]) - # return cmp(*[ - # np.dot(vm.get_center(), cmp_vect) - # for vm in vmobs - # ]) - # else: - # return 0 + # Compare to three dimensional mobjects based on + # how close they are to the camera + # return cmp(*[ + # -np.linalg.norm(vm.get_center()-camera_point) + # for vm in vmobs + # ]) + three_d_status = map(should_shade_in_3d, vmobs) + has_points = [vm.get_num_points() > 0 for vm in vmobs] + if all(three_d_status) and all(has_points): + cmp_vect = self.get_unit_normal_vect(vmobs[1]) + return cmp(*[ + np.dot(vm.get_center(), cmp_vect) + for vm in vmobs + ]) + else: + return 0 Camera.display_multiple_vectorized_mobjects( self, sorted(vmobjects, cmp = z_cmp) )