svn merge ^/trunk/blender -r48147:48153
authorCampbell Barton <ideasman42@gmail.com>
Thu, 21 Jun 2012 08:07:49 +0000 (08:07 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 21 Jun 2012 08:07:49 +0000 (08:07 +0000)
20 files changed:
intern/cycles/app/cycles_xml.cpp
release/scripts/startup/bl_ui/properties_texture.py
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/ipo.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_250.c
source/blender/compositor/nodes/COM_DilateErodeNode.cpp
source/blender/compositor/operations/COM_BlurBaseOperation.cpp
source/blender/compositor/operations/COM_BlurBaseOperation.h
source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
source/blender/editors/space_node/drawnode.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_scene.c
source/blender/nodes/composite/nodes/node_composite_dilate.c

index 4c1b460839eb5d77fc285d4c85f1043b5526a28f..5ec5cb929d6d50b9a55ecbb28e5080752a3aa28f 100644 (file)
@@ -277,7 +277,7 @@ static void xml_read_integrator(const XMLReadState& state, pugi::xml_node node)
        
        xml_read_bool(&integrator->transparent_shadows, node, "transparent_shadows");
        xml_read_bool(&integrator->no_caustics, node, "no_caustics");
-       xml_read_float(&integrator->blur_glossy, node, "blur_glossy");
+       xml_read_float(&integrator->filter_glossy, node, "blur_glossy");
        
        xml_read_int(&integrator->seed, node, "seed");
        xml_read_float(&integrator->sample_clamp, node, "sample_clamp");
index 1d5e96cf7016cc14c5a7e336a0b967d126c4d6b0..5bde9538e5482e04ab672fe26d0721f899449d1a 100644 (file)
@@ -23,6 +23,7 @@ from bpy.types import Menu, Panel
 from bpy.types import (Brush,
                        Lamp,
                        Material,
+                       Object,
                        ParticleSettings,
                        Texture,
                        World)
@@ -80,6 +81,15 @@ def context_tex_datablock(context):
     return idblock
 
 
+def id_tex_datablock(bid):
+    if isinstance(bid, Object):
+        if bid.type == 'LAMP':
+            return bid.data
+        return bid.active_material
+
+    return bid
+
+
 class TextureButtonsPanel():
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -114,7 +124,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
         pin_id = space.pin_id
 
         if space.use_pin_id and not isinstance(pin_id, Texture):
-            idblock = pin_id
+            idblock = id_tex_datablock(pin_id)
             pin_id = None
 
         if not space.use_pin_id:
index 144cbe2c18d46e92c024b611441ee839c9813b53..5fe28d2b2545592dcd290017922dcd2eaace610b 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         263
-#define BLENDER_SUBVERSION      12
+#define BLENDER_SUBVERSION      13
 
 #define BLENDER_MINVERSION      250
 #define BLENDER_MINSUBVERSION   0
index bbc1874c2ae0cca15e2d6981e1387c42b8cad0fd..f51fee674cfc7c0ed91462f23d117df57a234c83 100644 (file)
@@ -46,6 +46,7 @@
 /* since we have versioning code here */
 #define DNA_DEPRECATED_ALLOW
 
+#include "DNA_actuator_types.h"
 #include "DNA_anim_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_camera_types.h"
@@ -1753,6 +1754,24 @@ void do_versions_ipos_to_animato(Main *main)
                                ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL);
                                ob->ipo->id.us--;
                                ob->ipo = NULL;
+
+                               {
+                                       /* If we have any empty action actuators, assume they were
+                                          converted IPO Actuators using the object IPO */
+                                       bActuator *act;
+                                       bActionActuator *aa;
+
+                                       for (act = ob->actuators.first; act; act = act->next) {
+                                               /* Any actuators set to ACT_IPO at this point are actually Action Actuators that
+                                                  need this converted IPO to finish converting the actuator. */
+                                               if (act->type == ACT_IPO)
+                                               {
+                                                       aa = (bActionActuator*)act->data;
+                                                       aa->act = ob->adt->action;
+                                                       act->type = ACT_ACTION;
+                                               }
+                                       }
+                               }
                        }
                }
                
index b481fd421dc4fadc683315b634d8ab7a3269d4e3..47dab0dcc6caa37fc2141a3ba6474e581e976bd9 100644 (file)
@@ -6982,6 +6982,21 @@ static void do_version_ntree_image_user_264(void *UNUSED(data), ID *UNUSED(id),
        }
 }
 
+static void do_version_ntree_dilateerode_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+       bNode *node;
+
+       for (node = ntree->nodes.first; node; node = node->next) {
+               if (node->type == CMP_NODE_DILATEERODE) {
+                       if (node->storage == NULL) {
+                               NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), __func__);
+                               data->falloff = PROP_SMOOTH;
+                               node->storage = data;
+                       }
+               }
+       }
+}
+
 static void do_versions(FileData *fd, Library *lib, Main *main)
 {
        /* WATCH IT!!!: pointers from libdata have not been converted */
@@ -7789,6 +7804,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                ma->strand_widthfade = 0.0f;
        }
 
+       if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 13)) {
+               bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT);
+
+               if (ntreetype && ntreetype->foreach_nodetree)
+                       ntreetype->foreach_nodetree(main, NULL, do_version_ntree_dilateerode_264);
+       }
+
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
 
index 5ed39ad5307786084b9e74f8768cf2a94a763f04..bfaa526b9953e5b308a6431ca59f2a0b4fb3ae93 100644 (file)
@@ -2558,11 +2558,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
                        for (ob = main->object.first; ob; ob = ob->id.next) {
                                for (act = ob->actuators.first; act; act = act->next) {
                                        if (act->type == ACT_IPO) {
-                                               // Create the new actuator
+                                               /* Create the new actuator */
                                                ia = act->data;
                                                aa = MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version");
 
-                                               // Copy values
+                                               /* Copy values */
                                                aa->type = ia->type;
                                                aa->flag = ia->flag;
                                                aa->sta = ia->sta;
@@ -2572,12 +2572,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
                                                if (ob->adt)
                                                        aa->act = ob->adt->action;
 
-                                               // Get rid of the old actuator
+                                               /* Get rid of the old actuator */
                                                MEM_freeN(ia);
 
-                                               // Assign the new actuator
+                                               /* Assign the new actuator */
                                                act->data = aa;
                                                act->type = act->otype = ACT_ACTION;
+
+                                               /* Fix for converting 2.4x files: if we don't have an action, but we have an
+                                                  object IPO, then leave the actuator as an IPO actuator for now and let the
+                                                  IPO conversion code handle it */
+                                               if (ob->ipo && !aa->act)
+                                                       act->type = ACT_IPO;
                                        }
                                        else if (act->type == ACT_SHAPEACTION) {
                                                act->type = act->otype = ACT_ACTION;
index fbec1522e276071cc07c19dc70286e35dd7f8ecf..285bfa0470e2ee17077f41599a2d7be8da06e22d 100644 (file)
@@ -117,6 +117,12 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
 #endif
                operationx->setSubtract(editorNode->custom2 < 0);
                operationy->setSubtract(editorNode->custom2 < 0);
+
+               if (editorNode->storage) {
+                       NodeDilateErode *data = (NodeDilateErode *)editorNode->storage;
+                       operationx->setFalloff(data->falloff);
+                       operationy->setFalloff(data->falloff);
+               }
        }
        else {
                if (editorNode->custom2 > 0) {
index a233c7a50aee92849f20f6f24a3a286314222893..df64b7c8ddcfc7f75f016ebec75e1b17ef6f0317 100644 (file)
@@ -91,7 +91,7 @@ float *BlurBaseOperation::make_gausstab(int rad)
 
 /* normalized distance from the current (inverted so 1.0 is close and 0.0 is far)
  * 'ease' is applied after, looks nicer */
-float *BlurBaseOperation::make_dist_fac_inverse(int rad)
+float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff)
 {
        float *dist_fac_invert, val;
        int i, n;
@@ -103,9 +103,26 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad)
        for (i = -rad; i <= rad; i++) {
                val = 1.0f - fabsf(((float)i / (float)rad));
 
-               /* ease - gives less hard lines for dilate/erode feather */
-               val = (3.0f * val * val - 2.0f * val * val * val);
-
+               /* keep in sync with proportional_falloff_curve_only_items */
+               switch (falloff) {
+                       case PROP_SMOOTH:
+                               /* ease - gives less hard lines for dilate/erode feather */
+                               val = (3.0f * val * val - 2.0f * val * val * val);
+                               break;
+                       case PROP_SPHERE:
+                               val = sqrtf(2.0f * val - val * val);
+                               break;
+                       case PROP_ROOT:
+                               val = sqrtf(val);
+                               break;
+                       case PROP_SHARP:
+                               val = val * val;
+                               break;
+                       case PROP_LIN:
+                       default:
+                               /* nothing */
+                               break;
+               }
                dist_fac_invert[i + rad] = val;
        }
 
index 33c07abbb362746a67bcad06df5772fa2efb4f41..8f7208274dbcb5a393b05ca3f38673e5a6f7d2de 100644 (file)
@@ -37,7 +37,7 @@ protected:
        NodeBlurData *data;
        BlurBaseOperation(DataType data_type);
        float *make_gausstab(int rad);
-       float *make_dist_fac_inverse(int rad);
+       float *make_dist_fac_inverse(int rad, int falloff);
        float size;
        bool deleteData;
        bool sizeavailable;
index 1283ac489234719415c4bce1d12b6d26497c3e3c..954aef7b9164765063600c799a0d4b634a6ee9f9 100644 (file)
@@ -54,7 +54,7 @@ void GaussianAlphaXBlurOperation::initExecution()
 
                this->rad = rad;
                this->gausstab = BlurBaseOperation::make_gausstab(rad);
-               this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad);
+               this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff);
        }
 }
 
@@ -77,7 +77,7 @@ void GaussianAlphaXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
                        rad = 1;
 
                this->rad = rad;
-               this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad);
+               this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff);
        }
 }
 
index 3268e51be016cd30545fa6f07ae1ed508da1db19..38817ebef1d78f919ff129b61d13615d55dbe8e0 100644 (file)
@@ -30,6 +30,7 @@ class GaussianAlphaXBlurOperation : public BlurBaseOperation {
 private:
        float *gausstab;
        float *distbuf_inv;
+       int falloff;  /* falloff for distbuf_inv */
        bool do_subtract;
        int rad;
        void updateGauss(MemoryBuffer **memoryBuffers);
@@ -58,5 +59,6 @@ public:
         * Set subtract for Dilate/Erode functionality
         */
        void setSubtract(bool subtract) { this->do_subtract = subtract; }
+       void setFalloff(int falloff) { this->falloff = falloff; }
 };
 #endif
index 1d67c23e41b33fa5b33a22766f7b0c02fb5cb296..e1105cf94b1cdb2a7e051eb4ae336f0e69329e83 100644 (file)
@@ -54,7 +54,7 @@ void GaussianAlphaYBlurOperation::initExecution()
 
                this->rad = rad;
                this->gausstab = BlurBaseOperation::make_gausstab(rad);
-               this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad);
+               this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff);
        }
 }
 
@@ -77,7 +77,7 @@ void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
                        rad = 1;
 
                this->rad = rad;
-               this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad);
+               this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff);
        }
 }
 
index 0ffc264ba98368bfbcb9c55e8f177b58de0f22bd..67166be824110402da0c372cfcaf736cfdf3f5b8 100644 (file)
@@ -31,6 +31,7 @@ private:
        float *gausstab;
        float *distbuf_inv;
        bool do_subtract;
+       int falloff;
        int rad;
        void updateGauss(MemoryBuffer **memoryBuffers);
 public:
