[Experimental] Make bounding_box=None if it can't be calculated and raise error on derived values such as get_center()#4555
Draft
chopan050 wants to merge 5 commits intoManimCommunity:experimentalfrom
Conversation
…aise error on derived values such as get_center()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the
bounding_boxof an emptyOpenGLMobject(a Mobject with no points and whose family also has no points) simply defaults to a 3x3 array of zeroes. This causes interesting side effects:get_center(),get_corner(),get_edge()... all returnORIGINget_coord(),get_x(),get_y(),get_z()... all return0is_point_touching()returnsTrueif the given point is close enough toORIGINandFalseif it's not, even though the point is in neither case really touching anything because the Mobject has no physical presencemob.move_to(OpenGLVMobject())movesmobtoORIGINTransform(mob, OpenGLVMobject()), while it expectedly shrinksmobuntil it disappears, also moves it toORIGINin the processOpenGLMobjectusually gets treated in the same way as anOpenGLMobjectconsisting of one or multiple points atORIGIN, even though they're conceptually different and are, in other places, handled differently. Hypothetically, if we were to usePMobjectand also work with bounding boxes, they would exhibit the same behavior.This PR changes that. Now, an empty
OpenGLMobjecthas abounding_boxofNone, making it more different from anOpenGLMobjectwith points atORIGIN. This allows handling the side effects in the following way:get_center(),get_corner(),get_edge()... raise aRuntimeErrorbecause calculating a point makes no sense in these casesget_coord(),get_x(),get_y(),get_z()... also raise aRuntimeErroris_point_touching()always returnsFalsemob.move_to(OpenGLVMobject())does nothingTransform(mob, OpenGLVMobject())only shrinksmobuntil it disappears