Skip to content

How to efficiently clear a TriangleList? #216

Answered by jrouwe
whaqzhzd asked this question in Q&A
Discussion options

You must be logged in to vote

You don't actually show where you're using triangleList, I'm assuming this is for passing to MeshShapeSettings in which case it will need to be converted to a TriangleList object.

The TriangleList object keeps a copy of the vector, so you can simply do:

const triangle = new jolt.Triangle(v1, v2, v3);
triangleList.push(triangle);
Jolt.destroy(triangle);

or even better, you can do something like:

triangleList.resize(...)
for (...)
  triangleList.at(...).mV[...] = ...

to avoid allocations altogether.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@whaqzhzd
Comment options

Answer selected by whaqzhzd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants