Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Tue, 10 Apr 2018 14:15:25 +0000 (16:15 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 10 Apr 2018 14:15:30 +0000 (16:15 +0200)
1  2 
source/blender/editors/transform/transform_constraints.c

index 4e409e7f77f1ed66421b6d971fecd1db5961e15d,08bd36fe95ca06c480f48cdd15dc05f3b04cebac..f612dc0e4749710db7ecec4878094a48b6e19990
  #include "DNA_space_types.h"
  #include "DNA_view3d_types.h"
  
 -#include "BIF_gl.h"
  #include "BIF_glutil.h"
  
 +#include "GPU_immediate.h"
 +#include "GPU_matrix.h"
 +
  #include "BLI_math.h"
  #include "BLI_utildefines.h"
  #include "BLI_string.h"
@@@ -653,7 -651,7 +653,7 @@@ void setLocalConstraint(TransInfo *t, i
   */
  void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[])
  {
 -      char text[40];
 +      char text[256];
  
        switch (orientation) {
                case V3D_MANIP_GLOBAL:
                        BLI_snprintf(text, sizeof(text), ftext, IFACE_("gimbal"));
                        setConstraint(t, t->spacemtx, mode, text);
                        break;
 -              default: /* V3D_MANIP_CUSTOM */
 -                      BLI_snprintf(text, sizeof(text), ftext, t->spacename);
 +              case V3D_MANIP_CUSTOM:
 +              {
 +                      char orientation_str[128];
 +                      BLI_snprintf(orientation_str, sizeof(orientation_str), "%s \"%s\"",
 +                                   IFACE_("custom orientation"), t->custom_orientation->name);
 +                      BLI_snprintf(text, sizeof(text), ftext, orientation_str);
                        setConstraint(t, t->spacemtx, mode, text);
                        break;
 +              }
        }
  
        t->con.orientation = orientation;
@@@ -711,6 -704,8 +711,6 @@@ void drawConstraint(TransInfo *t
                return;
        if (!(tc->mode & CON_APPLY))
                return;
 -      if (t->flag & T_USES_MANIPULATOR)
 -              return;
        if (t->flag & T_NO_CONSTRAINT)
                return;
  
        else {
                if (tc->mode & CON_SELECT) {
                        float vec[3];
 -                      char col2[3] = {255, 255, 255};
                        int depth_test_enabled;
  
                        convertViewVec(t, vec, (t->mval[0] - t->con.imval[0]), (t->mval[1] - t->con.imval[1]));
                        drawLine(t, t->center_global, tc->mtx[1], 'Y', 0);
                        drawLine(t, t->center_global, tc->mtx[2], 'Z', 0);
  
 -                      glColor3ubv((GLubyte *)col2);
 -
                        depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
                        if (depth_test_enabled)
                                glDisable(GL_DEPTH_TEST);
  
 -                      setlinestyle(1);
 -                      glBegin(GL_LINES);
 -                      glVertex3fv(t->center_global);
 -                      glVertex3fv(vec);
 -                      glEnd();
 -                      setlinestyle(0);
 +                      const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
 +
 +                      immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
 +
 +                      float viewport_size[4];
 +                      glGetFloatv(GL_VIEWPORT, viewport_size);
 +                      immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
 +
 +                      immUniform1i("num_colors", 0);  /* "simple" mode */
 +                      immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f);
 +                      immUniform1f("dash_width", 2.0f);
 +                      immUniform1f("dash_factor", 0.5f);
 +
 +                      immBegin(GWN_PRIM_LINES, 2);
 +                      immVertex3fv(shdr_pos, t->center_global);
 +                      immVertex3fv(shdr_pos, vec);
 +                      immEnd();
 +
 +                      immUnbindProgram();
  
                        if (depth_test_enabled)
                                glEnable(GL_DEPTH_TEST);
@@@ -777,6 -762,8 +777,6 @@@ void drawPropCircle(const struct bConte
                float tmat[4][4], imat[4][4];
                int depth_test_enabled;
  
 -              UI_ThemeColor(TH_GRID);
 -
                if (t->spacetype == SPACE_VIEW3D && rv3d != NULL) {
                        copy_m4_m4(tmat, rv3d->viewmat);
                        invert_m4_m4(imat, tmat);
                        unit_m4(imat);
                }
  
 -              glPushMatrix();
 +              gpuPushMatrix();
  
                if (t->spacetype == SPACE_VIEW3D) {
                        /* pass */
                }
                else if (t->spacetype == SPACE_IMAGE) {
 -                      glScalef(1.0f / t->aspect[0], 1.0f / t->aspect[1], 1.0f);
 +                      gpuScale2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]);
                }
                else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) {
                        /* only scale y */
                        float ysize = BLI_rctf_size_y(datamask);
                        float xmask = BLI_rcti_size_x(mask);
                        float ymask = BLI_rcti_size_y(mask);
 -                      glScalef(1.0f, (ysize / xsize) * (xmask / ymask), 1.0f);
 +                      gpuScale2f(1.0f, (ysize / xsize) * (xmask / ymask));
                }
  
                depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
                if (depth_test_enabled)
                        glDisable(GL_DEPTH_TEST);
  
 +              unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
 +
 +              immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
 +              immUniformThemeColor(TH_GRID);
 +
                set_inverted_drawing(1);
 -              drawcircball(GL_LINE_LOOP, t->center_global, t->prop_size, imat);
 +              imm_drawcircball(t->center_global, t->prop_size, imat, pos);
                set_inverted_drawing(0);
  
 +              immUnbindProgram();
 +
                if (depth_test_enabled)
                        glEnable(GL_DEPTH_TEST);
  
 -              glPopMatrix();
 +              gpuPopMatrix();
        }
  }
  
@@@ -999,7 -979,7 +999,7 @@@ static void setNearestAxis3d(TransInfo 
         * of two 2D points 30 pixels apart (that's the last factor in the formula) after
         * projecting them with ED_view3d_win_to_delta and then get the length of that vector.
         */
-       zfac = mul_project_m4_v3_zfac(t->persmat, t->center);
+       zfac = mul_project_m4_v3_zfac(t->persmat, t->center_global);
        zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f;
  
        for (i = 0; i < 3; i++) {