@@ -58,5 +59,6 @@ public:
         * Set subtract for Dilate/Erode functionality
         */
        void setSubtract(bool subtract) { this->do_subtract = subtract; }
+       void setFalloff(int falloff) { this->falloff = falloff; }
 };
 #endif
index bce63b889509dd0b47c822ad91c42ec997f7f3cb..56b763d0773cb376c5addfb96cba1a976d7395fd 100644 (file)
@@ -1769,8 +1769,13 @@ static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C)
 {
        uiItemR(layout, ptr, "type", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
-       if (RNA_enum_get(ptr, "type") == CMP_NODE_DILATEERODE_DISTANCE_THRESH) {
-               uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE);
+       switch (RNA_enum_get(ptr, "type")) {
+               case CMP_NODE_DILATEERODE_DISTANCE_THRESH:
+                       uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE);
+                       break;
+               case CMP_NODE_DILATEERODE_DISTANCE_FEATHER:
+                       uiItemR(layout, ptr, "falloff", 0, NULL, ICON_NONE);
+                       break;
        }
 }
 
index 460038f60046c7b42fbdd13cc570d060d30fd744..b1045bf3c636ac915f675ae94c2ee9f9a98d51c1 100644 (file)
@@ -559,6 +559,11 @@ typedef struct NodeColorspill {
        float uspillr, uspillg, uspillb;
 } NodeColorspill;
 
+typedef struct NodeDilateErode {
+       char falloff;
+       char pad[7];
+} NodeDilateErode;
+
 typedef struct NodeTexBase {
        TexMapping tex_mapping;
        ColorMapping color_mapping;
index 473ab7485b09f5ff866af6411e7e475e5ccca643..a8d176db7679c4893b9c70f1e0f545d588cb4c75 100644 (file)
@@ -41,6 +41,7 @@ extern EnumPropertyItem object_mode_items[];
 extern EnumPropertyItem metaelem_type_items[];
 
 extern EnumPropertyItem proportional_falloff_items[];
+extern EnumPropertyItem proportional_falloff_curve_only_items[];
 extern EnumPropertyItem proportional_editing_items[];
 extern EnumPropertyItem snap_target_items[];
 extern EnumPropertyItem snap_element_items[];
index ecdfe1505c8a7259443a7ccf2f2fd29db383f6c3..15fdce09d83dc41ee64f02176e3faf51f1eeef27 100644 (file)
@@ -135,6 +135,8 @@ static void rna_CurveMapping_clipmaxy_range(PointerRNA *ptr, float *min, float *
 
 static char *rna_ColorRamp_path(PointerRNA *ptr)
 {
+       char *path = NULL;
+       
        /* handle the cases where a single datablock may have 2 ramp types */
        if (ptr->id.data) {
                ID *id = ptr->id.data;
@@ -145,16 +147,47 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
                                Material *ma = (Material *)id;
                                
                                if (ptr->data == ma->ramp_col)
-                                       return BLI_strdup("diffuse_ramp");
+                                       path = BLI_strdup("diffuse_ramp");
                                else if (ptr->data == ma->ramp_spec)
-                                       return BLI_strdup("specular_ramp");
+                                       path = BLI_strdup("specular_ramp");
+                               break;
                        }
-                       break;
+                       
+                       case ID_NT:
+                       {
+                               bNodeTree *ntree = (bNodeTree *)id;
+                               bNode *node;
+                               PointerRNA node_ptr;
+                               char *node_path;
+                               
+                               for (node = ntree->nodes.first; node; node = node->next) {
+                                       if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
+                                               if (node->storage == ptr->data) {
+                                                       /* all node color ramp properties called 'color_ramp'
+                                                        * prepend path from ID to the node
+                                                        */
+                                                       RNA_pointer_create(id, &RNA_Node, node, &node_ptr);
+                                                       node_path = RNA_path_from_ID_to_struct(&node_ptr);
+                                                       path = BLI_sprintfN("%s.color_ramp", node_path);
+                                                       MEM_freeN(node_path);
+                                               }
+                                       }
+                               }
+                               break;
+                       }
+                       
+                       default:
+                               /* everything else just uses 'color_ramp' */
+                               path = BLI_strdup("color_ramp");
+                               break;
                }
        }
