svn merge ^/trunk/blender -r42069:42076
authorCampbell Barton <ideasman42@gmail.com>
Tue, 22 Nov 2011 18:15:08 +0000 (18:15 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 22 Nov 2011 18:15:08 +0000 (18:15 +0000)
16 files changed:
intern/cycles/device/device_opencl.cpp
intern/cycles/kernel/kernel.cl
intern/cycles/render/filter.cpp
intern/cycles/util/util_path.cpp
intern/cycles/util/util_path.h
release/scripts/startup/bl_ui/properties_render.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenkernel/intern/ocean.c
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/makesrna/intern/rna_ui_api.c
source/blender/modifiers/intern/MOD_ocean.c

index f75928c1b8068fa291faf6f2268b1679f476dca9..e0b4f67da057dc2d4ff09341cc6f89026a1d4261 100644 (file)
@@ -278,10 +278,7 @@ public:
 
        bool build_kernel(const string& kernel_path)
        {
-               string build_options = "";
-
-               build_options += "-I " + kernel_path + ""; /* todo: escape path, but it doesn't get parsed correct? */
-               build_options += kernel_build_options();
+               string build_options = kernel_build_options();
        
                ciErr = clBuildProgram(cpProgram, 0, NULL, build_options.c_str(), NULL, NULL);
 
@@ -312,6 +309,8 @@ public:
                   kernel caches do not seem to recognize changes in included files.
                   so we force recompile on changes by adding the md5 hash of all files */
                string source = "#include \"kernel.cl\" // " + kernel_md5 + "\n";
+               source = path_source_replace_includes(source, kernel_path);
+
                size_t source_len = source.size();
                const char *source_str = source.c_str();
 
index 68ca24af58e942fe3bd1b55fb2daa9c7f6f6ad39..c00bc3fe9579317130eaf0db0da164ba771864cf 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "kernel_film.h"
 #include "kernel_path.h"
-//#include "kernel_displace.h"
 
 __kernel void kernel_ocl_path_trace(
        __constant KernelData *data,
index c000f1a063602bde68012c9f771b9e119f232b44..9bcf57b5a274f91b005a8aa2afc04d69a0486283 100644 (file)
@@ -53,7 +53,7 @@ static float filter_func_gaussian(float v, float width)
 
 static vector<float> filter_table(FilterType type, float width)
 {
-       const int filter_table_size = FILTER_TABLE_SIZE;
+       const int filter_table_size = FILTER_TABLE_SIZE-1;
        vector<float> filter_table_cdf(filter_table_size+1);
        vector<float> filter_table(filter_table_size+1);
        float (*filter_func)(float, float) = NULL;
index 55e6a95b54a00f067a1ce58b1d2ba27f941b8312..69069a3bbce4929884fdc60b6d2d7ebffc8a0151 100644 (file)
@@ -162,5 +162,46 @@ bool path_read_binary(const string& path, vector<uint8_t>& binary)
        return true;
 }
 
+static bool path_read_text(const string& path, string& text)
+{
+       vector<uint8_t> binary;
+
+       if(!path_exists(path) || !path_read_binary(path, binary))
+               return false;
+       
+       const char *str = (const char*)&binary[0];
+       size_t size = binary.size();
+       text = string(str, size);
+
+       return true;
+}
+
+string path_source_replace_includes(const string& source_, const string& path)
+{
+       /* our own little c preprocessor that replaces #includes with the file
+          contents, to work around issue of opencl drivers not supporting
+          include paths with spaces in them */
+       string source = source_;
+       const string include = "#include \"";
+       size_t n, pos = 0;
+
+       while((n = source.find(include, pos)) != string::npos) {
+               size_t n_start = n + include.size();
+               size_t n_end = source.find("\"", n_start);
+               string filename = source.substr(n_start, n_end - n_start);
+
+               string text, filepath = path_join(path, filename);
+
+               if(path_read_text(filepath, text)) {
+                       text = path_source_replace_includes(text, path_dirname(filepath));
+                       source.replace(n, n_end + 1 - n, "\n" + text + "\n");
+               }
+               else
+                       pos = n_end;
+       }
+
+       return source;
+}
+
 CCL_NAMESPACE_END
 
index 4a9d45ec5940b934f7d9e588359e4b1918a77950..6cba6a3158f0f2d5c75f9b018f7f4b8b3743b27c 100644 (file)
@@ -46,6 +46,8 @@ void path_create_directories(const string& path);
 bool path_write_binary(const string& path, const vector<uint8_t>& binary);
 bool path_read_binary(const string& path, vector<uint8_t>& binary);
 
+string path_source_replace_includes(const string& source, const string& path);
+
 CCL_NAMESPACE_END
 
 #endif
index 100f5b1730fc29f8d7c3e39412da489137eddac1..57df602f19a08492b2a783ca1ec63f5ec4a7d12e 100644 (file)
@@ -456,16 +456,13 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
         file_format = rd.image_settings.file_format
 
         layout.prop(rd, "filepath", text="")
+        
+        flow = layout.column_flow()
+        flow.prop(rd, "use_overwrite")
+        flow.prop(rd, "use_placeholder")
+        flow.prop(rd, "use_file_extension")
 
-        split = layout.split()
-
-        col = split.column()
-        col.template_image_settings(rd.image_settings)
-
-        col = split.column()
-        col.prop(rd, "use_file_extension")
-        col.prop(rd, "use_overwrite")
-        col.prop(rd, "use_placeholder")
+        layout.template_image_settings(rd.image_settings)
 
         if file_format == 'QUICKTIME_CARBON':
             layout.operator("scene.render_data_set_quicktime_codec")
index 5bcdbc1efe8f81ae2754d08b2d0d10ffe3fe2ac6..ddea7bd00fdeff6e719e7190ed3be1afac7c2f24 100644 (file)
@@ -88,7 +88,7 @@ class VIEW3D_PT_tools_objectmode(View3DPanel, Panel):
         col.operator("object.join")
 
         active_object = context.active_object
-        if active_object and active_object.type == 'MESH':
+        if active_object and active_object.type in {'MESH', 'CURVE', 'SURFACE'}:
 
             col = layout.column(align=True)
             col.label(text="Shading:")
index b8f96fa732d28d7cfd4e041c2734400ff6c90b85..ae622358fd2192b5c134e46ed5c3ec1b9de789bc 100644 (file)
@@ -313,8 +313,8 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float
        float uu,vv;
 
        // first wrap the texture so 0 <= (u,v) < 1
-       u = fmod(u,1.0f);
-       v = fmod(v,1.0f);
+       u = fmodf(u,1.0f);
+       v = fmodf(v,1.0f);
 
        if (u < 0) u += 1.0f;
        if (v < 0) v += 1.0f;
@@ -1021,6 +1021,22 @@ static void cache_filename(char *string, const char *path, const char *relbase,
        BKE_makepicstring(string, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, 1, TRUE);
 }
 
+/* silly functions but useful to inline when the args do a lot of indirections */
+MINLINE void rgb_to_rgba_unit_alpha(float r_rgba[4], const float rgb[3])
+{
+       r_rgba[0]= rgb[0];
+       r_rgba[1]= rgb[1];
+       r_rgba[2]= rgb[2];
+       r_rgba[3]= 1.0f;
+}
+MINLINE void value_to_rgba_unit_alpha(float r_rgba[4], const float value)
+{
+       r_rgba[0]= value;
+       r_rgba[1]= value;
+       r_rgba[2]= value;
+       r_rgba[3]= 1.0f;
+}
+
 void BKE_free_ocean_cache(struct OceanCache *och)
 {
        int i, f=0;
@@ -1076,9 +1092,7 @@ void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, in
 
        if (och->ibufs_disp[f]) {
                ibuf_sample(och->ibufs_disp[f], u, v, (1.0f/(float)res_x), (1.0f/(float)res_y), result);
-               ocr->disp[0] = result[0];
-               ocr->disp[1] = result[1];
-               ocr->disp[2] = result[2];
+               copy_v3_v3(ocr->disp, result);
        }
 
        if (och->ibufs_foam[f]) {
@@ -1088,34 +1102,31 @@ void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, in
 
        if (och->ibufs_norm[f]) {
                ibuf_sample(och->ibufs_norm[f], u, v, (1.0f/(float)res_x), (1.0f/(float)res_y), result);
-               ocr->normal[0] = result[0];
-               ocr->normal[1] = result[1];
-               ocr->normal[2] = result[2];
+               copy_v3_v3(ocr->normal, result);
        }
 }
 
 void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j)
 {
-       int res_x = och->resolution_x;
-       int res_y = och->resolution_y;
+       const int res_x = och->resolution_x;
+       const int res_y = och->resolution_y;
 
-       i = abs(i) % res_x;
-       j = abs(j) % res_y;
+       if (i < 0) i= -i;
+       if (j < 0) j= -j;
+
+       i = i % res_x;
+       j = j % res_y;
 
        if (och->ibufs_disp[f]) {
-               ocr->disp[0] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 0];
-               ocr->disp[1] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 1];
-               ocr->disp[2] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 2];
+               copy_v3_v3(ocr->disp, &och->ibufs_disp[f]->rect_float[4*(res_x*j + i)]);
        }
 
        if (och->ibufs_foam[f]) {
-               ocr->foam = och->ibufs_foam[f]->rect_float[4*(res_x*j + i) + 0];
+               ocr->foam = och->ibufs_foam[f]->rect_float[4*(res_x*j + i)];
        }
 
        if (och->ibufs_norm[f]) {
-               ocr->normal[0] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 0];
-               ocr->normal[1] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 1];
-               ocr->normal[2] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 2];
+               copy_v3_v3(ocr->normal, &och->ibufs_norm[f]->rect_float[4*(res_x*j + i)]);
        }
 }
 
@@ -1206,9 +1217,7 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
        /* setup image format */
        imf.imtype= R_IMF_IMTYPE_OPENEXR;
        imf.depth=  R_IMF_CHAN_DEPTH_16;
-       imf.exr_codec= R_IMF_EXR_CODEC_ZIP; /* ZIP */
-
-
+       imf.exr_codec= R_IMF_EXR_CODEC_ZIP;
 
        for (f=och->start, i=0; f<=och->end; f++, i++) {
 
@@ -1228,10 +1237,7 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
                                BKE_ocean_eval_ij(o, &ocr, x, y);
 
                                /* add to the image */
-                               ibuf_disp->rect_float[4*(res_x*y + x) + 0] = ocr.disp[0];
-                               ibuf_disp->rect_float[4*(res_x*y + x) + 1] = ocr.disp[1];
-                               ibuf_disp->rect_float[4*(res_x*y + x) + 2] = ocr.disp[2];
-                               ibuf_disp->rect_float[4*(res_x*y + x) + 3] = 1.0f;
+                               rgb_to_rgba_unit_alpha(&ibuf_disp->rect_float[4*(res_x*y + x)], ocr.disp);
 
                                if (o->_do_jacobian) {
                                        /* TODO, cleanup unused code - campbell */
@@ -1284,35 +1290,29 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
 
                                        prev_foam[res_x*y + x] = foam_result;
 
-                                       ibuf_foam->rect_float[4*(res_x*y + x) + 0] = foam_result;
-                                       ibuf_foam->rect_float[4*(res_x*y + x) + 1] = foam_result;
-                                       ibuf_foam->rect_float[4*(res_x*y + x) + 2] = foam_result;
-                                       ibuf_foam->rect_float[4*(res_x*y + x) + 3] = 1.0;
+                                       value_to_rgba_unit_alpha(&ibuf_foam->rect_float[4*(res_x*y + x)], foam_result);
                                }
 
                                if (o->_do_normals) {
-                                       ibuf_normal->rect_float[4*(res_x*y + x) + 0] = ocr.normal[0];
-                                       ibuf_normal->rect_float[4*(res_x*y + x) + 1] = ocr.normal[1];
-                                       ibuf_normal->rect_float[4*(res_x*y + x) + 2] = ocr.normal[2];
-                                       ibuf_normal->rect_float[4*(res_x*y + x) + 3] = 1.0;
+                                       rgb_to_rgba_unit_alpha(&ibuf_normal->rect_float[4*(res_x*y + x)], ocr.normal);
                                }
                        }
                }
 
                /* write the images */
                cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE);
-               if(0 == BKE_write_ibuf(ibuf_disp, string, &imf))  // 2 == ZIP exr codec
+               if(0 == BKE_write_ibuf(ibuf_disp, string, &imf))
                        printf("Cannot save Displacement File Output to %s\n", string);
 
                if (o->_do_jacobian) {
                        cache_filename(string, och->bakepath, och->relbase,  f, CACHE_TYPE_FOAM);
-                       if(0 == BKE_write_ibuf(ibuf_foam, string, &imf))  // 2 == ZIP exr codec
+                       if(0 == BKE_write_ibuf(ibuf_foam, string, &imf))
                                printf("Cannot save Foam File Output to %s\n", string);
                }
 
                if (o->_do_normals) {
                        cache_filename(string, och->bakepath,  och->relbase, f, CACHE_TYPE_NORMAL);
-                       if(0 == BKE_write_ibuf(ibuf_normal, string, &imf))  // 2 == ZIP exr codec
+                       if(0 == BKE_write_ibuf(ibuf_normal, string, &imf))
                                printf("Cannot save Normal File Output to %s\n", string);
                }
 
index 458fe175fbb1b0662c97e00315ad9f3b10787b59..ec6958c841512875534d8b6efbe24d632d922238 100644 (file)
@@ -115,6 +115,7 @@ typedef struct uiLayout uiLayout;
 #define UI_BLOCK_OUT_1                 1024
 #define UI_BLOCK_NO_FLIP               2048
 #define UI_BLOCK_POPUP_MEMORY  4096
+#define UI_BLOCK_CLIP_EVENTS   8192    /* stop handling mouse events */
 
 /* uiPopupBlockHandle->menuretval */
 #define UI_RETURN_CANCEL       1       /* cancel all menus cascading */
@@ -364,6 +365,7 @@ void uiTextBoundsBlock(uiBlock *block, int addval);
 void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my);
 void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my);
 void uiCenteredBoundsBlock(uiBlock *block, int addval);
+void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy);
 
 int            uiBlocksGetYMin         (struct ListBase *lb);
 
index 4b7adbc10643b11a38fe27c04236af37f8db92d8..86961cd84dcc58d28069c5a18bcfd4cddc3962cd 100644 (file)
@@ -434,6 +434,15 @@ void uiCenteredBoundsBlock(uiBlock *block, int addval)
        block->dobounds= UI_BLOCK_BOUNDS_POPUP_CENTER;
 }
 
+void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy)
+{
+       block->minx = minx;
+       block->miny = miny;
+       block->maxx = maxx;
+       block->maxy = maxy;
+       block->dobounds = 0;
+}
+
 /* ************** LINK LINE DRAWING  ************* */
 
 /* link line drawing is not part of buttons or theme.. so we stick with it here */
index 688e8f95ac780669166c3d8f2edc3b08b2ca3f60..1ba6acf367a405d06dff227d80359a4d8133d707 100644 (file)
@@ -5063,6 +5063,14 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
                        if(ui_but_contains_pt(but, mx, my))
                                butover= but;
                }
+
+               /* CLIP_EVENTS prevents the event from reaching other blocks */
+               if (block->flag & UI_BLOCK_CLIP_EVENTS) {
+                       /* check if mouse is inside block */
+                       if(block->minx <= mx && block->maxx >= mx &&
+                          block->miny <= my && block->maxy >= my)
+                               break;
+               }
        }
 
        return butover;
index 11a9c0d8d40be16212247474b3ce862245e75f26..720102a2b7c8ba157c139ffd350cad4be5cda23b 100644 (file)
@@ -487,38 +487,6 @@ static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v)
        }
 }
 
-#if 0
-static void image_pack_cb(bContext *C, void *ima_v, void *iuser_v) 
-{
-       if(ima_v) {
-               Image *ima= ima_v;
-               if(ima->source!=IMA_SRC_SEQUENCE && ima->source!=IMA_SRC_MOVIE) {
-                       if (ima->packedfile) {
-                               if (G.fileflags & G_AUTOPACK) {
-                                       if (okee("Disable AutoPack ?")) {
-                                               G.fileflags &= ~G_AUTOPACK;
-                                       }
-                               }
-                               
-                               if ((G.fileflags & G_AUTOPACK) == 0) {
-                                       unpackImage(NULL, ima, PF_ASK); /* XXX report errors */
-                                       ED_undo_push(C, "Unpack image");
-                               }
-                       } 
-                       else {
-                               ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser_v);
-                               if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) {
-                                       // XXX error("Can't pack painted image. Save image or use Repack as PNG");
-                               } else {
-                                       ima->packedfile = newPackedFile(NULL, ima->name); /* XXX report errors */
-                                       ED_undo_push(C, "Pack image");
-                               }
-                       }
-               }
-       }
-}
-#endif
-
 #if 0
 static void image_freecache_cb(bContext *C, void *ima_v, void *unused) 
 {
@@ -676,8 +644,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
        if(!compact)
                uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL);
 
-       // XXX missing: reload, pack
-
        if(ima) {
                uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL);
 
@@ -830,7 +796,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
        col= uiLayoutColumn(layout, 0);
 
        uiItemR(col, imfptr, "file_format", 0, "", ICON_NONE);
-
+       
        row= uiLayoutRow(col, 0);
        uiItemR(row, imfptr, "color_mode", UI_ITEM_R_EXPAND, "Color", ICON_NONE);
 
@@ -858,24 +824,27 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
        if (ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
                uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE);
        }
-
+       
+       row= uiLayoutRow(col, 0);
        if (BKE_imtype_supports_zbuf(imf->imtype)) {
-               uiItemR(col, imfptr, "use_zbuffer", 0, NULL, ICON_NONE);
+               uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE);
        }
 
        if (is_render_out && (imf->imtype == R_IMF_IMTYPE_OPENEXR)) {
-               uiItemR(col, imfptr, "use_preview", 0, NULL, ICON_NONE);
+               uiItemR(row, imfptr, "use_preview", 0, NULL, ICON_NONE);
        }
 
        if (imf->imtype == R_IMF_IMTYPE_JP2) {
+               row= uiLayoutRow(col, 0);
+               uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE);
+               uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE);
+               
                uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE);
-               uiItemR(col, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE);
-               uiItemR(col, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE);
        }
 
        if (imf->imtype == R_IMF_IMTYPE_CINEON) {
 #if 1
-               uiItemL(col, "FIXME: hard coded Non-Linear, Gamma:1.0", ICON_NONE);
+               uiItemL(col, "Hard coded Non-Linear, Gamma:1.0", ICON_NONE);
 #else
                uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
                uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE);
index 47cfa5c763de1ebd786209c6b3db69a896785946..4e9ac08d8c8e21f775d235f77f0824283b8a7d64 100644 (file)
@@ -471,6 +471,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
                float locx, locy;
                rctf *rect= &gnode->totr;
                float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
+               float group_header= 26*U.dpi/72;
                int counter;
                int dy;
                
@@ -594,6 +595,15 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
                                gsock = gsock->next;
                        }
                }
+               
+               /* Set the block bounds to clip mouse events from underlying nodes.
+                * Add margin for header and input/output columns.
+                */
+               uiExplicitBoundsBlock(gnode->block,
+                                                         rect->xmin - node_group_frame,
+                                                         rect->ymin,
+                                                         rect->xmax + node_group_frame,
+                                                         rect->ymax + group_header);
        }
 }
 
@@ -1001,7 +1011,6 @@ static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), Po
 
 static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
-       //uiItemR(layout, ptr, "image", 0, "", ICON_NONE);
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
        uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
 }
@@ -1637,10 +1646,9 @@ static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C)
        NodeImageFile *nif= node->storage;
        PointerRNA imfptr;
 
-       uiLayout *col, *row;
+       uiLayout *row;
 
-       col= uiLayoutColumn(layout, 0);
-       uiItemR(col, ptr, "filepath", 0, "", ICON_NONE);
+       uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE);
 
        RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &nif->im_format, &imfptr);
        uiTemplateImageSettings(layout, &imfptr);
index c4a7f2cb4730f9d48ce78260488dea8d38b51ed5..024db35a084910ecbf2ff137f8c40b6768ea1332 100644 (file)
@@ -197,28 +197,16 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree)
        bNode *node;
        char str[32];
        
-       /* add node uiBlocks in reverse order - prevents events going to overlapping nodes */
+       /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */
        
-       /* process selected nodes first so they're at the start of the uiblocks list */
-       for(node= ntree->nodes.last; node; node= node->prev) {
-               
-               if (node->flag & NODE_SELECT) {
+       for(node= ntree->nodes.first; node; node=node->next) {
                        /* ui block */
                        sprintf(str, "node buttons %p", (void *)node);
                        node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS);
                        uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
-               }
-       }
-       
-       /* then the rest */
-       for(node= ntree->nodes.last; node; node= node->prev) {
-               
-               if (!(node->flag & (NODE_GROUP_EDIT|NODE_SELECT))) {
-                       /* ui block */
-                       sprintf(str, "node buttons %p", (void *)node);
-                       node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS);
-                       uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
-               }
+                       
+                       /* this cancels events for background nodes */
+                       uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS);
        }
 }
 
@@ -339,6 +327,15 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
        node->totr.xmax= locx + node->width;
        node->totr.ymax= locy;
        node->totr.ymin= MIN2(dy, locy-2*NODE_DY);
+       
+       /* Set the block bounds to clip mouse events from underlying nodes.
+        * Add a margin for sockets on each side.
+        */
+       uiExplicitBoundsBlock(node->block,
+                                                 node->totr.xmin - NODE_SOCKSIZE,
+                                                 node->totr.ymin,
+                                                 node->totr.xmax + NODE_SOCKSIZE,
+                                                 node->totr.ymax);
 }
 
 /* based on settings in node, sets drawing rect info. each redraw! */
@@ -391,6 +388,15 @@ static void node_update_hidden(bNode *node)
                        rad+= drad;
                }
        }
+
+       /* Set the block bounds to clip mouse events from underlying nodes.
+        * Add a margin for sockets on each side.
+        */
+       uiExplicitBoundsBlock(node->block,
+                                                 node->totr.xmin - NODE_SOCKSIZE,
+                                                 node->totr.ymin,
+                                                 node->totr.xmax + NODE_SOCKSIZE,
+                                                 node->totr.ymax);
 }
 
 void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node)
index d0f25fcb60c17db8c83bbc4a81914dd7276b27ee..52ffdec7174aa1d2d6f8c7a245ead109d75fd32d 100644 (file)
@@ -399,11 +399,8 @@ void RNA_api_ui_layout(StructRNA *srna)
 
        func= RNA_def_function(srna, "template_image_settings", "uiTemplateImageSettings");
        RNA_def_function_ui_description(func, "User interface for setting image format options");
-       // RNA_def_function_flag(func, FUNC_USE_CONTEXT);
-       // api_ui_item_rna_common(func);
        parm= RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
-       // RNA_def_boolean(func, "compact", 0, "", "Use more compact layout");
 
        func= RNA_def_function(srna, "template_movieclip", "uiTemplateMovieClip");
        RNA_def_function_ui_description(func, "Item(s). User interface for selecting movie clips and their source paths");
index 991b4afe073526289e64211126660182667f11b5..140acc987709509d3606c6b536521ebe1af9d998 100644 (file)
@@ -78,10 +78,10 @@ static void init_ocean_modifier(struct OceanModifierData *omd)
 
        BKE_free_ocean_data(omd->ocean);
        BKE_init_ocean(omd->ocean, omd->resolution*omd->resolution, omd->resolution*omd->resolution, omd->spatial_size, omd->spatial_size,
-                                  omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
-                                  omd->depth, omd->time,
-                                  do_heightfield, do_chop, do_normals, do_jacobian,
-                                  omd->seed);
+                      omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
+                      omd->depth, omd->time,
+                      do_heightfield, do_chop, do_normals, do_jacobian,
+                      omd->seed);
 }
 
 static void simulate_ocean_modifier(struct OceanModifierData *omd)
@@ -90,7 +90,7 @@ static void simulate_ocean_modifier(struct OceanModifierData *omd)
 
        BKE_simulate_ocean(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount);
 }
-#endif // WITH_OCEANSIM
+#endif /* WITH_OCEANSIM */
 
 
 
@@ -261,13 +261,7 @@ static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, floa
 #endif
 
 #ifdef WITH_OCEANSIM
-MINLINE float ocean_co(OceanModifierData *omd, float v)
-{
-       //float scale = 1.0 / (omd->size * omd->spatial_size);
-       //*v = (*v * scale) + 0.5;
 
-       return (v / (omd->size * omd->spatial_size)) + 0.5f;
-}
 
 #define OMP_MIN_RES    18
 static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
@@ -378,10 +372,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
        DerivedMesh *dm=NULL;
        OceanResult ocr;
 
-       MVert *mv;
-       MFace *mf;
-
-       int cdlayer;
+       MVert *mverts, *mv;
 
        int i, j;
 
@@ -390,6 +381,14 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
 
        int cfra;
 
+       /* use cached & inverted value for speed
+        * expanded this would read...
+        *
+        * (axis / (omd->size * omd->spatial_size)) + 0.5f) */
+#define OCEAN_CO(_size_co_inv, _v) ((_v * _size_co_inv) + 0.5f)
+
+       const float size_co_inv= 1.0f / (omd->size * omd->spatial_size);
+
        /* update modifier */
        if (omd->refresh & MOD_OCEAN_REFRESH_ADD)
                omd->ocean = BKE_add_ocean();
@@ -422,72 +421,71 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
        num_verts = dm->getNumVerts(dm);
        num_faces = dm->getNumFaces(dm);
 
