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

A good start for ImGuizmos #41

Closed
wants to merge 2 commits into from
Closed

A good start for ImGuizmos #41

wants to merge 2 commits into from

Conversation

MrManiacc
Copy link

I've implemented the base/required functions to get the ImGuizmos library running. I plan to add support for things like ImGradients etc.

@MrManiacc MrManiacc mentioned this pull request Apr 4, 2021
@MrManiacc
Copy link
Author

Seems like all builds were fine other than the check style for some of the native functions. I don't think it's that big of a concern at the moment.

@SpaiR SpaiR added 3rd party feat New feature or request labels Apr 4, 2021
Copy link
Owner

@SpaiR SpaiR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Thanks for your contribution, I very appreciate your input.

Problems I see from the first look:

  • Cleanups. imgui-binding/tmp should not exist. As well as shadow plugin etc. If you need to test out your code - use example module. It could be started with locally built libraries.
  • Speaking about example: you need to provide one. As it's done for node-graphs bindings. It should demonstrotate how to use binding in Java ecosystem. Number of features you can show there depends on you, but it's required to exist for sure.
  • It's static native void, not native static void. Please, keep code consistency.

Generally speaking, code is fine, but you need to pay more attention to details. And to revamp your code so it will follow style of other parts of the binding. I see that it's a draft implementation, so please mark your PR title in an appropriate way. Or make the PR itself as a draft (github has such functionality). Other than that, good job!

Comment on lines +22 to +32
private native static void nEnabled(boolean[] buffer); /*
ImGuizmo::Enable(&buffer[0]);
*/

/**
* This will set the orthographic view
*/
public static void setEnabled(boolean isEnabled) {
buffer[0] = isEnabled;
nEnabled(buffer);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very strange code. Just pass boolean, don't use array.

setDrawList(ImGui.getWindowDrawList());
}

private native static void nBeginFrame(); /*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this method. Just make public static native void beginFrame and call native function there. So it should be like call native method not call java method->which calls native method. Java layer is needed to do custom logic, like extraction of internal data from types ImFloat etc. Other than that, do direct native calls.

* This will allow for manual editing of the guizmos
*/
public static void decomposeMatrixToComponents(float[] matrix, float[] translation, float[] rotation, float[] scale) {

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wierd empty lines everywhere.

Comment on lines +134 to +135
ImVec2 pos = ImGui.getWindowPos();
ImVec2 size = ImGui.getWindowSize();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of those methods create new objects. In binding I avoid unnecessary allocations as much as possible. You should do something like that

public ImRect rect() {
nRect(RECT.min, RECT.max);
return RECT;
}
private native void nRect(ImVec2 minDstImVec2, ImVec2 maxDstImVec2); /*
ImRect rect = IMGUI_DOCK_NODE->Rect();
Jni::ImVec2Cpy(env, &rect.Min, minDstImVec2);
Jni::ImVec2Cpy(env, &rect.Max, maxDstImVec2);
*/

/**
* This is just the java representtation of the imguizmo operation
*/
public enum Operation {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use enums. See any class in flag package to get the idea.

/**
* This will allow for manual editing of the guizmos
*/
public static void recomposeMatrixFromComponents(float[] matrix, float[] translation, float[] rotation, float[] scale) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguments order should be the same as for native method. Not something randomly generated. 😕

* This will allow us to draw an arbitrary cube in the world.
*/
public static void drawCubes(float[] view, float[] projection, float[]... cubeMatrices) {
float[] matrices = new float[cubeMatrices.length * 16];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking about unnecessary allocations, that is the case too.

@AAstroPhysiCS
Copy link
Contributor

AAstroPhysiCS commented Apr 28, 2021

Hi @MrManiacc,
I just wanted to ask if you're still working on this feature.
I am asking this because I plan to integrate this feature as well and in fact, I wanted to make a PR about it. Since, you've already done it, I did not want to make a another PR and just wait for you to finish.
If you stopped working on this feature or have limited time, I can gladly take over your work and integrate this by myself.

Thanks for your contribution!

@MrManiacc
Copy link
Author

Hi @MrManiacc,
I just wanted to ask if you're still working on this feature.
I am asking this because I plan to integrate this feature as well and in fact, I wanted to make a PR about it. Since, you've already done it, I did not want to make a another PR and just wait for you to finish.
If you stopped working on this feature or have limited time, I can gladly take over your work and integrate this by myself.

Thanks for your contribution!

Hi, feel free to take over. I'm going to be very busy for the next couple of weeks.

@AAstroPhysiCS AAstroPhysiCS mentioned this pull request May 8, 2021
@SpaiR
Copy link
Owner

SpaiR commented May 29, 2021

Implemented in #54

@SpaiR SpaiR closed this May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants