Code Monkey home page Code Monkey logo

Comments (16)

StellaSmith avatar StellaSmith commented on May 13, 2024 1

I would've guessed that std::array had a constexpr equality operator by C++17 but seems i guessed wrong.
Removing constexpr in edyn::matrix3x3::operator== should be the easiest fix, but std::array<T>::operator[] is constexpr so you can compare all the rows manually.

from edyn.

StellaSmith avatar StellaSmith commented on May 13, 2024 1

Another thing: edyn::matrix3x3::column(_dot) shouldn't be constexpr since they use edyn::vector3::operator[].

Overnight on my part, my bad.

from edyn.

RallyTronics avatar RallyTronics commented on May 13, 2024 1

Closing this as the exception I am getting is separate from the original issue.

from edyn.

xissburg avatar xissburg commented on May 13, 2024

That looks like a more fundamental problem which is likely not related to the shared_components tuple. More information is needed. Are you linking the library (static or dynamic?) against your own application?

from edyn.

RallyTronics avatar RallyTronics commented on May 13, 2024

I am linking statically against my own application ( 64 bit )

entt::registry reg;

int main(void)
{
    edyn::init();
    edyn::attach(reg);

    auto def = edyn::rigidbody_def();
    def.kind = edyn::rigidbody_kind::rb_dynamic;
    def.position = { 0, 3, 0 };
    def.orientation = edyn::quaternion_axis_angle({ 0, 1, 0 }, edyn::to_radians(30));
    def.linvel = edyn::vector3_zero;
    def.angvel = { 0, 0.314, 0 };
    def.mass = 50;
    def.shape = edyn::box_shape{ 0.5, 0.2, 0.4 }; // Shape is optional.
    def.update_inertia();
    def.material->restitution = 0.2; // Material is also optional.
    def.material->friction = 0.9;
    def.gravity = edyn::gravity_earth;
    auto entity = edyn::make_rigidbody(reg, def);

    while (1)
    {
        edyn::update(reg);

        auto rigid_bodies = reg.view<edyn::present_position, edyn::present_orientation>();

        for (auto rb : rigid_bodies)
        {
            auto& pp = rigid_bodies.get<edyn::present_position>(rb);
            auto& po = rigid_bodies.get<edyn::present_orientation>(rb);

            std::cout << "pos: (" << pp.x << ',' << pp.y << ',' << pp.z << ")  ori: " << edyn::quaternion_angle(po) << "\n";
        }
    }
    return 0;
}

from edyn.

xissburg avatar xissburg commented on May 13, 2024

It looks alright. I can't give any additional advice without more information.

from edyn.

RallyTronics avatar RallyTronics commented on May 13, 2024

It appears that shared_components is getting initialized multiple times, it crashes on the second initialization. I am still trying to figure out why.

from edyn.

xissburg avatar xissburg commented on May 13, 2024

Hmm interesting... shared_components is declared as static const in a header. That might be a problem... I will have to investigate.

from edyn.

xissburg avatar xissburg commented on May 13, 2024

I have pushed some changes to master. Let me know if that fixes it.

from edyn.

RallyTronics avatar RallyTronics commented on May 13, 2024

I have a ton of errors trying to build master regarding the matrix3x3 class

