Closed sonoro1234 closed 4 years ago
Ciao, Victor.
I guess that when the Mat4 is destroyed on ImGuIZMO.quat module
Yes, Mat4 is destroyed after to have copied values, so if you don't "copy" its values, they are invalid.
In C++ with assignment =
there is automatic call to implicitly/explicitly-declared copy constructor: T::T(const T&)
, that already is explicitly defined in vgMath for any data type.
In this way the copy is guaranteed from right side (const &T passed parameter, also allocated temporarily on it) to left side, as long as it is alive/valid.
mat4 m = mat4_cast(q);
// is like:
mat4 m(mat_cast(q));
// so also if the value is temporary, it's correctly copied
// and mat_cast(q) return the value, not reference.
Although I just modified these copy-constructors for Mat3 and Mat4 (recently) for the GCC issue that you have signaled, it seems works without problems also in glChAoS.P... were I use vgMath inside it not only for imGuIZMO.quat, but also for attractors (perhaps not with matrices) and all 3D OpenGL transformations.
Searching about nonUDT I found this: https://github.com/mellinoe/ImGui.NET/issues/121 that not explains the problem (it's casual), but strangely it refers to imgui port (to C#)... and seems to have same garbage (invalid values) on pointers.
Anyway let me check it a little deeper
Thanks for taking a look Michele, but in the end it was my LuaJIT script problem and is now working as expected.
In C++ with assignment
=
there is automatic call to implicitly/explicitly-declared copy constructor:
This was my doubt which is now solved
´Thanks again Michele
@BrutPitt Hi Michele,
As mat4_cast is returning a user defined type non C compatible I used what I have done in cimgui https://github.com/sonoro1234/LuaJIT-ImGui/commit/9c855436eba5fa88ae34f60cfe2db3317a1b0d5b But I can check in https://github.com/sonoro1234/LuaJIT-ImGui/blob/master/examples/widgets_sample.lua that the values returned get garbage values after some time (I guess that when the Mat4 is destroyed on ImGuIZMO.quat module) But this is strange as I would expect the values are copied to my provided struct in https://github.com/sonoro1234/LuaJIT-ImGui/blob/master/extras/imGuIZMO.quat.cpp#L28 but perhaps there is no copy contructor ? (My C++ skills are low)
What do you think that should be done?
Update: the problem seems to be on the LuaJIT side of things (in the C side I even tried memcopy and did not solve the issue)
Thanks