svn merge ^/trunk/blender -r47272:47306
authorCampbell Barton <ideasman42@gmail.com>
Fri, 1 Jun 2012 05:50:17 +0000 (05:50 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 1 Jun 2012 05:50:17 +0000 (05:50 +0000)
36 files changed:
intern/cycles/kernel/kernel_textures.h
release/scripts/modules/bpy_extras/keyconfig_utils.py
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/material.c
source/blender/blenlib/BLI_lasso.h
source/blender/blenlib/intern/path_util.c
source/blender/compositor/CMakeLists.txt
source/blender/compositor/intern/COM_WorkScheduler.cpp
source/blender/compositor/nodes/COM_DilateErodeNode.cpp
source/blender/compositor/nodes/COM_GlareNode.cpp
source/blender/compositor/operations/COM_CompositorOperation.cpp
source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
source/blender/compositor/operations/COM_GlareBaseOperation.h
source/blender/compositor/operations/COM_GlareGhostOperation.cpp [new file with mode: 0644]
source/blender/compositor/operations/COM_GlareGhostOperation.h [moved from source/blender/compositor/operations/COM_LensGlowImageOperation.h with 61% similarity]
source/blender/compositor/operations/COM_LensGhostOperation.cpp [deleted file]
source/blender/compositor/operations/COM_LensGhostOperation.h [deleted file]
source/blender/compositor/operations/COM_LensGlowImageOperation.cpp [deleted file]
source/blender/compositor/operations/COM_LensGlowOperation.cpp [deleted file]
source/blender/compositor/operations/COM_LensGlowOperation.h [deleted file]
source/blender/compositor/operations/COM_MathBaseOperation.cpp
source/blender/compositor/operations/COM_MathBaseOperation.h
source/blender/compositor/operations/COM_MovieDistortionOperation.h
source/blender/editors/include/ED_view3d.h
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/object/object_add.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/transform/transform.c
source/blender/makesrna/intern/rna_image_api.c
source/gameengine/Converter/BL_SkinDeformer.cpp
source/gameengine/Converter/BL_SkinDeformer.h

index 4ab2574c8ad6f487353ffe8f14b2d10132adae55..482f886df3e863dc920fa191bf567bb31a3769a7 100644 (file)
@@ -1,3 +1,20 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
 
 #ifndef KERNEL_TEX
 #define KERNEL_TEX(type, ttype, name)
index 306371ea6f5819d799fa1ef1eaa9720e60267e27..287cd81eff26be25d458f089ebca764c1ba49557 100644 (file)
@@ -146,7 +146,7 @@ def _export_properties(prefix, properties, lines=None):
         return result
 
     for pname in properties.bl_rna.properties.keys():
-        if pname != "rna_type" and not properties.is_property_hidden(pname):
+        if pname != "rna_type":
             value = getattr(properties, pname)
             if isinstance(value, OperatorProperties):
                 _export_properties(prefix + "." + pname, value, lines)
index 5774dd7b1bacd28ed264b09deb0dbd8feebf4067..7130776d05aa084866297c63fe91b085c0dd8118 100644 (file)
@@ -1054,10 +1054,10 @@ static void calc_weightpaint_vert_color(
        }
 
        if (make_black) { /* TODO, theme color */
-               r_col[3] = 0;
+               r_col[3] = 255;
                r_col[2] = 0;
                r_col[1] = 0;
-               r_col[0] = 255;
+               r_col[0] = 0;
        }
        else {
                CLAMP(input, 0.0f, 1.0f);
index adf268d4d02f74790c82e3fb77a4df081bf34e4e..48d629a29440cdfc6f17b98b6d916f89e6ad71ad 100644 (file)
@@ -840,7 +840,7 @@ void assign_matarar(struct Object *ob, struct Material ***matar, short totcol)
        int actcol_orig = ob->actcol;
        short i;
 
-       while (object_remove_material_slot(ob)) {};
+       while (object_remove_material_slot(ob)) {}
 
        /* now we have the right number of slots */
        for (i = 0; i < totcol; i++)
index 2360173c3b8c8aaeaa16a35b01fba429073dc975..85a000b000c195a023a2466931a5136af5e02ccf 100644 (file)
@@ -35,7 +35,7 @@
 struct rcti;
 
 void BLI_lasso_boundbox(struct rcti *rect, int mcords[][2], short moves);
-int  BLI_lasso_is_point_inside(int mcords[][2], short moves, int sx, int sy, const int error_value);
+int  BLI_lasso_is_point_inside(int mcords[][2], short moves, const int sx, const int sy, const int error_value);
 int  BLI_lasso_is_edge_inside(int mcords[][2], short moves, int x0, int y0, int x1, int y1, const int error_value);
 
 #endif
index 3c7e66f280a4ec7118190fd3f539902829536e3d..1bda7b5ee7e57ff62fe03edefa8c829c994175ed 100644 (file)
@@ -98,7 +98,7 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu
        if (lslash)
                lenlslash = (int)(lslash - string);
 
-       while (len > lenlslash && string[--len] != '.') {};
+       while (len > lenlslash && string[--len] != '.') {}
        if (len == lenlslash && string[len] != '.') len = len2;
 
        for (i = len - 1; i >= lenlslash; i--) {
index 3e29583756f968029a05a79dd6ca75de726b786a..6abc74700d6e56b9b67b2e75f05e629168854c27 100644 (file)
@@ -189,10 +189,6 @@ set(SRC
        operations/COM_CropOperation.cpp
        operations/COM_CropOperation.h
 
-       operations/COM_LensGlowOperation.cpp
-       operations/COM_LensGlowOperation.h
-       operations/COM_LensGhostOperation.cpp
-       operations/COM_LensGhostOperation.h
        nodes/COM_TransformNode.cpp
        nodes/COM_TransformNode.h
        nodes/COM_Stabilize2dNode.cpp
@@ -388,16 +384,14 @@ operations/COM_ColorSpillOperation.h
                operations/COM_RenderLayersCyclesOperation.cpp
                operations/COM_RenderLayersCyclesOperation.h
 
-operations/COM_ImageOperation.cpp
-operations/COM_ImageOperation.h
-operations/COM_MultilayerImageOperation.cpp
-operations/COM_MultilayerImageOperation.h
-operations/COM_TextureOperation.cpp
-operations/COM_TextureOperation.h
-operations/COM_BokehImageOperation.cpp
-operations/COM_BokehImageOperation.h
-operations/COM_LensGlowImageOperation.cpp
-operations/COM_LensGlowImageOperation.h
+       operations/COM_ImageOperation.cpp
+       operations/COM_ImageOperation.h
+       operations/COM_MultilayerImageOperation.cpp
+       operations/COM_MultilayerImageOperation.h
+       operations/COM_TextureOperation.cpp
+       operations/COM_TextureOperation.h
+       operations/COM_BokehImageOperation.cpp
+       operations/COM_BokehImageOperation.h
 
 
                operations/COM_SocketProxyOperation.h
@@ -589,6 +583,8 @@ operations/COM_ConvertDepthToRadiusOperation.cpp
        operations/COM_GlareSimpleStarOperation.h
        operations/COM_GlareStreaksOperation.cpp
        operations/COM_GlareStreaksOperation.h
+       operations/COM_GlareGhostOperation.cpp
+       operations/COM_GlareGhostOperation.h
        operations/COM_SetSamplerOperation.cpp
        operations/COM_SetSamplerOperation.h
 
index 7d709dd919c19cfeb36f3180e8f39ae8f7665439..80b91b2364c0ff6e341c634b87b0f509b6e35fc9 100644 (file)
@@ -275,7 +275,8 @@ void WorkScheduler::initialize()
                                printf("%s", build_log);
                                delete build_log;
                                
-                       } else {
+                       }
+                       else {
                                unsigned int indexDevices;
                                for (indexDevices = 0 ; indexDevices < totalNumberOfDevices ; indexDevices ++) {
                                        cl_device_id device = cldevices[indexDevices];
index b722e40a87570471a574cfd028542a1ae4be29bc..477919568653c621743ac92a879f4b2c4630bf8f 100644 (file)
@@ -52,7 +52,8 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
                        this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
                }
                graph->addOperation(operation);
-       } else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) {
+       }
+       else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) {
                if (editorNode->custom2 > 0) {
                        DilateDistanceOperation * operation = new DilateDistanceOperation();
                        operation->setDistance(editorNode->custom2);
@@ -67,7 +68,8 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
                        this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
                        graph->addOperation(operation);
                }
-       } else {
+       }
+       else {
                if (editorNode->custom2 > 0) {
                        DilateStepOperation * operation = new DilateStepOperation();
                        operation->setIterations(editorNode->custom2);
index 9382e726d76504574bb2cfca5ff75829cb85e3f0..dc367040c9a7a0bf45cab618ae1a296d0781c131 100644 (file)
@@ -29,6 +29,7 @@
 #include "COM_SetValueOperation.h"
 #include "COM_MixBlendOperation.h"
 #include "COM_FastGaussianBlurOperation.h"
+#include "COM_GlareGhostOperation.h"
 
 GlareNode::GlareNode(bNode *editorNode): Node(editorNode)
 {
@@ -42,6 +43,30 @@ void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext *
        switch (glare->type) {
        
        default:
+       case 3:
+               {
+                       GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+                       GlareGhostOperation * glareoperation = new GlareGhostOperation();
+                       SetValueOperation * mixvalueoperation = new SetValueOperation();
+                       MixBlendOperation * mixoperation = new MixBlendOperation();
+       
+                       this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
+                       addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
+                       addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
+                       addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
+                       addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
+                       this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+       
+                       thresholdOperation->setThreshold(glare->threshold);
+                       glareoperation->setGlareSettings(glare);
+                       mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
+                       mixoperation->setResolutionInputSocketIndex(1);
+       
+                       system->addOperation(glareoperation);
+                       system->addOperation(thresholdOperation);
+                       system->addOperation(mixvalueoperation);
+                       system->addOperation(mixoperation);
+               }
        case 2: // streaks
                {
                        GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
index 09e172f395e237f872d99e26cdd4e9947ae34d86..d75cb39325fa9a5dd6e6e25009557f331eaf8020 100644 (file)
@@ -68,7 +68,8 @@ void CompositorOperation::deinitExecution()
                                MEM_freeN(rr->rectf);
                        }
                        rr->rectf = outputBuffer;
-               } else {
+               }
+               else {
                        if (this->outputBuffer) {
                                MEM_freeN(this->outputBuffer);
                        }
index cf36e7f6ebe97855e5dbe350e16121ab1b44a56d..6c3e373472bbf2a451b2027fb8e7daeca87d32ad 100644 (file)
@@ -36,7 +36,7 @@ public:
        bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
        void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
        
-       void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy);
+       static void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy);
        void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
        void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
        
index e06244d3cddc3424a682ab302f36865b50980561..2fa8afc9c4c5be6426491bd7a3f98de9af484ad6 100644 (file)
 #include "COM_NodeOperation.h"
 #include "DNA_node_types.h"
 
+
+/* utility functions used by glare, tonemap and lens distortion */
+/* soms macros for color handling */
+typedef float fRGB[4];
+/* clear color */
+#define fRGB_clear(c) { c[0]=c[1]=c[2]=0.f; } (void)0
+/* copy c2 to c1 */
+#define fRGB_copy(c1, c2) { c1[0]=c2[0];  c1[1]=c2[1];  c1[2]=c2[2]; c1[3]=c2[3]; } (void)0
+/* add c2 to c1 */
+#define fRGB_add(c1, c2) { c1[0]+=c2[0];  c1[1]+=c2[1];  c1[2]+=c2[2]; } (void)0
+/* subtract c2 from c1 */
+#define fRGB_sub(c1, c2) { c1[0]-=c2[0];  c1[1]-=c2[1];  c1[2]-=c2[2]; } (void)0
+/* multiply c by float value s */
+#define fRGB_mult(c, s) { c[0]*=s;  c[1]*=s;  c[2]*=s; } (void)0
+/* multiply c2 by s and add to c1 */
+#define fRGB_madd(c1, c2, s) { c1[0]+=c2[0]*s;  c1[1]+=c2[1]*s;  c1[2]+=c2[2]*s; } (void)0
+/* multiply c2 by color c1 */
+#define fRGB_colormult(c, cs) { c[0]*=cs[0];  c[1]*=cs[1];  c[2]*=cs[2]; } (void)0
+/* multiply c2 by color c3 and add to c1 */
+#define fRGB_colormadd(c1, c2, c3) { c1[0]+=c2[0]*c3[0];  c1[1]+=c2[1]*c3[1];  c1[2]+=c2[2]*c3[2]; } (void)0
+/* multiply c2 by color rgb, rgb as separate arguments */
+#define fRGB_rgbmult(c, r, g, b) { c[0]*=(r);  c[1]*=(g);  c[2]*=(b); } (void)0
+/* swap colors c1 & c2 */
+#define fRGB_swap(c1, c2) { float _t=c1[0];  c1[0]=c2[0];  c2[0]=_t;\
+                                  _t=c1[1];  c1[1]=c2[1];  c2[1]=_t;\
+                                  _t=c1[2];  c1[2]=c2[2];  c2[2]=_t;\
+                                  _t=c1[3];  c1[3]=c2[3];  c3[3]=_t;\
+                          } (void)0
+
+
 class GlareBaseOperation : public NodeOperation {
 private:
        /**
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
new file mode 100644 (file)
index 0000000..c5b1d6c
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor: 
+ *             Jeroen Bakker 
+ *             Monique Dewanchand
+ */
+
+#include "COM_GlareGhostOperation.h"
+#include "BLI_math.h"
+#include "COM_FastGaussianBlurOperation.h"
+
+static float smoothMask(float x, float y)
+{
+       float t;
+       x = 2.f*x - 1.f, y = 2.f*y - 1.f;
+       if ((t = 1.f - sqrtf(x*x + y*y)) <= 0.f) return 0.f;
+       return t;
+}
+
+
+void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
+{
+       const int qt = 1 << settings->quality;
+       const float s1 = 4.f/(float)qt, s2 = 2.f*s1;
+       int x, y, n, p, np;
+       fRGB c, tc, cm[64];
+       float sc, isc, u, v, sm, s, t, ofs, scalef[64];
+       const float cmo = 1.f - settings->colmod;
+
+       MemoryBuffer *gbuf = inputTile->duplicate();
+       MemoryBuffer *tbuf1 = inputTile->duplicate();
+
+       FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 0, 3);
+       FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
+       FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
+       
+       MemoryBuffer *tbuf2 = tbuf1->duplicate();
+       
+       FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
+       FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
+       FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
+       
+       if (settings->iter & 1) ofs = 0.5f; else ofs = 0.f;
+       for (x=0; x<(settings->iter*4); x++) {
+               y = x & 3;
+               cm[x][0] = cm[x][1] = cm[x][2] = 1;
+               if (y==1) fRGB_rgbmult(cm[x], 1.f, cmo, cmo);
+               if (y==2) fRGB_rgbmult(cm[x], cmo, cmo, 1.f);
+               if (y==3) fRGB_rgbmult(cm[x], cmo, 1.f, cmo);
+               scalef[x] = 2.1f*(1.f-(x+ofs)/(float)(settings->iter*4));
+               if (x & 1) scalef[x] = -0.99f/scalef[x];
+       }
+
+       sc = 2.13;
+       isc = -0.97;
+       for (y=0; y<gbuf->getHeight(); y++) {
+               v = (float)(y+0.5f) / (float)gbuf->getHeight();
+               for (x=0; x<gbuf->getWidth(); x++) {
+                       u = (float)(x+0.5f) / (float)gbuf->getWidth();
+                       s = (u-0.5f)*sc + 0.5f, t = (v-0.5f)*sc + 0.5f;
+                       tbuf1->read(c, s*gbuf->getWidth(), t*gbuf->getHeight());
+                       sm = smoothMask(s, t);
+                       fRGB_mult(c, sm);
+                       s = (u-0.5f)*isc + 0.5f, t = (v-0.5f)*isc + 0.5f;
+                       tbuf2->read(tc, s*gbuf->getWidth()-0.5f, t*gbuf->getHeight()-0.5f);
+                       sm = smoothMask(s, t);
+                       fRGB_madd(c, tc, sm);
+                       
+                       gbuf->writePixel(x, y, c);
+               }
+       }
+
+       memset(tbuf1->getBuffer(), 0, tbuf1->getWidth()*tbuf1->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+       for (n=1; n<settings->iter; n++) {
+               for (y=0; y<gbuf->getHeight(); y++) {
+                       v = (float)(y+0.5f) / (float)gbuf->getHeight();
+                       for (x=0; x<gbuf->getWidth(); x++) {
+                               u = (float)(x+0.5f) / (float)gbuf->getWidth();
+                               tc[0] = tc[1] = tc[2] = 0.f;
+                               for (p=0;p<4;p++) {
+                                       np = (n<<2) + p;
+                                       s = (u-0.5f)*scalef[np] + 0.5f;
+                                       t = (v-0.5f)*scalef[np] + 0.5f;
+                                       gbuf->read(c, s*gbuf->getWidth() - 0.5f, t*gbuf->getHeight() - 0.5f);
+                                       fRGB_colormult(c, cm[np]);
+                                       sm = smoothMask(s, t)*0.25f;
+                                       fRGB_madd(tc, c, sm);
+                               }
+                               tbuf1->writePixel(x, y, tc);
+                       }
+               }
+               memcpy(gbuf->getBuffer(), tbuf1->getBuffer(), tbuf1->getWidth()*tbuf1->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+       }
+       memcpy(data, gbuf->getBuffer(), gbuf->getWidth()*gbuf->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+       
+       delete gbuf;
+       delete tbuf1;
+       delete tbuf2;
+}
similarity index 61%
rename from source/blender/compositor/operations/COM_LensGlowImageOperation.h
rename to source/blender/compositor/operations/COM_GlareGhostOperation.h
index 424b4d4fc3d1f834efcc8737bdfac4b4968e85a4..48b5e8986a981eb42902f90172fc5e8d9dc43b01 100644 (file)
  *             Monique Dewanchand
  */
 
-#ifndef _COM_LensGlowImageOperation_h
-#define _COM_LensGlowImageOperation_h
+#ifndef _COM_GlareGhostOperation_h
+#define _COM_GlareGhostOperation_h
 #include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+#include "COM_GlareBaseOperation.h"
 
-
-class LensGlowImageOperation : public NodeOperation {
-private:
-       float scale;
-
+class GlareGhostOperation : public GlareBaseOperation {
 public:
-       LensGlowImageOperation();
-
-       /**
-         * the inner loop of this program
-         */
-       void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
-       
-       /**
-         * Initialize the execution
-         */
-       void initExecution();
-       
-       /**
-         * Deinitialize the execution
-         */
-       void deinitExecution();
-       
-       void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+       GlareGhostOperation() : GlareBaseOperation() {}
+protected:
+       void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
 };
 #endif
diff --git a/source/blender/compositor/operations/COM_LensGhostOperation.cpp b/source/blender/compositor/operations/COM_LensGhostOperation.cpp
deleted file mode 100644 (file)
index bbf6df6..0000000
+++ /dev/null
@@ -1,815 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor: 
- *             Jeroen Bakker 
- *             Monique Dewanchand
- */
-
-#include "COM_LensGhostOperation.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#define MAX_STEP 256
-class Ray {
-public:
-       float position[3];
-       float direction[3];
-       float uv[2];
-       double wavelength;
-       float intensity;
-       bool valid;
-       void copyFrom(Ray *other) {
-               copy_v3_v3(position, other->position);
-               copy_v3_v3(direction, other->direction);
-               copy_v2_v2(uv, other->uv);
-               wavelength = other->wavelength;
-               intensity = other->intensity;
-               this->valid = other->valid;
-       }
-};
-
-class Intersection {
-public:
-       float position[3];
-       float normal[3];
-       double theta;
-       bool hit;
-       bool inverted;
-};
-
-class LensInterface {
-public:
-       float position[3];
-       float radius;
-       float nominalRadius;
-       double refraction1;
-       double refraction2;
-       double refraction3;
-       float thicknessCoathing;
-       virtual bool isFlat() = 0;
-       virtual void intersect(Intersection *result, Ray *ray) = 0;
-};
-
-class FlatInterface: public LensInterface {
-public:
-       bool isFlat() {return true;}
-       FlatInterface(float positionX, float positionY, float positionZ, float radius) {
-               this->position[0] = positionX;
-               this->position[1] = positionY;
-               this->position[2] = positionZ;
-               this->radius = radius;
-               this->nominalRadius = radius;
-               this->refraction1 = 1.0f;
-               this->refraction2 = 1.0f;
-               this->refraction3 = 1.0f;
-               this->thicknessCoathing = 0.0f;
-
-       }
-       void intersect(Intersection *result, Ray *ray) {
-               const float dz = this->position[2]-ray->position[2];
-               result->position[0] = ray->position[0] + ray->direction[0]*(dz)/ray->direction[2];
-               result->position[1] = ray->position[1] + ray->direction[1]*(dz)/ray->direction[2];
-               result->position[2] = ray->position[2] + ray->direction[2]*(dz)/ray->direction[2];
-               result->normal[0] = 0.0f;
-               result->normal[1] = 0.0f;
-               result->normal[2] = ray->direction[2]>0?-1.0f:1.0f;
-               result->theta = 0.0f;
-//             result->hit = this->nominalRadius>maxf(fabs(result->position[0]), fabs(result->position[1]));
-               result->hit = true;
-               result->inverted = false;
-       }
-};
-
-class SphereInterface: public LensInterface {
-public:
-       SphereInterface(float positionX, float positionY, float positionZ, float radius, float nominalRadius, float n0, float n2, float coatingPhase) {
-               this->position[0] = positionX;
-               this->position[1] = positionY;
-               this->position[2] = positionZ;
-               this->radius = radius;
-               this->nominalRadius = nominalRadius;
-               this->refraction1 = n0;
-               this->refraction3 = n2;
-               this->refraction2 = maxf(sqrtf(n0*n2), 1.38);
-
-               this->thicknessCoathing = coatingPhase/4/this->refraction2;
-       }
-       bool isFlat() {return false;}
-       void intersect(Intersection *result, Ray *ray) {
-               float delta[3] ={ray->position[0] - this->position[0],
-                       ray->position[1] - this->position[1],
-                       ray->position[2] - this->position[2]};
-               float b = dot_v3v3(delta, ray->direction);
-               float c = dot_v3v3(delta, delta) - this->radius*this->radius;
-               float b2c = b*b-c;
-               if (b2c < 0) {
-                       result->hit = false;
-               }
-               else {
-                       float sgn = (this->radius*ray->direction[2])>0?1.0f:-1.0f;
-                       float t = sqrtf(b2c)*sgn-b;
-                       result->position[0] = ray->direction[0]*t+ray->position[0];
-                       result->position[1] = ray->direction[1]*t+ray->position[1];
-                       result->position[2] = ray->direction[2]*t+ray->position[2];
-
-                       float p[3] = {
-                               result->position[0] - this->position[0],
-                               result->position[1] - this->position[1],
-                               result->position[2] - this->position[2]
-                       };
-                       normalize_v3(p);
-
-                       if (dot_v3v3(p, ray->direction)> 0) {
-                               result->normal[0] = -p[0];
-                               result->normal[1] = -p[1];
-                               result->normal[2] = -p[2];
-                       }
-                       else {
-                               result->normal[0] = p[0];
-                               result->normal[1] = p[1];
-                               result->normal[2] = p[2];
-                       }
-
-                       float inverse[3] ={
-                               -ray->direction[0],
-                               -ray->direction[1],
-                               -ray->direction[2]};
-
-                       result->theta = acosf(dot_v3v3(inverse, result->normal));
-                       result->hit = this->nominalRadius>sqrt(result->position[0]*result->position[0]+result->position[1]*result->position[1]);
-//                     result->hit = this->nominalRadius>maxf(fabs(result->position[0]), fabs(result->position[1]));
-//                     result->hit = true;
-                       result->inverted = t < 0;
-               }
-       }
-};
-class RayResult {
-public:
-       float x;
-       float y;
-       float intensity[3];
-       float u;
-       float v;
-       float screenX;
-       float screenY;
-       bool valid;
-       bool hasIntensity;
-};
-class Bounce {
-public:
-       LensInterface *interface1;
-       LensInterface *interface2;
-       RayResult *raster;
-       int length; // number of interfaces to travel
-       int rasterLength;
-       Bounce(LensInterface *interface1, LensInterface *interface2, int length, int rasterStep) {
-               this->interface1 = interface1;
-               this->interface2 = interface2;
-               this->length = length;
-               this->rasterLength = rasterStep;
-               this->raster = new RayResult[rasterLength*rasterLength];
-               for (int i = 0 ; i < rasterLength*rasterLength ; i++) {
-                       RayResult * res = &this->raster[i];
-                       res->intensity[0] = 0.0f;
-                       res->intensity[1] = 0.0f;
-                       res->intensity[2] = 0.0f;
-                       res->x = 0.0f;
-                       res->y = 0.0f;
-                       res->u = 0.0f;
-                       res->v = 0.0f;
-                       res->valid = false;
-               }
-       }
-       ~Bounce() {
-               delete raster;
-
-       }
-
-       RayResult *getRayResult(int x, int y) {
-               return &(raster[x+y*rasterLength]);
-       }
-};
-class LensSystem {
-public:
-       vector<LensInterface*> interfaces;
-       vector<Bounce*> bounces;
-       int bokehIndex;
-       int lensIndex;
-
-       ~LensSystem() {
-               for (int index = 0 ; index <bounces.size();index++) {delete bounces[index];}
-               for (int index = 0 ; index <interfaces.size();index++) {delete interfaces[index];}
-       }
-
-       void updateBounces(int step) {
-               for (int i = 0; i < interfaces.size()-1 ; i ++) {
-                       if (!interfaces[i]->isFlat()) {
-                               for (int j = i+1; j < interfaces.size()-1 ; j ++) {
-                                       if (!interfaces[j]->isFlat()) {
-                                               int length = interfaces.size()+2*(j-i);
-                                               Bounce *bounce = new Bounce(interfaces[j], interfaces[i], length, step);
-                                               bounces.push_back(bounce);
-                                       }
-                               }
-                       }
-               }
-
-       }
-
-       void addInterface(LensInterface *pinterface) {
-               this->interfaces.push_back(pinterface);
-               this->lensIndex = this->interfaces.size()-1;
-       }
-
-       static int refraction(float *refract, float *n, float *view, double index)
-       {
-
-                return 1;
-
-//                float dot, fac;
-
-//                VECCOPY(refract, view);
-
-//                dot = view[0]*n[0] + view[1]*n[1] + view[2]*n[2];
-
-//                if (dot>0.0f) {
-//                        index = 1.0f/index;
-//                        fac = 1.0f - (1.0f - dot*dot)*index*index;
-//                        if (fac<= 0.0f) return 0;
-//                        fac= -dot*index + sqrt(fac);
-//                }
-//                else {
-//                        fac = 1.0f - (1.0f - dot*dot)*index*index;
-//                        if (fac<= 0.0f) return 0;
-//                        fac= -dot*index - sqrt(fac);
-//                }
-
-//                refract[0] = index*view[0] + fac*n[0];
-//                refract[1] = index*view[1] + fac*n[1];
-//                refract[2] = index*view[2] + fac*n[2];
-
-//                normalize_v3(refract);
-//                return 1;
-               //---
-//             const double cosI = dot_v3v3(n, view);
-//             const double sinT2 = index * index * (1.0 - cosI * cosI);
-//             if (sinT2 >= 1.0f)
-//             {
-//                     return 0;
-//             }
-//             refract[0] = index*view[0] - (index + sqrt(1.0-sinT2))*n[0];
-//             refract[1] = index*view[1] - (index + sqrt(1.0-sinT2))*n[1];
-//             refract[2] = index*view[2] - (index + sqrt(1.0-sinT2))*n[2];
-//             normalize_v3(refract);
-//             return 1;
-               //---
-
-//                double ni = -dot_v3v3(view, n);
-//                double test = 1.0f - index*index*(1.0f-ni*ni);
-//                if (test < 0) {
-//                        return 0;
-//                }
-//                else {
-//                        double mul = index*ni + sqrt(test);
-//                        refract[0] = index * view[0] - mul*n[0];
-//                        refract[1] = index * view[1] - mul*n[1];
-//                        refract[2] = index * view[2] - mul*n[2];
-//                        normalize_v3(refract);
-//                        return 1;
-//                }
-       }
-
-       /* orn = original face normal */
-       static void reflection(float *ref, float *n, float *view)
-       {
-               float f1;
-
-               f1= -2.0f*dot_v3v3(n, view);
-
-               ref[0] = (view[0]+f1*n[0]);
-               ref[1] = (view[1]+f1*n[1]);
-               ref[2] = (view[2]+f1*n[2]);
-               normalize_v3(ref);
-       }
-
-       static float fresnelAR(float theta0, float lambda, float d1, float n0, float n1, float n2) {
-               // refractionangles in coating and the 2nd medium
-               float theta1 = asin(sin(theta0)*n0/n1);
-               float theta2 = asin(sin(theta0)*n0/n2);
-
-               float rs01 = -sin(theta0-theta1)/sin(theta0+theta1);
-               float rp01 = tan( theta0-theta1)/tan(theta0+theta1);
-               float ts01 = 2 * sin( theta1 ) * cos( theta0 ) / sin( theta0+theta1 ) ;
-               float tp01 = ts01*cos(theta0-theta1);
-               // amplitude for inner reflection
-               float rs12 = -sin( theta1-theta2 ) / sin( theta1+theta2 ) ;
-               float rp12 = +tan( theta1-theta2 ) / tan( theta1+theta2 ) ;
-               // after passing through first surface twice :
-               // 2 transmissions and 1 reflection
-               float ris = ts01 * ts01 * rs12 ;
-               float rip = tp01 * tp01 * rp12 ;
-               // phase difference between outer and inner reflections
-               float dy = d1 * n1 ;
-               float dx = tan( theta1 ) * dy ;
-               float delay = sqrt( dx * dx+dy * dy ) ;
-               float relPhase = 4 * M_PI / lambda * ( delay-dx * sin( theta0 ) ) ;
-               // Add up sines of different phase and amplitude
-               float out_s2 = rs01 * rs01 + ris * ris + 2 * rs01 * ris * cos( relPhase ) ;
-               float out_p2 = rp01 * rp01 + rip * rip + 2 * rp01 * rip * cos( relPhase ) ;
-               return (out_s2 + out_p2) / 2 ;
-       }
-
-       void detectHit(Ray *result, Ray *inputRay, Bounce *bounce) {
-               int phase = 0;
-               int delta = 1;
-               int t = 1;
-               int k;
-               result->copyFrom(inputRay);
-               result->valid = false;
-               LensInterface *next = bounce->interface1;
-               LensInterface *f = NULL;
-               Intersection intersection;
-               for (k = 0 ; k < bounce->length-1;k++, t+=delta) {
-                       f = this->interfaces[t];
-                       bool breflect = next == f;
-                       if (breflect) {
-                               delta = -delta;
-                               if (phase == 0) {
-                                       next = bounce->interface2;
-                               }
-                               else {
-                                       next = NULL;
-                               }
-                               phase ++;
-                       }
-
-                       f->intersect(&intersection, result);
-                       if (!intersection.hit) {
-                               break;
-                       }
-                       if (f->isFlat()) {
-                               if (t == this->bokehIndex) {
-                                       result->uv[0] = intersection.position[0]/f->nominalRadius;
-                                       result->uv[1] = intersection.position[1]/f->nominalRadius;
-                               }
-                       }
-
-                       float p[3] = {
-                               intersection.position[0]-result->position[0],
-                               intersection.position[1]-result->position[1],
-                               intersection.position[2]-result->position[2]
-                       };
-
-                       float nfac = sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
-
-                       if (intersection.inverted) {
-                               nfac *= -1;
-                       }
-
-                       result->direction[0] = p[0]/nfac;
-                       result->direction[1] = p[1]/nfac;
-                       result->direction[2] = p[2]/nfac;
-                       result->position[0] = intersection.position[0];
-                       result->position[1] = intersection.position[1];
-                       result->position[2] = intersection.position[2];
-
-                       if (!f->isFlat()) {
-                               // do refraction and reflection
-                               double n0 = result->direction[2]<0?f->refraction1:f->refraction3;
-                               double n1 = f->refraction2;
-                               double n2 = result->direction[2]<0?f->refraction3:f->refraction1;
-                               if (!breflect) {
-                                       float view[3] ={
-                                               result->direction[0],
-                                               result->direction[1],
-                                               result->direction[2]
-                                       };
-                                       int ref = this->refraction(result->direction, intersection.normal, view, n0/n1);
-                                       if (ref == 0) {
-                                               break;
-                                       }
-                               }
-                               else {
-                                       this->reflection(result->direction, intersection.normal, result->direction);
-                                       float  fresnelMultiplyer = fresnelAR(intersection.theta, result->wavelength, f->thicknessCoathing, n0, n1, n2);
-                                       if (isnan(fresnelMultiplyer)) {
-                                               fresnelMultiplyer = 0.0f;
-                                       }
-                                       result->intensity *= fresnelMultiplyer;
-                               }
-                       }
-
-               }
-               if (k < bounce->length-1) {
-                       result->intensity = 0;
-               }
-               else {
-                       result->valid = true;
-               }
-       }
-};
-
-typedef struct LensFace {
-       RayResult *v1;
-       RayResult *v2;
-       RayResult *v3;
-} LensFace;
-
-LensGhostProjectionOperation::LensGhostProjectionOperation(): NodeOperation()
-{
-       this->addInputSocket(COM_DT_COLOR);
-       this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
-       this->addOutputSocket(COM_DT_COLOR);
-       this->lampObject = NULL;
-       this->cameraObject = NULL;
-       this->system = NULL;
-       this->quality = COM_QUALITY_HIGH;
-       this->setComplex(false);
-}
-
-LensGhostOperation::LensGhostOperation(): LensGhostProjectionOperation()
-{
-       this->setComplex(true);
-
-}
-
-void LensGhostProjectionOperation::initExecution()
-{
-       if (this->cameraObject != NULL && this->lampObject != NULL) {
-               if (lampObject == NULL || cameraObject == NULL) {
-                       visualLampPosition[0] = 0;
-                       visualLampPosition[1] = 0;
-                       visualLampPosition[2] = 0;
-               }
-               else {
-                       /* too simple, better to return the distance on the view axis only
-                        * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */
-                       float matt[4][4], imat[4][4], obmat[4][4];
-
-                       copy_m4_m4(obmat, cameraObject->obmat);
-                       normalize_m4(obmat);
-                       invert_m4_m4(imat, obmat);
-                       mult_m4_m4m4(matt, imat, lampObject->obmat);
-
-                       visualLampPosition[0] = (float)(matt[3][0]);
-                       visualLampPosition[1] = (float)(matt[3][1]);
-                       visualLampPosition[2] = (float)fabs(matt[3][2]);
-               }
-       }
-       this->lamp = (Lamp*)lampObject->data;
-
-       this->step = this->quality==COM_QUALITY_LOW?64:this->quality==COM_QUALITY_MEDIUM?128:256;
-       this->bokehReader = this->getInputSocketReader(1);
-
-#define MM *0.001f
-#define CM *0.01f
-#define NM *0.000000001
-#define RED 650 NM
-#define GREEN 510 NM
-#define BLUE 475 NM
-#define AIR 1.000293f
-#define GLASS 1.5200f
-#define TEST 0.000002f
-       // determine interfaces
-       LensSystem *system = new LensSystem();
-       system->addInterface(new FlatInterface(0.0f,0.0f, 6.5 CM, 30 MM)); //ENTRANCE
-        system->addInterface(new SphereInterface(0.0f,0.0f, -3 CM, 8 CM, 3 CM, AIR, GLASS , 0.f));
-        system->addInterface(new SphereInterface(0.0f,0.0f, -4 CM, 8 CM, 3 CM, GLASS, AIR, GREEN));
-        system->addInterface(new FlatInterface(0.0f,0.0f, 3.0 CM, 15 MM)); // BOKEH
-        system->addInterface(new SphereInterface(0.0f,0.0f, 6 CM, 3 CM, 2 CM, AIR, GLASS, 0.0f));
-        system->addInterface(new SphereInterface(0.0f,0.0f, 5.5 CM, 3 CM, 2 CM, GLASS, AIR, 0.f));
-        system->addInterface(new FlatInterface(0.0f,0.0f,0 CM, 30 MM)); // SENSOR
-       system->bokehIndex = 3;
-
-       // determine interfaces
-//     LensSystem *system = new LensSystem();
-//     system->addInterface(new FlatInterface(0.0f,0.0f, 6.5 CM, 30 MM)); //ENTRANCE
-//     system->addInterface(new SphereInterface(0.0f,0.0f, 14 CM, 8 CM, 6 CM, AIR, GLASS , 0.0f));
-//     system->addInterface(new SphereInterface(0.0f,0.0f, 12 CM, 8 CM, 6 CM, GLASS, AIR, GREEN));
-//     system->addInterface(new FlatInterface(0.0f,0.0f, 3.0 CM, 30 MM)); // BOKEH
-//     system->addInterface(new SphereInterface(0.0f,0.0f, 1 CM, 3 CM, 2 CM, AIR, GLASS, GREEN));
-//     system->addInterface(new SphereInterface(0.0f,0.0f, -2 CM, 3 CM, 2 CM, GLASS, AIR, RED));
-//     system->addInterface(new FlatInterface(0.0f,0.0f,0 CM, 20 MM)); // SENSOR
-//     system->bokehIndex = 3;
-#undef CM
-#undef MM
-       // determine bounces
-       system->updateBounces(step);
-       this->system = system;
-}
-
-void LensGhostOperation::initExecution()
-{
-       LensGhostProjectionOperation::initExecution();
-       LensSystem *system = (LensSystem*)this->system;
-       LensInterface *interface1 = system->interfaces[0];
-
-       // for every herz
-       float HERZ[3]={650 NM,510 NM,475 NM}; /// @todo use 7 for high quality?
-       for (int iw = 0 ; iw < 3 ; iw ++) {
-               float wavelength = HERZ[iw];
-       // for every bounce
-               for (int ib = 0 ; ib < system->bounces.size() ; ib++) {
-                       Bounce *bounce = system->bounces[ib];
-       // based on quality setting the number of iteration will be different (128^2, 64^2, 32^2)
-                       for (int xi = 0 ; xi < step ; xi ++) {
-                               float x = -interface1->radius+xi*(interface1->radius*2/step);
-                               for (int yi = 0 ; yi < step ; yi ++) {
-                                       float y = -interface1->radius+yi*(interface1->radius*2/step);
-                                       Ray r;
-                                       Ray result;
-                                       r.wavelength = wavelength;
-                                       r.intensity = this->lamp->energy;
-                                       r.uv[0] = 0.0f;
-                                       r.uv[1] = 0.0f;
-                                       r.position[0] = visualLampPosition[0];
-                                       r.position[1] = visualLampPosition[1];
-                                       r.position[2] = visualLampPosition[2];
-                                       r.direction[0] = interface1->position[0]+x - r.position[0];
-                                       r.direction[1] = interface1->position[1]+y - r.position[1];
-                                       r.direction[2] = interface1->position[2] - r.position[2];
-                                       normalize_v3(r.direction);
-                                       system->detectHit(&result, &r, bounce);
-                                       RayResult *res = bounce->getRayResult(xi, yi);
-                                       if (iw == 0) {
-                                               res->x = result.position[0];
-                                               res->y = result.position[1];
-                                               res->u = result.uv[0];
-                                               res->v = result.uv[1];
-                                       }
-                                       res->intensity[iw] = result.intensity;
-                                       if (result.valid) {
-                                               res->valid = true;
-                                       }
-                               }
-                       }
-               }
-       }
-#undef NM
-       const int width = this->getWidth();
-       const int height = this->getHeight();
-       const float width2 = width/2.0f;
-       const float height2 = height/2.0f;
-       float *data = new float[width*height*4];
-       for (int i = 0 ; i < width*height ; i ++) {
-               data[i*4+0] = 0.0f;
-               data[i*4+1] = 0.0f;
-               data[i*4+2] = 0.0f;
-               data[i*4+3] = 1.0f;
-       }
-       /// @todo every bounce creates own image. these images are added together at the end
-//     LensSystem *system = (LensSystem*)this->system;
-       LensInterface * lens = system->interfaces[system->lensIndex];
-       for (int i = 0 ; i < system->bounces.size() ; i ++) {
-               Bounce *bounce = system->bounces[i];
-               for (int r = 0 ; r < bounce->rasterLength*bounce->rasterLength ; r ++) {
-                       RayResult *result = &bounce->raster[r];
-//                     if (result->valid) {
-                               float ru = result->x/lens->nominalRadius*width2+width2;
-                               float rv  = result->y/lens->nominalRadius*height2+height2;
-                               result->screenX = ru;
-                               result->screenY = rv;
-                               result->hasIntensity = result->intensity[0]>0.0f &&result->intensity[1]>0.0f&& result->intensity[2]>0.0f;
-//                     }
-               }
-       }
-}
-
-void *LensGhostOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
-{
-       vector<LensFace*>* result = new vector<LensFace*>();
-       LensSystem *system = (LensSystem*)this->system;
-       const float minx = rect->xmin;
-       const float miny = rect->ymin;
-       const float maxx = rect->xmax;
-       const float maxy = rect->ymax;
-       for (int i = 0 ; i < system->bounces.size() ; i ++) {
-               Bounce *bounce = system->bounces[i];
-               int faceX, faceY;
-               for (faceX = 0 ; faceX < bounce->rasterLength-1 ; faceX++) {
-                       for (faceY = 0 ; faceY < bounce->rasterLength-1 ; faceY++) {
-                               RayResult *vertex1 = bounce->getRayResult(faceX, faceY);
-                               RayResult *vertex2 = bounce->getRayResult(faceX+1, faceY);
-                               RayResult *vertex3 = bounce->getRayResult(faceX+1, faceY+1);
-                               RayResult *vertex4 = bounce->getRayResult(faceX, faceY+1);
-                               // early hit test
-                               if (!((vertex1->screenX < minx && vertex2->screenX < minx && vertex3->screenX < minx && vertex4->screenX < minx) ||
-                                       (vertex1->screenX > maxx && vertex2->screenX > maxx && vertex3->screenX > maxx && vertex4->screenX > maxx) ||
-                                       (vertex1->screenY < miny && vertex2->screenY < miny && vertex3->screenY < miny && vertex4->screenY < miny) ||
-                                       (vertex1->screenY > maxy && vertex2->screenY > maxy && vertex3->screenY > maxy && vertex4->screenY > maxy))) {
-                                       int number = vertex1->hasIntensity + vertex2->hasIntensity + vertex3->hasIntensity + vertex4->hasIntensity;
-                                       if (number == 4) {
-                                               LensFace *face = new LensFace();
-                                               face->v1 = vertex1;
-                                               face->v2 = vertex2;
-                                               face->v3 = vertex3;
-                                               result->push_back(face);
-                                               face = new LensFace();
-                                               face->v1 = vertex3;
-                                               face->v2 = vertex4;
-                                               face->v3 = vertex1;
-                                               result->push_back(face);
-                                       }
-                                       else if (number == 3) {
-                                               LensFace *face = new LensFace();
-                                               if (!vertex1->hasIntensity) {
-                                                       face->v1 = vertex2;
-                                                       face->v2 = vertex3;
-                                                       face->v3 = vertex4;
-                                               }
-                                               else if (!vertex2->hasIntensity) {
-                                                       face->v1 = vertex1;
-                                                       face->v2 = vertex3;
-                                                       face->v3 = vertex4;
-                                               }
-                                               else if (!vertex3->hasIntensity) {
-                                                       face->v1 = vertex1;
-                                                       face->v2 = vertex2;
-                                                       face->v3 = vertex4;
-                                               }
-                                               else {
-                                                       face->v1 = vertex1;
-                                                       face->v2 = vertex2;
-                                                       face->v3 = vertex3;
-                                               }
-                                               result->push_back(face);
-                                       }
-                               }
-                       }
-               }
-       }
-
-       return result;
-}
-
-void LensGhostOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data)
-{
-       if (data) {
-               vector<LensFace*>* faces = (vector<LensFace*>*)data;
-               while (faces->size() != 0) {
-                       LensFace *face = faces->back();
-                       faces->pop_back();
-                       delete face;
-               }
-               delete faces;
-       }
-}
-
-
-void LensGhostProjectionOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
-{
-       float bokeh[4];
-       LensSystem *system = (LensSystem*)this->system;
-       LensInterface *interface1 = system->interfaces[0];
-       color[0] = 0.0f;
-       color[1] = 0.0f;
-       color[2] = 0.0f;
-       color[3] = 0.0f;
-       const float width = this->getWidth();
-       const float height = this->getHeight();
-       const float size = min(height, width);
-       const float width2 = width/2;
-       const float height2 = height/2;
-       const float size2 = size/2;
-
-#define NM *0.000000001
-       float HERZ[3]={650 NM,510 NM,475 NM}; /// @todo use 7 for high quality?
-       float rx = ((x-width2)/size2) * interface1->radius;
-       float ry = ((y-height2)/size2) * interface1->radius;
-
-       for (int iw = 0 ; iw < 3 ; iw ++) {
-               float intensity = 0.0f;
-               float wavelength = HERZ[iw];
-               float colorcomponent = 0.0f;
-               if (iw ==0 ) colorcomponent = lamp->r;
-               if (iw ==1 ) colorcomponent = lamp->g;
-               if (iw ==2 ) colorcomponent = lamp->b;
-
-
-       // for every bounce
-               for (int ib = 0 ; ib < system->bounces.size() ; ib++) {
-                       Bounce *bounce = system->bounces[ib];
-       // based on quality setting the number of iteration will be different (128^2, 64^2, 32^2)
-
-                       Ray r;
-                       Ray result;
-                       r.wavelength = wavelength;
-                       r.intensity = this->lamp->energy;
-                       r.uv[0] = 0.0f;
-                       r.uv[1] = 0.0f;
-                       r.position[0] = visualLampPosition[0];
-                       r.position[1] = visualLampPosition[1];
-                       r.position[2] = visualLampPosition[2];
-                       r.direction[0] = interface1->position[0]+rx - r.position[0];
-                       r.direction[1] = interface1->position[1]+ry - r.position[1];
-                       r.direction[2] = interface1->position[2] - r.position[2];
-                       normalize_v3(r.direction);
-                       system->detectHit(&result, &r, bounce);
-                       if (result.valid) {
-                               float u = ((result.uv[0]+1.0f)/2)*bokehReader->getWidth();
-                               float v = ((result.uv[1]+1.0f)/2)*bokehReader->getHeight();
-
-                               bokehReader->read(bokeh, u, v, sampler, inputBuffers);
-
-                               intensity += result.intensity *bokeh[iw];
-                       }
-               }
-               intensity = maxf(0.0f, intensity);
-               color[iw] = intensity*colorcomponent;
-       }
-       color[3] = 1.0f;
-#undef NM
-
-}
-
-
-
-void LensGhostOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
-{
-       vector<LensFace*>* faces = (vector<LensFace*>*)data;
-#if 0 /* UNUSED */
-       const float bokehWidth = bokehReader->getWidth();
-       const float bokehHeight = bokehReader->getHeight();
-       float bokeh[4];
-#endif
-       color[0] = 0.0f;
-       color[1] = 0.0f;
-       color[2] = 0.0f;
-       color[3] = 1.0f;
-
-       unsigned int index;
-       for (index = 0 ; index < faces->size() ; index ++) {
-               LensFace * face = faces->operator [](index);
-               RayResult *vertex1 = face->v1;
-               RayResult *vertex2 = face->v2;
-               RayResult *vertex3 = face->v3;
-               if (!((vertex1->screenX < x && vertex2->screenX < x && vertex3->screenX < x) ||
-                       (vertex1->screenX > x && vertex2->screenX > x && vertex3->screenX > x) ||
-                       (vertex1->screenY < y && vertex2->screenY < y && vertex3->screenY < y) ||
-                       (vertex1->screenY > y && vertex2->screenY > y && vertex3->screenY > y))) {
-
-                       const float v1[2] = {vertex1->screenX, vertex1->screenY};
-                       const float v2[2] = {vertex2->screenX, vertex2->screenY};
-                       const float v3[2] = {vertex3->screenX, vertex3->screenY};
-                       const float co[2] = {x, y};
-                       float weights[3];
-
-                       barycentric_weights_v2(v1, v2, v3, co, weights);
-                       if (weights[0]>=0.0f && weights[0]<=1.0f &&
-                                       weights[1]>=0.0f && weights[1]<=1.0f &&
-                                       weights[2]>=0.0f && weights[2]<=1.0f) {
-//                            const float u = (vertex1->u*weights[0]+vertex2->u*weights[1]+vertex3->u*weights[2]);
-//                            const float v = (vertex1->v*weights[0]+vertex2->v*weights[1]+vertex3->v*weights[2]);
-//                            const float tu = ((u+1.0f)/2.0f)*bokehWidth;
-//                            const float tv = ((v+1.0f)/2.0f)*bokehHeight;
-//                            bokehReader->read(bokeh, tu, tv, inputBuffers);
-
-//                                                     color[0] = max(color[0], bokeh[0]*(vertex1->intensity[0]*weights[0]+vertex2->intensity[0]*weights[1]+vertex3->intensity[0]*weights[2]));
-//                            color[1] = max(color[1], bokeh[1]*(vertex1->intensity[1]*weights[0]+vertex2->intensity[1]*weights[1]+vertex3->intensity[1]*weights[2]));
-//                            color[2] = max(color[2], bokeh[2]*(vertex1->intensity[2]*weights[0]+vertex2->intensity[2]*weights[1]+vertex3->intensity[2]*weights[2]));
-                                                       color[0] = max(color[0], (vertex1->intensity[0]*weights[0]+vertex2->intensity[0]*weights[1]+vertex3->intensity[0]*weights[2]));
-                            color[1] = max(color[1], (vertex1->intensity[1]*weights[0]+vertex2->intensity[1]*weights[1]+vertex3->intensity[1]*weights[2]));
-                            color[2] = max(color[2], (vertex1->intensity[2]*weights[0]+vertex2->intensity[2]*weights[1]+vertex3->intensity[2]*weights[2]));
-                       }
-               }
-       }
-}
-
-
-void LensGhostProjectionOperation::deinitExecution()
-{
-       if (this->system) delete (LensSystem*)this->system;
-       this->system = NULL;
-       this->bokehReader = NULL;
-}
-
-bool LensGhostProjectionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
-{
-       rcti bokehInput;
-
-       NodeOperation *operation = this->getInputOperation(1);
-       bokehInput.xmax = operation->getWidth();
-       bokehInput.xmin = 0;
-       bokehInput.ymax = operation->getHeight();
-       bokehInput.ymin = 0;
-       if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) {
-               return true;
-       }
-
-       return NodeOperation::determineDependingAreaOfInterest(input, readOperation, output);
-}
diff --git a/source/blender/compositor/operations/COM_LensGhostOperation.h b/source/blender/compositor/operations/COM_LensGhostOperation.h
deleted file mode 100644 (file)
index 5546ce9..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor: 
- *             Jeroen Bakker 
- *             Monique Dewanchand
- */
-
-#ifndef _COM_LensGhostOperation_h
-#define _COM_LensGhostOperation_h
-#include "COM_NodeOperation.h"
-#include "DNA_lamp_types.h"
-#include "DNA_object_types.h"
-#include "DNA_camera_types.h"
-
-class LensGhostProjectionOperation : public NodeOperation {
-protected:
-       Object *lampObject;
-       Lamp *lamp;
-       Object *cameraObject;
-
-       void *system;
-       float visualLampPosition[3];
-       CompositorQuality quality;
-       int step;
-       SocketReader * bokehReader;
-
-public:
-       LensGhostProjectionOperation();
-
-       /**
-         * the inner loop of this program
-         */
-       void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
-
-       /**
-         * Initialize the execution
-         */
-       void initExecution();
-
-       /**
-         * Deinitialize the execution
-         */
-       void deinitExecution();
-       bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
-       void setLampObject(Object *lampObject) {this->lampObject = lampObject;}
-       void setCameraObject(Object *cameraObject) {this->cameraObject = cameraObject;}
-
-       void setQuality(CompositorQuality quality) {this->quality = quality;}
-};
-
-class LensGhostOperation : public LensGhostProjectionOperation {
-public:
-       LensGhostOperation();
-
-       void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
-       void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
-       /**
-         * the inner loop of this program
-         */
-       void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
-       /**
-         * Initialize the execution
-         */
-       void initExecution();
-};
-#endif
diff --git a/source/blender/compositor/operations/COM_LensGlowImageOperation.cpp b/source/blender/compositor/operations/COM_LensGlowImageOperation.cpp
deleted file mode 100644 (file)
index ee0a02e..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor: 
- *             Jeroen Bakker 
- *             Monique Dewanchand
- */
-
-#include "COM_LensGlowImageOperation.h"
-#include "BLI_math.h"
-
-LensGlowImageOperation::LensGlowImageOperation(): NodeOperation()
-{
-       this->addOutputSocket(COM_DT_COLOR);
-}
-void LensGlowImageOperation::initExecution()
-{
-       this->scale = 1/20000.0f;
-}
-void LensGlowImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
-{
-       const float cs_r = 1.f, cs_g = 1.f, cs_b = 1.f;
-       const float v = 2.f*(y / (float)512.0f) - 1.f;
-       const float u = 2.f*(x / (float)512.0f) - 1.f;
-       const float r = (u*u + v*v)*scale;
-       const float d = -sqrtf(sqrtf(sqrtf(r)))*9.f;
-       const float w = (0.5f + 0.5f*cos((double)u*M_PI))*(0.5f + 0.5f*cos((double)v*M_PI));
-       color[0] = expf(d*cs_r) * w;
-       color[1] = expf(d*cs_g) * w;
-       color[2] = expf(d*cs_b) * w;
-       color[3] = 1.0f;
-}
-
-void LensGlowImageOperation::deinitExecution()
-{
-}
-
-void LensGlowImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
-{
-       resolution[0] = 512;
-       resolution[1] = 512;
-}
diff --git a/source/blender/compositor/operations/COM_LensGlowOperation.cpp b/source/blender/compositor/operations/COM_LensGlowOperation.cpp
deleted file mode 100644 (file)
index 492dc71..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor: 
- *             Jeroen Bakker 
- *             Monique Dewanchand
- */
-
-#include "COM_LensGlowOperation.h"
-#include "BLI_math.h"
-
-LensGlowOperation::LensGlowOperation(): NodeOperation()
-{
-       this->addInputSocket(COM_DT_COLOR);
-       this->addOutputSocket(COM_DT_COLOR);
-       this->inputProgram = NULL;
-       this->lamp = NULL;
-}
-void LensGlowOperation::initExecution()
-{
-       this->inputProgram = this->getInputSocketReader(0);
-}
-
-void LensGlowOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
-{
-//     const float emit100 = this->lamp->energy*100;
-//     const float emit200 = emit100*2;
-//     const float deltaX = 160-x;
-//     const float deltaY = 100-y;
-//     const float distance = deltaX * deltaX + deltaY*deltaY;
-
-//     float glow = (emit100-(distance))/(emit200);
-//     if (glow<0) glow=0;
-
-//     color[0] = glow*lamp->r;
-//     color[1] = glow*lamp->g;
-//     color[2] = glow*lamp->b;
-//     color[3] = 1.0f;
-}
-
-void LensGlowOperation::deinitExecution()
-{
-       this->inputProgram = NULL;
-}
diff --git a/source/blender/compositor/operations/COM_LensGlowOperation.h b/source/blender/compositor/operations/COM_LensGlowOperation.h
deleted file mode 100644 (file)
index 77e13e8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor: 
- *             Jeroen Bakker 
- *             Monique Dewanchand
- */
-
-#ifndef _COM_LensGlowOperation_h
-#define _COM_LensGlowOperation_h
-#include "COM_NodeOperation.h"
-#include "DNA_lamp_types.h"
-
-class LensGlowOperation : public NodeOperation {
-private:
-       /**
-         * Cached reference to the inputProgram
-         */
-       SocketReader * inputProgram;
-       Lamp *lamp;
-
-public:
-       LensGlowOperation();
-       
-       /**
-         * the inner loop of this program
-         */
-       void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
-       
-       /**
-         * Initialize the execution
-         */
-       void initExecution();
-       
-       /**
-         * Deinitialize the execution
-         */
-       void deinitExecution();
-       
-       void setLamp(Lamp *lamp) {this->lamp = lamp;}
-};
-#endif
index 3a287cb7239192ab86b26d5f9b9050d2deba03db..2ea5f85253b36845dd1e5917d2447667b92e84c7 100644 (file)
@@ -47,6 +47,22 @@ void MathBaseOperation::deinitExecution()
        this->inputValue2Operation = NULL;
 }
 
+void MathBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
+{
+       InputSocket *socket;
+       unsigned int tempPreferredResolution[] = {0,0};
+       unsigned int tempResolution[2];
+
+       socket = this->getInputSocket(0);
+       socket->determineResolution(tempResolution, tempPreferredResolution);
+       if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
+               this->setResolutionInputSocketIndex(0);
+       } else {
+               this->setResolutionInputSocketIndex(1);
+       }
+       NodeOperation::determineResolution(resolution, preferredResolution);
+}
+
 void MathAddOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
 {
        float inputValue1[4];
index 87f8a30415876af899f8f93c3f53e2bbdfb8c2ce..64e8c4af88fae2689026dba34ef5486d64cf149a 100644 (file)
@@ -58,6 +58,10 @@ public:
          */
        void deinitExecution();
 
+       /**
+         * Determine resolution
+         */
+       void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
 };
 
 class MathAddOperation: public MathBaseOperation {
index f583493340b755b537ab670a6b5555fde867215f..5792248464ada91c14bbde28f6a7c89bdc83c74a 100644 (file)
@@ -81,10 +81,11 @@ public:
                if (x<0 || x >= this->width || y <0 || y >= this->height) {
                        *u = x;
                        *v = y;
-               } else {
-
+               }
+               else {
                        int offset = y * this->width + x;
-                       int offset2 = offset*2;
+                       int offset2 = offset * 2;
+
                        if (!bufferCalculated[offset]) {
                                //float overscan = 0.0f;
                                float w = (float)this->width/* / (1 + overscan) */;
@@ -99,7 +100,8 @@ public:
 
                                if (inverted) {
                                        BKE_tracking_invert_intrinsics(trackingData, in, out);
-                               } else {
+                               }
+                               else {
                                        BKE_tracking_apply_intrinsics(trackingData, in, out);
                                }
 
index f9f59c9bdd9f11ed155fa9848d3f004b6ec94134..55210080e018c89d6fa460a4f103cae7bdcc9f2a 100644 (file)
@@ -310,6 +310,8 @@ struct BGpic *ED_view3D_background_image_new(struct View3D *v3d);
 void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic);
 void ED_view3D_background_image_clear(struct View3D *v3d);
 
+float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit);
+
 /* view matrix properties utilities */
 /* unused */
 #if 0
index f9eb8770012f0c6fd7495783a5a711aa19a004cc..9cbd9e0b7da249659014f16f5ca33351e5bc4ed8 100644 (file)
 
 #include "mesh_intern.h"
 
-/* uses context to figure out transform for primitive */
-/* returns standard diameter */
-static float new_primitive_matrix(bContext *C, const float loc[3], const float rot[3], float primmat[][4])
-{
-       Object *obedit = CTX_data_edit_object(C);
-       View3D *v3d = CTX_wm_view3d(C);
-       float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3];
-       
-       unit_m4(primmat);
-
-       eul_to_mat3(rmat, rot);
-       invert_m3(rmat);
-       
-       /* inverse transform for initial rotation and object */
-       copy_m3_m4(mat, obedit->obmat);
-       mul_m3_m3m3(cmat, rmat, mat);
-       invert_m3_m3(imat, cmat);
-       copy_m4_m3(primmat, imat);
-
-       /* center */
-       copy_v3_v3(primmat[3], loc);
-       sub_v3_v3(primmat[3], obedit->obmat[3]);
-       invert_m3_m3(imat, mat);
-       mul_m3_v3(imat, primmat[3]);
-
-       return v3d ? v3d->grid : 1.0f;
-}
-
 /* ********* add primitive operators ************* */
 
 static void make_prim_init(bContext *C, const char *idname,
@@ -101,7 +73,7 @@ static void make_prim_init(bContext *C, const char *idname,
                *state = 1;
        }
 
-       *dia = new_primitive_matrix(C, loc, rot, mat);
+       *dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
 }
 
 static void make_prim_finish(bContext *C, int *state, int enter_editmode)
index 699b731bc15c1355c0f041c0f5c5f133681b1cb4..159f75b60e6565cf5ad0e36151b0b3b34c25d29f 100644 (file)
@@ -166,6 +166,7 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
 float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
                                      const float loc[3], const float rot[3], float primmat[][4])
 {
+       Scene *scene = CTX_data_scene(C);
        View3D *v3d = CTX_wm_view3d(C);
        float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3];
        
@@ -186,7 +187,9 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
        invert_m3_m3(imat, mat);
        mul_m3_v3(imat, primmat[3]);
        
-       if (v3d) return v3d->grid;
+       if (v3d)
+               return ED_view3d_grid_scale(scene, v3d, NULL);
+
        return 1.0f;
 }
 
index e05191dad3b92b7630884b15526b7f19697f52e8..88cf9b1b0dda04746350f5ac225436e81d7f5d0c 100644 (file)
@@ -1878,6 +1878,7 @@ static void do_weight_paint_vertex(
                float oldw;
                float neww;
                float testw = 0;
+               float observedChange = 0;
                float change = 0;
                float oldChange = 0;
                int i;
@@ -1889,13 +1890,14 @@ static void do_weight_paint_vertex(
                                    wpi->brush_alpha_value, wpi->do_flip, do_multipaint_totsel);
                
                /* setup multi-paint */
-               if (do_multipaint_totsel) {
+               observedChange = neww - oldw;
+               if (do_multipaint_totsel && observedChange) {
                        dv_copy.dw = MEM_dupallocN(dv->dw);
                        dv_copy.flag = dv->flag;
                        dv_copy.totweight = dv->totweight;
                        tdw = dw;
                        tdw_prev = dw_prev;
-                       change = get_mp_change(&wp->wpaint_prev[index], wpi->defbase_tot, wpi->defbase_sel, neww - oldw);
+                       change = get_mp_change(&wp->wpaint_prev[index], wpi->defbase_tot, wpi->defbase_sel, observedChange);
                        if (change) {
                                if (!tdw->weight) {
                                        i = get_first_selected_nonzero_weight(dv, wpi->defbase_tot, wpi->defbase_sel);
@@ -1911,7 +1913,7 @@ static void do_weight_paint_vertex(
                                        if (tdw->weight != tdw_prev->weight) {
                                                oldChange = tdw->weight / tdw_prev->weight;
                                                testw = tdw_prev->weight * change;
-                                               if (testw > tdw_prev->weight) {
+                                               if (observedChange > 0) {
                                                        if (change > oldChange) {
                                                                /* reset the weights and use the new change */
                                                                defvert_reset_to_prev(wp->wpaint_prev + index, dv);
index fddd7af93f1aa8e9ad5172fb3b808490e5884f9c..829973c744ee7fd74e208abfaae1c1d6a2d42332 100644 (file)
@@ -300,7 +300,8 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                                BLI_strncpy(expanded, lib->name, sizeof(expanded));
                                BLI_path_abs(expanded, G.main->name);
                                if (!BLI_exists(expanded)) {
-                                       BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Library path '%s' does not exist, correct this before saving", expanded);
+                                       BKE_reportf(CTX_wm_reports(C), RPT_ERROR,
+                                                   "Library path '%s' does not exist, correct this before saving", expanded);
                                }
                        }
                }
@@ -570,7 +571,8 @@ static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *ar
                BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME);
 }
 
-static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items)
+static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi),
+                               const char *str, uiSearchItems *items)
 {
        GHashIterator *iter = WM_operatortype_iter();
 
@@ -1192,7 +1194,11 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
 
                                uiSetRoundBox(UI_CNR_ALL);
                                glColor4ub(255, 255, 255, 100);
-                               uiRoundBox((float) *offsx - 0.5f * ufac, (float)ys - 1.0f * ufac, (float)*offsx + UI_UNIT_Y - 3.0f * ufac, (float)ys + UI_UNIT_Y - 3.0f * ufac, UI_UNIT_Y / 2.0f - 2.0f * ufac);
+                               uiRoundBox((float) *offsx - 0.5f * ufac,
+                                          (float)ys - 1.0f * ufac,
+                                          (float)*offsx + UI_UNIT_Y - 3.0f * ufac,
+                                          (float)ys + UI_UNIT_Y - 3.0f * ufac,
+                                          (float)UI_UNIT_Y / 2.0f - 2.0f * ufac);
                                glEnable(GL_BLEND); /* roundbox disables */
                        }
                        
@@ -1324,7 +1330,11 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                /* active circle */
                if (active) {
                        uiSetRoundBox(UI_CNR_ALL);
-                       uiRoundBox((float)startx + UI_UNIT_Y - 1.5f * ufac, (float)*starty + 2.0f * ufac, (float)startx + 2.0f * UI_UNIT_Y - 4.0f * ufac, (float)*starty + UI_UNIT_Y - 1.0f * ufac, UI_UNIT_Y / 2.0f - 2.0f * ufac);
+                       uiRoundBox((float)startx + UI_UNIT_Y - 1.5f * ufac,
+                                  (float)*starty + 2.0f * ufac,
+                                  (float)startx + 2.0f * UI_UNIT_Y - 4.0f * ufac,
+                                  (float)*starty + UI_UNIT_Y - 1.0f * ufac,
+                                  UI_UNIT_Y / 2.0f - 2.0f * ufac);
                        glEnable(GL_BLEND); /* roundbox disables it */
                        
                        te->flag |= TE_ACTIVE; // for lookup in display hierarchies
@@ -1549,7 +1559,10 @@ static void outliner_draw_restrictcols(ARegion *ar)
        
        /* background underneath */
        UI_ThemeColor(TH_BACK);
-       glRecti((int)ar->v2d.cur.xmax - OL_TOGW, (int)ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT - 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax);
+       glRecti((int)ar->v2d.cur.xmax - OL_TOGW,
+               (int)ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT - 1,
+               (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH,
+               (int)ar->v2d.cur.ymax);
        
        UI_ThemeColorShade(TH_BACK, 6);
        ystart = (int)ar->v2d.tot.ymax;
index 8a332e9329a3af409b444f565e3cb7f2f2879985..a752a7d71ae6df283914fba26396d404c4512cb5 100644 (file)
@@ -205,7 +205,8 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem,
        }
 }
 
-void item_rename_cb(bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+void item_rename_cb(bContext *C, Scene *UNUSED(scene), TreeElement *te,
+                    TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        ARegion *ar = CTX_wm_region(C);
        ReportList *reports = CTX_wm_reports(C); // XXX
@@ -340,7 +341,8 @@ int common_restrict_check(bContext *C, Object *ob)
 
 /* Toggle Visibility ---------------------------------------- */
 
-void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te,
+                                 TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base = (Base *)te->directdata;
        Object *ob = (Object *)tselem->id;
@@ -355,7 +357,8 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre
        }
 }
 
-void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
+                                TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Group *group = (Group *)tselem->id;
        restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_VIEW);
@@ -391,7 +394,8 @@ void OUTLINER_OT_visibility_toggle(wmOperatorType *ot)
 
 /* Toggle Selectability ---------------------------------------- */
 
-void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
+                                    TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base = (Base *)te->directdata;
        
@@ -401,7 +405,8 @@ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme
        }
 }
 
-void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
+                                   TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Group *group = (Group *)tselem->id;
        restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_SELECT);
@@ -437,7 +442,8 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot)
 
 /* Toggle Renderability ---------------------------------------- */
 
-void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
+                                    TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base = (Base *)te->directdata;
        
@@ -447,7 +453,8 @@ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme
        }
 }
 
-void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
+                                   TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Group *group = (Group *)tselem->id;
        restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_RENDER);
@@ -674,7 +681,8 @@ static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops)
 }
 
 /* find next element that has this name */
-static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound)
+static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *name, int flags,
+                                       TreeElement *prev, int *prevFound)
 {
        TreeElement *te, *tes;
        
@@ -961,7 +969,8 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
                BLI_addhead(&hierarchy, ld);
        }
        
-       /* step 2: step down hierarchy building the path (NOTE: addhead in previous loop was needed so that we can loop like this) */
+       /* step 2: step down hierarchy building the path
+        * (NOTE: addhead in previous loop was needed so that we can loop like this) */
        for (ld = hierarchy.first; ld; ld = ld->next) {
                /* get data */
                tem = (TreeElement *)ld->data;
@@ -972,7 +981,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
                /* check if we're looking for first ID, or appending to path */
                if (*id) {
                        /* just 'append' property to path 
-                        *      - to prevent memory leaks, we must write to newpath not path, then free old path + swap them
+                        * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them
                         */
                        if (tse->type == TSE_RNA_PROPERTY) {
                                if (RNA_property_type(prop) == PROP_POINTER) {
@@ -1019,7 +1028,8 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
                else {
                        /* no ID, so check if entry is RNA-struct, and if that RNA-struct is an ID datablock to extract info from */
                        if (tse->type == TSE_RNA_STRUCT) {
-                               /* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */
+                               /* ptr->data not ptr->id.data seems to be the one we want,
+                                * since ptr->data is sometimes the owner of this ID? */
                                if (RNA_struct_is_ID(ptr->type)) {
                                        *id = (ID *)ptr->data;
                                        
@@ -1090,7 +1100,9 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL
                        short groupmode = KSP_GROUP_KSNAME;
                        
                        /* check if RNA-property described by this selected element is an animatable prop */
-                       if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) {
+                       if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) &&
+                           RNA_property_animateable(&te->rnaptr, te->directdata))
+                       {
                                /* get id + path + index info from the selected element */
                                tree_element_to_path(soops, te, tselem, 
                                                     &id, &path, &array_index, &flag, &groupmode);
@@ -1269,7 +1281,9 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
                        short groupmode = KSP_GROUP_KSNAME;
                        
                        /* check if RNA-property described by this selected element is an animatable prop */
-                       if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) {
+                       if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) &&
+                           RNA_property_animateable(&te->rnaptr, te->directdata))
+                       {
                                /* get id + path + index info from the selected element */
                                tree_element_to_path(soops, te, tselem, 
                                                     &id, &path, &array_index, &flag, &groupmode);
@@ -1282,7 +1296,8 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
                                        case KEYINGSET_EDITMODE_ADD:
                                        {
                                                /* add a new path with the information obtained (only if valid) */
-                                               // TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name
+                                               /* TODO: what do we do with group name?
+                                                * for now, we don't supply one, and just let this use the KeyingSet name */
                                                BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode);
                                                ks->active_path = BLI_countlist(&ks->paths);
                                        }
@@ -1487,7 +1502,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
                
                scene = (Scene *)outliner_search_back(soops, te_found, ID_SCE);
 
-               if(scene == NULL) {
+               if (scene == NULL) {
                        return OPERATOR_CANCELLED;
                }
 
@@ -1671,7 +1686,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
        /* then search backwards to get the scene */
        scene = (Scene *)outliner_search_back(soops, te, ID_SCE);
 
-       if(scene == NULL) {
+       if (scene == NULL) {
                return OPERATOR_CANCELLED;
        }
 
index 068532a08a2dac4329cc95bd50259f6f8fbe10b9..812fba50295bcd7e973710a01dbd046a4dcd1bd0 100644 (file)
@@ -670,7 +670,8 @@ int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement
 
 /* generic call for non-id data to make/check active in UI */
 /* Context can be NULL when set==0 */
-int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set)
+int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops,
+                             TreeElement *te, TreeStoreElem *tselem, int set)
 {
        switch (tselem->type) {
                case TSE_DEFGROUP:
@@ -710,7 +711,8 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl
 
 /* ================================================ */
 
-static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2])
+static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops,
+                                     TreeElement *te, int extend, const float mval[2])
 {
        
        if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
index 72b954b88e719b189061f87ea980d38dec52eb0c..b556fbf5c9d4e342512a67d54890bfebfc4664ed 100644 (file)
@@ -125,13 +125,15 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb,
        }
 }
 
-static void unlink_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
+static void unlink_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                             TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
 {
        /* just set action to NULL */
        BKE_animdata_set_action(CTX_wm_reports(C), tsep->id, NULL);
 }
 
-static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
+static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te,
+                               TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
 {
        Material **matar = NULL;
        int a, totcol = 0;
@@ -165,7 +167,8 @@ static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEl
        }
 }
 
-static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
+static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te,
+                              TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
 {
        MTex **mtex = NULL;
        int a;
@@ -194,7 +197,8 @@ static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEle
        }
 }
 
-static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                            TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
        Group *group = (Group *)tselem->id;
        
@@ -209,7 +213,8 @@ static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme
        }
 }
 
-static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                            TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
        Scene *parscene = (Scene *)tsep->id;
        World *wo = (World *)tselem->id;
@@ -220,7 +225,8 @@ static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme
 }
 
 static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, 
-                                          void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *))
+                                          void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
+                                                               TreeStoreElem *, TreeStoreElem *))
 {
        TreeElement *te;
        TreeStoreElem *tselem;
@@ -241,7 +247,8 @@ static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *
 
 /* */
 
-static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
+                             TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base = (Base *)te->directdata;
        
@@ -252,7 +259,8 @@ static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
        }
 }
 
-static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
+                               TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base = (Base *)te->directdata;
        
@@ -263,7 +271,8 @@ static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *t
        }
 }
 
-static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te,
+                             TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Base *base = (Base *)te->directdata;
        
@@ -280,7 +289,8 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
        }
 }
 
-static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        if (tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) {
                /* if the ID type has no special local function,
@@ -292,7 +302,8 @@ static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(t
        }
 }
 
-static void id_fake_user_set_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void id_fake_user_set_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                                TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        ID *id = tselem->id;
        
@@ -302,7 +313,8 @@ static void id_fake_user_set_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeE
        }
 }
 
-static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                                  TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        ID *id = tselem->id;
        
@@ -312,7 +324,8 @@ static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), Tre
        }
 }
 
-static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                                 TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
        ID *id = tselem->id;
        
@@ -328,7 +341,8 @@ static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement
        }
 }
 
-static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem)
+static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                                TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
        ID *id = tselem->id;
        
@@ -345,7 +359,8 @@ static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement *
        }
 }
 
-static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
+                                   TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        Group *group = (Group *)tselem->id;
        GroupObject *gob;
@@ -371,7 +386,8 @@ static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElemen
 }
 
 void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, 
-                                  void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *))
+                                  void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
+                                                       TreeStoreElem *, TreeStoreElem *))
 {
        TreeElement *te;
        TreeStoreElem *tselem;
@@ -399,13 +415,15 @@ void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soop
 
 /* ******************************************** */
 
-static void unlinkact_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te), TreeStoreElem *tselem, void *UNUSED(arg))
+static void unlinkact_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
+                                  TreeStoreElem *tselem, void *UNUSED(arg))
 {
        /* just set action to NULL */
        BKE_animdata_set_action(NULL, tselem->id, NULL);
 }
 
-static void cleardrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te), TreeStoreElem *tselem, void *UNUSED(arg))
+static void cleardrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
+                                     TreeStoreElem *tselem, void *UNUSED(arg))
 {
        IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id;
        
@@ -413,7 +431,8 @@ static void cleardrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
        free_fcurves(&iat->adt->drivers);
 }
 
-static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te), TreeStoreElem *tselem, void *UNUSED(arg))
+static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
+                                       TreeStoreElem *tselem, void *UNUSED(arg))
 {
        IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id;
        FCurve *fcu;
@@ -713,7 +732,8 @@ static EnumPropertyItem prop_id_op_types[] = {
        {OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""},
        {OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""},
        {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
-       {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User", "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
+       {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User",
+     "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
        {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
        {OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""},
        {0, NULL, 0, NULL, NULL}
@@ -928,7 +948,9 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
        else if (act->idroot == 0) {
                /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */
                BKE_reportf(op->reports, RPT_WARNING,
-                           "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems",
+                           "Action '%s' does not specify what datablocks it can be used on. "
+                           "Try setting the 'ID Root Type' setting from the Datablocks Editor "
+                           "for this Action to avoid future problems",
                            act->id.name + 2);
        }
        
@@ -1158,7 +1180,8 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
 /* ******************** */
 
 
-static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, const float mval[2])
+static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops,
+                                       TreeElement *te, wmEvent *event, const float mval[2])
 {
        ReportList *reports = CTX_wm_reports(C); // XXX...
        
index ee02f99d5b7ffa67063f01b7066f2f94acd2a6be..14afcaa855f7be86510752c358e0e0eb9de2d3eb 100644 (file)
@@ -437,16 +437,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
 }
 #undef GRID_MIN_PX
 
-static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
+float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit)
 {
-       float grid, grid_scale;
-       unsigned char col_grid[3];
-       const int gridlines = v3d->gridlines / 2;
-
-       if (v3d->gridlines < 3) return;
-       
-       grid_scale = v3d->grid;
-       /* use 'grid_scale' instead of 'v3d->grid' from now on */
+       float grid_scale = v3d->grid;
 
        /* apply units */
        if (scene->unit.system) {
@@ -457,11 +450,25 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
 
                if (usys) {
                        int i = bUnit_GetBaseUnit(usys);
-                       *grid_unit = bUnit_GetNameDisplay(usys, i);
+                       if (grid_unit)
+                               *grid_unit = bUnit_GetNameDisplay(usys, i);
                        grid_scale = (grid_scale * (float)bUnit_GetScaler(usys, i)) / scene->unit.scale_length;
                }
        }
 
+       return grid_scale;
+}
+
+static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
+{
+       float grid, grid_scale;
+       unsigned char col_grid[3];
+       const int gridlines = v3d->gridlines / 2;
+
+       if (v3d->gridlines < 3) return;
+       
+       /* use 'grid_scale' instead of 'v3d->grid' from now on */
+       grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit);
        grid = gridlines * grid_scale;
 
        if (v3d->zbuf && scene->obedit) glDepthMask(0);  // for zbuffer-select
index cb2eaf7aef908c5fd1a87abadd54cac5ca47813c..006704e26bff1b9197f0df0c349f1d1ced3e4ce2 100644 (file)
@@ -4595,8 +4595,8 @@ static int createSlideVerts(TransInfo *t)
        BMBVHTree *btree = BMBVH_NewBVH(em, BMBVH_RESPECT_HIDDEN, NULL, NULL);
        SmallHash table;
        SlideData *sld = MEM_callocN(sizeof(*sld), "sld");
-       View3D *v3d = t->sa ? t->sa->spacedata.first : NULL;
-       RegionView3D *rv3d = t->ar ? t->ar->regiondata : NULL; /* background mode support */
+       View3D *v3d = NULL;
+       RegionView3D *rv3d = NULL;
        ARegion *ar = t->ar;
        float projectMat[4][4];
        float mval[2] = {(float)t->mval[0], (float)t->mval[1]};
@@ -4604,11 +4604,17 @@ static int createSlideVerts(TransInfo *t)
        float vec[3], vec2[3], lastvec[3] /*, size, dis=0.0, z */ /* UNUSED */;
        int numsel, i, j;
 
+       if (t->spacetype == SPACE_VIEW3D) {
+               /* background mode support */
+               v3d = t->sa ? t->sa->spacedata.first : NULL;
+               rv3d = t->ar ? t->ar->regiondata : NULL;
+       }
+
        sld->is_proportional = TRUE;
        sld->curr_sv_index = 0;
        sld->flipped_vtx = FALSE;
 
-       if (!v3d) {
+       if (!rv3d) {
                /* ok, let's try to survive this */
                unit_m4(projectMat);
        }
@@ -4808,7 +4814,7 @@ static int createSlideVerts(TransInfo *t)
                                        if (BM_elem_flag_test(e2, BM_ELEM_SELECT))
                                                continue;
                                        
-                                       if (!BMBVH_EdgeVisible(btree, e2, ar, v3d, t->obedit))
+                                       if (v3d && !BMBVH_EdgeVisible(btree, e2, ar, v3d, t->obedit))
                                                continue;
                                        
                                        j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v));
@@ -4871,8 +4877,8 @@ static int createSlideVerts(TransInfo *t)
                BLI_smallhash_insert(&sld->vhash, (uintptr_t)sv_array->v, sv_array);
        }
 
-       calcNonProportionalEdgeSlide(t, sld, mval);
-
+       if (rv3d)
+               calcNonProportionalEdgeSlide(t, sld, mval);
 
        sld->origfaces_init = TRUE;
        sld->em = em;
index f84e213bfd0f069b77bb04b58e3fbfb5054e91aa..14d01444681d5d65938bcd9e97467e26f2332402 100644 (file)
@@ -208,7 +208,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int
 
        if (!error) {
                /* clean glError buffer */
-               while (glGetError() != GL_NO_ERROR){};
+               while (glGetError() != GL_NO_ERROR) {}
 
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, image->tpageflag & IMA_CLAMP_U ? GL_CLAMP : GL_REPEAT);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, image->tpageflag & IMA_CLAMP_V ? GL_CLAMP : GL_REPEAT);
index ab275fa773a52a6ee9f208127b7fbf2d49a92e41..9bbf07a3ed2d01bd8210661cb40c68fe29edf5ca 100644 (file)
@@ -49,6 +49,7 @@
 #include "DNA_action_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
 #include "BLI_utildefines.h"
 #include "BKE_armature.h"
 #include "BKE_action.h"
@@ -66,6 +67,23 @@ extern "C"{
 #define __NLA_DEFNORMALS
 //#undef __NLA_DEFNORMALS
 
+short get_deformflags(struct Object *bmeshobj)
+{
+       short flags = ARM_DEF_VGROUP;
+
+       ModifierData *md;
+       for (md = (ModifierData*)bmeshobj->modifiers.first; md; md = (ModifierData*)md->next)
+       {
+               if (md->type == eModifierType_Armature)
+               {
+                       flags |= ((ArmatureModifierData*)md)->deformflag;
+                       break;
+               }
+       }
+
+       return flags;
+}
+
 BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj,
                                                                struct Object *bmeshobj, 
                                                                class RAS_MeshObject *mesh,
@@ -82,6 +100,7 @@ BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj,
                                                        m_dfnrToPC(NULL)
 {
        copy_m4_m4(m_obmat, bmeshobj->obmat);
+       m_deformflags = get_deformflags(bmeshobj);
 };
 
 BL_SkinDeformer::BL_SkinDeformer(
@@ -107,6 +126,7 @@ BL_SkinDeformer::BL_SkinDeformer(
                // in the calculation, so we must use the matrix of the original object to
                // simulate a pure replacement of the mesh.
                copy_m4_m4(m_obmat, bmeshobj_new->obmat);
+               m_deformflags = get_deformflags(bmeshobj_new);
        }
 
 BL_SkinDeformer::~BL_SkinDeformer()
@@ -201,7 +221,7 @@ void BL_SkinDeformer::BlenderDeformVerts()
        // set reference matrix
        copy_m4_m4(m_objMesh->obmat, m_obmat);
 
-       armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, ARM_DEF_VGROUP, NULL, NULL );
+       armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, m_deformflags, NULL, NULL );
                
        // restore matrix 
        copy_m4_m4(m_objMesh->obmat, obmat);
index dd8577b382e251266e14cd90c96e7314cc40d6e5..8e3d58515735ee634d9259d8386baaeb5cac6310 100644 (file)
@@ -109,6 +109,7 @@ protected:
        bool                                    m_recalcNormal;
        bool                                    m_copyNormals; // dirty flag so we know if Apply() needs to copy normal information (used for BGEDeformVerts())
        struct bPoseChannel**   m_dfnrToPC;
+       short                                   m_deformflags;
 
        void BlenderDeformVerts();
        void BGEDeformVerts();