Skip to content

Rescaling the shape/body at runtime using WASM/javascript #1154

Answered by jrouwe
MAG-AdrianMeredith asked this question in Q&A
Discussion options

You must be logged in to vote

Javascript does have the capability to cast the shape to a scaled shape.

I'm assuming you meant to say 'doesn't have the capability'. Use Jolt.castObject(shape, Jolt.ScaledShape) to cast it.

But I'm not sure about destroying the ScaledShape? it crashes if I try and remove the previous one? whats the option here so that I'm not leaking memory?

As described here, shapes are reference counted. When you assign a shape to a body it gets a ref count of 1. If you then assign another shape to the same body, the first shape is released, its ref count reaches 0 and the shape gets deleted.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jrouwe
Comment options

Answer selected by MAG-AdrianMeredith
@MAG-AdrianMeredith
Comment options

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