Skip to content

ERROR: Collider copied but shape is nullptr! Jolt Physics #1504

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

You must be logged in to vote

I have noticed that mShapePtr in JPH::BoxShapeSettings settings in PhysicsEngine::addBody is set but not mShape but I don't know why...

mShapePtr contains the Shape object as it will be used by the engine
mShape contains a ShapeSettings object that is used to create the Shape

you can provide either to the BodyCreationSettings constructor and it will make sure that by the time the body is added an actual Shape is created.

This should not compile because Shape is a pure virtual class:

JPH::Shape* dummyShape = new JPH::Shape();

If you pass a pointer to a Ref then lifetime is managed by it and you should not call delete:

delete dummyShape;

Replies: 1 comment 2 replies

Comment options

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

@jrouwe
Comment options

Answer selected by Sekaus
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