CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
MIT License
3.12k stars 878 forks source link

Behind camera culling. #10

Open volcoma opened 8 years ago

volcoma commented 8 years ago

when behind the camera the gizmo is still rendered but wrong. Add the following stuff to prevent this.

gContext.mCameraNearPlane.x = (gContext.mViewProjection.m[0][2]); gContext.mCameraNearPlane.y = (gContext.mViewProjection.m[1][2]); gContext.mCameraNearPlane.z = (gContext.mViewProjection.m[2][2]); gContext.mCameraNearPlane.w = (gContext.mViewProjection.m[3][2]);

and this

`void Manipulate(const float _view, const float projection, OPERATION operation, MODE mode, float matrix, float *deltaMatrix) { ComputeContext(view, projection, matrix, mode); // set delta to identity if (deltaMatrix) ((matrixt)deltaMatrix)->SetToIdentity();

    vec_t cameraEyeToGizmo = Normalized(gContext.mModel.v.position - gContext.mCameraEye);
    if (cameraEyeToGizmo.Dot3(gContext.mCameraNearPlane) < 0)
        return;'
CedricGuillemet commented 8 years ago

Shame on me! And same applies to the debug cube display. That will be fixed tomorrow. Thank you!