mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7495 from boyu0/physics_flip_bug
Fix the bug: flip scale for physics body make it's size incorrect.
This commit is contained in:
commit
1f4b516f66
|
@ -453,7 +453,7 @@ void PhysicsShapeCircle::update(float delta)
|
|||
|
||||
if (_dirty)
|
||||
{
|
||||
cpFloat factor = PhysicsHelper::float2cpfloat( _newScaleX / _scaleX );
|
||||
cpFloat factor = std::abs(PhysicsHelper::float2cpfloat( _newScaleX / _scaleX ));
|
||||
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
cpVect v = cpCircleShapeGetOffset(shape);
|
||||
|
@ -710,6 +710,17 @@ void PhysicsShapePolygon::update(float delta)
|
|||
vects[i].y *= factorY;
|
||||
}
|
||||
|
||||
// convert hole to clockwise
|
||||
if ( factorX * factorY < 0 )
|
||||
{
|
||||
for (int i = 0; i < count / 2; ++i)
|
||||
{
|
||||
cpVect v = vects[i];
|
||||
vects[i] = vects[count - i - 1];
|
||||
vects[count - i - 1] = v;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
cpVect n = cpvnormalize(cpvperp(cpvsub(vects[i], vects[(i + 1) % count])));
|
||||
|
|
Loading…
Reference in New Issue