-
I understand the errors this potentially introduces depending on the next update of the simulation, but is there a way to adjust the dimensions of a shape after it's been created? For example, modifying the radius of a sphere, or the length/width/height of a box. As far as use case, I'm specifically thinking of a game where you can change characters. Those characters potentially have different dimensions (one may be taller than the other, or fatter than the other, etc.). Can this be done without destroying the shape and creating a new one? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
My wild guess is that you can use BodyInterface::SetShape(): https://jrouwe.github.io/JoltPhysics/class_body_interface.html#a051a4064706509e2b1c4dcc6d688676d So you basically have to create a modified Shape first and then completely overwrite it using SetShape, suspecting that allowing changing body shape dimensions in runtime would affect the optimizations/performance. But also note according to https://jrouwe.github.io/JoltPhysics/index.html#creating-shapes:
|
Beta Was this translation helpful? Give feedback.
-
To change a shape, you have to create a new one and then call BodyInterface::SetShape. Adjusting a shape would not be thread safe (collision queries could be accessing the shape from a different thread) and is therefore not supported. Note that there is ShapeSettings::ClearCachedResult if you want to create a new shape from the same settings object (although with a simple sphere you can also directly construct it). |
Beta Was this translation helpful? Give feedback.
To change a shape, you have to create a new one and then call BodyInterface::SetShape. Adjusting a shape would not be thread safe (collision queries could be accessing the shape from a different thread) and is therefore not supported. Note that there is ShapeSettings::ClearCachedResult if you want to create a new shape from the same settings object (although with a simple sphere you can also directly construct it).