Jelajahi Sumber

Reverted the matrix uniform transpose on desktop GL due to problems on OS X.
Fixed assert due to improper threaded weak pointer assignment (FindZone.)

Lasse Öörni 13 tahun lalu
induk
melakukan
8fb76dde01

+ 20 - 0
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -881,6 +881,9 @@ void Graphics::SetShaderParameter(StringHash param, const float* data, unsigned
                 break;
                 
             case GL_FLOAT_MAT3:
+                #ifndef GL_ES_VERSION_2_0
+                glUniformMatrix3fv(info->location_, count / 9, GL_TRUE, data);
+                #else
                 {
                     for (unsigned i = 0; i < count; i += 9)
                     {
@@ -888,9 +891,13 @@ void Graphics::SetShaderParameter(StringHash param, const float* data, unsigned
                         glUniformMatrix3fv(info->location_ + i / 9, 1, GL_FALSE, matrix.Transpose().Data());
                     }
                 }
+                #endif
                 break;
                 
             case GL_FLOAT_MAT4:
+                #ifndef GL_ES_VERSION_2_0
+                glUniformMatrix4fv(info->location_, count / 16, GL_TRUE, data);
+                #else
                 {
                     for (unsigned i = 0; i < count; i += 16)
                     {
@@ -898,6 +905,7 @@ void Graphics::SetShaderParameter(StringHash param, const float* data, unsigned
                         glUniformMatrix4fv(info->location_ + i / 16, 1, GL_FALSE, matrix.Transpose().Data());
                     }
                 }
+                #endif
                 break;
             }
         }
@@ -925,7 +933,13 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
     {
         const ShaderParameter* info = shaderProgram_->GetParameter(param);
         if (info)
+        {
+            #ifndef GL_ES_VERSION_2_0
+            glUniformMatrix3fv(info->location_, 1, GL_TRUE, matrix.Data());
+            #else
             glUniformMatrix3fv(info->location_, 1, GL_FALSE, matrix.Transpose().Data());
+            #endif
+        }
     }
 }
 
@@ -961,7 +975,13 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix4& matrix)
     {
         const ShaderParameter* info = shaderProgram_->GetParameter(param);
         if (info)
+        {
+            #ifndef GL_ES_VERSION_2_0
+            glUniformMatrix4fv(info->location_, 1, GL_TRUE, matrix.Data());
+            #else
             glUniformMatrix4fv(info->location_, 1, GL_FALSE, matrix.Transpose().Data());
+            #endif
+        }
     }
 }
 

+ 5 - 3
Engine/Graphics/View.cpp

@@ -233,8 +233,6 @@ void CheckVisibilityWork(const WorkItem* item, unsigned threadIndex)
                 
                 drawable->SetMinMaxZ(viewCenterZ - viewEdgeZ, viewCenterZ + viewEdgeZ);
                 drawable->ClearLights();
-                if (!drawable->GetZone() && !view->cameraZoneOverride_)
-                    view->FindZone(drawable, threadIndex);
             }
         }
     }
@@ -639,6 +637,10 @@ void View::GetDrawables()
         
         if (drawable->GetDrawableFlags() & DRAWABLE_GEOMETRY)
         {
+            // Find zone for the drawable if necessary
+            if (!drawable->GetZone() && !cameraZoneOverride_)
+                FindZone(drawable);
+            
             // Expand the scene bounding box and Z range (skybox not included because of infinite size) and store the drawawble
             if (drawable->GetType() != Skybox::GetTypeStatic())
             {
@@ -2202,7 +2204,7 @@ void View::QuantizeDirLightShadowCamera(Camera* shadowCamera, Light* light, cons
     }
 }
 
-void View::FindZone(Drawable* drawable, unsigned threadIndex)
+void View::FindZone(Drawable* drawable)
 {
     Vector3 center = drawable->GetWorldBoundingBox().Center();
     int bestPriority = M_MIN_INT;

+ 1 - 1
Engine/Graphics/View.h

@@ -151,7 +151,7 @@ private:
     /// Split directional or point light for shadow rendering.
     unsigned SplitLight(Light* light);
     /// Find and set a new zone for a drawable when it has moved.
-    void FindZone(Drawable* drawable, unsigned threadIndex);
+    void FindZone(Drawable* drawable);
     /// Return the drawable's zone, or camera zone if it has override mode enabled.
     Zone* GetZone(Drawable* drawable);
     /// Return the drawable's light mask, considering also its zone.