+       else {
+               /* everything else just uses 'color_ramp' */
+               path = BLI_strdup("color_ramp");
+       }
        
-       /* everything else just uses 'color_ramp' */
-       return BLI_strdup("color_ramp");
+       return path;
 }
 
 static char *rna_ColorRampElement_path(PointerRNA *ptr)
@@ -204,7 +237,6 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
                        }
                        break;
                                
-                       /* TODO: node trees need special attention */
                        case ID_NT:
                        {
                                bNodeTree *ntree = (bNodeTree *)id;
index 44ee8698c5d33ae9c6b50fbaeadac25c171f142d..31854413fa877359bd9d88c1ef33527063e0d6a0 100644 (file)
@@ -2068,11 +2068,21 @@ static void def_cmp_dilate_erode(StructRNA *srna)
        RNA_def_property_ui_text(prop, "Distance", "Distance to grow/shrink (number of iterations)");
        RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
+       /* CMP_NODE_DILATEERODE_DISTANCE_THRESH only */
        prop = RNA_def_property(srna, "edge", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "custom3");
        RNA_def_property_range(prop, -100, 100);
        RNA_def_property_ui_text(prop, "Edge", "Edge to inset");
        RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+       RNA_def_struct_sdna_from(srna, "NodeDilateErode", "storage");
+
+       /* CMP_NODE_DILATEERODE_DISTANCE_FEATHER only */
+       prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "falloff");
+       RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items);
+       RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
 static void def_cmp_scale(StructRNA *srna)
index 85c7b5679c1c520b0d50bf460719cbb4ba5067c1..072df099cea4aadc9f5ce6530d0c882676ec58f7 100644 (file)
@@ -101,6 +101,16 @@ EnumPropertyItem proportional_falloff_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
+/* subset of the enum - only curves, missing random and const */
+EnumPropertyItem proportional_falloff_curve_only_items[] = {
+       {PROP_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", "Smooth falloff"},
+       {PROP_SPHERE, "SPHERE", ICON_SPHERECURVE, "Sphere", "Spherical falloff"},
+       {PROP_ROOT, "ROOT", ICON_ROOTCURVE, "Root", "Root falloff"},
+       {PROP_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", "Sharp falloff"},
+       {PROP_LIN, "LINEAR", ICON_LINCURVE, "Linear", "Linear falloff"},
+       {0, NULL, 0, NULL, NULL}
+};
+
 
 EnumPropertyItem proportional_editing_items[] = {
        {PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", "Proportional Editing disabled"},
index 2f139831cc959ee0c07e0cc265767b1b5ef4abad..5977d291388472c97fa39391609a7692d05ee157 100644 (file)
@@ -146,6 +146,13 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod
        }
 }
 
+static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), "NodeDilateErode");
+       data->falloff = PROP_SMOOTH;
+       node->storage = data;
+}
+
 void register_node_type_cmp_dilateerode(bNodeTreeType *ttype)
 {
        static bNodeType ntype;
@@ -153,7 +160,10 @@ void register_node_type_cmp_dilateerode(bNodeTreeType *ttype)
        node_type_base(ttype, &ntype, CMP_NODE_DILATEERODE, "Dilate/Erode", NODE_CLASS_OP_FILTER, NODE_OPTIONS);
        node_type_socket_templates(&ntype, cmp_node_dilateerode_in, cmp_node_dilateerode_out);
        node_type_size(&ntype, 130, 100, 320);
+       node_type_init(&ntype, node_composit_init_dilateerode);
        node_type_exec(&ntype, node_composit_exec_dilateerode);
        
+       node_type_storage(&ntype, "NodeDilateErode", node_free_standard_storage, node_copy_standard_storage);
+
        nodeRegisterType(ttype, &ntype);
 }