Commit: 9c01aaa3dd7456d6811bad4f37190833fa5a04a0
Author: Mike Erwin
Date:   Fri Apr 7 03:08:00 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB9c01aaa3dd7456d6811bad4f37190833fa5a04a0

OpenGL: disable rotate manipulator clipping on Mac

This fixes T51143.

gl_ClipDistance is part of GLSL version 1.3 but Mac is stuck on 1.2 for now.

This workaround uses GPU_SHADER_3D_UNIFORM_COLOR for the entire rotation 
widget, ignoring any clipping plane. The CLIPPING shader only works on GLSL 
1.3+ so I removed its 1.2 cruft.

A legacy implementation using gl_ClipVertex might be possible, but is not worth 
the effort. This problem (and workaround) goes away when all platforms move to 
3.3 core profile.

===================================================================

M       source/blender/editors/transform/transform_manipulator.c
M       source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl

===================================================================

diff --git a/source/blender/editors/transform/transform_manipulator.c 
b/source/blender/editors/transform/transform_manipulator.c
index 384bdb3b258..624cd7db679 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1133,18 +1133,24 @@ static void draw_manipulator_rotate(
        // donut arcs
        if (arcs) {
                float axis_model_mat[4][4];
+
+#if !APPLE_LEGACY
                float clip_plane[4];
 
                copy_v3_v3(clip_plane, rv3d->viewinv[2]);
                clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], rv3d->twmat[3]);
                clip_plane[3] -= 0.02f * size; /* clip just a bit more so view 
aligned arcs are not visible */
+#endif
 
                gpuPopMatrix(); /* we setup our own matrix, pop previously set 
twmat */
+
+#if !APPLE_LEGACY
                immUnbindProgram();
                immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR);
                immUniform4fv("ClipPlane", clip_plane);
 
                glEnable(GL_CLIP_DISTANCE0);
+#endif
 
                /* Z circle */
                if (drawflags & MAN_ROT_Z) {
@@ -1152,7 +1158,9 @@ static void draw_manipulator_rotate(
                        else manipulator_setcolor(v3d, 'Z', colcode, 255);
 
                        twmat_to_rotation_axis_mat(rv3d->twmat, 2, ortho, 
axis_model_mat);
+#if !APPLE_LEGACY
                        immUniformMatrix4fv("ModelMatrix", axis_model_mat);
+#endif
                        gpuPushMatrix();
                        gpuMultMatrix3D(axis_model_mat);
 
@@ -1165,7 +1173,9 @@ static void draw_manipulator_rotate(
                        else manipulator_setcolor(v3d, 'X', colcode, 255);
 
                        twmat_to_rotation_axis_mat(rv3d->twmat, 0, ortho, 
axis_model_mat);
+#if !APPLE_LEGACY
                        immUniformMatrix4fv("ModelMatrix", axis_model_mat);
+#endif
                        gpuPushMatrix();
                        gpuMultMatrix3D(axis_model_mat);
 
@@ -1178,7 +1188,9 @@ static void draw_manipulator_rotate(
                        else manipulator_setcolor(v3d, 'Y', colcode, 255);
 
                        twmat_to_rotation_axis_mat(rv3d->twmat, 1, ortho, 
axis_model_mat);
+#if !APPLE_LEGACY
                        immUniformMatrix4fv("ModelMatrix", axis_model_mat);
+#endif
                        gpuPushMatrix();
                        gpuMultMatrix3D(axis_model_mat);
 
@@ -1186,7 +1198,10 @@ static void draw_manipulator_rotate(
                        gpuPopMatrix();
                }
 
+#if !APPLE_LEGACY
                glDisable(GL_CLIP_DISTANCE0);
+#endif
+
                gpuPushMatrix(); /* to balance final pop at end of function */
        }
        else {
diff --git 
a/source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl 
b/source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl
index 2988bb3b682..84e44837264 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl
@@ -3,11 +3,7 @@ uniform mat4 ModelViewProjectionMatrix;
 uniform mat4 ModelMatrix;
 uniform vec4 ClipPlane;
 
-#if __VERSION__ == 120
-  attribute vec3 pos;
-#else
-  in vec3 pos;
-#endif
+in vec3 pos;
 
 void main()
 {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to