Cast custom user define type to Varian in C++?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vannongtinh

I’m trying to use C++ with Godot and face a problem.


struct CharacterInterpolatedData
{
    static const CharacterInterpolatedData IDENTITY;
    CharacterInterpolatedData();
    CharacterInterpolatedData(Vector3 p_position, Quat p_orientation);
    CharacterInterpolatedData(const CharacterInterpolatedData &p_other);

    CharacterInterpolatedData linear_interpolate(const CharacterInterpolatedData &p_to, float p_percent);
    bool operator==(const CharacterInterpolatedData &p_other);
    bool operator!=(const CharacterInterpolatedData &p_other);

    Vector3 Position;
    Quat Orientation;
};

 rset("m_interpolatedData", m_interpolatedData);

it complained that no suitable convention from CharacterInterpolatedData to Variant. How can I achieve what I want? I means cast CharacterInterpolatedData to Variant.

:bust_in_silhouette: Reply From: sash-rc

You can’t. Except maybe to dump your whole struct to buffer like PoolXXXArray, or simply pass your Vector3 and Quat separately.

But can you tell what a practical usage of packing it to Variant are you implying?
Otherwise it sounds like XY-problem..