dmuratshin 9 years ago
parent
commit
25e44f62c7

+ 16 - 4
oxygine/src/dev_tools/TreeInspectorPreview.cpp

@@ -72,7 +72,7 @@ namespace oxygine
 
 
         RenderState rs;
         RenderState rs;
         rs.material = &mat;
         rs.material = &mat;
-        RectF clip(0,0,getStage()->getWidth(), getStage()->getHeight());
+        RectF clip = RectF::huge();
         rs.clip = &clip;
         rs.clip = &clip;
         renderer.begin(0);
         renderer.begin(0);
         if (child)
         if (child)
@@ -253,6 +253,7 @@ namespace oxygine
     void VideoDriverCache::setUniform(const char* id, const Matrix* v)
     void VideoDriverCache::setUniform(const char* id, const Matrix* v)
     {
     {
         addUni(id, cached_batch::uni::uni_matrix, v, sizeof(*v));
         addUni(id, cached_batch::uni::uni_matrix, v, sizeof(*v));
+        wvp = *v;
     }
     }
 
 
     void VideoDriverCache::setUniform(const char* id, const Vector2* v, int num)
     void VideoDriverCache::setUniform(const char* id, const Vector2* v, int num)
@@ -295,14 +296,20 @@ namespace oxygine
 
 
     void VideoDriverCache::nextBatch()
     void VideoDriverCache::nextBatch()
     {
     {
-        const vertexPCT2* v = (const vertexPCT2*)(&current().vertices.front());
+        vertexPCT2* v = (vertexPCT2*)(&current().vertices.front());
 
 
         size_t num = current().vertices.size() / current().vdecl->size;
         size_t num = current().vertices.size() / current().vdecl->size;
         
         
 
 
         for (size_t i = 0; i != num; ++i)
         for (size_t i = 0; i != num; ++i)
         {
         {
-            v = (const vertexPCT2*)(&current().vertices.front() + current().vdecl->size * i);
+            v = (vertexPCT2*)(&current().vertices.front() + current().vdecl->size * i);
+            Vector4 p(v->x, v->y, v->z, 1.0f);
+            p = wvp.transformVec4(p);
+            p.x /= p.w;
+            p.y /= p.w;
+            v->x = p.x * getStage()->getWidth();
+            v->y = getStage()->getHeight() - p.y * getStage()->getHeight();
             RectF f(v->x, v->y, 0, 0);
             RectF f(v->x, v->y, 0, 0);
             _bounds.unite(f);
             _bounds.unite(f);
         }
         }
@@ -390,7 +397,12 @@ namespace oxygine
                 case cached_batch::uni::uni_int:
                 case cached_batch::uni::uni_int:
                     instance->setUniformInt(uni.id.c_str(), *((const int*)&uni.data[0])); break;
                     instance->setUniformInt(uni.id.c_str(), *((const int*)&uni.data[0])); break;
                 case cached_batch::uni::uni_matrix:
                 case cached_batch::uni::uni_matrix:
-                    instance->setUniform(uni.id.c_str(), ((const Matrix*)&uni.data[0])); break;
+                {
+                    Matrix m = STDRenderer::instance->getViewProjection();
+                    //instance->setUniform(uni.id.c_str(), ((const Matrix*)&uni.data[0])); 
+                    instance->setUniform(uni.id.c_str(), &m);
+                    break;
+                }
                 case cached_batch::uni::uni_vec2:
                 case cached_batch::uni::uni_vec2:
                     instance->setUniform(uni.id.c_str(), ((const Vector2*)&uni.data[0]), uni.data.size() / sizeof(Vector2)); break;
                     instance->setUniform(uni.id.c_str(), ((const Vector2*)&uni.data[0]), uni.data.size() / sizeof(Vector2)); break;
                 case cached_batch::uni::uni_vec3:
                 case cached_batch::uni::uni_vec3:

+ 1 - 0
oxygine/src/dev_tools/TreeInspectorPreview.h

@@ -116,6 +116,7 @@ namespace oxygine
         void transform(const AffineTransform& m);
         void transform(const AffineTransform& m);
 
 
         spNativeTexture rt;
         spNativeTexture rt;
+        Matrix wvp;
     };
     };
 
 
 
 

+ 13 - 4
oxygine/src/math/Rect.h

@@ -20,10 +20,19 @@ namespace oxygine
         static const RectT invalidated()
         static const RectT invalidated()
         {
         {
             return RectT(
             return RectT(
-                       std::numeric_limits<T>::max() / 2,
-                       std::numeric_limits<T>::max() / 2,
-                       -std::numeric_limits<T>::max(),
-                       -std::numeric_limits<T>::max());
+                std::numeric_limits<T>::max() / 2,
+                std::numeric_limits<T>::max() / 2,
+                -std::numeric_limits<T>::max(),
+                -std::numeric_limits<T>::max());
+        }
+
+        static const RectT huge()
+        {
+            return RectT(
+                -std::numeric_limits<T>::max() / 2,
+                -std::numeric_limits<T>::max() / 2,
+                std::numeric_limits<T>::max(),
+                std::numeric_limits<T>::max());
         }
         }
 
 
         bool operator == (const RectT& r) const
         bool operator == (const RectT& r) const