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

gizmo drawn incorrectly at direction (-1, 0, 0) #11

Open
koala999cn opened this issue Jun 1, 2023 · 1 comment
Open

gizmo drawn incorrectly at direction (-1, 0, 0) #11

koala999cn opened this issue Jun 1, 2023 · 1 comment
Labels
question Further information is requested

Comments

@koala999cn
Copy link

koala999cn commented Jun 1, 2023

Hello!
When entering the following code, incorrect result appears

vgm::Vec3 dir(-1, 0, 0);
ImGui::gizmo3D("Direction", dir);

It means, I wanna (-1, 0, 0), but get (1, 0, 0).

@BrutPitt
Copy link
Owner

BrutPitt commented Dec 4, 2024

Hi @koala999cn, and sorry for the (very!) late reply.

I tried your example, but the problem does not happen.
On picture, below, there is my debug session (tested with both gcc 14.2.1 and clang 18.1. 8):

Screenshot at 2024-12-04 22-21-49

A value (1.0, 0.0, 0.0) is a condition that can occur/be returmed only if the length of vector "dir" < FLT_EPSILON (alias: NULL vector): and this would not be the case!
Below the code relative, used to avoid a NULL vector and consequentially a division by ZERO

        float len = length(dir);

        if(len<1.0 && len>= FLT_EPSILON) { normalize(dir); len = 1.0; }
        else if(len< FLT_EPSILON) { dir = vec3(1.f, 0.f, 0.f); len = 1.0; }

        q = angleAxis(acosf(dir.x/len), normalize(vec3(FLT_EPSILON, -dir.z, dir.y)));

On the basis of this I can assume that dir is initialized to (0.0, 0.0, 0.0) instead of (-1.0, 0.0, 0.0)

For this reason, please, tell me more about your C/C++ compiler (brand, version and used compiler flags) and your OS

@BrutPitt BrutPitt added the question Further information is requested label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants