svn merge ^/trunk/blender -r48658:48674
authorCampbell Barton <ideasman42@gmail.com>
Fri, 6 Jul 2012 09:24:47 +0000 (09:24 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 6 Jul 2012 09:24:47 +0000 (09:24 +0000)
source/blender/bmesh/intern/bmesh_polygon.c
source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
source/blender/editors/space_node/drawnode.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c
source/gameengine/GameLogic/SCA_PropertySensor.cpp
source/gameengine/GameLogic/SCA_PropertySensor.h
source/gameengine/Rasterizer/RAS_2DFilterManager.cpp

index 094b5af9a0016fc20dc60d4e3ae8bd506d529d5d..6b9abfb3e2077495ecb41a34c7ee3dc1f953543c 100644 (file)
@@ -320,7 +320,14 @@ void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nvert
 
        angle = saacos(dot_v3v3(normal, up));
 
-       if (angle == 0.0) return;
+       if (angle < FLT_EPSILON)
+               return;
+
+       if (len_v3(axis) < FLT_EPSILON) {
+               axis[0] = 0.0f;
+               axis[1] = 1.0f;
+               axis[2] = 0.0f;
+       }
 
        axis_angle_to_quat(q, axis, (float)angle);
        quat_to_mat3(mat, q);
@@ -611,39 +618,42 @@ int BM_face_point_inside_test(BMFace *f, const float co[3])
        return crosses % 2 != 0;
 }
 
-static int bm_face_goodline(float const (*projectverts)[3], BMFace *f,
-                            int v1i, int v2i, int v3i,
-                            int UNUSED(nvert))
+static int bm_face_goodline(float const (*projectverts)[3], BMFace *f, int v1i, int v2i, int v3i)
 {
        BMLoop *l_iter;
        BMLoop *l_first;
-       float v1[3], v2[3], v3[3], pv1[3], pv2[3];
+       float v1[3], v2[3], v3[3], pv1[3];
        int i;
 
        copy_v3_v3(v1, projectverts[v1i]);
        copy_v3_v3(v2, projectverts[v2i]);
        copy_v3_v3(v3, projectverts[v3i]);
-       
+
+       /* v3 must be on the left side of [v1, v2] line, else we know [v1, v3] is outside of f! */
        if (testedgesidef(v1, v2, v3)) {
                return FALSE;
        }
 
-       //for (i = 0; i < nvert; i++) {
        l_iter = l_first = BM_FACE_FIRST_LOOP(f);
        do {
                i = BM_elem_index_get(l_iter->v);
-               if (i == v1i || i == v2i || i == v3i) {
+               copy_v3_v3(pv1, projectverts[i]);
+
+               if (ELEM3(i, v1i, v2i, v3i)) {
+#if 0
+                       printf("%d in (%d, %d, %d) tri (from indices!), continuing\n", i, v1i, v2i, v3i);
+#endif
                        continue;
                }
-               
-               copy_v3_v3(pv1, projectverts[BM_elem_index_get(l_iter->v)]);
-               copy_v3_v3(pv2, projectverts[BM_elem_index_get(l_iter->next->v)]);
-               
-               //if (linecrossesf(pv1, pv2, v1, v3)) return FALSE;
 
-               if (isect_point_tri_v2(pv1, v1, v2, v3) ||
-                   isect_point_tri_v2(pv2, v3, v2, v1))
+               if (isect_point_tri_v2(pv1, v1, v2, v3) || isect_point_tri_v2(pv1, v3, v2, v1))
                {
+#if 0
+                       if (isect_point_tri_v2(pv1, v1, v2, v3))
+                               printf("%d in (%d, %d, %d)\n", v3i, i, v1i, v2i);
+                       else
+                               printf("%d in (%d, %d, %d)\n", v1i, i, v3i, v2i);
+#endif
                        return FALSE;
                }
        } while ((l_iter = l_iter->next) != l_first);
@@ -653,15 +663,13 @@ static int bm_face_goodline(float const (*projectverts)[3], BMFace *f,
 /**
  * \brief Find Ear
  *
- * Used by tessellator to find
- * the next triangle to 'clip off'
- * of a polygon while tessellating.
+ * Used by tessellator to find the next triangle to 'clip off' of a polygon while tessellating.
  *
  * \param use_beauty Currently only applies to quads, can be extended later on.
  * \param abscoss Must be allocated by caller, and at least f->len length
  *        (allow to avoid allocating a new one for each tri!).
  */
-static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int use_beauty, float *abscoss)
+static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int use_beauty, float *abscoss)
 {
        BMLoop *bestear = NULL;
 
@@ -706,8 +714,8 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int
                /* Last check we do not get overlapping triangles
                 * (as much as possible, ther are some cases with no good solution!) */
                i4 = (i + 3) % 4;
-               if (!bm_face_goodline((float const (*)[3])verts, f, BM_elem_index_get(larr[i4]->v), BM_elem_index_get(larr[i]->v),
-                                     BM_elem_index_get(larr[i + 1]->v), nvert))
+               if (!bm_face_goodline((float const (*)[3])verts, f, BM_elem_index_get(larr[i4]->v),
+                                     BM_elem_index_get(larr[i]->v), BM_elem_index_get(larr[i + 1]->v)))
                {
                        i = !i;
                }
@@ -750,10 +758,13 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int
                        if (BM_edge_exists(v1, v3)) {
                                isear = FALSE;
                        }
-                       else if (!bm_face_goodline((float const (*)[3])verts, f,
-                                                  BM_elem_index_get(v1), BM_elem_index_get(v2), BM_elem_index_get(v3),
-                                                  nvert))
+                       else if (!bm_face_goodline((float const (*)[3])verts, f, BM_elem_index_get(v1),
+                                                  BM_elem_index_get(v2), BM_elem_index_get(v3)))
                        {
+#if 0
+                               printf("(%d, %d, %d) would not be a valid tri!\n",
+                                      BM_elem_index_get(v1), BM_elem_index_get(v2), BM_elem_index_get(v3));
+#endif
                                isear = FALSE;
                        }
 
@@ -836,9 +847,8 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int
  *
  * \note newedgeflag sets a flag layer flag, obviously not the header flag.
  */
-void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3],
-                         const short newedge_oflag, const short newface_oflag, BMFace **newfaces,
-                         const short use_beauty)
+void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], const short newedge_oflag,
+                         const short newface_oflag, BMFace **newfaces, const short use_beauty)
 {
        int i, done, nvert, nf_i = 0;
        BMLoop *newl;
@@ -847,7 +857,7 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3],
        float *abscoss = NULL;
        BLI_array_fixedstack_declare(abscoss, 16, f->len, "BM_face_triangulate: temp absolute cosines of face corners");
 
-       /* copy vertex coordinates to vertspace arra */
+       /* copy vertex coordinates to vertspace area */
        i = 0;
        l_iter = l_first = BM_FACE_FIRST_LOOP(f);
        do {
@@ -873,13 +883,11 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3],
        done = FALSE;
        while (!done && f->len > 3) {
                done = TRUE;
-               l_iter = find_ear(f, projectverts, nvert, use_beauty, abscoss);
+               l_iter = find_ear(f, projectverts, use_beauty, abscoss);
                if (l_iter) {
                        done = FALSE;
 /*                     printf("Subdividing face...\n");*/
-                       f = BM_face_split(bm, l_iter->f, l_iter->prev->v,
-                                         l_iter->next->v,
-                                         &newl, NULL, TRUE);
+                       f = BM_face_split(bm, l_iter->f, l_iter->prev->v, l_iter->next->v, &newl, NULL, TRUE);
 
                        if (UNLIKELY(!f)) {
                                fprintf(stderr, "%s: triangulator failed to split face! (bmesh internal error)\n", __func__);
@@ -890,7 +898,8 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3],
                        BMO_elem_flag_enable(bm, newl->e, newedge_oflag);
                        BMO_elem_flag_enable(bm, f, newface_oflag);
                        
-                       if (newfaces) newfaces[nf_i++] = f;
+                       if (newfaces)
+                               newfaces[nf_i++] = f;
 
 #if 0
                        l = f->loopbase;
@@ -933,7 +942,8 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3],
        BLI_array_fixedstack_free(abscoss);
 
        /* NULL-terminate */
-       if (newfaces) newfaces[nf_i] = NULL;
+       if (newfaces)
+               newfaces[nf_i] = NULL;
 }
 
 /**
index 0abf7efdcfa8591c36b452776eb86fccfe84bd5f..4627d20ab2f0b9135b28aba94d6ef3da9cbc6c21 100644 (file)
@@ -79,9 +79,8 @@ void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node)
 
 Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup, bool fast)
 {
-       Converter converter;
        Node *node;
-       node = converter.convert(b_node, fast);
+       node = Converter::convert(b_node, fast);
        node->setIsInActiveGroup(inActiveGroup);
        if (node != NULL) {
                addNode(nodes, node);
index d28e3ac5507871b872a76ac31a23afc76482161a..31485463f4f674795f9b231dd2b49bd9c04348ec 100644 (file)
@@ -2992,7 +2992,25 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
                        display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, &win->display_settings, &cache_handle);
 
                        if (display_buffer) {
-                               if (snode->flag & SNODE_SHOW_ALPHA) {
+                               if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) {
+                                       int ofs;
+
+                                       if      (snode->flag & SNODE_SHOW_R) ofs = 1;
+                                       else if (snode->flag & SNODE_SHOW_G) ofs = 2;
+                                       else                                 ofs = 3;
+
+                                       if (ENDIAN_ORDER == B_ENDIAN) {
+                                               ofs = 3 - ofs;
+                                       }
+
+                                       glPixelZoom(snode->zoom, snode->zoom);
+                                       /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
+
+                                       glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ((unsigned char *)ibuf->rect) + ofs);
+
+                                       glPixelZoom(1.0f, 1.0f);
+                               }
+                               else if (snode->flag & SNODE_SHOW_ALPHA) {
                                        glPixelZoom(snode->zoom, snode->zoom);
                                        /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
                                        if (ENDIAN_ORDER == B_ENDIAN)
index 6183300a813118b7a3fd2c87536431c78fd0e107..816187ad61d315bc6e94e47032fee03c8b0153fa 100644 (file)
@@ -883,6 +883,9 @@ typedef enum eSpaceNode_Flag {
 /*  SNODE_DISPGP         = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */
        SNODE_USE_ALPHA      = (1 << 3),
        SNODE_SHOW_ALPHA     = (1 << 4),
+       SNODE_SHOW_R         = (1 << 7),
+       SNODE_SHOW_G         = (1 << 8),
+       SNODE_SHOW_B         = (1 << 9),
        SNODE_AUTO_RENDER    = (1 << 5),
        SNODE_SHOW_HIGHLIGHT = (1 << 6),
 } eSpaceNode_Flag;
index e4f97fc871da882a544e4925402425d96a1537cb..ff0e44922a57ddec182ab94374ddda410fc59ff9 100644 (file)
@@ -2858,6 +2858,9 @@ static void rna_def_space_node(BlenderRNA *brna)
                {SNODE_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha",
                                  "Draw image with RGB colors and alpha transparency"},
                {SNODE_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel"},
+               {SNODE_SHOW_R, "RED", 0, "Red", ""},
+               {SNODE_SHOW_G, "GREEN", 0, "Green", ""},
+               {SNODE_SHOW_B, "BLUE", 0, "Blue", ""},
                {0, NULL, 0, NULL, NULL}
        };
 
index a92ffac412917bb76698c56e26c653bc1cf2ee1c..5dd4cc501ca570c48f3cf134881937ae42afda81 100644 (file)
@@ -57,8 +57,7 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
          m_checktype(checktype),
          m_checkpropval(propval),
          m_checkpropmaxval(propmaxval),
-         m_checkpropname(propname),
-         m_range_expr(NULL)
+         m_checkpropname(propname)
 {
        //CParser pars;
        //pars.SetContext(this->AddRef());
@@ -71,10 +70,6 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
        }
        orgprop->Release();
 
-       if (m_checktype==KX_PROPSENSOR_INTERVAL)
-       {
-               PrecalculateRangeExpression();
-       }
        Init();
 }
 
@@ -85,45 +80,12 @@ void SCA_PropertySensor::Init()
        m_reset = true;
 }
 
-void SCA_PropertySensor::PrecalculateRangeExpression()
-{
-               CParser pars;
-               //The context is needed to retrieve the property at runtime but it creates
-               //loop of references
-               pars.SetContext(this->AddRef());
-               STR_String checkstr = ("(" + m_checkpropval + " <= "  +
-                                      m_checkpropname + ") && ( " +
-                                      m_checkpropname + " <= " +
-                                      m_checkpropmaxval + ")");
-
-               m_range_expr = pars.ProcessText(checkstr);
-}
-
-// Forced deletion of precalculated range expression to break reference loop
-// Use this function when you know that you won't use the sensor anymore
-void SCA_PropertySensor::Delete()
-{
-       if (m_range_expr)
-       {
-               m_range_expr->Release();
-               m_range_expr = NULL;
-       }
-       Release();
-}
-
 CValue* SCA_PropertySensor::GetReplica()
 {
        SCA_PropertySensor* replica = new SCA_PropertySensor(*this);
        // m_range_expr must be recalculated on replica!
        replica->ProcessReplica();
        replica->Init();
-
-       replica->m_range_expr = NULL;
-       if (replica->m_checktype==KX_PROPSENSOR_INTERVAL)
-       {
-               replica->PrecalculateRangeExpression();
-       }
-       
        
        return replica;
 }
@@ -143,15 +105,6 @@ bool SCA_PropertySensor::IsPositiveTrigger()
 
 SCA_PropertySensor::~SCA_PropertySensor()
 {
-       //if (m_rightexpr)
-       //      m_rightexpr->Release();
-
-       if (m_range_expr)
-       {
-               m_range_expr->Release();
-               m_range_expr=NULL;
-       }
-
 }
 
 
@@ -241,34 +194,13 @@ bool      SCA_PropertySensor::CheckPropertyCondition()
                }
        case KX_PROPSENSOR_INTERVAL:
                {
-                       //CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
-                       //if (orgprop)
-                       //{
-                               if (m_range_expr)
-                               {
-                                       CValue* vallie = m_range_expr->Calculate();
-                                       if (vallie)
-                                       {
-                                               const STR_String& errtext = vallie->GetText();
-                                               if (&errtext == &CBoolValue::sTrueString)
-                                               {
-                                                       result = true;
-                                               } else
-                                               {
-                                                       if (vallie->IsError())
-                                                       {
-                                                               //printf (errtext.ReadPtr());
-                                                       } 
-                                               }
-                                               
-                                               vallie->Release();
-                                       }
-                               }
+                       CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
+                       if (!orgprop->IsError())
+                       {
+                               float val = orgprop->GetText().ToFloat(), min = m_checkpropval.ToFloat(), max = m_checkpropmaxval.ToFloat();
 
-                               
-                       //}
-                       
-               //cout << " \nSens:Prop:interval!"; /* need implementation here!!! */
+                               result = (min <= val) && (val <= max);
+                       }
 
                break;
                }
@@ -326,28 +258,6 @@ int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*)
        return 0;
 }
 
