Revision: 49728
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49728
Author:   jwilkins
Date:     2012-08-09 09:14:50 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Some matrix fixes to fix a GPU_SAFETY assertion in blf.c

Changed gpuGetMatrix and removed gpuGetSpecificMatrix, we only really need one.
Added casts to gpuProject and gpuUnproject to quiet a lot of warnings.  
Hopefully this kind of macro will go away.
Made sure that default mode GL_MODELVIEW is reset after changing other matrixes
gpuGetMatrix returns a const pointer.  It does not seem like a good idea to 
expose the internals of the matrix module.
Some white space formatting for gpuCommitMatrix, and other matrix functions.
note: gluPerspective is present in KX_Dome.cpp, but it is commented out
Some code in the RAS_OpenGLRasteriser.cpp used OpenGL as a scratch space to 
make a new matrix, I removed that and just did the calculation using Blender's 
matrix functions.

Modified Paths:
--------------
    branches/soc-2012-swiss_cheese/source/blender/editors/screen/glutil.c
    
branches/soc-2012-swiss_cheese/source/blender/editors/sculpt_paint/paint_utils.c
    
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_edit.c
    
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_view.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_matrix.h
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_extensions.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c
    
branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_subwindow.c
    
branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
    
branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Camera.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Dome.cpp
    
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
    
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
    
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/screen/glutil.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/screen/glutil.c       
2012-08-09 09:03:56 UTC (rev 49727)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/screen/glutil.c       
2012-08-09 09:14:50 UTC (rev 49728)
@@ -635,8 +635,8 @@
 
        glGetIntegerv(GL_VIEWPORT, (GLint *)di->orig_vp);
        glGetIntegerv(GL_SCISSOR_BOX, (GLint *)di->orig_sc);
-       gpuGetSpecificMatrix(GL_PROJECTION, (GLfloat *)di->orig_projmat);
-       gpuGetSpecificMatrix(GL_MODELVIEW, (GLfloat *)di->orig_viewmat);
+       gpuGetMatrix(GL_PROJECTION_MATRIX, (GLfloat *)di->orig_projmat);
+       gpuGetMatrix(GL_MODELVIEW_MATRIX, (GLfloat *)di->orig_viewmat);
 
        di->screen_rect = *screen_rect;
        if (world_rect) {
@@ -691,8 +691,8 @@
 {
        const double badvalue = 1.0e-6;
 
-       gpuGetSpecificMatrix(GL_MODELVIEW, mats->modelview);
-       gpuGetSpecificMatrix(GL_PROJECTION, mats->projection);
+       gpuGetMatrix(GL_MODELVIEW_MATRIX, mats->modelview);
+       gpuGetMatrix(GL_PROJECTION_MATRIX, mats->projection);
        glGetIntegerv(GL_VIEWPORT, (GLint *)mats->viewport);
        
        /* Very strange code here - it seems that certain bad values in the
@@ -728,21 +728,20 @@
 
                /* hack below is to mimic polygon offset */
                gpuMatrixMode(GL_PROJECTION);
-               gpuGetMatrix((float *)winmat);
-               
+               gpuGetMatrix(GL_PROJECTION_MATRIX, (float *)winmat);
+
                /* dist is from camera to center point */
                
                if (winmat[15] > 0.5f) offs = 0.00001f * dist * viewdist;  // 
ortho tweaking
                else offs = 0.0005f * dist;  // should be clipping value or 
so...
-               
+
                winmat[14] -= offs;
                offset += offs;
-               
+
                gpuLoadMatrix(winmat);
                gpuMatrixMode(GL_MODELVIEW);
        }
        else {
-
                gpuMatrixMode(GL_PROJECTION);
                winmat[14] += offset;
                offset = 0.0;

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/editors/sculpt_paint/paint_utils.c
    2012-08-09 09:03:56 UTC (rev 49727)
+++ 
branches/soc-2012-swiss_cheese/source/blender/editors/sculpt_paint/paint_utils.c
    2012-08-09 09:14:50 UTC (rev 49728)
@@ -221,8 +221,8 @@
 
        /* get the needed opengl matrices */
        glGetIntegerv(GL_VIEWPORT, view);
-       gpuGetSpecificMatrix(GL_MODELVIEW,  (float *)model);
-       gpuGetSpecificMatrix(GL_PROJECTION, (float *)proj);
+       gpuGetMatrix(GL_MODELVIEW_MATRIX,  (float *)model);
+       gpuGetMatrix(GL_PROJECTION_MATRIX, (float *)proj);
        view[0] = view[1] = 0;
 
        /* project the verts */

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_edit.c
    2012-08-09 09:03:56 UTC (rev 49727)
+++ 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_edit.c
    2012-08-09 09:14:50 UTC (rev 49728)
@@ -2601,12 +2601,8 @@
 
                cent[2] = corner[2] = depth_close;
                /* convert border to 3d coordinates */
-               if ( (!gpuUnProject(cent,
-                                   mats.modelview, mats.projection, (GLint 
*)mats.viewport,
-                                                       p)) ||
-                        (!gpuUnProject(corner,
-                                   mats.modelview, mats.projection, (GLint 
*)mats.viewport,
-                                                       p_corner)))
+               if ( (!gpuUnProject(cent, mats.modelview, mats.projection, 
(GLint *)mats.viewport, p)) ||
+                        (!gpuUnProject(corner, mats.modelview, 
mats.projection, (GLint *)mats.viewport, p_corner)))
                {
                        return OPERATOR_CANCELLED;
                }
@@ -2632,9 +2628,8 @@
 
                cent[2] = depth_close;
                /* convert the drawn rectangle into 3d space */
-               if (depth_close != FLT_MAX && gpuUnProject(cent,
-                                                          mats.modelview, 
mats.projection, (GLint *)mats.viewport,
-                                                                               
                   p))
+               if (depth_close != FLT_MAX &&
+                       gpuUnProject(cent, mats.modelview, mats.projection, 
(GLint *)mats.viewport, p)) 
                {
                        new_ofs[0] = -p[0];
                        new_ofs[1] = -p[1];
@@ -3585,19 +3580,13 @@
 
        cent[2] = view_autodist_depth_margin(ar, mval, 4);
 
-       if (cent[3] == FLT_MAX)
+       if (cent[2] == FLT_MAX)
                return 0;
 
        cent[0] = mval[0];
        cent[1] = mval[1];
 
-       if (!gpuUnProject(cent,
-                                         mats.modelview, mats.projection, 
(GLint *)mats.viewport, mouse_worldloc))
-       {
-               return 0;
-       }
-
-       return 1;
+       return gpuUnProject(cent, mats.modelview, mats.projection, (GLint 
*)mats.viewport, mouse_worldloc);
 }
 
 int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode)
@@ -3636,13 +3625,7 @@
 
        bgl_get_mats(&mats);
 
-       if (!gpuUnProject(cent,
-                                         mats.modelview, mats.projection, 
(GLint *)mats.viewport, mouse_worldloc))
-       {
-               return 0;
-       }
-
-       return 1;
+       return gpuUnProject(cent, mats.modelview, mats.projection, (GLint 
*)mats.viewport, mouse_worldloc);
 }
 
 int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int 
margin, float *depth)

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_view.c
    2012-08-09 09:03:56 UTC (rev 49727)
+++ 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_view.c
    2012-08-09 09:14:50 UTC (rev 49728)
@@ -768,9 +768,7 @@
 {
        float win[] = {x, y, z};
 
-       gpuUnProject(win, mats->modelview, mats->projection,
-                                (GLint *)mats->viewport, out);
-
+       gpuUnProject(win, mats->modelview, mats->projection, (GLint 
*)mats->viewport, out);
 }
 
 /* use view3d_get_object_project_mat to get projecting mat */
@@ -1070,7 +1068,7 @@
        }
 
        /* update matrix in 3d view region */
-       gpuGetSpecificMatrix(GL_PROJECTION, (float *)rv3d->winmat);
+       gpuGetMatrix(GL_PROJECTION_MATRIX, (float *)rv3d->winmat);
 }
 
 static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, 
short smooth)

Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_matrix.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_matrix.h      
2012-08-09 09:03:56 UTC (rev 49727)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_matrix.h      
2012-08-09 09:14:50 UTC (rev 49728)
@@ -55,8 +55,7 @@
 GLenum gpuGetMatrixMode(void);
 
 void gpuLoadMatrix(const GLfloat * m);
-GLfloat * gpuGetMatrix(GLfloat * m);
-GLfloat * gpuGetSpecificMatrix(GLenum type, GLfloat * m);
+const GLfloat * gpuGetMatrix(GLenum type, GLfloat * m);
 
 void gpuLoadIdentity(void);
 
@@ -86,10 +85,14 @@
 #endif
 
 #if GPU_MAT_CAST_ANY
-#define gpuLoadMatrix(m)  gpuLoadMatrix((const GLfloat *) m);
-#define gpuGetMatrix(m)   gpuGetMatrix((GLfloat *) m);
-#define gpuMultMatrix(m)  gpuMultMatrix((const GLfloat *) m);
-#define gpuMultMatrixd(m) gpuMultMatrixd((const double *) m);
+
+#define gpuLoadMatrix(m)  gpuLoadMatrix((const GLfloat *)(m))
+#define gpuMultMatrix(m)  gpuMultMatrix((const GLfloat *)(m))
+#define gpuMultMatrixd(m) gpuMultMatrixd((const double *)(m))
+
+#define gpuProject(o, m, p, v, w)   gpuProject   (o, (const GLfloat 
(*)[4])(m), (const GLfloat (*)[4])(p), v, w)
+#define gpuUnProject(w, m, p, v, o) gpuUnProject (w, (const GLfloat 
(*)[4])(m), (const GLfloat (*)[4])(p), v, o)
+
 #endif
 
 

Modified: 
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_extensions.c   
2012-08-09 09:03:56 UTC (rev 49727)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_extensions.c   
2012-08-09 09:14:50 UTC (rev 49728)
@@ -927,12 +927,12 @@
        glViewport(0, 0, GPU_texture_opengl_width(blurtex), 
GPU_texture_opengl_height(blurtex));
 
        /* Peparing to draw quad */
-       gpuMatrixMode(GL_MODELVIEW);
-       gpuLoadIdentity();
        gpuMatrixMode(GL_TEXTURE);
        gpuLoadIdentity();
        gpuMatrixMode(GL_PROJECTION);
        gpuLoadIdentity();
+       gpuMatrixMode(GL_MODELVIEW); /* make sure last current matrix is 
modelview */
+       gpuLoadIdentity();
 
        GPU_texture_bind(tex, 0);
 

Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c       
2012-08-09 09:03:56 UTC (rev 49727)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c       
2012-08-09 09:14:50 UTC (rev 49728)
@@ -179,21 +179,8 @@
        glPushMatrix();
 
        glMatrixMode(glstackmode);
-       switch(glstackmode)
-       {
-               case GL_MODELVIEW:
-                       gpuMatrixMode(GL_MODELVIEW);
-                       break;
-               case GL_TEXTURE:
-                       gpuMatrixMode(GL_TEXTURE);
-                       break;
-               case GL_PROJECTION:
-                       gpuMatrixMode(GL_PROJECTION);
-                       break;
+       gpuMatrixMode(glstackmode);
 
-       }
-
-
 #endif
 
 }
@@ -360,37 +347,28 @@
        CHECKMAT
 }
 
-GLfloat * gpuGetMatrix(GLfloat * m)
+const GLfloat * gpuGetMatrix(GLenum type, GLfloat *m)
 {
-       if(m)
-               copy_m4_m4((GLfloat (*)[4])m, CURMATRIX);
-       else
-               return (GLfloat*)(CURMATRIX);
-       ms_current->changed = 1;
-       return 0;
-}
-
-GLfloat * gpuGetSpecificMatrix(GLenum type, GLfloat *m)
-{
        GPU_matrix_stack * ms_select;
 
+       GPU_ASSERT(ELEM3(type, GL_MODELVIEW_MATRIX, GL_PROJECTION_MATRIX, 
GL_TEXTURE_MATRIX));
+
        switch(type)
        {
-               case GL_MODELVIEW:
+               case GL_MODELVIEW_MATRIX:
                        ms_select = &ms_modelview;
                        break;
-               case GL_PROJECTION:
+               case GL_PROJECTION_MATRIX:
                        ms_select = &ms_projection;
                        break;
-               case GL_TEXTURE:
+               case GL_TEXTURE_MATRIX:
                        ms_select = & ms_texture;
                        break;
                default:
-                       BLI_assert(0);
                        return 0;
        }
 
-       if(m)
+       if (m)
                copy_m4_m4((GLfloat (*)[4])m, 
ms_select->dynstack[ms_select->pos]);
        else
                return (GLfloat*)(ms_select->dynstack[ms_select->pos]);
@@ -568,7 +546,7 @@
        mult_m4_m4m4_q(pm, proj, model);
 
        if(!invert_m4(pm))
-               return 0;
+               return FALSE;
 
 
 
@@ -588,6 +566,6 @@
        obj[0] = objd[0];
        obj[1] = objd[1];
        obj[2] = objd[2];
-       return 1;
+       return TRUE;
 
 }

Modified: 
branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_subwindow.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_subwindow.c
   2012-08-09 09:03:56 UTC (rev 49727)
+++ 
branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_subwindow.c
   2012-08-09 09:14:50 UTC (rev 49728)
@@ -142,9 +142,8 @@
                        wm_subwindow_getsize(win, swin->swinid, &width, 
&height);

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to