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

Assert crash in GJK code #24

Closed
ColinGilbert opened this issue Sep 2, 2015 · 5 comments
Closed

Assert crash in GJK code #24

ColinGilbert opened this issue Sep 2, 2015 · 5 comments
Assignees
Labels

Comments

@ColinGilbert
Copy link
Contributor

EDIT: Forgot to add: This is on the master branch. Currently testing develop
EDIT 2: Fails on develop as well. I am also raycasting every frame. Code that does raycasting on comment below.

There is a crash that occurs once in a while, usually after about a minute. I isolated it to the GJK code. Body's shape is a capsule.

Here is gdb output:

/home/noob/noobgame/engine/lib/reactphysics3d/src/collision/narrowphase/GJK/Simplex.cpp:48: void reactphysics3d::Simplex::addPoint(const reactphysics3d::Vector3&, const reactphysics3d::Vector3&, const reactphysics3d::Vector3&): Assertion `!isFull()' failed.

Here is a backtrace:

#0  0x00007ffff3a89a17 in raise () from /lib64/libc.so.6
#1  0x00007ffff3a8adaa in abort () from /lib64/libc.so.6
#2  0x00007ffff3a8288d in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff3a82942 in __assert_fail () from /lib64/libc.so.6
#4  0x00000000007d96be in reactphysics3d::Simplex::addPoint (this=0x7fffffffd510, point=..., suppPointA=..., suppPointB=...)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/narrowphase/GJK/Simplex.cpp:48
#5  0x00000000007cca9d in reactphysics3d::GJKAlgorithm::raycast (this=0x16b81c0, ray=..., collisionShape=0x1c17bf0, raycastInfo=...)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/narrowphase/GJK/GJKAlgorithm.cpp:456
#6  0x0000000000798136 in reactphysics3d::ConvexMeshShape::raycast (this=0x1c2c6a0, ray=..., raycastInfo=..., proxyShape=0x1c17bf0)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/shapes/ConvexMeshShape.cpp:242
#7  0x000000000079d79d in reactphysics3d::ProxyShape::raycast (this=0x1c17bf0, ray=..., raycastInfo=...) at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/ProxyShape.h:261
#8  0x000000000079d58d in reactphysics3d::RaycastTest::raycastAgainstShape (this=0x7fffffffdc50, shape=0x1c17bf0, ray=...)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/RaycastInfo.cpp:38
#9  0x00000000007902fc in reactphysics3d::DynamicAABBTree::raycast (this=0x16b8170, ray=..., raycastTest=..., raycastWithCategoryMaskBits=65535)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/broadphase/DynamicAABBTree.cpp:651
#10 0x00000000006780de in raycast (raycastWithCategoryMaskBits=65535, raycastTest=..., ray=..., this=<optimized out>)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/broadphase/BroadPhaseAlgorithm.h:182
#11 raycast (raycastWithCategoryMaskBits=65535, ray=..., raycastCallback=0x7fffffffdca0, this=<optimized out>)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/CollisionDetection.h:239
#12 raycast (raycastWithCategoryMaskBits=65535, raycastCallback=0x7fffffffdca0, ray=..., this=<optimized out>)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/engine/CollisionWorld.h:195
#13 noob::character_controller::update (this=0x1b379a0) at /home/noob/noobgame/engine/common/CharacterController.cpp:26
#14 0x00000000006936fc in noob::actor::update (this=<optimized out>) at /home/noob/noobgame/engine/common/Actor.cpp:13
#15 0x000000000068dcbf in noob::stage::update (this=this@entry=0x16b8130, dt=dt@entry=1.1769868966740179e-316) at /home/noob/noobgame/engine/common/Stage.cpp:36
#16 0x000000000066b042 in noob::application::update (this=this@entry=0x16b8090, delta=1.1769868966740179e-316) at /home/noob/noobgame/engine/common/Application.cpp:51
#17 0x000000000066b2f2 in noob::application::step (this=0x16b8090) at /home/noob/noobgame/engine/common/Application.cpp:93
#18 0x000000000062c6a8 in main () at /home/noob/noobgame/engine/platform/nix/EngineDesktop.cpp:425

Full backtrace:

(gdb) bt full
#0  0x00007ffff3a89a17 in raise () from /lib64/libc.so.6
No symbol table info available.
#1  0x00007ffff3a8adaa in abort () from /lib64/libc.so.6
No symbol table info available.
#2  0x00007ffff3a8288d in __assert_fail_base () from /lib64/libc.so.6
No symbol table info available.
#3  0x00007ffff3a82942 in __assert_fail () from /lib64/libc.so.6
No symbol table info available.
#4  0x00000000007d96be in reactphysics3d::Simplex::addPoint (this=0x7fffffffd510, point=..., suppPointA=..., suppPointB=...)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/narrowphase/GJK/Simplex.cpp:48
        __PRETTY_FUNCTION__ = "void reactphysics3d::Simplex::addPoint(const reactphysics3d::Vector3&, const reactphysics3d::Vector3&, const reactphysics3d::Vector3&)"
#5  0x00000000007cca9d in reactphysics3d::GJKAlgorithm::raycast (this=0x16b81c0, ray=..., collisionShape=0x1c17bf0, raycastInfo=...)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/narrowphase/GJK/GJKAlgorithm.cpp:456
        epsilon = 9.99999975e-05
        v = {x = 0.0189624038, y = 0.00210423698, z = 0.0570573546}
        vDotW = -8.48199558
        vDotR = -0.792089462
        w = {x = -94.4290924, y = 0.000972747803, z = -117.274887}
        pointA = {x = -nan(0x7fdc10), y = 4.59163468e-41, z = 1.14531991e-38}
        suppA = {x = 5.57090759, y = 3.00097275, z = -17.274889}
        localToWorldTransform = {mPosition = {x = 0, y = -20, z = 0}, mOrientation = {x = 0, y = 0, z = 0, w = 1}}
        worldToLocalTransform = {mPosition = {x = 0, y = 20, z = 0}, mOrientation = {x = -0, y = -0, z = -0, w = 1}}
        rayDirection = {x = 0, y = -1, z = 0}
        lambda = 0.791116774
        pointB = {x = 5.57090235, y = 2.99999976, z = -17.4416027}
        suppB = {x = 100, y = 3, z = 100}
        machineEpsilonSquare = 1.42108547e-14
        point1 = {x = 5.57090759, y = 3.79208946, z = -17.274889}
        n = {x = -1.27999999e-06, y = 0.792089462, z = -7.67999973e-06}
        point2 = {x = 5.57090759, y = 2.79208946, z = -17.274889}
        simplex = {mPoints = {{x = -94.4290924, y = 0.792089462, z = -117.274887}, {x = -94.4290924, y = 0.000972747803, z = 82.7251129}, {x = 105.570908, y = 0.000972747803, 
              z = -117.274887}, {x = 105.570908, y = 0.000972747803, z = 82.7251129}}, mPointsLengthSquare = {22670.8789, 15760.2979, 24898.6172, 17988.6602}, 
          mMaxLengthSquare = 24898.6172, mSuppPointsA = {{x = 5.57090759, y = 3.79208946, z = -17.274889}, {x = 5.57090759, y = 3.00097275, z = -17.274889}, {x = 5.57090759, 
              y = 3.00097275, z = -17.274889}, {x = 5.57090759, y = 3.00097275, z = -17.274889}}, mSuppPointsB = {{x = 100, y = 3, z = 100}, {x = 100, y = 3, z = -100}, {x = -100, y = 3, 
              z = 100}, {x = -100, y = 3, z = -100}}, mDiffLength = {{{x = 0, y = 0, z = 0}, {x = 0, y = 0.791116714, z = -200}, {x = -200, y = 0.791116714, z = 0}, {x = -200, 
                y = 0.791116714, z = -200}}, {{x = -0, y = -0.791116714, z = 200}, {x = 0, y = 0, z = 0}, {x = -200, y = 0, z = 200}, {x = -200, y = -0, z = -0}}, {{x = 200, 
                y = -0.791116714, z = -0}, {x = 200, y = -0, z = -200}, {x = 0, y = 0, z = 0}, {x = -0, y = -0, z = -200}}, {{x = 200, y = -0.791116714, z = 200}, {x = 200, y = 0, z = 0}, {
                x = 0, y = 0, z = 200}, {x = 0, y = 0, z = 0}}}, mDet = {{0.920738995, -0.185574993, 0, -0.0274467953}, {1, 0.977887094, 0, 5.57090759}, {-16.2079124, 1, 1, 
              1.11207046e-41}, {16545.0234, 23455.6035, 4.59163468e-41, 4.3260505e-38}, {0, 6.59177075e-38, 1, 0.938853025}, {21114.1816, 0.0964297354, 18886.4453, 0.34322238}, {
              0.920738995, 44569.1562, 35430.8438, -0.0274467953}, {-93631744, 938227008, 755454976, 4.20389539e-45}, {-16.2079124, 4.20389539e-44, 0, 1}, {37659.2031, 4.20389539e-45, 0, 
              42341.4219}, {0, 21114.1816, 0, 18885.8184}, {661800960, 182779584, 0, 755444608}, {1.54142831e-43, 0, 16545.0234, 23454.9766}, {844567296, 1.66754517e-43, -182755904, 
              938213760}, {-16.2079124, 844567296, 661800960, 93631872}, {1441792, 530579456, 415236096, 60817408}}, mNormSquare = {{-16.2079124, 40000.625, 40000.625, 80000.625}, {
              40000.625, 0.979474306, 80000, 40000}, {40000.625, 80000, 0, 40000}, {80000.625, 40000, 40000, -6.42588997}}, mBitsCurrentSimplex = 15, mLastFound = 2, mLastFoundBit = 4, 
          mAllBits = 15}
        distSquare = 0.00361954235
        nbIterations = 6
#6  0x0000000000798136 in reactphysics3d::ConvexMeshShape::raycast (this=0x1c2c6a0, ray=..., raycastInfo=..., proxyShape=0x1c17bf0)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/shapes/ConvexMeshShape.cpp:242
No locals.
#7  0x000000000079d79d in reactphysics3d::ProxyShape::raycast (this=0x1c17bf0, ray=..., raycastInfo=...) at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/ProxyShape.h:261
No locals.
#8  0x000000000079d58d in reactphysics3d::RaycastTest::raycastAgainstShape (this=0x7fffffffdc50, shape=0x1c17bf0, ray=...)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/RaycastInfo.cpp:38
        raycastInfo = {worldPoint = {x = 0, y = 0, z = 0}, worldNormal = {x = 0, y = 0, z = 0}, hitFraction = 1.11178263e-38, body = 0x0, proxyShape = 0x0}
        isHit = 193
#9  0x00000000007902fc in reactphysics3d::DynamicAABBTree::raycast (this=0x16b8170, ray=..., raycastTest=..., raycastWithCategoryMaskBits=65535)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/broadphase/DynamicAABBTree.cpp:651
---Type <return> to continue, or q <return> to quit---
        rayTemp = {point1 = {x = 5.57090759, y = -16.2079105, z = -17.274889}, point2 = {x = 5.57090759, y = -17.2079105, z = -17.274889}, maxFraction = 1}
        hitFraction = 0
        nodeID = 3
        node = 0x16b5fe8
        maxFraction = 1
        endPoint = {x = 5.57090759, y = -17.2079105, z = -17.274889}
        rayAABB = {mMinCoordinates = {x = 5.57090759, y = -17.2079105, z = -17.274889}, mMaxCoordinates = {x = 5.57090759, y = -16.2079105, z = -17.274889}}
        stack = {mInitArray = {2, 3, -9392, 32767, 7950348, 0, 1064327341, 0, 7950348, 0, 0, 0, -9632, 32767, 7952463, 1036352754, 1044252509, 1064982223, -9472, -1048169206, -1049223086, 
            1086280000, -9384, 32767, -9632, 32767, 8151244, 0, -9632, 32767, -9392, 32767, -9408, 32767, -9584, 32767, -9264, 32767, 7951267, 0, 1062417542, 1056930776, -9168, 32767, 
            -9200, 32767, 29440816, 0, -1098907648, -1086324736, -1098907648, 0, 1048576000, 1061158912, 1048576000, 0, -1093614087, -1085066106, -1090552872, 0, 1064982223, 1044252509, 
            1036352754, 0, 1045712093, 1064023438, 1051278449, 32767, -9200, 32767, 23813972, 0, 1053869561, 1062417542, 23813952, 16777216, -9376, 32767, 7921662, 0, -9216, 32767, -9200, 
            32767, 1021368346, 0, 23822704, 0, 1084569728, -1048034447, -1047645976, 0, 1086280000, -1049223086, 2090833408, 602201166, 16095056, 0, 29440816, 0, -9312, 32767, 7914006, 0, 
            -9216, 32767, -9200, 32767, 29457216, 0, 23822704, 0, 1021368346, -1103231139, -9200, 32767, -9264, 32767, 7936033, 0, -9216, 32767, -9200, 32767, 29457216, 0, -9216, 32767}, 
          mElements = 0x7fffffffd9d0, mNbElements = 1, mNbAllocatedElements = 128}
#10 0x00000000006780de in raycast (raycastWithCategoryMaskBits=65535, raycastTest=..., ray=..., this=<optimized out>)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/broadphase/BroadPhaseAlgorithm.h:182
No locals.
#11 raycast (raycastWithCategoryMaskBits=65535, ray=..., raycastCallback=0x7fffffffdca0, this=<optimized out>)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/collision/CollisionDetection.h:239
        rayCastTest = {userCallback = 0x7fffffffdca0}
#12 raycast (raycastWithCategoryMaskBits=65535, raycastCallback=0x7fffffffdca0, ray=..., this=<optimized out>)
    at /home/noob/noobgame/engine/lib/reactphysics3d/src/engine/CollisionWorld.h:195
No locals.
#13 noob::character_controller::update (this=0x1b379a0) at /home/noob/noobgame/engine/common/CharacterController.cpp:26
        from = {v = {_M_elems = {5.57090759, -16.2079105, -17.274889}}}
        to = {v = {_M_elems = {5.57090759, -17.2079105, -17.274889}}}
        ray = {point1 = {x = 5.57090759, y = -16.2079105, z = -17.274889}, point2 = {x = 5.57090759, y = -17.2079105, z = -17.274889}, maxFraction = 1}
        ground_cb = {<reactphysics3d::RaycastCallback> = {_vptr.RaycastCallback = 0xf20750 <vtable for noob::character_controller::groundcast_callback+16>}, grounded = false, from = {v = {
              _M_elems = {5.57090759, -16.2079105, -17.274889}}}, to = {v = {_M_elems = {5.57090759, -17.2079105, -17.274889}}}, slope = {v = {_M_elems = {0, 0, 0}}}}
#14 0x00000000006936fc in noob::actor::update (this=<optimized out>) at /home/noob/noobgame/engine/common/Actor.cpp:13
No locals.
#15 0x000000000068dcbf in noob::stage::update (this=this@entry=0x16b8130, dt=dt@entry=1.1769868966740179e-316) at /home/noob/noobgame/engine/common/Stage.cpp:36
        actor_it = {first = "player-character", second = std::shared_ptr (count 3, weak 0) 0x1b37880}
        __for_range = std::unordered_map with 1 elements = {["player-character"] = std::shared_ptr (count 3, weak 0) 0x1b37880}
#16 0x000000000066b042 in noob::application::update (this=this@entry=0x16b8090, delta=1.1769868966740179e-316) at /home/noob/noobgame/engine/common/Application.cpp:51
No locals.
#17 0x000000000066b2f2 in noob::application::step (this=0x16b8090) at /home/noob/noobgame/engine/common/Application.cpp:93
        timeNow = {tv_sec = 963611, tv_nsec = 828192335}
        uNowNano = <optimized out>
        delta = <optimized out>
#18 0x000000000062c6a8 in main () at /home/noob/noobgame/engine/platform/nix/EngineDesktop.cpp:425
        info = {movement = false, translation = {v = {_M_elems = {0, 0, 0}}}, rotation = {v = {_M_elems = {0, 0, 0}}}}
        window = 0x14fa300

@ColinGilbert
Copy link
Contributor Author

Raycast class header:

class noob::character_controller
{
    class groundcast_callback : public rp3d::RaycastCallback
        {
            public:
                groundcast_callback(noob::vec3 _from, noob::vec3 _to) : grounded(false), from(_from), to(_to), slope(0.0, 0.0, 0.0) {}
                virtual rp3d::decimal notifyRaycastHit(const rp3d::RaycastInfo& info);
                bool is_grounded() const { return grounded; }
                noob::vec3 get_slope() const { return slope; }

            protected:

                //float cast_distance;
                bool grounded;
                noob::vec3 from, to, slope;             
        };
};

Raycast class implementation:

rp3d::decimal noob::character_controller::groundcast_callback::notifyRaycastHit(const rp3d::RaycastInfo& info)
{
    grounded = true;
    slope = info.worldNormal;

    return 0.0;
}

@DanielChappuis DanielChappuis self-assigned this Sep 3, 2015
@DanielChappuis DanielChappuis added this to the Version 0.6.0 milestone Sep 3, 2015
@DanielChappuis DanielChappuis removed this from the Version 0.6.0 milestone Apr 18, 2016
@JordanWhittle
Copy link

Has anyone found out what exactly causes this yet?

@DanielChappuis
Copy link
Owner

I am currently working on the next version of the library that I expect to release this summer. I have refactored a lot of the collision detection code in order to make it faster and more robust. I also expect to fix this issue for this release.

@DanielChappuis
Copy link
Owner

I will try to fix this issue. However, this issue has been created about the bug happening in GJK algorithm during ray casting against a capsule shape but GJK is not used for ray casting with capsule shape. In the trace, it seams to happen during ray casting against a convex mesh instead.

Do you also observe this issue during ray casting ? Against which kind of shape?

@DanielChappuis
Copy link
Owner

This issue should now be fixed in the version v0.7.0 of ReactPhysics3D that has been released.
Thanks a lot for reporting this.

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

No branches or pull requests

3 participants