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

function declaration without name for arguments #7

Open
sonoro1234 opened this issue Sep 2, 2020 · 5 comments
Open

function declaration without name for arguments #7

sonoro1234 opened this issue Sep 2, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@sonoro1234
Copy link

sonoro1234 commented Sep 2, 2020

Hi Michele,

I am trying to have https://github.com/cimgui/cimguizmo_quat programmatically generated, having https://github.com/BrutPitt/imGuIZMO.quat/blob/master/imGuIZMO.quat/imGuIZMOquat.h#L317 without argument names while it is valid C is a problem for the generator, it asumes that it is not happening and uses this name arguments in the whole process. I could detect this situation and generate the names myself, but I feel that this would make the parser less robust.

Could you please assign names to this arguments?

Something similar happens with https://github.com/BrutPitt/imGuIZMO.quat/blob/master/imGuIZMO.quat/imGuIZMOquat.h#L78

where parser expects an enum tag. Could a tag be added as

enum      iGq_MODES_ {                        

or similar?

@BrutPitt BrutPitt added the enhancement New feature or request label Sep 3, 2020
@BrutPitt
Copy link
Owner

BrutPitt commented Sep 4, 2020

Hi, Victor.

You really need of enum qualifier, or the problem is the const int specifier in prototype assignment of function?
(because const specifier is need/permitted only in the definition and not in the prototype... even if it's not an error)

So, try if it works (removing const):

IMGUI_API bool gizmo3D(const char*, quat&, float=IMGUIZMO_DEF_SIZE, int=imguiGizmo::mode3Axes|imguiGizmo::cubeAtOrigin);

If it don't works, and if I assign the enum qualifier like:

enum gizmoModes {                        //0b0000'0000, //C++14 notation
                mode3Axes          = 0x0001, //0b0000'0001, 
                modeDirection      = 0x0002, //0b0000'0010,
                modeDirPlane       = 0x0004, //0b0000'0100,
                modeDual           = 0x0008, //0b0000'1000,
                modePanDolly       = 0x0010, //0b0001'0000,
                modeMask           = 0x00ff, 
                

                cubeAtOrigin       = 0x0100, //0b0000'0000, 
                sphereAtOrigin     = 0x0200, //0b0001'0000,
                noSolidAtOrigin    = 0x0400, //0b0010'0000,
                modeFullAxes       = 0x0800,
                axesModeMask       = 0xff00  
    };

the following code works fine, anyway?

IMGUI_API bool gizmo3D(const char*, quat&, float=IMGUIZMO_DEF_SIZE, int=imguiGizmo::mode3Axes|imguiGizmo::cubeAtOrigin);

... or do you need a more specific assignment, like this one?

IMGUI_API bool gizmo3D(const char*, quat&, float=IMGUIZMO_DEF_SIZE, int=imguiGizmo::gizmoModes::mode3Axes|imguiGizmo::gizmoModes::cubeAtOrigin);

Let me know,
Michele

@sonoro1234
Copy link
Author

sonoro1234 commented Sep 5, 2020

I used #8
It compiled without problems

But I dont know if used from C++ it makes use of imguiGizmo::mode3Axes or imguiGizmo::enumname::mode3Axes it should be tested compiling some C++ program (I have not used this enum explicitely in my compilation (only in function declaration))

I used the patched imGuIZMOquat.h (had to move it to example/src/tools ) for compiling qjSet without problem. Should that be enough test? May be it is because it is used in uiMainDlg.cpp


I just found another stopper not for cimgizmo_quat in LuaJIT-ImGui but for LuaJIT-ImGui in anima:
In anima I have

typedef struct vec2 { double x, y;       } vec2;
typedef struct vec3 { double x, y, z;    } vec3;
typedef struct vec4 { double x, y, z, w; } vec4;

But cimguizmo_quat automatic building needs:

typedef struct vec3 { float x, y, z;    } vec3;
typedef struct vec4 { float x, y, z, w; } vec4;

so LuaJIT says attempt to redefine 'vec4'

It is probably a bad idea using such common names both in anima and in imGuIZMO.quat
That is probably the reason Omar Cornut had to name them ImVec2 or ImVec4

I have managed to solve it with substitution of vec3 for G3Dvec3 in the LuaJIT-ImGui automated build process (not touching cimguizmo_quat)

@BrutPitt
Copy link
Owner

BrutPitt commented Sep 5, 2020

But I dont know if used from C++ it makes use of imguiGizmo::mode3Axes or imguiGizmo::enumname::mode3Axes it should be tested compiling some C++ program (I have not used this enum explicitely in my compilation (only in function declaration))

Your syntax imguiGizmo::mode3Axes works fine in C++

I used the patched imGuIZMOquat.h (had to move it to example/src/tools ) for compiling qjSet without problem. Should that be enough test? May be it is because it is used in uiMainDlg.cpp

Yes, you have right: I use a symbolic link in my computer, so, for me, the example/src/tools ==> imGuIZMO.quat (both point same folder and share same files), but in the git repo are distinct folders.
Maybe I need to improve the git tree structure, mostly for those who use the fork.

I just found another stopper not for cimgizmo_quat in LuaJIT-ImGui but for LuaJIT-ImGui in anima:
It is probably a bad idea using such common names both in anima and in imGuIZMO.quat
That is probably the reason Omar Cornut had to name them ImVec2 or ImVec4

In origin the widget used glm math library (widely used in OpenGL): it uses the GLSL types name convention, so the difference is between vec4 for a float type and dvec4 for a double type.
Subsequently, talking with users, I wrote a more compact and "light" math library (vgMath) for a stand-alone use of ImGuIZMO.quat, and that didn't necessarily use template classes (also under the advice of Omar).
ImGuIZMO.quat widget don't need of double type and by default only the vec*/quat of float type are available using static classes (no template classes)
But the template classes are available using the VGM_USES_TEMPLATE define: in this way you have both vec* and dvec*, as well as mat* and dmat*, and also ivec* e uvec*, like in glm (and GLSL)
Definitely vgMath is a subset of glm, it maintains the compatibility with types, calls and operators, and you can switch to glm at any time, using VGIZMO_USES_GLM define (especially if your project already used glm).

I don't know if it can help...
From ver 3.0 there is, in vgConfig.h:

//------------------------------------------------------------------------------
// uncomment to avoid vgMath.h add follow line code:
//      using namespace vgm | glm; // if (!VGIZMO_USES_GLM | VGIZMO_USES_GLM)
//
// Automatically "using namespace" is added to the end vgMath.h:
//      it help to maintain compatibilty between vgMath & glm declaration types,
//      but can go in confict with other pre-exist data types in your project
//
// note: this is only if you use vgMath.h in your project, for your data types:
//       it have no effect for vGizmo | imGuIZMO internal use
//
// Default ==> vgMath.h add: using namespace vgm | glm;
//------------------------------------------------------------------------------
//#define VGM_DISABLE_AUTO_NAMESPACE

Using VGM_DISABLE_AUTO_NAMESPACE define, you need to specify vgm::vec4, or need to specify yopurself using namespace vgm for file or parts of code.
(warning: it has not been fully tested)

I have managed to solve it with substitution of vec3 for G3Dvec3 in the LuaJIT-ImGui automated build process (not touching cimguizmo_quat)

I read this after (Sorry, I already answered above)

I used #8

Now I start working on the enum changes

@sonoro1234
Copy link
Author

sonoro1234 commented Sep 6, 2020

This are the functions auto generated.

typedef ImVector<vec3> ImVector_vec3;
CIMGUI_API void imguiGizmo_buildPlane(const float size,const float thickness);
CIMGUI_API void imguiGizmo_buildCube(const float size);
CIMGUI_API void imguiGizmo_buildPolygon(const vec3 size,ImVector_vec3* vtx,ImVector_vec3* norm);
CIMGUI_API void imguiGizmo_buildSphere(const float radius,const int tessFactor);
CIMGUI_API void imguiGizmo_buildCone(const float x0,const float x1,const float radius,const int slices);
CIMGUI_API void imguiGizmo_buildCylinder(const float x0,const float x1,const float radius,const int slices);
CIMGUI_API void imguiGizmo_resizeAxesOf(const vec3 newSize);
CIMGUI_API void imguiGizmo_restoreAxesSize(void);
CIMGUI_API void imguiGizmo_resizeSolidOf(float newSize);
CIMGUI_API void imguiGizmo_restoreSolidSize(void);
CIMGUI_API void imguiGizmo_setDirectionColorU32U32(ImU32 dColor,const ImU32 pColor);
CIMGUI_API void imguiGizmo_setDirectionColorVec4Vec4(const ImVec4 dColor,const ImVec4 pColor);
CIMGUI_API void imguiGizmo_setDirectionColorU32(ImU32 color);
CIMGUI_API void imguiGizmo_setDirectionColorVec4(const ImVec4 color);
CIMGUI_API void imguiGizmo_restoreDirectionColor(void);
CIMGUI_API void imguiGizmo_setSphereColorsVec4(const ImVec4 a,const ImVec4 b);
CIMGUI_API void imguiGizmo_setSphereColorsU32(ImU32 a,ImU32 b);
CIMGUI_API void imguiGizmo_restoreSphereColors(void);
CIMGUI_API void imguiGizmo_setGizmoFeelingRot(float f);
CIMGUI_API float imguiGizmo_getGizmoFeelingRot(void);
CIMGUI_API void imguiGizmo_setPanModifier(vgModifiers v);
CIMGUI_API void imguiGizmo_setDollyModifier(vgModifiers v);
CIMGUI_API void imguiGizmo_setDollyScale(float scale);
CIMGUI_API float imguiGizmo_getDollyScale(void);
CIMGUI_API void imguiGizmo_setPanScale(float scale);
CIMGUI_API float imguiGizmo_getPanScale(void);
CIMGUI_API bool imguiGizmo_drawFunc(imguiGizmo* self,const char* label,float size);
CIMGUI_API void imguiGizmo_modeSettings(imguiGizmo* self,int mode);
CIMGUI_API void imguiGizmo_setDualMode(imguiGizmo* self,const int mode);
CIMGUI_API bool imguiGizmo_getTransformsvec3(imguiGizmo* self,quat* q,const char* label,vec3* dir,float size);
CIMGUI_API bool imguiGizmo_getTransformsvec4(imguiGizmo* self,quat* q,const char* label,vec4* axis_angle,float size);
CIMGUI_API bool iggizmo3DquatFloatInt(const char* label,quat* a,float size,const int mode);
CIMGUI_API bool iggizmo3Dvec4(const char* label,vec4* a,float size,const int mode);
CIMGUI_API bool iggizmo3Dvec3FloatInt(const char* label,vec3* a,float size,const int mode);
CIMGUI_API bool iggizmo3DquatquatFloatInt(const char* label,quat* a,quat* b,float size,const int mode);
CIMGUI_API bool iggizmo3Dquatvec4FloatInt(const char* label,quat* a,vec4* b,float size,const int mode);
CIMGUI_API bool iggizmo3Dquatvec3FloatInt(const char* label,quat* a,vec3* b,float size,const int mode);
CIMGUI_API bool iggizmo3Dvec3quatFloatInt(const char* label,vec3* a,quat* b,float size,const int mode);
CIMGUI_API bool iggizmo3Dvec3vec4FloatInt(const char* label,vec3* a,vec4* b,float size,const int mode);
CIMGUI_API bool iggizmo3Dvec3vec3FloatInt(const char* label,vec3* a,vec3* b,float size,const int mode);
CIMGUI_API bool iggizmo3Dvec3quatquat(const char* label,vec3* a,quat* b,quat* c,float size,const int mode);
CIMGUI_API bool iggizmo3Dvec3quatvec4(const char* label,vec3* a,quat* b,vec4* c,float size,const int mode);
CIMGUI_API bool iggizmo3Dvec3quatvec3(const char* label,vec3* a,quat* b,vec3* c,float size,const int mode);

I guess that some of them are not useful as for example

CIMGUI_API void imguiGizmo_buildPlane(const float size,const float thickness);
CIMGUI_API void imguiGizmo_buildCube(const float size);
CIMGUI_API void imguiGizmo_buildPolygon(const vec3 size,ImVector_vec3* vtx,ImVector_vec3* norm);
CIMGUI_API void imguiGizmo_buildSphere(const float radius,const int tessFactor);
CIMGUI_API void imguiGizmo_buildCone(const float x0,const float x1,const float radius,const int slices);
CIMGUI_API void imguiGizmo_buildCylinder(const float x0,const float x1,const float radius,const int slices);
CIMGUI_API bool imguiGizmo_drawFunc(imguiGizmo* self,const char* label,float size);
CIMGUI_API void imguiGizmo_modeSettings(imguiGizmo* self,int mode);
CIMGUI_API void imguiGizmo_setDualMode(imguiGizmo* self,const int mode);
CIMGUI_API bool imguiGizmo_getTransformsvec3(imguiGizmo* self,quat* q,const char* label,vec3* dir,float size);
CIMGUI_API bool imguiGizmo_getTransformsvec4(imguiGizmo* self,quat* q,const char* label,vec4* axis_angle,float size);

They can be eliminated if you confirm that they are not useful (or may be keep someone)

I have made changes to cimgui in order to allow not named arguments and not tagged enums so now cimguizmo_quat is automatically generated, adding names would be still desirable for better clarity.

@sonoro1234
Copy link
Author

So much time without contibutions makes me worry: Hope you are well!!

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

No branches or pull requests

2 participants