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
Make Camera
an Actor
and improve performance
#67
Open
quephird
wants to merge
14
commits into
main
Choose a base branch
from
experimental_make_camera_an_actor
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
…p. Also removed all async calls in World.
…ecilalizatons of that method to avoid using a switch and casting. Also now passing IDs instead of entire shapes, all to avoid copying and adding performance overhead.
…hild shape IDs to their parents. Consequently, parentId is no longer a nullable property of Shape.
… to speed up lookups, and we promoted the top level intersect function to be part of the Shape protocol to improve performance further.
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.
There are quite a few endeavors in this pull request but the main thrust is to designate
Camera
as an actor instead ofWorld
, and to takeCamera
out ofWorld
as a property and instead make it a top-level object in the scene. Moreover, therender()
method has been moved out ofWorld
and intoCamera
, and is now passed an instance of the former into for rendering, as well as being responsible for tracking the progress of a render . Additionally,rayForPixel()
has been moved fromWorld
toCamera
since it made more sense forCamera
to be generating rays and sending them into aWorld
Other related changes:
ScintillaApp
andScintillaView
now have acamera
propertyWorldBuilder
no longer needs to worry about being passed aCamera
to any of its methods.World
is no longer an actor so none of its methods need to be designated asasync
, and callers no longer need toawait
calling them, including those in tests suites.rayForPixel()
have been moved toCameraTests.swift
IntesectionTests.swift
andWorldTests.swift
no longer have to constuctCamera
s and so many of those tests were updated.The following changes were made to improve performance:
CSG
s now maintain a cache of IDs of right children, rather than relying on the oldfindShape()
to navigate down the tree for each ray and intersection. Additionally,Shape
,CSG
, andGroup
have a new methodgetAllChildIDs()
which is called during the initialization of the enclosingWorld
to populate the cache in eachCSG
instance.Shape
,CSG
andGroup
all expose a new method,populateParentCache()
, that is also only ever called during the initialization process so that the top level instance ofWorld
maintains a new cache of parent objects. The cache replaces the need for a sharedparentID
property inSharedShapeProperties
and its proxy property method inShape
.World.objectToWorld()
andWorld.worldToObject
has been greatly simplified because it no longer needs to navigate the scene tree upward and instance can consult the cache , viaWorld.parent(of:)
.intersect()
method has been renamed to_intersect()
and declared as part of the protocol forShape
. The name begins with an underscore to discourage anyone from overriding it, as there is already a default implementation, but it is part of the protocol now so that copies of the implemenation can be localized with anyShape
type.