Skip to content
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

Raycast performance #70

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open

Raycast performance #70

wants to merge 22 commits into from

Conversation

andrewdolce
Copy link
Member

General optimization of raycast-related code.

Adds a ray-performance.js test based on performance.js, which adds 4 raycasts for each rigidbody
and also steps the simulation 10 times per frame.

Removes allocations from:

  • CollisionWorld.js
  • VoronoiSimplexSolver.js
  • Vector3.js
  • SphereShape.js
  • DbvtBroadphase.js
  • SubsimplexConvexCast.js
  • Dbvt.js

andrewdolce and others added 22 commits August 15, 2012 15:43
Allocations are replaced with get and del functions to recycle objects
from memory pools. In some cases, "set" functions were added to a few
object types so that they can be easily reinitialized without causing
unwanted allocation.
Transform inverseTimes() was being called without a destination.
Removed allocations in closestPtPointTetrahedron and
pointOutsideOfPlane. Also removed a pointless conditional
from closestPtPointTetrahedron.
Recycle Vector3 and array objects. The `stack` array is handled as
a special case with its own memory pool. This is because the stack
array needs to be resized and could end up being large. By
recycling it and only resizing when we need the length to increase,
we can make it so that the resize only happens a finite number of
times, until there exist arrays of sufficient length for all
future ray tests.
add LocalAddrInfo2.set to set values of objects acquired from mempool.
add delArray to Dbvt.rayCast
remove tmpV4 and tmpV5. Bounds isn't edited in RayAabb2 so we don't
need them.
Change object to be of the form

    { "value": 0 }

instead of

    { "tmin": 0 }

to be consistent with other uses of scalar references in the port.
List of allocations removed:

  - array in rayTestInternal
  - scalar reference in rayTestInternal
  - scalar reference in rayTest
  - scalar reference in maxdepth
The `signs` property was incorrectly initialized as a Vector3,
but is now correctly initialized as an Array. Also removed
unnecessary array-like access to Vector3 variables.
The `set` function is used in place of `clone` when re-initializing a
recycled SphereShape. It is similar to `init` but unrolls all the calls
to _super into a single function and removes any unnecessary or
redundant statements. Currently used in `CollisionWorld.rayTestSingle`.
The unit test had not been updated to reflect the newly corrected type
for the `signs` property.
Made separate ray-performance test, and restored performance.js
to match with the general performance test from the develop branch.
Changed the ray-performance `stats.begin()` and `stats.end()`
calls to match with the updated ones from develop.
@andrewdolce andrewdolce reopened this Aug 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants