Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

int Slot::intersectsSegment() error fix #181

Open
namuda opened this issue Mar 19, 2018 · 1 comment
Open

int Slot::intersectsSegment() error fix #181

namuda opened this issue Mar 19, 2018 · 1 comment

Comments

@namuda
Copy link

namuda commented Mar 19, 2018

DragonBonesCPP/DragonBones/src/dragonBones/armature/Slot.cpp - line 780

if (intersectionCount > 0)
{
if (intersectionCount == 1 || intersectionCount == 2)
{
if (intersectionPointA == nullptr)
{
globalTransformMatrix.transformPoint(intersectionPointA->x, intersectionPointA->y, *intersectionPointA);
if (intersectionPointB == nullptr)
{
intersectionPointB->x = intersectionPointA->x;
intersectionPointB->y = intersectionPointA->y;
}
}
else if (intersectionPointB == nullptr)
{
globalTransformMatrix.transformPoint(intersectionPointB->x, intersectionPointB->y, *intersectionPointB);
}
}
else
{
if (intersectionPointA == nullptr)
{
globalTransformMatrix.transformPoint(intersectionPointA->x, intersectionPointA->y, *intersectionPointA);
}

        if (intersectionPointB == nullptr) 
        {
            globalTransformMatrix.transformPoint(intersectionPointB->x, intersectionPointB->y, *intersectionPointB);
        }
    }

    if (normalRadians == nullptr)
    {
        globalTransformMatrix.transformPoint(cos(normalRadians->x), sin(normalRadians->x), _helpPoint, true);
        normalRadians->x = atan2(_helpPoint.y, _helpPoint.x);

        globalTransformMatrix.transformPoint(cos(normalRadians->y), sin(normalRadians->y), _helpPoint, true);
        normalRadians->y = atan2(_helpPoint.y, _helpPoint.x);
    }

-fix code

if (intersectionCount > 0)
{
if (intersectionCount == 1 || intersectionCount == 2)
{
if (intersectionPointA != nullptr)
{
globalTransformMatrix.transformPoint(intersectionPointA->x, intersectionPointA->y, *intersectionPointA);
if (intersectionPointB != nullptr)
{
intersectionPointB->x = intersectionPointA->x;
intersectionPointB->y = intersectionPointA->y;
}
}
else if (intersectionPointB != nullptr)
{
globalTransformMatrix.transformPoint(intersectionPointB->x, intersectionPointB->y, *intersectionPointB);
}
}
else
{
if (intersectionPointA != nullptr)
{
globalTransformMatrix.transformPoint(intersectionPointA->x, intersectionPointA->y, *intersectionPointA);
}

        if (intersectionPointB != nullptr) 
        {
            globalTransformMatrix.transformPoint(intersectionPointB->x, intersectionPointB->y, *intersectionPointB);
        }
    }

    if (normalRadians != nullptr)
    {
        globalTransformMatrix.transformPoint(cos(normalRadians->x), sin(normalRadians->x), _helpPoint, true);
        normalRadians->x = atan2(_helpPoint.y, _helpPoint.x);

        globalTransformMatrix.transformPoint(cos(normalRadians->y), sin(normalRadians->y), _helpPoint, true);
        normalRadians->y = atan2(_helpPoint.y, _helpPoint.x);
    }
@akdcl
Copy link
Member

akdcl commented Mar 28, 2018

Sorry for the late reply, the bug has been fixed in the dev batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants