Problems if you change scale the level. Chipmunk physic

Hi everyone.

Making a 2D platformer game using cocos2d-x v3.17.2 (chipmunk) physics.
Encountered a problem related to changes in the level size.

When the scale of the visual world changes, the scale of the physical world does not change.
When the scale of the game level decreases, the characters keep their correct positions, but they move quickly around the map.
If the level scale increases, the characters slow down.

The velocity of the physical body for the character does not change, and the speed of movement the image in pixels increases.

For example, in Box2d, I did not have such a problem with scaling the game level.
In addition, in Box2d, you can set coordinates for images based on the coordinates of physical bodies.

spriteBody->setPosition(Vec2(b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO));
float rotatePos = -(CC_RADIANS_TO_DEGREES(b->GetAngle()));

Also, when changing the position or scale, there is a problem with raycast

I solve it by sending coordinates in the physical world, taking into account the shift and scale. And that’s fine with me.

But when scaling the level, the only thing I was able to do was scale all the heroes velocity and gravity of the physical world.
This is not the right approach at all, and I would like to find the right solution to this problem. Can you suggest a solution to my problem?

I’m not sure that this is the most correct solution, but it helped me partially solve the problem.
I made changes to the file CCPhysicsBody.cpp

I added a new function, getAfterSimulationWorldPos(Vec2 simulationPos):

// функция возвращает мировые координаты для позиции после симуляции физики
Vec2 PhysicsBody::getAfterSimulationWorldPos(Vec2 simulationPos)
Vec2 delta = simulationPos - _owner->getPosition();
float scaleX = _owner->getScaleX() != 0 ? _recordScaleX / _owner->getScaleX() : _recordScaleX;
float scaleY = _owner->getScaleY() != 0 ? _recordScaleY / _owner->getScaleY() : _recordScaleY;
delta.x *= scaleX;
delta.y *= scaleY;
return _owner->getPosition() + delta;

and made a change to the function, afterSimulation(const Mat4& parentToWorldTransform, float parentRotation), line 922:

  _owner->setPosition(getAfterSimulationWorldPos(Vec2(positionInParent.x - _offset.x, positionInParent.y - _offset.y))); //_owner->setPosition(positionInParent.x - _offset.x, positionInParent.y - _offset.y);

In addition, I have to solve the problem of reducing the momentum of collision of bodies when changing the scale.

If anyone has a better solution, please let me know.