Merging r48264 through r48276 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Jun 2012 16:37:58 +0000 (16:37 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Jun 2012 16:37:58 +0000 (16:37 +0000)
15 files changed:
intern/cycles/SConscript
intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/blender/blender_util.h
intern/cycles/kernel/kernel_triangle.h
intern/guardedalloc/MEM_guardedalloc.h
source/blender/blenkernel/intern/tracking.c
source/blender/compositor/intern/COM_compositor.cpp
source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
source/blender/compositor/operations/COM_NormalizeOperation.cpp
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_space.c

index 03880bddd8aec146cd7e1c45c9462dfc5cd9fd68..a7b8637e3adb0856daf1dee964de54ab3497335e 100644 (file)
@@ -14,7 +14,7 @@ sources.remove(path.join('kernel', 'kernel_optimized.cpp'))
 
 incs = [] 
 defs = []
-cxxflags = []
+cxxflags = Split(env['CXXFLAGS'])
 
 defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {')
 defs.append('CCL_NAMESPACE_END=}')
@@ -58,9 +58,9 @@ if env['WITH_BF_RAYOPTIMIZATION']:
     optim_sources = [path.join('kernel', 'kernel_optimized.cpp')]
 
     cycles_optim = cycles.Clone()
-    cycles_optim.BlenderLib('bf_intern_cycles_optimized', optim_sources, incs, optim_defs, libtype=['intern'], priority=[10], compileflags=[None], cxx_compileflags=optim_cxxflags)
+    cycles_optim.BlenderLib('bf_intern_cycles_optimized', optim_sources, incs, optim_defs, libtype=['intern'], priority=[10], cxx_compileflags=optim_cxxflags)
 
-cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], compileflags=[None], cxx_compileflags=cxxflags)
+cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], cxx_compileflags=cxxflags)
 
 # cuda kernel binaries
 if env['WITH_BF_CYCLES_CUDA_BINARIES']:
index d5b884cfccd46ca822c8f607fcb0bc1368e2e2b2..a928bd9a6ea98a7df3dcfdf7707e0b3061d90016 100644 (file)
@@ -305,7 +305,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
        for(; b_sce; b_sce = b_sce.background_set()) {
                for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end(); ++b_ob) {
                        bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render();
-                       uint ob_layer = get_layer(b_ob->layers());
+                       uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), object_is_light(*b_ob));
                        hide = hide || !(ob_layer & scene_layer);
 
                        if(!hide) {
index 5640a411fd71243f600086eb4931bab2bdfa42e4..c9d2d68da0ab604d2c2bed8a82345641676a112d 100644 (file)
@@ -219,7 +219,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer)
                        layer = layername.c_str();
                }
                else {
-                       render_layer.scene_layer = get_layer(b_v3d.layers());
+                       render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view());
                        render_layer.layer = render_layer.scene_layer;
                        render_layer.holdout_layer = 0;
                        render_layer.material_override = PointerRNA_NULL;
index b5a76836bedb6e33e35cbfbde9a76fcf3807ad68..ebbd4e1221cf941bd4d9c7d091f44fd86cd04ef6 100644 (file)
@@ -166,6 +166,28 @@ static inline uint get_layer(BL::Array<int, 20> array)
        return layer;
 }
 
+static inline uint get_layer(BL::Array<int, 20> array, BL::Array<int, 8> local_array, bool is_light = false)
+{
+       uint layer = 0;
+
+       for(uint i = 0; i < 20; i++)
+               if(array[i])
+                       layer |= (1 << i);
+
+       if(is_light) {
+               /* consider lamps on all local view layers */
+               for(uint i = 0; i < 8; i++)
+                       layer |= (1 << (20+i));
+       }
+       else {
+               for(uint i = 0; i < 8; i++)
+                       if(local_array[i])
+                               layer |= (1 << (20+i));
+       }
+       
+       return layer;
+}
+
 #if 0
 static inline float3 get_float3(PointerRNA& ptr, const char *name)
 {
index 384c3a8a506468d44a969872603b9163f6c95708..6c1ea46551524faf71ad00263f609de4968ae117 100644 (file)
@@ -191,7 +191,7 @@ __device int triangle_find_attribute(KernelGlobals *kg, ShaderData *sd, uint id)
                attr_map = kernel_tex_fetch(__attributes_map, ++attr_offset);
 
        /* return result */
-       return (attr_map.y == ATTR_ELEMENT_NONE)? ATTR_STD_NOT_FOUND: attr_map.z;
+       return (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : attr_map.z;
 }
 
 __device float4 triangle_motion_vector(KernelGlobals *kg, ShaderData *sd)
index bb4c372e46ddb149e58762e4c8ef038be315f305..1d0a8db6329af897b43544ecf2323a16c431bd88 100644 (file)
@@ -176,13 +176,15 @@ public:                                                                       \
                return MEM_mallocN(num_bytes, _id);                                   \
        }                                                                         \
        void operator delete(void *mem) {                                         \
-               MEM_freeN(mem);                                                       \
+               if (mem)                                                              \
+                       MEM_freeN(mem);                                                   \
        }                                                                         \
        void *operator new[](size_t num_bytes) {                                  \
                return MEM_mallocN(num_bytes, _id "[]");                              \
        }                                                                         \
        void operator delete[](void *mem) {                                       \
-               MEM_freeN(mem);                                                       \
+               if (mem)                                                              \
+                       MEM_freeN(mem);                                                   \
        }                                                                         \
 
 #endif
index a5c04387b68d5231ce4f4ab2140f3179a5310cd8..3dea8a85915e68caa322ac5437f1189dca419dc9 100644 (file)
@@ -2551,7 +2551,8 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in
 
                        if ((marker->flag & MARKER_DISABLED) == 0) {
                                libmv_tracksInsert(tracks, marker->framenr, tracknr,
-                                                  marker->pos[0] * width, marker->pos[1] * height);
+                                                  (marker->pos[0] + track->offset[0]) * width,
+                                                  (marker->pos[1] + track->offset[1]) * height);
                        }
                }
 
index ccd3b2e6458defa48406d85e74341b6d078c3864..7282cf65bc3bca461ae7f118af8b7e281720cb9c 100644 (file)
@@ -33,11 +33,12 @@ extern "C" {
 #include "COM_WorkScheduler.h"
 #include "OCL_opencl.h"
 
-static ThreadMutex compositorMutex = {{0}};
+static ThreadMutex compositorMutex;
 static char is_compositorMutex_init = FALSE;
 void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
 {
        if (is_compositorMutex_init == FALSE) { /// TODO: move to blender startup phase
+               memset(&compositorMutex, 0, sizeof(compositorMutex));
                BLI_mutex_init(&compositorMutex);
                OCL_init();
                WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere
index 6fd20b477e76f8323ead152ea4c71b52b873203c..c75762a3f86ceefcf01970ad7770b95b02727abb 100644 (file)
@@ -101,7 +101,14 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
        else
                tracksbase = BKE_tracking_get_active_tracks(tracking);
 
-       sites_total = BLI_countlist(tracksbase);
+       /* count sites */
+       for (track = (MovieTrackingTrack *) tracksbase->first, sites_total = 0; track; track = track->next) {
+               MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
+
+               if ((marker->flag & MARKER_DISABLED) == 0) {
+                       sites_total++;
+               }
+       }
 
        if (!sites_total)
                return NULL;
@@ -117,11 +124,17 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
        sites = (VoronoiSite *) MEM_callocN(sizeof(VoronoiSite) * sites_total, "keyingscreen voronoi sites");
        track = (MovieTrackingTrack *) tracksbase->first;
        for (track = (MovieTrackingTrack *) tracksbase->first, i = 0; track; track = track->next, i++) {
-               VoronoiSite *site = &sites[i];
                MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
-               ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE);
+               VoronoiSite *site;
+               ImBuf *pattern_ibuf;
                int j;
 
+               if (marker->flag & MARKER_DISABLED)
+                       continue;
+
+               site = &sites[i];
+               pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE);
+
                zero_v3(site->color);
                for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
                        if (pattern_ibuf->rect_float) {
index 6d12141a45557cd5819f2fbcafa3dd3a0341f551..c0c22e055084ca58361f5af0543eb1e4c2165261 100644 (file)
@@ -58,7 +58,8 @@ void NormalizeOperation::deinitExecution()
 bool NormalizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
 {
        rcti imageInput;
-
+       if (this->cachedInstance) return false;
+       
        NodeOperation *operation = getInputOperation(0);
        imageInput.xmax = operation->getWidth();
        imageInput.xmin = 0;
@@ -92,8 +93,12 @@ void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu
                float value;
                while (p--) {
                        value = bc[0];
-                       maxv = max(value, maxv);
-                       minv = min(value, minv);
+                       if ((value > maxv) && (value <= BLENDER_ZMAX)) {
+                               maxv = value;
+                       }
+                       if ((value < minv) && (value >= -BLENDER_ZMAX)) {
+                               minv = value;
+                       }
                        bc += 4;
                }
 
index a6fb30120ad356bac6181754a0708e3e74d62f6d..0ef62e536fad38e468aed910bd06dcbc260b2445 100644 (file)
@@ -1001,12 +1001,13 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
        BMEdge *eed;
        int select = TRUE;
        int dist = 50;
-       
+       float mvalf[2];
+
        em_setup_viewcontext(C, &vc);
-       vc.mval[0] = mval[0];
-       vc.mval[1] = mval[1];
+       mvalf[0] = (float)(vc.mval[0] = mval[0]);
+       mvalf[1] = (float)(vc.mval[1] = mval[1]);
        em = vc.em;
-       
+
        /* no afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad */
        view3d_validate_backbuf(&vc);
 
@@ -1041,26 +1042,59 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
                }
 
                EDBM_selectmode_flush(em);
-//                     if (EM_texFaceCheck())
-               
+
                /* sets as active, useful for other tools */
-#if 0
                if (select) {
                        if (em->selectmode & SCE_SELECT_VERTEX) {
-                               /* TODO: would be nice if the edge vertex chosen here
-                                * was the one closer to the selection pointer, instead
-                                * of arbitrarily selecting the first one */
-                               BM_select_history_store(em->bm, eed->v1);
+                               /* Find nearest vert from mouse. */
+                               float v1_co[2], v2_co[2];
+
+                               /* We can't be sure this has already been set... */
+                               ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
+                               project_float_noclip(vc.ar, eed->v1->co, v1_co);
+                               project_float_noclip(vc.ar, eed->v2->co, v2_co);
+#if 0
+                               printf("mouse to v1: %f\nmouse to v2: %f\n", len_squared_v2v2(mvalf, v1_co),
+                                      len_squared_v2v2(mvalf, v2_co));
+#endif
+                               if (len_squared_v2v2(mvalf, v1_co) < len_squared_v2v2(mvalf, v2_co))
+                                       BM_select_history_store(em->bm, eed->v1);
+                               else
+                                       BM_select_history_store(em->bm, eed->v2);
                        }
                        else if (em->selectmode & SCE_SELECT_EDGE) {
                                BM_select_history_store(em->bm, eed);
                        }
-                       /* TODO: would be nice if the nearest face that
-                        * belongs to the selected edge could be set to
-                        * active here in face select mode */
+                       else if (em->selectmode & SCE_SELECT_FACE) {
+                               /* Select the face of eed which is the nearest of mouse. */
+                               BMFace *f, *efa = NULL;
+                               BMIter iterf;
+                               float best_dist = MAXFLOAT;
+
+                               /* We can't be sure this has already been set... */
+                               ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
+
+                               BM_ITER_ELEM(f, &iterf, eed, BM_FACES_OF_EDGE) {
+                                       if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+                                               float cent[3];
+                                               float co[2], tdist;
+
+                                               BM_face_calc_center_mean(f, cent);
+                                               project_float_noclip(vc.ar, cent, co);
+                                               tdist = len_squared_v2v2(mvalf, co);
+                                               if (tdist < best_dist) {
+/*                                                     printf("Best face: %p (%f)\n", f, tdist);*/
+                                                       best_dist = tdist;
+                                                       efa = f;
+                                               }
+                                       }
+                               }
+                               if (efa) {
+                                       BM_active_face_set(em->bm, efa);
+                                       BM_select_history_store(em->bm, efa);
+                               }
+                       }
                }
-#endif
-               mouse_mesh(C, mval, select, TRUE, FALSE);
 
                WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit);
        }