+       mverts = dm->getVertArray(dm);
+
        /* add vcols before displacement - allows lookup based on position */
 
        if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
-               MCol *mc;
-               float foam;
-               char cf;
-
-               float u=0.0, v=0.0;
-
-               cdlayer= CustomData_number_of_layers(&dm->faceData, CD_MCOL);
-               if(cdlayer >= MAX_MCOL)
-                       return dm;
-
-               CustomData_add_layer_named(&dm->faceData, CD_MCOL, CD_CALLOC, NULL, num_faces, omd->foamlayername);
-
-               mc = dm->getFaceDataArray(dm, CD_MCOL);
-               mv = dm->getVertArray(dm);
-               mf = dm->getFaceArray(dm);
-
-               for (i = 0; i < num_faces; i++, mf++) {
-                       j= mf->v4 ? 3 : 2;
-                       do {
-                               const float *co= mv[*(&mf->v1 + j)].co;
-                               u = ocean_co(omd, co[0]);
-                               v = ocean_co(omd, co[1]);
-
-                               if (omd->oceancache && omd->cached==TRUE) {
-                                       BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v);
-                                       foam = ocr.foam;
-                                       CLAMP(foam, 0.0f, 1.0f);
-                               }
-                               else {
-                                       BKE_ocean_eval_uv(omd->ocean, &ocr, u, v);
-                                       foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage);
-                               }
-
-                               cf = (char)(foam * 255);
-                               mc[i*4 + j].r = mc[i*4 + j].g = mc[i*4 + j].b = cf;
-                               mc[i*4 + j].a = 255;
-                       } while (j--);
+               int cdlayer= CustomData_number_of_layers(&dm->faceData, CD_MCOL);
+
+               if(cdlayer < MAX_MCOL) {
+                       MFace *mfaces= dm->getFaceArray(dm);
+                       MFace *mf;
+
+                       MCol *mcols, *mc;
+                       float foam;
+
+                       CustomData_add_layer_named(&dm->faceData, CD_MCOL, CD_CALLOC, NULL, num_faces, omd->foamlayername);
+
+                       mcols = dm->getFaceDataArray(dm, CD_MCOL);
+
+                       for (i = 0, mf= mfaces; i < num_faces; i++, mf++) {
+                               j= mf->v4 ? 3 : 2;
+                               do {
+                                       const float *co= mverts[*(&mf->v1 + j)].co;
+                                       const float u = OCEAN_CO(size_co_inv, co[0]);
+                                       const float v = OCEAN_CO(size_co_inv, co[1]);
+
+                                       if (omd->oceancache && omd->cached==TRUE) {
+                                               BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v);
+                                               foam = ocr.foam;
+                                               CLAMP(foam, 0.0f, 1.0f);
+                                       }
+                                       else {
+                                               BKE_ocean_eval_uv(omd->ocean, &ocr, u, v);
+                                               foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage);
+                                       }
+
+                                       mc= &mcols[i*4 + j];
+                                       mc->r = mc->g = mc->b = (char)(foam * 255);
+                                       /* mc->a = 255; */ /* no need to set */
+                               } while (j--);
+                       }
                }
        }
 
 
        /* displace the geometry */
 
-       mv = dm->getVertArray(dm);
-
        //#pragma omp parallel for private(i, ocr) if (omd->resolution > OMP_MIN_RES)
-       for (i=0; i< num_verts; i++) {
-               const float u = ocean_co(omd, mv[i].co[0]);
-               const float v = ocean_co(omd, mv[i].co[1]);
+       for (i=0, mv= mverts; i< num_verts; i++, mv++) {
+               const float u = OCEAN_CO(size_co_inv, mv->co[0]);
+               const float v = OCEAN_CO(size_co_inv, mv->co[1]);
 
                if (omd->oceancache && omd->cached==TRUE)
                        BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v);
                else
                        BKE_ocean_eval_uv(omd->ocean, &ocr, u, v);
 
-               mv[i].co[2] += ocr.disp[1];
+               mv->co[2] += ocr.disp[1];
 
                if (omd->chop_amount > 0.0f) {
-                       mv[i].co[0] += ocr.disp[0];
-                       mv[i].co[1] += ocr.disp[2];
+                       mv->co[0] += ocr.disp[0];
+                       mv->co[1] += ocr.disp[2];
                }
        }
 
+       #undef OCEAN_CO
 
        return dm;
 }