-int SCA_PropertySensor::validValueForIntervalProperty(void *self, const PyAttributeDef*)
-{
-       SCA_PropertySensor*     sensor = reinterpret_cast<SCA_PropertySensor*>(self);
-
-       if (sensor->m_checktype==KX_PROPSENSOR_INTERVAL)
-       {
-               sensor->PrecalculateRangeExpression();
-       }
-       return 0;
-}
-
-int SCA_PropertySensor::modeChange(void *self, const PyAttributeDef* attrdef)
-{
-       SCA_PropertySensor*     sensor = reinterpret_cast<SCA_PropertySensor*>(self);
-
-       if (sensor->m_checktype==KX_PROPSENSOR_INTERVAL)
-       {
-               sensor->PrecalculateRangeExpression();
-       }
-       return 0;
-}
-
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_PropertySensor::Type = {
        PyVarObject_HEAD_INIT(NULL, 0)
@@ -376,11 +286,11 @@ PyMethodDef SCA_PropertySensor::Methods[] = {
 };
 
 PyAttributeDef SCA_PropertySensor::Attributes[] = {
-       KX_PYATTRIBUTE_INT_RW_CHECK("mode",KX_PROPSENSOR_NODEF,KX_PROPSENSOR_MAX-1,false,SCA_PropertySensor,m_checktype,modeChange),
+       KX_PYATTRIBUTE_INT_RW("mode",KX_PROPSENSOR_NODEF,KX_PROPSENSOR_MAX-1,false,SCA_PropertySensor,m_checktype),
        KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,MAX_PROP_NAME,false,SCA_PropertySensor,m_checkpropname,CheckProperty),
        KX_PYATTRIBUTE_STRING_RW_CHECK("value",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty),
-       KX_PYATTRIBUTE_STRING_RW_CHECK("min",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForIntervalProperty),
-       KX_PYATTRIBUTE_STRING_RW_CHECK("max",0,100,false,SCA_PropertySensor,m_checkpropmaxval,validValueForIntervalProperty),
+       KX_PYATTRIBUTE_STRING_RW_CHECK("min",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty),
+       KX_PYATTRIBUTE_STRING_RW_CHECK("max",0,100,false,SCA_PropertySensor,m_checkpropmaxval,validValueForProperty),
        { NULL }        //Sentinel
 };
 
index ca942076efaceafb0391bf26f7e78ee70c3e46b8..fee03dcf4c0be1ac121482666e8cb8acaeffe42a 100644 (file)
@@ -46,7 +46,6 @@ class SCA_PropertySensor : public SCA_ISensor
        STR_String              m_previoustext;
        bool                    m_lastresult;
        bool                    m_recentresult;
-       CExpression*    m_range_expr;
 
  protected:
 
@@ -69,16 +68,10 @@ public:
                                          const STR_String& propval,
                                          const STR_String& propmaxval,
                                          KX_PROPSENSOR_TYPE checktype);
-       
-       /** 
-        *  For property sensor, it is used to release the pre-calculated expression
-        *  so that self references are removed before the sensor itself is released
-        */
-       virtual void Delete();
+
        virtual ~SCA_PropertySensor();
        virtual CValue* GetReplica();
        virtual void Init();
-       void    PrecalculateRangeExpression();
        bool    CheckPropertyCondition();
 
        virtual bool Evaluate();
@@ -96,16 +89,6 @@ public:
         */
        static int validValueForProperty(void* self, const PyAttributeDef*);
 
-       /**
-        * Test whether this is a sensible value for interval (type check) and updates Range Expression
-        */
-       static int validValueForIntervalProperty(void* self, const PyAttributeDef*);
-
-       /**
-        * Test if the new mode is interval. If positive updates Range Expression
-        */
-       static int modeChange(void* self, const PyAttributeDef* attrdef);
-
 #endif
 };
 
index 43acb9e5f8a4ddaaffd96845a65d9171cd32b839..cf6ea6534020366980a1edaadb37af539aa663b2 100644 (file)
@@ -431,7 +431,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas)
        // reverting to texunit 0, without this we get bug [#28462]
        glActiveTextureARB(GL_TEXTURE0);
 
-       glViewport(rect.GetLeft(), rect.GetBottom(), texturewidth, textureheight);
+       glViewport(rect.GetLeft(), rect.GetBottom(), rect.GetWidth()+1, rect.GetHeight()+1);
 
        glDisable(GL_DEPTH_TEST);
        // in case the previous material was wire