Merging r47215 through r47226 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 30 May 2012 14:33:24 +0000 (14:33 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 30 May 2012 14:33:24 +0000 (14:33 +0000)
source/blender/blenkernel/intern/bvhutils.c
source/blender/blenlib/BLI_kdopbvh.h
source/blender/compositor/operations/COM_CompositorOperation.cpp

index 24583c124e684d69c7446cece3e22a5c89f99a0c..752bdab2c00773411e91f271528fbfcc5b4aac26 100644 (file)
@@ -383,6 +383,9 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3
                        nearest->dist = dist;
                        copy_v3_v3(nearest->co, nearest_tmp);
                        normal_tri_v3(nearest->no, t0, t1, t2);
+
+                       if (t1 == vert[face->v3].co)
+                               nearest->flags |= BVH_ONQUAD;
                }
 
                t1 = t2;
@@ -420,6 +423,9 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
                        madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist);
 
                        normal_tri_v3(hit->no, t0, t1, t2);
+
+                       if (t1 == vert[face->v3].co)
+                               hit->flags |= BVH_ONQUAD;
                }
 
                t1 = t2;
index 7041c122ff9e36703af215ec20db2cac26e4f610..5ec8247c03a2897f4fdf71ef4ded45f579dc761e 100644 (file)
@@ -49,11 +49,15 @@ typedef struct BVHTreeOverlap {
        int indexB;
 } BVHTreeOverlap;
 
+/* flags */
+#define BVH_ONQUAD (1<<0)
+
 typedef struct BVHTreeNearest {
        int index;          /* the index of the nearest found (untouched if none is found within a dist radius from the given coordinates) */
        float co[3];        /* nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */
        float no[3];        /* normal at nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */
        float dist;         /* squared distance to search arround */
+       int flags;
 } BVHTreeNearest;
 
 typedef struct BVHTreeRay {
@@ -67,6 +71,7 @@ typedef struct BVHTreeRayHit {
        float co[3];        /* coordinates of the hit point */
        float no[3];        /* normal on hit point */
        float dist;         /* distance to the hit point */
+       int flags;
 } BVHTreeRayHit;
 
 /* callback must update nearest in case it finds a nearest result */
index 5a919965ede33c6f5e08fb1ac429f21684a64fda..09e172f395e237f872d99e26cdd4e9947ae34d86 100644 (file)
@@ -68,6 +68,10 @@ void CompositorOperation::deinitExecution()
                                MEM_freeN(rr->rectf);
                        }
                        rr->rectf = outputBuffer;
+               } else {
+                       if (this->outputBuffer) {
+                               MEM_freeN(this->outputBuffer);
+                       }
                }
                if (re) {
                        RE_ReleaseResult(re);