edyn/math/matrix3x3.hpp(25,23): error C3615: constexpr function 'edyn::matrix3x3::column' cannot result in a constant expression
edyn/math/matrix3x3.hpp(26,25): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(26,25): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(26,36): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(26,36): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(26,47): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(26,47): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(29,22): error C3615: constexpr function 'edyn::matrix3x3::column_dot' cannot result in a constant expression
edyn/math/matrix3x3.hpp(30,24): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(30,24): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(30,42): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(30,42): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(30,60): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(30,60): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(101,16): error C3615: constexpr function 'edyn::operator ==' cannot result in a constant expression
edyn/math/matrix3x3.hpp(102,18): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(102,18): message : see usage of 'std::operator =='
edyn/math/matrix3x3.hpp(106,16): error C3615: constexpr function 'edyn::operator !=' cannot result in a constant expression
edyn/math/matrix3x3.hpp(107,18): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(107,18): message : see usage of 'std::operator !='
edyn/math/matrix3x3.hpp(149,21): error C3615: constexpr function 'edyn::inverse_matrix_symmetric' cannot result in a constant expression
edyn/math/matrix3x3.hpp(150,5): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(150,5): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(150,5): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(150,5): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(151,5): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(151,5): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(151,5): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(151,5): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(152,5): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(152,5): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(152,5): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(152,5): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(158,22): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(158,22): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(158,37): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(158,37): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(158,52): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(158,52): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(159,22): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(159,22): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(159,37): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(159,37): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(160,22): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(160,22): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(164,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(164,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(165,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(165,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(166,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(166,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(168,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(168,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(168,29): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(168,29): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(169,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(169,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(170,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(170,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(172,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(172,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(172,29): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(172,29): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(173,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(173,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(173,29): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(173,29): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(174,15): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(174,15): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(188,19): error C3615: constexpr function 'edyn::get_diagonal' cannot result in a constant expression
edyn/math/matrix3x3.hpp(189,19): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(189,19): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(189,28): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(189,28): message : see usage of 'edyn::vector3::operator []'
edyn/math/matrix3x3.hpp(189,37): message : failure was caused by call of undefined function or one not declared 'constexpr'
edyn/math/matrix3x3.hpp(189,37): message : see usage of 'edyn::vector3::operator []'


from edyn.

RallyTronics avatar RallyTronics commented on May 13, 2024

If declare the vector3 array operators as constexpr

    constexpr scalar& operator[](size_t i) noexcept {
        EDYN_ASSERT(i < 3);
        return (&x)[i];
    }

    constexpr scalar operator[](size_t i) const noexcept {
        EDYN_ASSERT(i < 3);
        return (&x)[i];
    }

I get it down to 2 errors:

math/matrix3x3.hpp(101,16): error C3615: constexpr function 'edyn::operator ==' cannot result in a constant expression
math/matrix3x3.hpp(102,18): message : failure was caused by call of undefined function or one not declared 'constexpr'
math/matrix3x3.hpp(102,18): message : see usage of 'std::operator =='
math/matrix3x3.hpp(106,16): error C3615: constexpr function 'edyn::operator !=' cannot result in a constant expression
math/matrix3x3.hpp(107,18): message : failure was caused by call of undefined function or one not declared 'constexpr'
math/matrix3x3.hpp(107,18): message : see usage of 'std::operator !='

from edyn.

xissburg avatar xissburg commented on May 13, 2024

@StellaSmith do you think this is caused by the std::array equality operator? As it is not constexpr before C++20 https://en.cppreference.com/w/cpp/container/array/operator_cmp and it is used in theedyn::matrix3x3 equality operator. It could be replaced by an individual comparison between row vectors.

from edyn.

xissburg avatar xissburg commented on May 13, 2024

@RallyTronics let me know if the latest commit changes anything.

from edyn.

RallyTronics avatar RallyTronics commented on May 13, 2024

The vector3 array operator [] is still not constexpr so I still get a ton of errors. If I declare those as constexpr it builds correctly. I no longer get the stack-based buffer overrun error. It now crashes in make_rigidbody() here:

    if (def.presentation && def.kind == rigidbody_kind::rb_dynamic) {
        registry.emplace<present_position>(entity, def.position);
        registry.emplace<present_orientation>(entity, def.orientation);
    }

I get an exception on the
registry.emplace<present_position>(entity, def.position);
line. I am still digging.

from edyn.

RallyTronics avatar RallyTronics commented on May 13, 2024
Exception occurs here in delegate.hpp
    /**
     * @brief Triggers a delegate.
     *
     * The delegate invokes the underlying function and returns the result.
     *
     * @warning
     * Attempting to trigger an invalid delegate results in undefined
     * behavior.
     *
     * @param args Arguments to use to invoke the underlying function.
     * @return The value returned by the underlying function.
     */
    Ret operator()(Args... args) const {
        ENTT_ASSERT(static_cast<bool>(*this), "Uninitialized delegate");
        return fn(data, std::forward<Args>(args)...);
    }

from edyn.

RallyTronics avatar RallyTronics commented on May 13, 2024

I get the same exception when running the hello_world example.

from edyn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.