index 709de274b8b19d1ef5791a8d8d48c67441aee439..2d4fbb90ae11c1a0c19d606bcbd945e7feb84256 100644 (file)
@@ -2795,6 +2795,14 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar)
 
 static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit);
 
+static int view3d_main_area_do_render_draw(const bContext *C)
+{
+       Scene *scene = CTX_data_scene(C);
+       RenderEngineType *type = RE_engines_find(scene->r.engine);
+
+       return (type && type->view_update && type->view_draw);
+}
+
 static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw_border)
 {
        Scene *scene = CTX_data_scene(C);
@@ -3131,7 +3139,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
        int draw_border = (rv3d->persp == RV3D_CAMOB && (scene->r.mode & R_BORDER));
 
        /* draw viewport using opengl */
-       if (v3d->drawtype != OB_RENDER || draw_border) {
+       if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(C) || draw_border) {
                view3d_main_area_draw_objects(C, ar, &grid_unit);
                ED_region_pixelspace(ar);
        }
index 8fb012a18d630795aad4706337dd96bc59816073..4782b95ba1c7321ca409f443464e1bcaa76706d6 100644 (file)
@@ -1564,13 +1564,15 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa)
 
 static int localview_exec(bContext *C, wmOperator *UNUSED(unused))
 {
+       Main *bmain = CTX_data_main(C);
        View3D *v3d = CTX_wm_view3d(C);
        
        if (v3d->localvd)
                endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C));
        else
                initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C));
-       
+
+       DAG_id_type_tag(bmain, ID_OB);
        ED_area_tag_redraw(CTX_wm_area(C));
        
        return OPERATOR_FINISHED;
index 0399a8ee60db1a2ceb43cee19bf827ed899adc0e..5072bda7508ade65c89dbde16744920c65defeab 100644 (file)
@@ -174,6 +174,11 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA
        rna_Object_internal_update(bmain, scene, ptr);
 }
 
+static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+       DAG_id_type_tag(bmain, ID_OB);
+}
+
 static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
 {
        Object *ob = ptr->id.data;
@@ -1971,6 +1976,12 @@ static void rna_def_object(BlenderRNA *brna)
        RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_layer_update");
 
+       prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
+       RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
+       RNA_def_property_array(prop, 8);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object is on");
+
        prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
        RNA_def_property_ui_text(prop, "Select", "Object selection state");
@@ -2308,7 +2319,7 @@ static void rna_def_object(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
        RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
-       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
 
        prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
@@ -2320,7 +2331,7 @@ static void rna_def_object(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
        RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
-       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
 
        /* anim */
        rna_def_animdata_common(srna);
@@ -2579,6 +2590,12 @@ static void rna_def_object_base(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on");
        RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set");
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_layer_update");
+
+       prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
+       RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
+       RNA_def_property_array(prop, 8);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object base is on");
        
        prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT);
index bbefad3df10d6f02fc63cbec5f87f205ba45b9e7..8ae2500ddc1713f6e5ed06b3f69f76dc0d82d061 100644 (file)
@@ -1699,6 +1699,12 @@ static void rna_def_space_view3d(BlenderRNA *brna)
        RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_layer_set");
        RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible in this 3D View");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_layer_update");
+
+       prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
+       RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
+       RNA_def_property_array(prop, 8);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Local View Layers", "Local view layers visible in this 3D View");
        
        prop = RNA_def_property(srna, "layers_used", PROP_BOOLEAN, PROP_LAYER_MEMBER);
        RNA_def_property_boolean_sdna(prop, NULL, "lay_used", 1);