john-chapman / im3d

Immediate mode rendering and 3d gizmos.
MIT License
1.21k stars 63 forks source link

plane drawing issue in local mode #35

Closed shadd3 closed 6 years ago

shadd3 commented 6 years ago

Hi Some planes in local "translation mode" are not drawn I have fixed that by a workaround (see below); but i guess there is a better solution Regards

world mode image local mode image

workaround: color.setA(1.0 / color.getA() aligned */);

void Context::gizmoPlaneTranslation_Draw(Id _id, const Vec3& _origin, const Vec3& _normal, float _worldSize, Color _color)
{
    Vec3 viewDir = m_appData.m_projOrtho
        ? m_appData.m_viewDirection
        : Normalize(m_appData.m_viewOrigin - _origin)
        ;
    float aligned = fabs(Dot(_normal, viewDir));
    aligned = Remap(aligned, 0.1f, 0.2f);
    Color color = _color;
    color.setA(1.0 /*color.getA() * aligned*/); <=== HERE
    pushColor(color);
        pushAlpha(_id == m_hotId ? 0.7f : 0.1f * getAlpha());
            DrawQuadFilled(_origin, _normal, Vec2(_worldSize));
        popAlpha();
        DrawQuad(_origin, _normal, Vec2(_worldSize));
    popColor();
}

result in local mode image

john-chapman commented 6 years ago

Hi - thanks very much for reporting this. The root cause of the issue was that translation planes expect the local matrix to be pushed however the view-dependent fadeout wasn't using this information. Fixed in https://github.com/john-chapman/im3d/commit/50585c06ceb89cb7d7343e0c855024ee4b970844.