From 050f09aa6c80d24da0ccadafce73b82160a55894 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 01:41:24 +0000 Subject: [PATCH 001/115] buildsystem cleanup: remove duplicate source & includes for scons, add a check for duplicates in BlenderLib()m, if 0'd now. --- build_files/scons/tools/Blender.py | 14 ++++++++++++++ source/blender/editors/space_sequencer/SConscript | 2 +- source/blender/gpu/SConscript | 1 - source/blender/imbuf/intern/dds/SConscript | 9 +++++---- source/gameengine/Converter/SConscript | 2 +- source/gameengine/GamePlayer/common/SConscript | 1 - source/gameengine/GamePlayer/ghost/SConscript | 1 - .../Rasterizer/RAS_OpenGLRasterizer/SConscript | 2 +- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 7b8932bbb4c..a5e47a50d10 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -790,6 +790,20 @@ class BlenderEnvironment(SConsEnvironment): def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority = 100, compileflags=None, cc_compileflags=None, cxx_compileflags=None, cc_compilerchange=None, cxx_compilerchange=None): global vcp + + # sanity check + # run once in a while to check we dont have duplicates + if 0: + for name, dirs in (("source", sources), ("include", includes)): + files_clean = [os.path.normpath(f) for f in dirs] + files_clean_set = set(files_clean) + if len(files_clean) != len(files_clean_set): + for f in sorted(files_clean_set): + if f != '.' and files_clean.count(f) > 1: + raise Exception("Found duplicate %s %r" % (name, f)) + del name, dirs, files_clean, files_clean_set, f + # end sanity check + if not self or not libname or not sources: print bc.FAIL+'Cannot continue. Missing argument for BuildBlenderLib '+libname+bc.ENDC self.Exit() diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index 0b429ae750b..bc72786fc5f 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.c') -incs = '../include ../../blenlib ../../blenkernel ../../blenfont ../../makesdna ../../imbuf' +incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna ../../blenloader ../../blenfont' incs += ' #/intern/audaspace/intern' diff --git a/source/blender/gpu/SConscript b/source/blender/gpu/SConscript index f7ed9effc7a..9b8a86eac15 100644 --- a/source/blender/gpu/SConscript +++ b/source/blender/gpu/SConscript @@ -27,7 +27,6 @@ sources.extend(( os.path.join(env['DATA_SOURCES'], "gpu_shader_vertex.glsl.c"), os.path.join(env['DATA_SOURCES'], "gpu_shader_sep_gaussian_blur_frag.glsl.c"), os.path.join(env['DATA_SOURCES'], "gpu_shader_sep_gaussian_blur_vert.glsl.c"), - os.path.join(env['DATA_SOURCES'], "gpu_shader_material.glsl.c"), os.path.join(env['DATA_SOURCES'], "gpu_shader_vsm_store_frag.glsl.c"), os.path.join(env['DATA_SOURCES'], "gpu_shader_vsm_store_vert.glsl.c"), )) diff --git a/source/blender/imbuf/intern/dds/SConscript b/source/blender/imbuf/intern/dds/SConscript index d5a613f5981..475d21135aa 100644 --- a/source/blender/imbuf/intern/dds/SConscript +++ b/source/blender/imbuf/intern/dds/SConscript @@ -3,16 +3,17 @@ Import ('env') source_files = ['dds_api.cpp', 'DirectDrawSurface.cpp', 'Stream.cpp', 'BlockDXT.cpp', 'ColorBlock.cpp', 'Image.cpp', 'FlipDXT.cpp'] -incs = ['.', - '../../', - '../..', +incs = [ + '.', '..', + '../..', '../../../makesdna', '../../../blenkernel', '../../../blenlib', 'intern/include', '#/intern/guardedalloc', - '#/intern/utfconv'] + '#/intern/utfconv' + ] defs = ['WITH_DDS'] diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index bfd44dc90fc..b9c70910283 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -11,7 +11,7 @@ incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf' incs += ' #intern/moto/include #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork' incs += ' #source/blender/blenlib #source/blender/blenkernel #source/blender' incs += ' #source/blender/editors/include #source/blender/makesdna #source/gameengine/Rasterizer' -incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #source/gameengine/GameLogic' +incs += ' #source/gameengine/GameLogic' incs += ' #source/gameengine/Expressions #source/gameengine/Network #source/gameengine/SceneGraph' incs += ' #source/gameengine/Physics/common #source/gameengine/Physics/Bullet' incs += ' #source/gameengine/Physics/Dummy' diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index d5e1f081d21..6a1f47c51af 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -31,7 +31,6 @@ incs = ['.', '#source/blender', '#source/blender/include', '#source/blender/makesdna', - '#source/gameengine/BlenderRoutines', '#source/gameengine/Rasterizer', '#source/gameengine/GameLogic', '#source/gameengine/Expressions', diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index 9fb0f053ed8..fb046d0fdf8 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -26,7 +26,6 @@ incs = ['.', '#source/blender/include', '#source/blender/makesdna', '#source/blender/makesrna', - '#source/gameengine/BlenderRoutines', '#source/gameengine/Rasterizer', '#source/gameengine/GameLogic', '#source/gameengine/Expressions', diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index 5f3af7360ff..63b28a90412 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -8,7 +8,7 @@ defs = [ 'GLEW_STATIC' ] incs = '. #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines ' incs += ' #intern/container #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC'] incs += ' #source/blender/gameengine/Ketsji #source/gameengine/SceneGraph #source/blender/makesdna #source/blender/blenkernel' -incs += ' #intern/guardedalloc #source/blender/blenlib #source/gameengine/BlenderRoutines' +incs += ' #intern/guardedalloc #source/blender/blenlib' if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') From cc8a43fb22e714953a347533f87402148f48e6e4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 02:03:34 +0000 Subject: [PATCH 002/115] style cleanup: with uv remove doubles, weld distance soft/hard ranges were wrong rename to "Remove Doubles UV" to avoid confusion with the mesh operator of the same name. --- source/blender/editors/uvedit/uvedit_ops.c | 49 ++++++++++++---------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 3828064185e..52f36da7be4 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1568,10 +1568,10 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) Image *ima; BMEditMesh *em; MTexPoly *tf; - int UV_a; - int UV_b; - float UVp1[2]; - float UVp2[2]; + int uv_a_index; + int uv_b_index; + float uv_a[2]; + float uv_b[2]; float weld_dist; MLoopUV **loop_arr = NULL; BLI_array_declare(loop_arr); @@ -1608,30 +1608,33 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) } } - for (UV_a = 0; UV_auv); + copy_v2_v2(uv_a, vert_arr[uv_a_index].uv_loop->uv); - copy_v2_v2(near_UV, UVp1); - copy_v2_v2(far_UV, UVp1); + copy_v2_v2(uv_max, uv_a); + copy_v2_v2(uv_min, uv_a); - vert_arr[UV_a].weld = TRUE; - for (UV_b = 0; UV_buv); - if (UV_b != UV_a && vert_arr[UV_b].weld == FALSE && UVp1[0]-UVp2[0] > -weld_dist && UVp1[0] - UVp2[0] < weld_dist && UVp1[1] - UVp2[1] > -weld_dist && UVp1[1] - UVp2[1] < weld_dist){ - minmax_v2v2_v2(near_UV, far_UV, UVp2); - BLI_array_append(loop_arr, vert_arr[UV_b].uv_loop); - vert_arr[UV_b].weld = TRUE; + vert_arr[uv_a_index].weld = TRUE; + for (uv_b_index = 0; uv_b_index < BLI_array_count(vert_arr); uv_b_index++) { + copy_v2_v2(uv_b, vert_arr[uv_b_index].uv_loop->uv); + if ((uv_a_index != uv_b_index) && + (vert_arr[uv_b_index].weld == FALSE) && + (len_manhattan_v2v2(uv_a, uv_b) < weld_dist)) + { + minmax_v2v2_v2(uv_max, uv_min, uv_b); + BLI_array_append(loop_arr, vert_arr[uv_b_index].uv_loop); + vert_arr[uv_b_index].weld = TRUE; } } - for (UV_b = 0; UV_buv, far_UV, near_UV); + for (uv_b_index = 0; uv_b_index < BLI_array_count(loop_arr); uv_b_index++) { + mid_v2_v2v2(loop_arr[uv_b_index]->uv, uv_min, uv_max); } } } @@ -1648,7 +1651,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) static void UV_OT_remove_doubles(wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove Doubles"; + ot->name = "Remove Doubles UV"; ot->description = "Selected UV vertices that are within a radius of eachother are welded together"; ot->idname = "UV_OT_remove_doubles"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1657,7 +1660,7 @@ static void UV_OT_remove_doubles(wmOperatorType *ot) ot->exec = remove_doubles_exec; ot->poll = ED_operator_uvedit; - RNA_def_float(ot->srna, "weld_dist", 0.02f, 0.0f, 1.0f, "Weld Distance", "Maximum distance between welded vertices", 0.001f, 10.0f); + RNA_def_float(ot->srna, "weld_dist", 0.02f, 0.0f, 10.0f, "Weld Distance", "Maximum distance between welded vertices", 0.0f, 1.0f); } /* ******************** weld operator **************** */ From 54ff14c29ded160c05389a0ca08c771aa01a41ab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 02:58:43 +0000 Subject: [PATCH 003/115] speedup to uv remove doubles. - no need to copy the UV vectors, just point to them. - calculate the midpoint once and copy rather then mid_v2_v2v2() on each UV. - reduce the number of comparisons by only checking the remaining uv's in the nested loop. --- source/blender/editors/uvedit/uvedit_ops.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 52f36da7be4..0ca25096359 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1570,8 +1570,8 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) MTexPoly *tf; int uv_a_index; int uv_b_index; - float uv_a[2]; - float uv_b[2]; + float *uv_a; + float *uv_b; float weld_dist; MLoopUV **loop_arr = NULL; BLI_array_declare(loop_arr); @@ -1616,16 +1616,15 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) BLI_array_empty(loop_arr); BLI_array_append(loop_arr, vert_arr[uv_a_index].uv_loop); - copy_v2_v2(uv_a, vert_arr[uv_a_index].uv_loop->uv); + uv_a = vert_arr[uv_a_index].uv_loop->uv; copy_v2_v2(uv_max, uv_a); copy_v2_v2(uv_min, uv_a); vert_arr[uv_a_index].weld = TRUE; - for (uv_b_index = 0; uv_b_index < BLI_array_count(vert_arr); uv_b_index++) { - copy_v2_v2(uv_b, vert_arr[uv_b_index].uv_loop->uv); - if ((uv_a_index != uv_b_index) && - (vert_arr[uv_b_index].weld == FALSE) && + for (uv_b_index = uv_a_index + 1; uv_b_index < BLI_array_count(vert_arr); uv_b_index++) { + uv_b = vert_arr[uv_b_index].uv_loop->uv; + if ((vert_arr[uv_b_index].weld == FALSE) && (len_manhattan_v2v2(uv_a, uv_b) < weld_dist)) { minmax_v2v2_v2(uv_max, uv_min, uv_b); @@ -1633,8 +1632,12 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) vert_arr[uv_b_index].weld = TRUE; } } - for (uv_b_index = 0; uv_b_index < BLI_array_count(loop_arr); uv_b_index++) { - mid_v2_v2v2(loop_arr[uv_b_index]->uv, uv_min, uv_max); + if (BLI_array_count(loop_arr)) { + float uv_mid[2]; + mid_v2_v2v2(uv_mid, uv_min, uv_max); + for (uv_b_index = 0; uv_b_index < BLI_array_count(loop_arr); uv_b_index++) { + copy_v2_v2(loop_arr[uv_b_index]->uv, uv_mid); + } } } } From ebde2d579a8e53a95f0f6cb8c0ca016c44ec9744 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 03:13:51 +0000 Subject: [PATCH 004/115] each different remove doubles function used a different property name, use 'threshold' for all now. --- source/blender/editors/mesh/editmesh_tools.c | 9 ++++----- source/blender/editors/physics/particle_edit.c | 3 ++- source/blender/editors/uvedit/uvedit_ops.c | 11 +++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0c5c756a0fc..322d09b7608 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2183,7 +2183,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; - const float mergedist = RNA_float_get(op->ptr, "mergedist"); + const float threshold = RNA_float_get(op->ptr, "threshold"); int use_unselected = RNA_boolean_get(op->ptr, "use_unselected"); int totvert_orig = em->bm->totvert; int count; @@ -2191,7 +2191,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) if (use_unselected) { EDBM_op_init(em, &bmop, op, "automerge verts=%hv dist=%f", - BM_ELEM_SELECT, mergedist); + BM_ELEM_SELECT, threshold); BMO_op_exec(em->bm, &bmop); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { @@ -2201,7 +2201,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) else { EDBM_op_init(em, &bmop, op, "find_doubles verts=%hv dist=%f", - BM_ELEM_SELECT, mergedist); + BM_ELEM_SELECT, threshold); BMO_op_exec(em->bm, &bmop); if (!EDBM_op_callf(em, op, "weld_verts targetmap=%s", &bmop, "targetmapout")) { @@ -2236,8 +2236,7 @@ void MESH_OT_remove_doubles(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_float(ot->srna, "mergedist", 0.0001f, 0.000001f, 50.0f, - "Merge Distance", + RNA_def_float(ot->srna, "threshold", 0.0001f, 0.000001f, 50.0f, "Merge Distance", "Minimum distance between elements to merge", 0.00001, 10.0); RNA_def_boolean(ot->srna, "use_unselected", 0, "Unselected", "Merge selected to other unselected vertices"); } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index f8ec51c7a7c..0c88519b62b 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2437,7 +2437,8 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_float(ot->srna, "threshold", 0.0002f, 0.0f, FLT_MAX, "Threshold", "Threshold distance withing which particles are removed", 0.00001f, 0.1f); + RNA_def_float(ot->srna, "threshold", 0.0002f, 0.0f, FLT_MAX, + "Merge Distance", "Threshold distance withing which particles are removed", 0.00001f, 0.1f); } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 0ca25096359..c47670cd101 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1562,6 +1562,8 @@ typedef struct UVvert { static int remove_doubles_exec(bContext *C, wmOperator *op) { + const float threshold = RNA_float_get(op->ptr, "threshold"); + SpaceImage *sima; Scene *scene; Object *obedit; @@ -1572,7 +1574,6 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) int uv_b_index; float *uv_a; float *uv_b; - float weld_dist; MLoopUV **loop_arr = NULL; BLI_array_declare(loop_arr); @@ -1588,9 +1589,6 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) em = BMEdit_FromObject(obedit); ima = CTX_data_edit_image(C); - weld_dist = RNA_float_get(op->ptr, "weld_dist"); - - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); if (!uvedit_face_visible_test(scene, ima, efa, tf)) @@ -1625,7 +1623,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) for (uv_b_index = uv_a_index + 1; uv_b_index < BLI_array_count(vert_arr); uv_b_index++) { uv_b = vert_arr[uv_b_index].uv_loop->uv; if ((vert_arr[uv_b_index].weld == FALSE) && - (len_manhattan_v2v2(uv_a, uv_b) < weld_dist)) + (len_manhattan_v2v2(uv_a, uv_b) < threshold)) { minmax_v2v2_v2(uv_max, uv_min, uv_b); BLI_array_append(loop_arr, vert_arr[uv_b_index].uv_loop); @@ -1663,7 +1661,8 @@ static void UV_OT_remove_doubles(wmOperatorType *ot) ot->exec = remove_doubles_exec; ot->poll = ED_operator_uvedit; - RNA_def_float(ot->srna, "weld_dist", 0.02f, 0.0f, 10.0f, "Weld Distance", "Maximum distance between welded vertices", 0.0f, 1.0f); + RNA_def_float(ot->srna, "threshold", 0.02f, 0.0f, 10.0f, + "Merge Distance", "Maximum distance between welded vertices", 0.0f, 1.0f); } /* ******************** weld operator **************** */ From 697d29cbed037060a8d0ce3df7f12d39142b1361 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 04:02:43 +0000 Subject: [PATCH 005/115] add 'use_unselected' option to UV_OT_remove_doubles, handy of you have a UV island that doesnt quite fit into its surrounding UV's - its a quick way to snap selected -> unselected UV's. --- source/blender/editors/uvedit/uvedit_ops.c | 151 ++++++++++++++------- 1 file changed, 102 insertions(+), 49 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index c47670cd101..a37a1e77454 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1563,6 +1563,7 @@ typedef struct UVvert { static int remove_doubles_exec(bContext *C, wmOperator *op) { const float threshold = RNA_float_get(op->ptr, "threshold"); + const int use_unselected = RNA_boolean_get(op->ptr, "use_unselected"); SpaceImage *sima; Scene *scene; @@ -1574,11 +1575,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) int uv_b_index; float *uv_a; float *uv_b; - MLoopUV **loop_arr = NULL; - BLI_array_declare(loop_arr); - UVvert *vert_arr = NULL; - BLI_array_declare(vert_arr); BMIter iter, liter; BMFace *efa; BMLoop *l; @@ -1589,58 +1586,113 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) em = BMEdit_FromObject(obedit); ima = CTX_data_edit_image(C); - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if (!uvedit_face_visible_test(scene, ima, efa, tf)) - continue; + if (use_unselected == FALSE) { + UVvert *vert_arr = NULL; + BLI_array_declare(vert_arr); + MLoopUV **loop_arr = NULL; + BLI_array_declare(loop_arr); - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(em, scene, l)) { + /* TODO, use qsort as with MESH_OT_remove_doubles, this isn't optimal */ + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); + if (!uvedit_face_visible_test(scene, ima, efa, tf)) + continue; + + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + if (uvedit_uv_select_test(em, scene, l)) { + MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); + UVvert vert; + vert.uv_loop = luv; + vert.weld = FALSE; + BLI_array_append(vert_arr, vert); + } + + } + } + + for (uv_a_index = 0; uv_a_index < BLI_array_count(vert_arr); uv_a_index++) { + if (vert_arr[uv_a_index].weld == FALSE) { + float uv_min[2]; + float uv_max[2]; + + BLI_array_empty(loop_arr); + BLI_array_append(loop_arr, vert_arr[uv_a_index].uv_loop); + + uv_a = vert_arr[uv_a_index].uv_loop->uv; + + copy_v2_v2(uv_max, uv_a); + copy_v2_v2(uv_min, uv_a); + + vert_arr[uv_a_index].weld = TRUE; + for (uv_b_index = uv_a_index + 1; uv_b_index < BLI_array_count(vert_arr); uv_b_index++) { + uv_b = vert_arr[uv_b_index].uv_loop->uv; + if ((vert_arr[uv_b_index].weld == FALSE) && + (len_manhattan_v2v2(uv_a, uv_b) < threshold)) + { + minmax_v2v2_v2(uv_max, uv_min, uv_b); + BLI_array_append(loop_arr, vert_arr[uv_b_index].uv_loop); + vert_arr[uv_b_index].weld = TRUE; + } + } + if (BLI_array_count(loop_arr)) { + float uv_mid[2]; + mid_v2_v2v2(uv_mid, uv_min, uv_max); + for (uv_b_index = 0; uv_b_index < BLI_array_count(loop_arr); uv_b_index++) { + copy_v2_v2(loop_arr[uv_b_index]->uv, uv_mid); + } + } + } + } + + BLI_array_free(vert_arr); + BLI_array_free(loop_arr); + } + else { + /* selected -> unselected + * + * No need to use 'UVvert' here */ + MLoopUV **loop_arr = NULL; + BLI_array_declare(loop_arr); + MLoopUV **loop_arr_unselected = NULL; + BLI_array_declare(loop_arr_unselected); + + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); + if (!uvedit_face_visible_test(scene, ima, efa, tf)) + continue; + + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - UVvert vert; - vert.uv_loop = luv; - vert.weld = FALSE; - BLI_array_append(vert_arr, vert); - } - - } - } - - for (uv_a_index = 0; uv_a_index < BLI_array_count(vert_arr); uv_a_index++) { - if (vert_arr[uv_a_index].weld == FALSE) { - float uv_min[2]; - float uv_max[2]; - - BLI_array_empty(loop_arr); - BLI_array_append(loop_arr, vert_arr[uv_a_index].uv_loop); - - uv_a = vert_arr[uv_a_index].uv_loop->uv; - - copy_v2_v2(uv_max, uv_a); - copy_v2_v2(uv_min, uv_a); - - vert_arr[uv_a_index].weld = TRUE; - for (uv_b_index = uv_a_index + 1; uv_b_index < BLI_array_count(vert_arr); uv_b_index++) { - uv_b = vert_arr[uv_b_index].uv_loop->uv; - if ((vert_arr[uv_b_index].weld == FALSE) && - (len_manhattan_v2v2(uv_a, uv_b) < threshold)) - { - minmax_v2v2_v2(uv_max, uv_min, uv_b); - BLI_array_append(loop_arr, vert_arr[uv_b_index].uv_loop); - vert_arr[uv_b_index].weld = TRUE; + if (uvedit_uv_select_test(em, scene, l)) { + BLI_array_append(loop_arr, luv); } - } - if (BLI_array_count(loop_arr)) { - float uv_mid[2]; - mid_v2_v2v2(uv_mid, uv_min, uv_max); - for (uv_b_index = 0; uv_b_index < BLI_array_count(loop_arr); uv_b_index++) { - copy_v2_v2(loop_arr[uv_b_index]->uv, uv_mid); + else { + BLI_array_append(loop_arr_unselected, luv); } } } + + for (uv_a_index = 0; uv_a_index < BLI_array_count(loop_arr); uv_a_index++) { + float dist_best = FLT_MAX, dist; + float *uv_best = NULL; + + uv_a = loop_arr[uv_a_index]->uv; + for (uv_b_index = 0; uv_b_index < BLI_array_count(loop_arr_unselected); uv_b_index++) { + uv_b = loop_arr_unselected[uv_b_index]->uv; + dist = len_manhattan_v2v2(uv_a, uv_b); + if ((dist < threshold) && (dist < dist_best)) { + uv_best = uv_b; + dist_best = dist; + } + } + if (uv_best) { + copy_v2_v2(uv_a, uv_best); + } + } + + BLI_array_free(loop_arr); + BLI_array_free(loop_arr_unselected); } - BLI_array_free(loop_arr); - BLI_array_free(vert_arr); uvedit_live_unwrap_update(sima, scene, obedit); DAG_id_tag_update(obedit->data, 0); @@ -1663,6 +1715,7 @@ static void UV_OT_remove_doubles(wmOperatorType *ot) RNA_def_float(ot->srna, "threshold", 0.02f, 0.0f, 10.0f, "Merge Distance", "Maximum distance between welded vertices", 0.0f, 1.0f); + RNA_def_boolean(ot->srna, "use_unselected", 0, "Unselected", "Merge selected to other unselected vertices"); } /* ******************** weld operator **************** */ From 4cd129bb508d75ff635199397e9ff17cebd0639e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 06:13:42 +0000 Subject: [PATCH 006/115] fix for the update issue reported in [#32452] When blending shape key, opening the popup didnt execute anything - making it so pressing a button would update the result even if the value didnt change. --- source/blender/editors/mesh/editmesh_tools.c | 4 +-- source/blender/windowmanager/WM_api.h | 1 + .../windowmanager/intern/wm_operators.c | 28 +++++++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 322d09b7608..e9fd2f142a2 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2438,7 +2438,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) totshape = CustomData_number_of_layers(&em->bm->vdata, CD_SHAPEKEY); if (totshape == 0 || shape < 0 || shape >= totshape) return OPERATOR_CANCELLED; - + /* get shape key - needed for finding reference shape (for add mode only) */ if (key) { kb = BLI_findlink(&key->block, shape); @@ -2517,7 +2517,7 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot) /* api callbacks */ ot->exec = edbm_blend_from_shape_exec; - ot->invoke = WM_operator_props_popup; + ot->invoke = WM_operator_props_popup_call; ot->poll = ED_operator_editmesh; /* flags */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index c53c4dca74c..e35e3edfa33 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -181,6 +181,7 @@ int WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const char imt /* poll callback, context checks */ int WM_operator_winactive (struct bContext *C); /* invoke callback, exec + redo popup */ +int WM_operator_props_popup_call(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_operator_props_dialog_popup (struct bContext *C, struct wmOperator *op, int width, int height); int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 126d497e08e..035e9d44b02 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1201,8 +1201,11 @@ int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) return OPERATOR_RUNNING_MODAL; } -/* operator menu needs undo, for redo callback */ -int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +/** + * For use by #WM_operator_props_popup_call, #WM_operator_props_popup only. + * + * \note operator menu needs undo flag enabled , for redo callback */ +static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_call) { if ((op->type->flag & OPTYPE_REGISTER) == 0) { @@ -1210,15 +1213,34 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) "Operator '%s' does not have register enabled, incorrect invoke function", op->type->idname); return OPERATOR_CANCELLED; } - + ED_undo_push_op(C, op); + wm_operator_register(C, op); uiPupBlock(C, wm_block_create_redo, op); + if (do_call) { + WM_operator_repeat(C, op); + } + return OPERATOR_RUNNING_MODAL; } +/* Same as WM_operator_props_popup but call the operator first, + * This way - the button values corraspond to the result of the operator. + * Without this, first access to a button will make the result jump, + * see [#32452] */ +int WM_operator_props_popup_call(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + return wm_operator_props_popup_ex(C, op, TRUE); +} + +int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + return wm_operator_props_popup_ex(C, op, FALSE); +} + int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height) { wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); From 2417967267a35451331f05307a79cdcd596a5859 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 14 Nov 2012 08:05:40 +0000 Subject: [PATCH 007/115] Fix #33171: Sculpt lag in recent builds Issue was caused by own previous change in PBVH which in this case lead to unneeded draw buffers rebuilding. --- source/blender/blenlib/intern/pbvh.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index e21ce0716d2..6fa6d86589f 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -1715,11 +1715,14 @@ void BLI_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, bvh->grids = grids; bvh->gridadj = gridadj; bvh->gridfaces = gridfaces; - bvh->grid_flag_mats = flagmats; - bvh->grid_hidden = grid_hidden; - for (a = 0; a < bvh->totnode; ++a) - BLI_pbvh_node_mark_rebuild_draw(&bvh->nodes[a]); + if (flagmats != bvh->grid_flag_mats || bvh->grid_hidden != grid_hidden) { + bvh->grid_flag_mats = flagmats; + bvh->grid_hidden = grid_hidden; + + for (a = 0; a < bvh->totnode; ++a) + BLI_pbvh_node_mark_rebuild_draw(&bvh->nodes[a]); + } } float (*BLI_pbvh_get_vertCos(PBVH * pbvh))[3] From 7138beaa64941bd98a3d33f0d109bfb6fb216b99 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 14 Nov 2012 08:12:52 +0000 Subject: [PATCH 008/115] Fix for oiio/ocio/boost in those scons config, else specifying a custom "root" path for those libs in user-config.py is useless! --- build_files/scons/config/darwin-config.py | 12 ++++++------ build_files/scons/config/linux-config.py | 12 ++++++------ build_files/scons/config/win32-mingw-config.py | 12 ++++++------ build_files/scons/config/win64-mingw-config.py | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index b89f3f92cfe..79027ee13b8 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -278,22 +278,22 @@ WITH_BF_CYCLES = True WITH_BF_OIIO = True BF_OIIO = LIBDIR + '/openimageio' -BF_OIIO_INC = BF_OIIO + '/include' +BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB = 'OpenImageIO' -BF_OIIO_LIBPATH = BF_OIIO + '/lib' +BF_OIIO_LIBPATH = '${BF_OIIO}/lib' WITH_BF_OCIO = True BF_OCIO = LIBDIR + '/opencolorio' -BF_OCIO_INC = BF_OCIO + '/include' +BF_OCIO_INC = '${BF_OCIO}/include' BF_OCIO_LIB = 'OpenColorIO tinyxml yaml-cpp' -BF_OCIO_LIBPATH = BF_OCIO + '/lib' +BF_OCIO_LIBPATH = '${BF_OCIO}/lib' WITH_BF_BOOST = True BF_BOOST = LIBDIR + '/boost' -BF_BOOST_INC = BF_BOOST + '/include' +BF_BOOST_INC = '${BF_BOOST}/include' BF_BOOST_LIB = 'boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt' BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mt' -BF_BOOST_LIBPATH = BF_BOOST + '/lib' +BF_BOOST_LIBPATH = '${BF_BOOST}/lib' WITH_BF_CYCLES_CUDA_BINARIES = False BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc' diff --git a/build_files/scons/config/linux-config.py b/build_files/scons/config/linux-config.py index 9ffe67e6b48..0ffd9ca9cc6 100644 --- a/build_files/scons/config/linux-config.py +++ b/build_files/scons/config/linux-config.py @@ -204,9 +204,9 @@ BF_OIIO = LIBDIR + '/oiio' if not os.path.exists(LCGDIR + '/oiio'): WITH_BF_OIIO = False BF_OIIO = '/usr' -BF_OIIO_INC = BF_OIIO + '/include' +BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB = 'OpenImageIO' -BF_OIIO_LIBPATH = BF_OIIO + '/lib' +BF_OIIO_LIBPATH = '${BF_OIIO}/lib' WITH_BF_OCIO = True WITH_BF_STATICOCIO = False @@ -214,9 +214,9 @@ BF_OCIO = LIBDIR + '/ocio' if not os.path.exists(LCGDIR + '/ocio'): WITH_BF_OCIO = False BF_OCIO = '/usr' -BF_OCIO_INC = BF_OCIO + '/include' +BF_OCIO_INC = '${BF_OCIO}/include' BF_OCIO_LIB = 'OpenColorIO yaml-cpp tinyxml' -BF_OCIO_LIBPATH = BF_OCIO + '/lib' +BF_OCIO_LIBPATH = '${BF_OCIO}/lib' WITH_BF_BOOST = True WITH_BF_STATICBOOST = False @@ -224,10 +224,10 @@ BF_BOOST = LIBDIR + '/boost' if not os.path.exists(LCGDIR + '/boost'): WITH_BF_BOOST = False BF_BOOST = '/usr' -BF_BOOST_INC = BF_BOOST + '/include' +BF_BOOST_INC = '${BF_BOOST}/include' BF_BOOST_LIB = 'boost_date_time boost_filesystem boost_regex boost_system boost_thread' BF_BOOST_LIB_INTERNATIONAL = 'boost_locale' -BF_BOOST_LIBPATH = BF_BOOST + '/lib' +BF_BOOST_LIBPATH = '${BF_BOOST}/lib' WITH_BF_CYCLES = WITH_BF_OIIO and WITH_BF_BOOST diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py index 77641f8c842..80e3592c71e 100644 --- a/build_files/scons/config/win32-mingw-config.py +++ b/build_files/scons/config/win32-mingw-config.py @@ -150,22 +150,22 @@ WITH_BF_CYCLES = True WITH_BF_OIIO = True BF_OIIO = LIBDIR + '/openimageio' -BF_OIIO_INC = BF_OIIO + '/include' +BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB = 'OpenImageIO' -BF_OIIO_LIBPATH = BF_OIIO + '/lib' +BF_OIIO_LIBPATH = '${BF_OIIO}/lib' WITH_BF_OCIO = True BF_OCIO = LIBDIR + '/opencolorio' -BF_OCIO_INC = BF_OCIO + '/include' +BF_OCIO_INC = '${BF_OCIO}/include' BF_OCIO_LIB = 'OpenColorIO' -BF_OCIO_LIBPATH = BF_OCIO + '/lib' +BF_OCIO_LIBPATH = '${BF_OCIO}/lib' WITH_BF_BOOST = True BF_BOOST = LIBDIR + '/boost' -BF_BOOST_INC = BF_BOOST + '/include' +BF_BOOST_INC = '${BF_BOOST}/include' BF_BOOST_LIB = 'boost_date_time-mgw46-mt-s-1_49 boost_filesystem-mgw46-mt-s-1_49 boost_regex-mgw46-mt-s-1_49 boost_system-mgw46-mt-s-1_49 boost_thread-mgw46-mt-s-1_49' BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mgw46-mt-s-1_49' -BF_BOOST_LIBPATH = BF_BOOST + '/lib' +BF_BOOST_LIBPATH = '${BF_BOOST}/lib' #Ray trace optimization WITH_BF_RAYOPTIMIZATION = True diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py index 0840c6fd7e3..b4e06655c7e 100644 --- a/build_files/scons/config/win64-mingw-config.py +++ b/build_files/scons/config/win64-mingw-config.py @@ -162,10 +162,10 @@ BF_OCIO_LIBPATH = '${BF_OCIO}/lib' WITH_BF_BOOST = True BF_BOOST = LIBDIR + '/boost' -BF_BOOST_INC = BF_BOOST + '/include' +BF_BOOST_INC = '${BF_BOOST}/include' BF_BOOST_LIB = 'boost_date_time-mgw47-mt-s-1_49 boost_date_time-mgw47-mt-sd-1_49 boost_filesystem-mgw47-mt-s-1_49 boost_filesystem-mgw47-mt-sd-1_49 boost_regex-mgw47-mt-s-1_49 boost_regex-mgw47-mt-sd-1_49 boost_system-mgw47-mt-s-1_49 boost_system-mgw47-mt-sd-1_49 boost_thread-mgw47-mt-s-1_49 boost_thread-mgw47-mt-sd-1_49' BF_BOOST_LIB_INTERNATIONAL = ' boost_locale-mgw47-mt-s-1_49 boost_locale-mgw47-mt-sd-1_49' -BF_BOOST_LIBPATH = BF_BOOST + '/lib' +BF_BOOST_LIBPATH = '${BF_BOOST}/lib' #Ray trace optimization WITH_BF_RAYOPTIMIZATION = True From 97fe21410c350bc5e1aa4a7ebba78ef7a1e2b855 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 14 Nov 2012 08:12:53 +0000 Subject: [PATCH 009/115] Fix #33166: Wrong profile name in config.ocio causes crash In this case we can not validate OCIO configuration and the only way to fix such issues is to add NULL-pointer checks.. --- source/blender/imbuf/intern/colormanagement.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 3fd31f9a58c..1c68a466ade 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -2465,7 +2465,8 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManag } display_space = display_transform_get_colorspace(applied_view_settings, display_settings); - cm_processor->is_data_result = display_space->is_data; + if (display_space) + cm_processor->is_data_result = display_space->is_data; cm_processor->processor = create_display_buffer_processor(applied_view_settings->view_transform, display_settings->display_device, applied_view_settings->exposure, applied_view_settings->gamma); From 7c3db355b1e0496e9e75e8d6fd575dae17729e83 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 09:45:15 +0000 Subject: [PATCH 010/115] remove ifdef'd bevel code, current bevel works better then the previous code. reduce strlen check in texttool_suggest_add() use 'del list[:]' rather then 'list[:] = []' in python scripts which clear lists. --- build_files/cmake/cmake_consistency_check.py | 4 +- doc/python_api/sphinx_doc_gen.py | 6 +- release/scripts/modules/bpy/utils.py | 2 +- .../scripts/modules/bpy_extras/mesh_utils.py | 12 +- .../bl_operators/uvcalc_smart_project.py | 6 +- .../blender/blenkernel/intern/suggestions.c | 10 +- source/blender/bmesh/operators/bmo_bevel.c | 857 ------------------ 7 files changed, 20 insertions(+), 877 deletions(-) diff --git a/build_files/cmake/cmake_consistency_check.py b/build_files/cmake/cmake_consistency_check.py index 072bbb12fb3..83ebf927b3c 100755 --- a/build_files/cmake/cmake_consistency_check.py +++ b/build_files/cmake/cmake_consistency_check.py @@ -222,8 +222,8 @@ def cmake_get_src(f): ''' # reset - sources_h[:] = [] - sources_c[:] = [] + del sources_h[:] + del sources_c[:] filen.close() diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 6f7d4f3582a..410612fabd5 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -1251,7 +1251,7 @@ def pyrna2sphinx(basepath): bases = list(reversed(struct.get_bases())) # props - lines[:] = [] + del lines[:] if _BPY_STRUCT_FAKE: descr_items = [(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items()) if not key.startswith("__")] @@ -1282,7 +1282,7 @@ def pyrna2sphinx(basepath): fw("\n") # funcs - lines[:] = [] + del lines[:] if _BPY_STRUCT_FAKE: for key, descr in descr_items: @@ -1305,7 +1305,7 @@ def pyrna2sphinx(basepath): fw(line) fw("\n") - lines[:] = [] + del lines[:] if struct.references: # use this otherwise it gets in the index for a normal heading. diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 573694ff08e..4ad00eb267e 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -216,7 +216,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): for mod in _global_loaded_modules: test_reload(mod) - _global_loaded_modules[:] = [] + del _global_loaded_modules[:] for base_path in script_paths(): for path_subdir in _script_module_dirs: diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index ad3cf8c08ec..2042cc1c8a1 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -223,7 +223,7 @@ def edge_loops_from_tessfaces(mesh, tessfaces=None, seams=()): else: other_dir = None - ed_adj[:] = [] + del ed_adj[:] flipped = False @@ -235,22 +235,22 @@ def edge_loops_from_tessfaces(mesh, tessfaces=None, seams=()): if other_dir and flipped is False: flipped = True # only flip the list once context_loop.reverse() - ed_adj[:] = [] + del ed_adj[:] context_loop.append(other_dir) # save 1 look-up ed_adj = edges[context_loop[-1]] if len(ed_adj) != 2: - ed_adj[:] = [] + del ed_adj[:] break else: - ed_adj[:] = [] + del ed_adj[:] break i = ed_adj.index(context_loop[-2]) context_loop.append(ed_adj[not i]) # Dont look at this again - ed_adj[:] = [] + del ed_adj[:] return edge_loops @@ -436,7 +436,7 @@ def ngon_tessellate(from_data, indices, fix_loops=True): if s1[0][1] == s1[-1][1]: # remove endpoints double s1.pop() - s2[:] = [] # Empty this segment s2 so we don't use it again. + del s2[:] # Empty this segment s2 so we don't use it again. return True joining_segments = True diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 9fa44cac812..eb05057de3d 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -517,7 +517,7 @@ def mergeUvIslands(islandList): for uv in f.uv: uv+= offset - sourceIsland[0][:] = [] # Empty + del sourceIsland[0][:] # Empty # Move edge loop into new and offset. @@ -527,7 +527,7 @@ def mergeUvIslands(islandList): (e[0]+offset, e[1]+offset, e[2])\ ) for e in sourceIsland[6] ] ) - sourceIsland[6][:] = [] # Empty + del sourceIsland[6][:] # Empty # Sort by edge length, reverse so biggest are first. @@ -540,7 +540,7 @@ def mergeUvIslands(islandList): for p in sourceIsland[7]: p+= offset - sourceIsland[7][:] = [] + del sourceIsland[7][:] # Decrement the efficiency diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index 99e33594a3e..ff9774f85af 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -47,6 +47,7 @@ static SuggList suggestions = {NULL, NULL, NULL, NULL, NULL}; static char *documentation = NULL; //static int doc_lines = 0; +/* TODO, replace with BLI_strncasecmp() */ static int txttl_cmp(const char *first, const char *second, int len) { int cmp, i; @@ -113,19 +114,18 @@ short texttool_text_is_active(Text *text) void texttool_suggest_add(const char *name, char type) { + const int len = strlen(name); + int cmp; SuggItem *newitem, *item; - int len, cmp; - newitem = MEM_mallocN(sizeof(SuggItem) + strlen(name) + 1, "SuggestionItem"); + newitem = MEM_mallocN(sizeof(SuggItem) + len + 1, "SuggItem"); if (!newitem) { printf("Failed to allocate memory for suggestion.\n"); return; } newitem->name = (char *) (newitem + 1); - len = strlen(name); - strncpy(newitem->name, name, len); - newitem->name[len] = '\0'; + memcpy(newitem->name, name, len + 1); newitem->type = type; newitem->prev = newitem->next = NULL; diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index db5b769d078..37489510976 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -37,9 +37,6 @@ #include "intern/bmesh_operators_private.h" /* own include */ -#define NEW_BEVEL 1 - -#ifdef NEW_BEVEL #define BEVEL_FLAG 1 #define EDGE_SELECTED 2 @@ -1496,858 +1493,4 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) } free_bevel_params(&bp); } - } - -#else -#define BEVEL_FLAG 1 -#define BEVEL_DEL 2 -#define FACE_NEW 4 -#define EDGE_OLD 8 -#define FACE_OLD 16 -#define VERT_OLD 32 -#define FACE_SPAN 64 -#define FACE_HOLE 128 - -typedef struct LoopTag { - BMVert *newv; -} LoopTag; - -typedef struct EdgeTag { - BMVert *newv1, *newv2; -} EdgeTag; - -static void calc_corner_co(BMLoop *l, const float fac, float r_co[3], - const short do_dist, const short do_even) -{ - float no[3], l_vec_prev[3], l_vec_next[3], l_co_prev[3], l_co[3], l_co_next[3], co_ofs[3]; - int is_concave; - - /* first get the prev/next verts */ - if (l->f->len > 2) { - copy_v3_v3(l_co_prev, l->prev->v->co); - copy_v3_v3(l_co, l->v->co); - copy_v3_v3(l_co_next, l->next->v->co); - - /* calculate normal */ - sub_v3_v3v3(l_vec_prev, l_co_prev, l_co); - sub_v3_v3v3(l_vec_next, l_co_next, l_co); - - cross_v3_v3v3(no, l_vec_prev, l_vec_next); - is_concave = dot_v3v3(no, l->f->no) > 0.0f; - } - else { - BMIter iter; - BMLoop *l2; - float up[3] = {0.0f, 0.0f, 1.0f}; - - copy_v3_v3(l_co_prev, l->prev->v->co); - copy_v3_v3(l_co, l->v->co); - - BM_ITER_ELEM (l2, &iter, l->v, BM_LOOPS_OF_VERT) { - if (l2->f != l->f) { - copy_v3_v3(l_co_next, BM_edge_other_vert(l2->e, l2->next->v)->co); - break; - } - } - - sub_v3_v3v3(l_vec_prev, l_co_prev, l_co); - sub_v3_v3v3(l_vec_next, l_co_next, l_co); - - cross_v3_v3v3(no, l_vec_prev, l_vec_next); - if (dot_v3v3(no, no) == 0.0f) { - no[0] = no[1] = 0.0f; no[2] = -1.0f; - } - - is_concave = dot_v3v3(no, up) < 0.0f; - } - - - /* now calculate the new location */ - if (do_dist) { /* treat 'fac' as distance */ - - normalize_v3(l_vec_prev); - normalize_v3(l_vec_next); - - add_v3_v3v3(co_ofs, l_vec_prev, l_vec_next); - if (UNLIKELY(normalize_v3(co_ofs) == 0.0f)) { /* edges form a straight line */ - cross_v3_v3v3(co_ofs, l_vec_prev, l->f->no); - } - - if (do_even) { - negate_v3(l_vec_next); - mul_v3_fl(co_ofs, fac * shell_angle_to_dist(0.5f * angle_normalized_v3v3(l_vec_prev, l_vec_next))); - /* negate_v3(l_vec_next); */ /* no need unless we use again */ - } - else { - mul_v3_fl(co_ofs, fac); - } - } - else { /* treat as 'fac' as a factor (0 - 1) */ - - /* not strictly necessary, balance vectors - * so the longer edge doesn't skew the result, - * gives nicer, move even output. - * - * Use the minimum rather then the middle value so skinny faces don't flip along the short axis */ - float min_fac = min_ff(normalize_v3(l_vec_prev), normalize_v3(l_vec_next)); - float angle; - - if (do_even) { - negate_v3(l_vec_next); - angle = angle_normalized_v3v3(l_vec_prev, l_vec_next); - negate_v3(l_vec_next); /* no need unless we use again */ - } - else { - angle = 0.0f; - } - - mul_v3_fl(l_vec_prev, min_fac); - mul_v3_fl(l_vec_next, min_fac); - - add_v3_v3v3(co_ofs, l_vec_prev, l_vec_next); - - if (UNLIKELY(is_zero_v3(co_ofs))) { - cross_v3_v3v3(co_ofs, l_vec_prev, l->f->no); - normalize_v3(co_ofs); - mul_v3_fl(co_ofs, min_fac); - } - - /* done */ - if (do_even) { - mul_v3_fl(co_ofs, (fac * 0.5f) * shell_angle_to_dist(0.5f * angle)); - } - else { - mul_v3_fl(co_ofs, fac * 0.5f); - } - } - - /* apply delta vec */ - if (is_concave) - negate_v3(co_ofs); - - add_v3_v3v3(r_co, co_ofs, l->v->co); -} - - -#define ETAG_SET(e, v, nv) ( \ - (v) == (e)->v1 ? \ - (etags[BM_elem_index_get((e))].newv1 = (nv)) : \ - (etags[BM_elem_index_get((e))].newv2 = (nv)) \ - ) - -#define ETAG_GET(e, v) ( \ - (v) == (e)->v1 ? \ - (etags[BM_elem_index_get((e))].newv1) : \ - (etags[BM_elem_index_get((e))].newv2) \ - ) - -void bmo_bevel_exec(BMesh *bm, BMOperator *op) -{ - BMOIter siter; - BMIter iter; - BMEdge *e; - BMVert *v; - BMFace **faces = NULL, *f; - LoopTag *tags = NULL, *tag; - EdgeTag *etags = NULL; - BMVert **verts = NULL; - BMEdge **edges = NULL; - BLI_array_declare(faces); - BLI_array_declare(tags); - BLI_array_declare(etags); - BLI_array_declare(verts); - BLI_array_declare(edges); - SmallHash hash; - float fac = BMO_slot_float_get(op, "percent"); - const short do_even = BMO_slot_bool_get(op, "use_even"); - const short do_dist = BMO_slot_bool_get(op, "use_dist"); - int i, li, has_elens, HasMDisps = CustomData_has_layer(&bm->ldata, CD_MDISPS); - - has_elens = CustomData_has_layer(&bm->edata, CD_PROP_FLT) && BMO_slot_bool_get(op, "use_lengths"); - if (has_elens) { - li = BMO_slot_int_get(op, "lengthlayer"); - } - - BLI_smallhash_init(&hash); - - BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) { - BMO_elem_flag_enable(bm, e, BEVEL_FLAG | BEVEL_DEL); - BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG | BEVEL_DEL); - BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG | BEVEL_DEL); - - if (BM_edge_face_count(e) < 2) { - BMO_elem_flag_disable(bm, e, BEVEL_DEL); - BMO_elem_flag_disable(bm, e->v1, BEVEL_DEL); - BMO_elem_flag_disable(bm, e->v2, BEVEL_DEL); - } -#if 0 - if (BM_edge_is_wire(e)) { - BMVert *verts[2] = {e->v1, e->v2}; - BMEdge *edges[2] = {e, BM_edge_create(bm, e->v1, e->v2, e, 0)}; - - BMO_elem_flag_enable(bm, edges[1], BEVEL_FLAG); - BM_face_create(bm, verts, edges, 2, FALSE); - } -#endif - } - - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - BMO_elem_flag_enable(bm, v, VERT_OLD); - } - -#if 0 - /* a bit of cleaner code that, alas, doens't work. */ - /* build edge tag */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - if (BMO_elem_flag_test(bm, e->v1, BEVEL_FLAG) || BMO_elem_flag_test(bm, e->v2, BEVEL_FLAG)) { - BMIter liter; - BMLoop *l; - - if (!BMO_elem_flag_test(bm, e, EDGE_OLD)) { - BM_elem_index_set(e, BLI_array_count(etags)); /* set_dirty! */ - BLI_array_grow_one(etags); - - BMO_elem_flag_enable(bm, e, EDGE_OLD); - } - - BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) { - BMLoop *l2; - BMIter liter2; - - if (BMO_elem_flag_test(bm, l->f, BEVEL_FLAG)) - continue; - - BM_ITER_ELEM (l2, &liter2, l->f, BM_LOOPS_OF_FACE) { - BM_elem_index_set(l2, BLI_array_count(tags)); /* set_loop */ - BLI_array_grow_one(tags); - - if (!BMO_elem_flag_test(bm, l2->e, EDGE_OLD)) { - BM_elem_index_set(l2->e, BLI_array_count(etags)); /* set_dirty! */ - BLI_array_grow_one(etags); - - BMO_elem_flag_enable(bm, l2->e, EDGE_OLD); - } - } - - BMO_elem_flag_enable(bm, l->f, BEVEL_FLAG); - BLI_array_append(faces, l->f); - } - } - else { - BM_elem_index_set(e, -1); /* set_dirty! */ - } - } -#endif - - /* create and assign looptag structure */ - BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) { - BMLoop *l; - BMIter liter; - - BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG | BEVEL_DEL); - BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG | BEVEL_DEL); - - if (BM_edge_face_count(e) < 2) { - BMO_elem_flag_disable(bm, e, BEVEL_DEL); - BMO_elem_flag_disable(bm, e->v1, BEVEL_DEL); - BMO_elem_flag_disable(bm, e->v2, BEVEL_DEL); - } - - if (!BLI_smallhash_haskey(&hash, (intptr_t)e)) { - BLI_array_grow_one(etags); - BM_elem_index_set(e, BLI_array_count(etags) - 1); /* set_dirty! */ - BLI_smallhash_insert(&hash, (intptr_t)e, NULL); - BMO_elem_flag_enable(bm, e, EDGE_OLD); - } - - /* find all faces surrounding e->v1 and, e->v2 */ - for (i = 0; i < 2; i++) { - BM_ITER_ELEM (l, &liter, i ? e->v2 : e->v1, BM_LOOPS_OF_VERT) { - BMLoop *l2; - BMIter liter2; - - /* see if we've already processed this loop's fac */ - if (BLI_smallhash_haskey(&hash, (intptr_t)l->f)) - continue; - - /* create tags for all loops in l-> */ - BM_ITER_ELEM (l2, &liter2, l->f, BM_LOOPS_OF_FACE) { - BLI_array_grow_one(tags); - BM_elem_index_set(l2, BLI_array_count(tags) - 1); /* set_loop */ - - if (!BLI_smallhash_haskey(&hash, (intptr_t)l2->e)) { - BLI_array_grow_one(etags); - BM_elem_index_set(l2->e, BLI_array_count(etags) - 1); /* set_dirty! */ - BLI_smallhash_insert(&hash, (intptr_t)l2->e, NULL); - BMO_elem_flag_enable(bm, l2->e, EDGE_OLD); - } - } - - BLI_smallhash_insert(&hash, (intptr_t)l->f, NULL); - BMO_elem_flag_enable(bm, l->f, BEVEL_FLAG); - BLI_array_append(faces, l->f); - } - } - } - - bm->elem_index_dirty |= BM_EDGE; - - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - BMIter eiter; - - if (!BMO_elem_flag_test(bm, v, BEVEL_FLAG)) - continue; - - BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { - if (!BMO_elem_flag_test(bm, e, BEVEL_FLAG) && !ETAG_GET(e, v)) { - BMVert *v2; - float co[3]; - - v2 = BM_edge_other_vert(e, v); - sub_v3_v3v3(co, v2->co, v->co); - if (has_elens) { - float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, e->head.data, CD_PROP_FLT, li); - - normalize_v3(co); - mul_v3_fl(co, elen); - } - - mul_v3_fl(co, fac); - add_v3_v3(co, v->co); - - v2 = BM_vert_create(bm, co, v); - ETAG_SET(e, v, v2); - } - } - } - - for (i = 0; i < BLI_array_count(faces); i++) { - BMLoop *l; - BMIter liter; - - BMO_elem_flag_enable(bm, faces[i], FACE_OLD); - - BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) { - float co[3]; - - if (BMO_elem_flag_test(bm, l->e, BEVEL_FLAG)) { - if (BMO_elem_flag_test(bm, l->prev->e, BEVEL_FLAG)) { - tag = tags + BM_elem_index_get(l); - calc_corner_co(l, fac, co, do_dist, do_even); - tag->newv = BM_vert_create(bm, co, l->v); - } - else { - tag = tags + BM_elem_index_get(l); - tag->newv = ETAG_GET(l->prev->e, l->v); - - if (!tag->newv) { - sub_v3_v3v3(co, l->prev->v->co, l->v->co); - if (has_elens) { - float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, l->prev->e->head.data, - CD_PROP_FLT, li); - - normalize_v3(co); - mul_v3_fl(co, elen); - } - - mul_v3_fl(co, fac); - add_v3_v3(co, l->v->co); - - tag->newv = BM_vert_create(bm, co, l->v); - - ETAG_SET(l->prev->e, l->v, tag->newv); - } - } - } - else if (BMO_elem_flag_test(bm, l->v, BEVEL_FLAG)) { - tag = tags + BM_elem_index_get(l); - tag->newv = ETAG_GET(l->e, l->v); - - if (!tag->newv) { - sub_v3_v3v3(co, l->next->v->co, l->v->co); - if (has_elens) { - float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, l->e->head.data, CD_PROP_FLT, li); - - normalize_v3(co); - mul_v3_fl(co, elen); - } - - mul_v3_fl(co, fac); - add_v3_v3(co, l->v->co); - - tag = tags + BM_elem_index_get(l); - tag->newv = BM_vert_create(bm, co, l->v); - - ETAG_SET(l->e, l->v, tag->newv); - } - } - else { - tag = tags + BM_elem_index_get(l); - tag->newv = l->v; - BMO_elem_flag_disable(bm, l->v, BEVEL_DEL); - } - } - } - - /* create new faces inset from original face */ - for (i = 0; i < BLI_array_count(faces); i++) { - BMLoop *l; - BMIter liter; - BMFace *f; - BMVert *lastv = NULL, *firstv = NULL; - - BMO_elem_flag_enable(bm, faces[i], BEVEL_DEL); - - BLI_array_empty(verts); - BLI_array_empty(edges); - - BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) { - BMVert *v2; - - tag = tags + BM_elem_index_get(l); - BLI_array_append(verts, tag->newv); - - if (!firstv) - firstv = tag->newv; - - if (lastv) { - e = BM_edge_create(bm, lastv, tag->newv, l->e, TRUE); - BM_elem_attrs_copy(bm, bm, l->prev->e, e); - BLI_array_append(edges, e); - } - lastv = tag->newv; - - v2 = ETAG_GET(l->e, l->next->v); - - tag = &tags[BM_elem_index_get(l->next)]; - if (!BMO_elem_flag_test(bm, l->e, BEVEL_FLAG) && v2 && v2 != tag->newv) { - BLI_array_append(verts, v2); - - e = BM_edge_create(bm, lastv, v2, l->e, TRUE); - BM_elem_attrs_copy(bm, bm, l->e, e); - - BLI_array_append(edges, e); - lastv = v2; - } - } - - e = BM_edge_create(bm, firstv, lastv, BM_FACE_FIRST_LOOP(faces[i])->e, TRUE); - if (BM_FACE_FIRST_LOOP(faces[i])->prev->e != e) { - BM_elem_attrs_copy(bm, bm, BM_FACE_FIRST_LOOP(faces[i])->prev->e, e); - } - BLI_array_append(edges, e); - - f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), FALSE); - if (UNLIKELY(f == NULL)) { - printf("%s: could not make face!\n", __func__); - continue; - } - - BMO_elem_flag_enable(bm, f, FACE_NEW); - } - - for (i = 0; i < BLI_array_count(faces); i++) { - BMLoop *l; - BMIter liter; - int j; - - /* create quad spans between split edge */ - BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) { - BMVert *v1 = NULL, *v2 = NULL, *v3 = NULL, *v4 = NULL; - - if (!BMO_elem_flag_test(bm, l->e, BEVEL_FLAG)) - continue; - - v1 = tags[BM_elem_index_get(l)].newv; - v2 = tags[BM_elem_index_get(l->next)].newv; - if (l->radial_next != l) { - v3 = tags[BM_elem_index_get(l->radial_next)].newv; - if (l->radial_next->next->v == l->next->v) { - v4 = v3; - v3 = tags[BM_elem_index_get(l->radial_next->next)].newv; - } - else { - v4 = tags[BM_elem_index_get(l->radial_next->next)].newv; - } - } - else { - /* the loop is on a boundar */ - v3 = l->next->v; - v4 = l->v; - - for (j = 0; j < 2; j++) { - BMIter eiter; - BMVert *v = j ? v4 : v3; - - BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { - if (!BM_vert_in_edge(e, v3) || !BM_vert_in_edge(e, v4)) - continue; - - if (!BMO_elem_flag_test(bm, e, BEVEL_FLAG) && BMO_elem_flag_test(bm, e, EDGE_OLD)) { - BMVert *vv; - - vv = ETAG_GET(e, v); - if (!vv || BMO_elem_flag_test(bm, vv, BEVEL_FLAG)) - continue; - - if (j) { - v1 = vv; - } - else { - v2 = vv; - } - break; - } - } - } - - BMO_elem_flag_disable(bm, v3, BEVEL_DEL); - BMO_elem_flag_disable(bm, v4, BEVEL_DEL); - } - - if (v1 != v2 && v2 != v3 && v3 != v4) { - BMIter liter2; - BMLoop *l2, *l3; - BMEdge *e1, *e2; - float d1, d2, *d3; - - f = BM_face_create_quad_tri(bm, v4, v3, v2, v1, l->f, TRUE); - - e1 = BM_edge_exists(v4, v3); - e2 = BM_edge_exists(v2, v1); - BM_elem_attrs_copy(bm, bm, l->e, e1); - BM_elem_attrs_copy(bm, bm, l->e, e2); - - /* set edge lengths of cross edges as the average of the cross edges they're based o */ - if (has_elens) { - /* angle happens not to be used. why? - not sure it just isn't - campbell. - * leave this in in case we need to use it later */ -#if 0 - float ang; -#endif - e1 = BM_edge_exists(v1, v4); - e2 = BM_edge_exists(v2, v3); - - if (l->radial_next->v == l->v) { - l2 = l->radial_next->prev; - l3 = l->radial_next->next; - } - else { - l2 = l->radial_next->next; - l3 = l->radial_next->prev; - } - - d3 = CustomData_bmesh_get_n(&bm->edata, e1->head.data, CD_PROP_FLT, li); - d1 = *(float *)CustomData_bmesh_get_n(&bm->edata, l->prev->e->head.data, CD_PROP_FLT, li); - d2 = *(float *)CustomData_bmesh_get_n(&bm->edata, l2->e->head.data, CD_PROP_FLT, li); -#if 0 - ang = angle_v3v3v3(l->prev->v->co, l->v->co, BM_edge_other_vert(l2->e, l->v)->co); -#endif - *d3 = (d1 + d2) * 0.5f; - - d3 = CustomData_bmesh_get_n(&bm->edata, e2->head.data, CD_PROP_FLT, li); - d1 = *(float *)CustomData_bmesh_get_n(&bm->edata, l->next->e->head.data, CD_PROP_FLT, li); - d2 = *(float *)CustomData_bmesh_get_n(&bm->edata, l3->e->head.data, CD_PROP_FLT, li); -#if 0 - ang = angle_v3v3v3(BM_edge_other_vert(l->next->e, l->next->v)->co, l->next->v->co, - BM_edge_other_vert(l3->e, l->next->v)->co); -#endif - *d3 = (d1 + d2) * 0.5f; - } - - if (UNLIKELY(f == NULL)) { - fprintf(stderr, "%s: face index out of range! (bmesh internal error)\n", __func__); - continue; - } - - BMO_elem_flag_enable(bm, f, FACE_NEW | FACE_SPAN); - - /* un-tag edges in f for deletio */ - BM_ITER_ELEM (l2, &liter2, f, BM_LOOPS_OF_FACE) { - BMO_elem_flag_disable(bm, l2->e, BEVEL_DEL); - } - } - else { - f = NULL; - } - } - } - - /* fill in holes at vertices */ - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - BMIter eiter; - BMVert *vv, *vstart = NULL, *lastv = NULL; - SmallHash tmphash; - int rad, insorig = 0, err = 0; - - BLI_smallhash_init(&tmphash); - - if (!BMO_elem_flag_test(bm, v, BEVEL_FLAG)) - continue; - - BLI_array_empty(verts); - BLI_array_empty(edges); - - BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { - BMIter liter; - BMVert *v1 = NULL, *v2 = NULL; - BMLoop *l; - - if (BM_edge_face_count(e) < 2) - insorig = 1; - - if (BM_elem_index_get(e) == -1) - continue; - - rad = 0; - BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) { - if (!BMO_elem_flag_test(bm, l->f, FACE_OLD)) - continue; - - rad++; - - tag = tags + BM_elem_index_get((l->v == v) ? l : l->next); - - if (!v1) - v1 = tag->newv; - else if (!v2) - v2 = tag->newv; - } - - if (rad < 2) - insorig = 1; - - if (!v1) - v1 = ETAG_GET(e, v); - if (!v2 || v1 == v2) - v2 = ETAG_GET(e, v); - - if (v1) { - if (!BLI_smallhash_haskey(&tmphash, (intptr_t)v1)) { - BLI_array_append(verts, v1); - BLI_smallhash_insert(&tmphash, (intptr_t)v1, NULL); - } - - if (v2 && v1 != v2 && !BLI_smallhash_haskey(&tmphash, (intptr_t)v2)) { - BLI_array_append(verts, v2); - BLI_smallhash_insert(&tmphash, (intptr_t)v2, NULL); - } - } - } - - if (!BLI_array_count(verts)) - continue; - - if (insorig) { - BLI_array_append(verts, v); - BLI_smallhash_insert(&tmphash, (intptr_t)v, NULL); - } - - /* find edges that exist between vertices in verts. this is basically - * a topological walk of the edges connecting them */ - vstart = vstart ? vstart : verts[0]; - vv = vstart; - do { - BM_ITER_ELEM (e, &eiter, vv, BM_EDGES_OF_VERT) { - BMVert *vv2 = BM_edge_other_vert(e, vv); - - if (vv2 != lastv && BLI_smallhash_haskey(&tmphash, (intptr_t)vv2)) { - /* if we've go over the same vert twice, break out of outer loop */ - if (BLI_smallhash_lookup(&tmphash, (intptr_t)vv2) != NULL) { - e = NULL; - err = 1; - break; - } - - /* use self pointer as ta */ - BLI_smallhash_remove(&tmphash, (intptr_t)vv2); - BLI_smallhash_insert(&tmphash, (intptr_t)vv2, vv2); - - lastv = vv; - BLI_array_append(edges, e); - vv = vv2; - break; - } - } - - if (e == NULL) { - break; - } - } while (vv != vstart); - - if (err) { - continue; - } - - /* there may not be a complete loop of edges, so start again and make - * final edge afterwards. in this case, the previous loop worked to - * find one of the two edges at the extremes. */ - if (vv != vstart) { - /* undo previous taggin */ - for (i = 0; i < BLI_array_count(verts); i++) { - BLI_smallhash_remove(&tmphash, (intptr_t)verts[i]); - BLI_smallhash_insert(&tmphash, (intptr_t)verts[i], NULL); - } - - vstart = vv; - lastv = NULL; - BLI_array_empty(edges); - do { - BM_ITER_ELEM (e, &eiter, vv, BM_EDGES_OF_VERT) { - BMVert *vv2 = BM_edge_other_vert(e, vv); - - if (vv2 != lastv && BLI_smallhash_haskey(&tmphash, (intptr_t)vv2)) { - /* if we've go over the same vert twice, break out of outer loo */ - if (BLI_smallhash_lookup(&tmphash, (intptr_t)vv2) != NULL) { - e = NULL; - err = 1; - break; - } - - /* use self pointer as ta */ - BLI_smallhash_remove(&tmphash, (intptr_t)vv2); - BLI_smallhash_insert(&tmphash, (intptr_t)vv2, vv2); - - lastv = vv; - BLI_array_append(edges, e); - vv = vv2; - break; - } - } - if (e == NULL) - break; - } while (vv != vstart); - - if (!err) { - e = BM_edge_create(bm, vv, vstart, NULL, TRUE); - BLI_array_append(edges, e); - } - } - - if (err) - continue; - - if (BLI_array_count(edges) >= 3) { - BMFace *f; - - if (BM_face_exists(bm, verts, BLI_array_count(verts), &f)) - continue; - - f = BM_face_create_ngon(bm, lastv, vstart, edges, BLI_array_count(edges), FALSE); - if (UNLIKELY(f == NULL)) { - fprintf(stderr, "%s: in bevel vert fill! (bmesh internal error)\n", __func__); - } - else { - BMO_elem_flag_enable(bm, f, FACE_NEW | FACE_HOLE); - } - } - BLI_smallhash_release(&tmphash); - } - - /* copy over customdat */ - for (i = 0; i < BLI_array_count(faces); i++) { - BMLoop *l; - BMIter liter; - BMFace *f = faces[i]; - - BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - BMLoop *l2; - BMIter liter2; - - tag = tags + BM_elem_index_get(l); - if (!tag->newv) - continue; - - BM_ITER_ELEM (l2, &liter2, tag->newv, BM_LOOPS_OF_VERT) { - if (!BMO_elem_flag_test(bm, l2->f, FACE_NEW) || (l2->v != tag->newv && l2->v != l->v)) - continue; - - if (tag->newv != l->v || HasMDisps) { - BM_elem_attrs_copy(bm, bm, l->f, l2->f); - BM_loop_interp_from_face(bm, l2, l->f, TRUE, TRUE); - } - else { - BM_elem_attrs_copy(bm, bm, l->f, l2->f); - BM_elem_attrs_copy(bm, bm, l, l2); - } - - if (HasMDisps) { - BMLoop *l3; - BMIter liter3; - - BM_ITER_ELEM (l3, &liter3, l2->f, BM_LOOPS_OF_FACE) { - BM_loop_interp_multires(bm, l3, l->f); - } - } - } - } - } - - /* handle vertices along boundary edge */ - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (BMO_elem_flag_test(bm, v, VERT_OLD) && - BMO_elem_flag_test(bm, v, BEVEL_FLAG) && - !BMO_elem_flag_test(bm, v, BEVEL_DEL)) - { - BMLoop *l; - BMLoop *lorig = NULL; - BMIter liter; - - BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { - // BMIter liter2; - // BMLoop *l2 = l->v == v ? l : l->next, *l3; - - if (BMO_elem_flag_test(bm, l->f, FACE_OLD)) { - lorig = l; - break; - } - } - - if (!lorig) - continue; - - BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { - BMLoop *l2 = l->v == v ? l : l->next; - - BM_elem_attrs_copy(bm, bm, lorig->f, l2->f); - BM_elem_attrs_copy(bm, bm, lorig, l2); - } - } - } -#if 0 - /* clean up any remaining 2-edged face */ - BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (f->len == 2) { - BMFace *faces[2] = {f, BM_FACE_FIRST_LOOP(f)->radial_next->f}; - - if (faces[0] == faces[1]) - BM_face_kill(bm, f); - else - BM_faces_join(bm, faces, 2); - } - } -#endif - - BMO_op_callf(bm, op->flag, "delete geom=%fv context=%i", BEVEL_DEL, DEL_VERTS); - - /* clean up any edges that might not get properly delete */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - if (BMO_elem_flag_test(bm, e, EDGE_OLD) && !e->l) - BMO_elem_flag_enable(bm, e, BEVEL_DEL); - } - - BMO_op_callf(bm, op->flag, "delete geom=%fe context=%i", BEVEL_DEL, DEL_EDGES); - BMO_op_callf(bm, op->flag, "delete geom=%ff context=%i", BEVEL_DEL, DEL_FACES); - - BLI_smallhash_release(&hash); - BLI_array_free(tags); - BLI_array_free(etags); - BLI_array_free(verts); - BLI_array_free(edges); - BLI_array_free(faces); - - BMO_slot_buffer_from_enabled_flag(bm, op, "face_spans", BM_FACE, FACE_SPAN); - BMO_slot_buffer_from_enabled_flag(bm, op, "face_holes", BM_FACE, FACE_HOLE); -} -#endif /* NEW_BEVEL */ From 0163ae1701bb1725225d3efdb49e54e179209bc7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 10:08:39 +0000 Subject: [PATCH 011/115] speedup bevel by tagging verts and edges to bevel, this avoids a loop over all bevel edges for each bevel vert (can use edges-of-vert instead) --- source/blender/bmesh/operators/bmo_bevel.c | 52 +++++++++++++--------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 37489510976..3437873b953 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -107,8 +107,6 @@ typedef struct BevelParams { ListBase vertList; /* list of BevVert for each vertex involved in bevel */ float offset; /* blender units to offset each side of a beveled edge */ int seg; /* number of segments in beveled edge profile */ - - BMOperator *op; } BevelParams; /* Make a new BoundVert of the given kind, insert it at the end of the circular linked @@ -1164,10 +1162,8 @@ static void build_vmesh(BMesh *bm, BevVert *bv) /* * Construction around the vertex */ -static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMOperator *op, BMVert *v) +static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) { - - BMOIter siter; BMEdge *bme; BevVert *bv; BMEdge *bme2, *unflagged_bme; @@ -1179,12 +1175,10 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMOperator *op, BMV /* Gather input selected edges. * Only bevel selected edges that have exactly two incident faces. - * - * TODO, optimization - we could tag edges in 'geom' - * and then just iterate edges-of-vert, checking tags. */ - BMO_ITER (bme, &siter, bm, op, "geom", BM_EDGE) { - if (BM_vert_in_edge(bme, v)) { + + BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) { + if (BM_elem_flag_test(bme, BM_ELEM_TAG)) { if (BM_edge_is_manifold(bme)) { BMO_elem_flag_enable(bm, bme, EDGE_SELECTED); nsel++; @@ -1464,33 +1458,51 @@ static void free_bevel_params(BevelParams *bp) void bmo_bevel_exec(BMesh *bm, BMOperator *op) { + BMIter iter; BMOIter siter; BMVert *v; BMEdge *e; BevelParams bp = {{NULL}}; bp.offset = BMO_slot_float_get(op, "offset"); - bp.op = op; bp.seg = BMO_slot_int_get(op, "segments"); if (bp.offset > 0) { + /* first flush 'geom' into flags, this makes it possible to check connected data */ + BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE, BM_ELEM_TAG, FALSE); + + BMO_ITER (v, &siter, bm, op, "geom", BM_VERT | BM_EDGE) { + BM_elem_flag_enable(v, BM_ELEM_TAG); + } + /* The analysis of the input vertices and execution additional constructions */ - BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { - bevel_vert_construct(bm, &bp, op, v); + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(v, BM_ELEM_TAG)) { + bevel_vert_construct(bm, &bp, v); + } } + /* Build polygons for edges */ - BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) { - bevel_build_edge_polygons(bm, &bp, e); + BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e, BM_ELEM_TAG)) { + bevel_build_edge_polygons(bm, &bp, e); + } } - BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { - bevel_rebuild_existing_polygons(bm, &bp, v); + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(v, BM_ELEM_TAG)) { + bevel_rebuild_existing_polygons(bm, &bp, v); + } } - BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { - if (find_bevvert(&bp, v)) - BM_vert_kill(bm, v); + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(v, BM_ELEM_TAG)) { + if (find_bevvert(&bp, v)) { + BM_vert_kill(bm, v); + } + } } + free_bevel_params(&bp); } } From 7295d98e0707db3eeb09123a272fbed3849db70a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 10:23:38 +0000 Subject: [PATCH 012/115] use ghash for bevel verts, saves list lookups when getting a BMVert's BevVert --- source/blender/bmesh/operators/bmo_bevel.c | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 3437873b953..ed4d19b845a 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -92,7 +92,6 @@ typedef struct VMesh { /* Data for a vertex involved in a bevel */ typedef struct BevVert { - struct BevVert *next, *prev; BMVert *v; /* original mesh vertex */ int edgecount; /* total number of edges around the vertex */ int selcount; /* number of selected edges around the vertex */ @@ -104,7 +103,10 @@ typedef struct BevVert { * Bevel parameters and state */ typedef struct BevelParams { - ListBase vertList; /* list of BevVert for each vertex involved in bevel */ + /* hash of BevVert for each vertex involved in bevel + * GHash: (key=(BMVert *), value=(BevVert *)) */ + GHash *vert_hash; + float offset; /* blender units to offset each side of a beveled edge */ int seg; /* number of segments in beveled edge profile */ } BevelParams; @@ -194,13 +196,7 @@ static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e) /* find the BevVert corresponding to BMVert bmv */ static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv) { - BevVert *bv; - - for (bv = bp->vertList.first; bv; bv = bv->next) { - if (bv->v == bmv) - return bv; - } - return NULL; + return BLI_ghash_lookup(bp->vert_hash, bmv); } /* Return a good respresentative face (for materials, etc.) for faces @@ -1197,7 +1193,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) bv->edges = (EdgeHalf *)MEM_callocN(ntot * sizeof(EdgeHalf), "EdgeHalf"); bv->vmesh = (VMesh *)MEM_callocN(sizeof(VMesh), "VMesh"); bv->vmesh->seg = bp->seg; - BLI_addtail(&bp->vertList, bv); + BLI_ghash_insert(bp->vert_hash, v, bv); /* add edges to bv->edges in order that keeps adjacent edges sharing * a face, if possible */ @@ -1435,11 +1431,17 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) static void free_bevel_params(BevelParams *bp) { - BevVert *bv; VMesh *vm; BoundVert *v, *vnext; - for (bv = bp->vertList.first; bv; bv = bv->next) { + + GHashIterator ghi; + + /* look on deform bones first */ + BLI_ghashIterator_init(&ghi, bp->vert_hash); + + for (; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { + BevVert *bv = (BevVert *)BLI_ghashIterator_getValue(&ghi); MEM_freeN(bv->edges); vm = bv->vmesh; v = vm->boundstart; @@ -1452,8 +1454,9 @@ static void free_bevel_params(BevelParams *bp) if (vm->mesh) MEM_freeN(vm->mesh); MEM_freeN(vm); + MEM_freeN(bv); } - BLI_freelistN(&bp->vertList); + BLI_ghash_free(bp->vert_hash, NULL, NULL); } void bmo_bevel_exec(BMesh *bm, BMOperator *op) @@ -1462,12 +1465,14 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) BMOIter siter; BMVert *v; BMEdge *e; - BevelParams bp = {{NULL}}; + BevelParams bp = {NULL}; bp.offset = BMO_slot_float_get(op, "offset"); bp.seg = BMO_slot_int_get(op, "segments"); if (bp.offset > 0) { + bp.vert_hash = BLI_ghash_ptr_new(__func__); + /* first flush 'geom' into flags, this makes it possible to check connected data */ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE, BM_ELEM_TAG, FALSE); From a286afe75ddaed8003afb695d14483a05733c4a0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 11:06:58 +0000 Subject: [PATCH 013/115] use memarena for bevel allocs --- source/blender/bmesh/operators/bmo_bevel.c | 83 ++++++++-------------- 1 file changed, 29 insertions(+), 54 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index ed4d19b845a..f812b6c5320 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -26,10 +26,9 @@ #include "MEM_guardedalloc.h" -#include "BLI_listbase.h" #include "BLI_array.h" #include "BLI_math.h" -#include "BLI_smallhash.h" +#include "BLI_memarena.h" #include "BKE_customdata.h" @@ -44,8 +43,8 @@ /* Constructed vertex, sometimes later instantiated as BMVert */ typedef struct NewVert { - float co[3]; BMVert *v; + float co[3]; } NewVert; struct BoundVert; @@ -105,7 +104,8 @@ typedef struct BevVert { typedef struct BevelParams { /* hash of BevVert for each vertex involved in bevel * GHash: (key=(BMVert *), value=(BevVert *)) */ - GHash *vert_hash; + GHash *vert_hash; + MemArena *mem_arena; /* use for all allocs while bevel runs, if we need to free we can switch to mempool */ float offset; /* blender units to offset each side of a beveled edge */ int seg; /* number of segments in beveled edge profile */ @@ -113,9 +113,10 @@ typedef struct BevelParams { /* Make a new BoundVert of the given kind, insert it at the end of the circular linked * list with entry point bv->boundstart, and return it. */ -static BoundVert *add_new_bound_vert(VMesh *vm, float co[3]) +static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, float co[3]) { - BoundVert *ans = (BoundVert *) MEM_callocN(sizeof(BoundVert), "BoundVert"); + BoundVert *ans = (BoundVert *)BLI_memarena_alloc(mem_arena, sizeof(BoundVert)); + copy_v3_v3(ans->nv.co, co); if (!vm->boundstart) { ans->index = 0; @@ -552,7 +553,7 @@ static void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], cons * of a vertex on the the boundary of the beveled vertex bv->v. * Also decide on the mesh pattern that will be used inside the boundary. * Doesn't make the actual BMVerts */ -static void build_boundary(BevVert *bv) +static void build_boundary(MemArena *mem_arena, BevVert *bv) { EdgeHalf *efirst, *e; BoundVert *v; @@ -569,17 +570,17 @@ static void build_boundary(BevVert *bv) /* special case: beveled edge meets non-beveled one at valence 2 vert */ no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL); offset_in_plane(e, no, TRUE, co); - v = add_new_bound_vert(vm, co); + v = add_new_bound_vert(mem_arena, vm, co); v->efirst = v->elast = v->ebev = e; e->leftv = v; no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL); offset_in_plane(e, no, FALSE, co); - v = add_new_bound_vert(vm, co); + v = add_new_bound_vert(mem_arena, vm, co); v->efirst = v->elast = e; e->rightv = v; /* make artifical extra point along unbeveled edge, and form triangle */ slide_dist(e->next, bv->v, e->offset, co); - v = add_new_bound_vert(vm, co); + v = add_new_bound_vert(mem_arena, vm, co); v->efirst = v->elast = e->next; vm->mesh_kind = M_POLY; return; @@ -593,7 +594,7 @@ static void build_boundary(BevVert *bv) if (e->prev->isbev) { BLI_assert(e->prev != e); /* see: wire edge special case */ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co); - v = add_new_bound_vert(vm, co); + v = add_new_bound_vert(mem_arena, vm, co); v->efirst = e->prev; v->elast = v->ebev = e; e->leftv = v; @@ -607,7 +608,7 @@ static void build_boundary(BevVert *bv) /* TODO: fix case when one or both faces in following are NULL */ offset_in_two_planes(e->prev->prev, e, bv->v, e->prev->prev->fnext, e->fprev, co); - v = add_new_bound_vert(vm, co); + v = add_new_bound_vert(mem_arena, vm, co); v->efirst = e->prev->prev; v->elast = v->ebev = e; e->leftv = v; @@ -617,7 +618,7 @@ static void build_boundary(BevVert *bv) else { /* neither e->prev nor e->prev->prev are beveled: make on-edge on e->prev */ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co); - v = add_new_bound_vert(vm, co); + v = add_new_bound_vert(mem_arena, vm, co); v->efirst = e->prev; v->elast = v->ebev = e; e->leftv = v; @@ -635,7 +636,7 @@ static void build_boundary(BevVert *bv) else if (e->prev->isbev) { /* on-edge meet between e->prev and e */ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co); - v = add_new_bound_vert(vm, co); + v = add_new_bound_vert(mem_arena, vm, co); v->efirst = e->prev; v->elast = e; e->leftv = v; @@ -648,7 +649,7 @@ static void build_boundary(BevVert *bv) * Could slide to make an even bevel plane but for now will * just use last distance a meet point moved from bv->v. */ slide_dist(e, bv->v, lastd, co); - v = add_new_bound_vert(vm, co); + v = add_new_bound_vert(mem_arena, vm, co); v->efirst = v->elast = e; e->leftv = v; } @@ -1082,7 +1083,7 @@ static void bevel_build_quadstrip(BMesh *bm, BevVert *bv) /* Given that the boundary is built, now make the actual BMVerts * for the boundary and the interior of the vertex mesh. */ -static void build_vmesh(BMesh *bm, BevVert *bv) +static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) { VMesh *vm = bv->vmesh; BoundVert *v, *weld1, *weld2; @@ -1093,7 +1094,7 @@ static void build_vmesh(BMesh *bm, BevVert *bv) ns = vm->seg; ns2 = ns / 2; - vm->mesh = (NewVert *)MEM_callocN(n * (ns2 + 1) * (ns + 1) * sizeof(NewVert), "NewVert"); + vm->mesh = (NewVert *)BLI_memarena_alloc(mem_arena, n * (ns2 + 1) * (ns + 1) * sizeof(NewVert)); /* special case: two beveled ends welded together */ weld = (bv->selcount == 2) && (vm->count == 2); @@ -1186,12 +1187,12 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) return; ntot = BM_vert_edge_count(v); - bv = (BevVert *)MEM_callocN(sizeof(BevVert), "BevVert"); + bv = (BevVert *)BLI_memarena_alloc(bp->mem_arena, (sizeof(BevVert))); bv->v = v; bv->edgecount = ntot; bv->selcount = nsel; - bv->edges = (EdgeHalf *)MEM_callocN(ntot * sizeof(EdgeHalf), "EdgeHalf"); - bv->vmesh = (VMesh *)MEM_callocN(sizeof(VMesh), "VMesh"); + bv->edges = (EdgeHalf *)BLI_memarena_alloc(bp->mem_arena, ntot * sizeof(EdgeHalf)); + bv->vmesh = (VMesh *)BLI_memarena_alloc(bp->mem_arena, sizeof(VMesh)); bv->vmesh->seg = bp->seg; BLI_ghash_insert(bp->vert_hash, v, bv); @@ -1285,8 +1286,8 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) e->prev = &bv->edges[(i + ntot - 1) % ntot]; } - build_boundary(bv); - build_vmesh(bm, bv); + build_boundary(bp->mem_arena, bv); + build_vmesh(bp->mem_arena, bm, bv); } /* Face f has at least one beveled vertex. Rebuild f */ @@ -1428,37 +1429,6 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) } } - -static void free_bevel_params(BevelParams *bp) -{ - VMesh *vm; - BoundVert *v, *vnext; - - - GHashIterator ghi; - - /* look on deform bones first */ - BLI_ghashIterator_init(&ghi, bp->vert_hash); - - for (; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { - BevVert *bv = (BevVert *)BLI_ghashIterator_getValue(&ghi); - MEM_freeN(bv->edges); - vm = bv->vmesh; - v = vm->boundstart; - if (v) { - do { - vnext = v->next; - MEM_freeN(v); - } while ((v = vnext) != vm->boundstart); - } - if (vm->mesh) - MEM_freeN(vm->mesh); - MEM_freeN(vm); - MEM_freeN(bv); - } - BLI_ghash_free(bp->vert_hash, NULL, NULL); -} - void bmo_bevel_exec(BMesh *bm, BMOperator *op) { BMIter iter; @@ -1471,7 +1441,10 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) bp.seg = BMO_slot_int_get(op, "segments"); if (bp.offset > 0) { + /* primary alloc */ bp.vert_hash = BLI_ghash_ptr_new(__func__); + bp.mem_arena = BLI_memarena_new((1 << 16), __func__); + BLI_memarena_use_calloc(bp.mem_arena); /* first flush 'geom' into flags, this makes it possible to check connected data */ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE, BM_ELEM_TAG, FALSE); @@ -1508,6 +1481,8 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) } } - free_bevel_params(&bp); + /* primary free */ + BLI_ghash_free(bp.vert_hash, NULL, NULL); + BLI_memarena_free(bp.mem_arena); } } From 8c6350f9262581fe405020449f6a8d06a2a9aaa0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Nov 2012 14:47:45 +0000 Subject: [PATCH 014/115] fix [#33169] Interface destroyed after Text Object Edit --- .../blender/editors/space_view3d/drawobject.c | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f100f003ff5..729f810eb87 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3600,9 +3600,12 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B return 0; } -/* returns 1 when nothing was drawn */ -static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, - const short dt, const short dflag, const unsigned char ob_wire_col[4]) +/** + * Only called by #drawDispList + * \return 1 when nothing was drawn + */ +static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + const short dt, const short dflag, const unsigned char ob_wire_col[4]) { Object *ob = base->object; ListBase *lb = NULL; @@ -3610,20 +3613,9 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas Curve *cu; const short render_only = (v3d->flag2 & V3D_RENDER_OVERRIDE); const short solid = (dt > OB_WIRE); - int retval = 0; - - /* backface culling */ - if (v3d->flag2 & V3D_BACKFACE_CULLING) { - /* not all displists use same in/out normal direction convention */ - glEnable(GL_CULL_FACE); - glCullFace((ob->type == OB_MBALL) ? GL_BACK : GL_FRONT); - } if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == 0) { - if (v3d->flag2 & V3D_BACKFACE_CULLING) - glDisable(GL_CULL_FACE); - - return 0; + return FALSE; } switch (ob->type) { @@ -3635,7 +3627,9 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas if (solid) { dl = lb->first; - if (dl == NULL) return 1; + if (dl == NULL) { + return TRUE; + } if (dl->nors == NULL) BKE_displist_normals_add(lb); index3_nors_incr = 0; @@ -3669,9 +3663,11 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas } else { if (!render_only || (render_only && BKE_displist_has_faces(lb))) { + int retval; draw_index_wire = 0; retval = drawDispListwire(lb); draw_index_wire = 1; + return retval; } } break; @@ -3681,7 +3677,9 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas if (solid) { dl = lb->first; - if (dl == NULL) return 1; + if (dl == NULL) { + return TRUE; + } if (dl->nors == NULL) BKE_displist_normals_add(lb); @@ -3697,7 +3695,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas } } else { - retval = drawDispListwire(lb); + return drawDispListwire(lb); } break; case OB_MBALL: @@ -3705,7 +3703,9 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas if (BKE_mball_is_basis(ob)) { lb = &ob->disp; if (lb->first == NULL) BKE_displist_make_mball(scene, ob); - if (lb->first == NULL) return 1; + if (lb->first == NULL) { + return TRUE; + } if (solid) { @@ -3722,14 +3722,31 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas } else { /* MetaBalls use DL_INDEX4 type of DispList */ - retval = drawDispListwire(lb); + return drawDispListwire(lb); } } break; } - - if (v3d->flag2 & V3D_BACKFACE_CULLING) + + return FALSE; +} +static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + const short dt, const short dflag, const unsigned char ob_wire_col[4]) +{ + int retval; + + /* backface culling */ + if (v3d->flag2 & V3D_BACKFACE_CULLING) { + /* not all displists use same in/out normal direction convention */ + glEnable(GL_CULL_FACE); + glCullFace((base->object->type == OB_MBALL) ? GL_BACK : GL_FRONT); + } + + retval = drawDispList_nobackface(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); + + if (v3d->flag2 & V3D_BACKFACE_CULLING) { glDisable(GL_CULL_FACE); + } return retval; } From 71389d4d74fd1e632ff0e23416d33ca5e63c609d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 14 Nov 2012 17:18:47 +0000 Subject: [PATCH 015/115] Cycles OSL: windows build fixes. --- CMakeLists.txt | 8 ++++---- intern/cycles/kernel/kernel_accumulate.h | 4 ---- intern/cycles/util/util_thread.h | 6 +----- source/creator/CMakeLists.txt | 18 ++++++++++++++++-- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e5f62355af..70a75773d16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,7 +403,7 @@ if(WITH_CYCLES OR WITH_MOD_BOOLEAN OR WITH_AUDASPACE OR WITH_INTERNATIONAL) endif() # auto enable llvm for cycles_osl -if(WITH_CYCLES_OSL) +if(WITH_CYCLES_OSL AND NOT WIN32) set(WITH_LLVM ON CACHE BOOL "ON" FORCE) endif() @@ -928,7 +928,6 @@ elseif(WIN32) find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib) find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib) find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib) - # WARNING! depends on correct order of OSL libs linking list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} ${OSL_LIB_EXEC} ${OSL_LIB_QUERY}) find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) @@ -1139,7 +1138,7 @@ elseif(WIN32) set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) set(OPENIMAGEIO_LIBRARIES OpenImageIO) set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib) - set(OPENIMAGEIO_DEFINITIONS) + set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0") endif() if(WITH_OPENCOLORIO) @@ -1150,6 +1149,7 @@ elseif(WIN32) set(OPENCOLORIO_DEFINITIONS) endif() + set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib") # MSVC only, Mingw doesnt need @@ -1675,7 +1675,7 @@ if(WITH_CYCLES) message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES") endif() - if(WITH_CYCLES_OSL) + if(WITH_CYCLES_OSL AND NOT WIN32) if(NOT WITH_LLVM) message(FATAL_ERROR "Cycles OSL reqires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL") endif() diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h index 2f2314c9a8b..d99beb8905a 100644 --- a/intern/cycles/kernel/kernel_accumulate.h +++ b/intern/cycles/kernel/kernel_accumulate.h @@ -301,10 +301,6 @@ __device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L) __device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float clamp) { - #ifdef __OSL__ - using std::isfinite; - #endif - float sum = fabsf((*L_sum).x) + fabsf((*L_sum).y) + fabsf((*L_sum).z); if(!isfinite(sum)) { diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h index 843764ca9d6..751d22b2f63 100644 --- a/intern/cycles/util/util_thread.h +++ b/intern/cycles/util/util_thread.h @@ -75,7 +75,7 @@ protected: * Boost implementation is a bit slow, and Mac OS X __thread is not supported * but the pthreads implementation is optimized, so we use these macros. */ -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(_WIN32) #define tls_ptr(type, name) \ pthread_key_t name @@ -90,10 +90,6 @@ protected: #else -#ifdef __WIN32 -#define __thread __declspec(thread) -#endif - #define tls_ptr(type, name) \ __thread type *name #define tls_set(name, value) \ diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 9087d106f96..b61466e8fe2 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -622,10 +622,10 @@ elseif(WIN32) if(WITH_OPENIMAGEIO) if(NOT MINGW) - set(OIIOBIN ${LIBDIR}/openimageio) + set(OIIOBIN ${LIBDIR}/openimageio/bin) install( FILES - ${OIIOBIN}/bin/OpenImageIO.dll + ${OIIOBIN}/OpenImageIO.dll DESTINATION ${TARGETDIR} ) endif() @@ -648,6 +648,20 @@ elseif(WIN32) endif() endif() + if(WITH_CYCLES AND WITH_CYCLES_OSL) + if(NOT MINGW) + set(OSLBIN ${LIBDIR}/osl/bin) + install( + FILES + ${OSLBIN}/oslexec.dll + ${OSLBIN}/oslquery.dll + ${OSLBIN}/oslcomp.dll + DESTINATION ${TARGETDIR} + ) + endif() + endif() + + elseif(APPLE) # handy install macro to exclude files, we use \$ escape for the "to" From 7cfb79256e5cd21405528887b8d3b6b405ebba62 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 14 Nov 2012 19:53:46 +0000 Subject: [PATCH 016/115] Map Range Node (tiles) this node allows for more control for normalization of the mapped input range. Made during BlenderPRO 2012 - Brasilia, Brazil :) Idea and testing: Daniel Salazar Implementation: yours truly Reviewed by Lukas Toenne and Sergey Sharybin --- source/blender/blenkernel/BKE_node.h | 2 + source/blender/blenkernel/intern/node.c | 1 + source/blender/compositor/CMakeLists.txt | 4 + .../compositor/intern/COM_Converter.cpp | 4 + .../compositor/nodes/COM_MapRangeNode.cpp | 54 +++++++++++++ .../compositor/nodes/COM_MapRangeNode.h | 38 +++++++++ .../operations/COM_MapRangeOperation.cpp | 81 +++++++++++++++++++ .../operations/COM_MapRangeOperation.h | 71 ++++++++++++++++ source/blender/editors/space_node/drawnode.c | 11 +++ source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_nodetree.c | 10 +++ .../makesrna/intern/rna_nodetree_types.h | 1 + source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_composite.h | 1 + .../composite/nodes/node_composite_mapRange.c | 58 +++++++++++++ 15 files changed, 338 insertions(+) create mode 100644 source/blender/compositor/nodes/COM_MapRangeNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MapRangeNode.h create mode 100644 source/blender/compositor/operations/COM_MapRangeOperation.cpp create mode 100644 source/blender/compositor/operations/COM_MapRangeOperation.h create mode 100644 source/blender/nodes/composite/nodes/node_composite_mapRange.c diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index b365d93b246..65610b5c989 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -706,6 +706,8 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria #define CMP_NODE_SWITCH 317 #define CMP_NODE_PIXELATE 318 +#define CMP_NODE_MAP_RANGE 319 + /* channel toggles */ #define CMP_CHAN_RGB 1 #define CMP_CHAN_A 2 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 2d76484b60a..06b846a6df9 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2184,6 +2184,7 @@ static void registerCompositNodes(bNodeTreeType *ttype) register_node_type_cmp_normal(ttype); register_node_type_cmp_curve_vec(ttype); register_node_type_cmp_map_value(ttype); + register_node_type_cmp_map_range(ttype); register_node_type_cmp_normalize(ttype); register_node_type_cmp_filter(ttype); diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index b3e76a287ea..8259cb6f297 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -267,6 +267,8 @@ set(SRC nodes/COM_MathNode.h nodes/COM_MapValueNode.cpp nodes/COM_MapValueNode.h + nodes/COM_MapRangeNode.cpp + nodes/COM_MapRangeNode.h operations/COM_NormalizeOperation.cpp operations/COM_NormalizeOperation.h @@ -572,6 +574,8 @@ set(SRC operations/COM_SetAlphaOperation.h operations/COM_MapValueOperation.cpp operations/COM_MapValueOperation.h + operations/COM_MapRangeOperation.cpp + operations/COM_MapRangeOperation.h # Distort operation operations/COM_TranslateOperation.h diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 2b09c9d5b8c..9c4a32f20c9 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -83,6 +83,7 @@ #include "COM_LuminanceMatteNode.h" #include "COM_MapUVNode.h" #include "COM_MapValueNode.h" +#include "COM_MapRangeNode.h" #include "COM_MaskNode.h" #include "COM_MathNode.h" #include "COM_MixNode.h" @@ -351,6 +352,9 @@ Node *Converter::convert(bNode *b_node, bool fast) case CMP_NODE_MAP_VALUE: node = new MapValueNode(b_node); break; + case CMP_NODE_MAP_RANGE: + node = new MapRangeNode(b_node); + break; case CMP_NODE_TRANSFORM: node = new TransformNode(b_node); break; diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.cpp b/source/blender/compositor/nodes/COM_MapRangeNode.cpp new file mode 100644 index 00000000000..232be3d41b0 --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapRangeNode.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 2012, 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: + * Dalai Felinto + * Daniel Salazar + */ + +#include "COM_MapRangeNode.h" + +#include "COM_MapRangeOperation.h" +#include "COM_ExecutionSystem.h" + +MapRangeNode::MapRangeNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void MapRangeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) +{ + InputSocket *valueSocket = this->getInputSocket(0); + InputSocket *sourceMinSocket = this->getInputSocket(1); + InputSocket *sourceMaxSocket = this->getInputSocket(2); + InputSocket *destMinSocket = this->getInputSocket(3); + InputSocket *destMaxSocket = this->getInputSocket(4); + OutputSocket *outputSocket = this->getOutputSocket(0); + + MapRangeOperation *operation = new MapRangeOperation(); + + valueSocket->relinkConnections(operation->getInputSocket(0), 0, graph); + sourceMinSocket->relinkConnections(operation->getInputSocket(1), 1, graph); + sourceMaxSocket->relinkConnections(operation->getInputSocket(2), 2, graph); + destMinSocket->relinkConnections(operation->getInputSocket(3), 3, graph); + destMaxSocket->relinkConnections(operation->getInputSocket(4), 4, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + + operation->setUseClamp(this->getbNode()->custom1); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.h b/source/blender/compositor/nodes/COM_MapRangeNode.h new file mode 100644 index 00000000000..6667720be3d --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapRangeNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2012, 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: + * Dalai Felinto + * Daniel Salazar + */ + +#ifndef __COM_MAPRANGENODE_H__ +#define __COM_MAPRANGENODE_H__ + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief MapRangeNode + * @ingroup Node + */ +class MapRangeNode : public Node { +public: + MapRangeNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif /* __COM_MAPRANGENODE_H__ */ diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp new file mode 100644 index 00000000000..3facaaebc9c --- /dev/null +++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp @@ -0,0 +1,81 @@ +/* + * Copyright 2012, 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: + * Dalai Felinto + * Daniel Salazar + */ + +#include "COM_MapRangeOperation.h" + +MapRangeOperation::MapRangeOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); + this->addOutputSocket(COM_DT_VALUE); + this->m_inputOperation = NULL; + this->m_useClamp = FALSE; +} + +void MapRangeOperation::initExecution() +{ + this->m_inputOperation = this->getInputSocketReader(0); + this->m_sourceMinOperation = this->getInputSocketReader(1); + this->m_sourceMaxOperation = this->getInputSocketReader(2); + this->m_destMinOperation = this->getInputSocketReader(3); + this->m_destMaxOperation = this->getInputSocketReader(4); +} + +void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float inputs[8]; /* includes the 5 inputs + 3 pads */ + float value; + float source_min, source_max; + float dest_min, dest_max; + + this->m_inputOperation->read(inputs, x, y, sampler); + this->m_sourceMinOperation->read(inputs+1, x, y, sampler); + this->m_sourceMaxOperation->read(inputs+2, x, y, sampler); + this->m_destMinOperation->read(inputs+3, x, y, sampler); + this->m_destMaxOperation->read(inputs+4, x, y, sampler); + + value = inputs[0]; + source_min = inputs[1]; + source_max = inputs[2]; + dest_min = inputs[3]; + dest_max = inputs[4]; + + value = (value - source_min) / (source_max - source_min); + value = dest_min + value * (dest_max - dest_min); + + if (this->m_useClamp) + CLAMP(value, dest_min, dest_max); + + output[0] = value; +} + +void MapRangeOperation::deinitExecution() +{ + this->m_inputOperation = NULL; + this->m_sourceMinOperation = NULL; + this->m_sourceMaxOperation = NULL; + this->m_destMinOperation = NULL; + this->m_destMaxOperation = NULL; +} diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.h b/source/blender/compositor/operations/COM_MapRangeOperation.h new file mode 100644 index 00000000000..00dfc68168c --- /dev/null +++ b/source/blender/compositor/operations/COM_MapRangeOperation.h @@ -0,0 +1,71 @@ +/* + * Copyright 2012, 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: + * Dalai Felinto + * Daniel Salazar + */ + +#ifndef _COM_MapRangeOperation_h +#define _COM_MapRangeOperation_h +#include "COM_NodeOperation.h" +#include "DNA_texture_types.h" + +/** + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. + */ +class MapRangeOperation : public NodeOperation { +private: + /** + * Cached reference to the inputProgram + */ + SocketReader *m_inputOperation; + SocketReader *m_sourceMinOperation; + SocketReader *m_sourceMaxOperation; + SocketReader *m_destMinOperation; + SocketReader *m_destMaxOperation; + + bool m_useClamp; +public: + /** + * Default constructor + */ + MapRangeOperation(); + + /** + * the inner loop of this program + */ + void executePixel(float output[4], float x, float y, PixelSampler sampler); + + /** + * Initialize the execution + */ + void initExecution(); + + /** + * Deinitialize the execution + */ + void deinitExecution(); + + /** + * Clamp the output + */ + void setUseClamp(bool value) { this->m_useClamp = value; } + +}; +#endif diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 8d44da2e367..f808a08d5d2 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1887,6 +1887,14 @@ static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUS uiItemR(col, ptr, "edge_mode", 0, "", ICON_NONE); } +static void node_composit_buts_map_range(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *col; + + col = uiLayoutColumn(layout, TRUE); + uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE); +} + static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *sub, *col; @@ -2825,6 +2833,9 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_MAP_VALUE: ntype->uifunc = node_composit_buts_map_value; break; + case CMP_NODE_MAP_RANGE: + ntype->uifunc = node_composit_buts_map_range; + break; case CMP_NODE_TIME: ntype->uifunc = node_buts_time; break; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 5f667db4425..c9b44be06f9 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -148,6 +148,7 @@ extern StructRNA RNA_CompositorNodeLevels; extern StructRNA RNA_CompositorNodeLumaMatte; extern StructRNA RNA_CompositorNodeMapUV; extern StructRNA RNA_CompositorNodeMapValue; +extern StructRNA RNA_CompositorNodeMapRange; extern StructRNA RNA_CompositorNodeMath; extern StructRNA RNA_CompositorNodeMask; extern StructRNA RNA_CompositorNodeMixRGB; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a68bcf62df8..46eca04a00b 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2199,6 +2199,16 @@ static void def_cmp_map_value(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_cmp_map_range(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1); + RNA_def_property_ui_text(prop, "Clamp", "Clamp result of the node to 0..1 range"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + static void def_cmp_vector_blur(StructRNA *srna) { PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index fbbcbae6c12..14cdbc6cf7d 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -114,6 +114,7 @@ DefNode( CompositorNode, CMP_NODE_ALPHAOVER, def_cmp_alpha_over, "ALPHA DefNode( CompositorNode, CMP_NODE_BLUR, def_cmp_blur, "BLUR", Blur, "Blur", "" ) DefNode( CompositorNode, CMP_NODE_FILTER, def_cmp_filter, "FILTER", Filter, "Filter", "" ) DefNode( CompositorNode, CMP_NODE_MAP_VALUE, def_cmp_map_value, "MAP_VALUE", MapValue, "Map Value", "" ) +DefNode( CompositorNode, CMP_NODE_MAP_RANGE, def_cmp_map_range, "MAP_RANGE", MapRange, "Map Range", "" ) DefNode( CompositorNode, CMP_NODE_TIME, def_time, "TIME", Time, "Time", "" ) DefNode( CompositorNode, CMP_NODE_VECBLUR, def_cmp_vector_blur, "VECBLUR", VecBlur, "Vector Blur", "" ) DefNode( CompositorNode, CMP_NODE_SEPRGBA, 0, "SEPRGBA", SepRGBA, "Separate RGBA", "" ) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 7dca4d07b24..9e412785467 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -84,6 +84,7 @@ set(SRC composite/nodes/node_composite_lummaMatte.c composite/nodes/node_composite_mapUV.c composite/nodes/node_composite_mapValue.c + composite/nodes/node_composite_mapRange.c composite/nodes/node_composite_math.c composite/nodes/node_composite_mask.c composite/nodes/node_composite_mixrgb.c diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h index ee67ac88085..eecc1e46827 100644 --- a/source/blender/nodes/NOD_composite.h +++ b/source/blender/nodes/NOD_composite.h @@ -72,6 +72,7 @@ void register_node_type_cmp_huecorrect(struct bNodeTreeType *ttype); void register_node_type_cmp_normal(struct bNodeTreeType *ttype); void register_node_type_cmp_curve_vec(struct bNodeTreeType *ttype); void register_node_type_cmp_map_value(struct bNodeTreeType *ttype); +void register_node_type_cmp_map_range(struct bNodeTreeType *ttype); void register_node_type_cmp_normalize(struct bNodeTreeType *ttype); void register_node_type_cmp_filter(struct bNodeTreeType *ttype); diff --git a/source/blender/nodes/composite/nodes/node_composite_mapRange.c b/source/blender/nodes/composite/nodes/node_composite_mapRange.c new file mode 100644 index 00000000000..f96e133b19f --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_mapRange.c @@ -0,0 +1,58 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * The Original Code is Copyright (C) 2006 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_mapRange.c + * \ingroup cmpnodes + */ + + +#include "node_composite_util.h" + +/* **************** MAP VALUE ******************** */ +static bNodeSocketTemplate cmp_node_map_range_in[] = { + { SOCK_FLOAT, 1, N_("Value"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("From Min"), 0.0f, 1.0f, 1.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("From Max"), 1.0f, 1.0f, 1.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("To Min"), 0.0f, 1.0f, 1.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("To Max"), 1.0f, 1.0f, 1.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { -1, 0, "" } +}; +static bNodeSocketTemplate cmp_node_map_range_out[] = { + { SOCK_FLOAT, 0, N_("Value")}, + { -1, 0, "" } +}; + +void register_node_type_cmp_map_range(bNodeTreeType *ttype) +{ + static bNodeType ntype; + + node_type_base(ttype, &ntype, CMP_NODE_MAP_RANGE, "Map Range", NODE_CLASS_OP_VECTOR, NODE_OPTIONS); + node_type_socket_templates(&ntype, cmp_node_map_range_in, cmp_node_map_range_out); + node_type_size(&ntype, 120, 60, 150); + + nodeRegisterType(ttype, &ntype); +} From 67f0a4b4242abe15bf7ec5530231966da2fd0dd9 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 14 Nov 2012 21:57:47 +0000 Subject: [PATCH 017/115] Fixes, mostly for RPM (tested on fedora17): *Better handling of optional libs for ffmpeg, and is now able to check and give user additional link libs for ffmpeg. *Added two helpers (only used by RPM for now) to: **check whether a version number is greater or equal than another one, and... **check whether a version number is "included" into another one (eg 3.3.2 is included into more general 3.3). *Added date-time as target when building our own boost. *Removed apt-get upgrade action for DEB (let the user decide when he wants to globally upgrade its system!). --- build_files/build_environment/install_deps.sh | 126 ++++++++++++++++-- 1 file changed, 112 insertions(+), 14 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 853f38610c2..74c03c01686 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -13,6 +13,7 @@ OCIO_VERSION="1.0.7" FFMPEG_VERSION="1.0" _ffmpeg_list_sep=";" +# XXX Looks like ubuntu has libxvidcore4-dev, while debian has libxvidcore-dev... HASXVID=false XVIDDEV="" HASVPX=false @@ -34,6 +35,46 @@ INFO() { echo "${@}" } +# Return 1 if $1 >= $2, else 0. +# $1 and $2 should be version numbers made of numbers only. +version_ge() { + if [ $(echo -e "$1\n$2" | sort --version-sort | head --lines=1) = "$1" ]; then + return 0 + else + return 1 + fi +} + +# Return 1 if $1 is into $2 (e.g. 3.3.2 is into 3.3, but not 3.3.0 or 3.3.5) +# $1 and $2 should be version numbers made of numbers only. +# $1 should be at least as long as $2! +version_match() { + backIFS=$IFS + IFS='.' + + # Split both version numbers into their numeric elements. + arr1=( $1 ) + arr2=( $2 ) + + ret=0 + + count1=${#arr1[@]} + count2=${#arr2[@]} + if [ $count1 -ge $count2 ]; then + ret=1 + for (( i=0; $i < $count2; i++ )) + do + if [ $(( 10#${arr1[$i]} )) -ne $(( 10#${arr2[$i]} )) ]; then + ret=0 + break + fi + done + fi + + IFS=$backIFS + return $ret +} + detect_distro() { if [ -f /etc/debian_version ]; then DISTRO="DEB" @@ -101,7 +142,7 @@ compile_Boost() { fi cd $SRC/boost_$BOOST_VERSION - ./bootstrap.sh --with-libraries=system,filesystem,thread,regex,locale --prefix=/opt/lib/boost-$version_dots + ./bootstrap.sh --with-libraries=system,filesystem,thread,regex,locale,date-time --prefix=/opt/lib/boost-$version_dots ./b2 install ./b2 --clean @@ -297,7 +338,8 @@ install_DEB() { INFO "Installing dependencies for DEB-based distributive" sudo apt-get update - sudo apt-get -y upgrade +# XXX Why in hell? Let's let this stuff to the user's responsability!!! +# sudo apt-get -y upgrade sudo apt-get install -y cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \ libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \ @@ -416,17 +458,18 @@ check_package_RPM() { fi } -check_package_version_RPM() { +check_package_version_match_RPM() { v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'` - # for now major and minor versions only (as if x.y, not x.y.z) - r=`echo $v | grep -c $2` + version_match $v $2 + return $? +} - if [ $r -ge 1 ]; then - return 0 - else - return 1 - fi +check_package_version_ge_RPM() { + v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'` + + version_ge $v $2 + return $? } install_RPM() { @@ -438,14 +481,39 @@ install_RPM() { freetype-devel libX11-devel libXi-devel wget libsqlite3x-devel ncurses-devel \ readline-devel openjpeg-devel openexr-devel openal-soft-devel \ glew-devel yasm schroedinger-devel libtheora-devel libvorbis-devel SDL-devel \ - fftw-devel lame-libs jack-audio-connection-kit-devel x264-devel libspnav-devel \ + fftw-devel lame-libs jack-audio-connection-kit-devel libspnav-devel \ libjpeg-devel patch python-devel HASOPENJPEG=true HASSCHRO=true - check_package_version_RPM python-devel 3.3. + check_package_RPM x264-devel if [ $? -eq 0 ]; then + sudo yum install -y x264-devel + HASX264=true + fi + + check_package_RPM xvidcore-devel + if [ $? -eq 0 ]; then + sudo yum install -y xvidcore-devel + HASXVID=true + XVIDDEV="xvidcore-devel" + fi + + check_package_version_ge_RPM libvpx-devel 0.9.7 + if [ $? -eq 1 ]; then + sudo yum install -y libvpx-devel + HASVPX=true + fi + + check_package_RPM lame-devel + if [ $? -eq 0 ]; then + sudo yum install -y lame-devel + HASMP3LAME=true + fi + + check_package_version_match_RPM python3-devel 3.3 + if [ $? -eq 1 ]; then sudo yum install -y python-devel else compile_Python @@ -555,6 +623,36 @@ print_info_ffmpeglink_DEB() { dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.so" | awk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }' } +print_info_ffmpeglink_RPM() { + _packages="libtheora-devel" + + if $HASXVID; then + _packages="$_packages $XVIDDEV" + fi + + if $HASVPX; then + _packages="$_packages libvpx-devel" + fi + + if $HASMP3LAME; then + _packages="$_packages lame-devel" + fi + + if $HASX264; then + _packages="$_packages x264-devel" + fi + + if $HASOPENJPEG; then + _packages="$_packages openjpeg-devel" + fi + + if $HASSCHRO; then + _packages="$_packages schroedinger-devel" + fi + + rpm -ql $_packages | grep -e ".*\/lib[^\/]\+\.so" | awk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }' +} + print_info_ffmpeglink() { # This func must only print a ';'-separated list of libs... if [ -z "$DISTRO" ]; then @@ -562,10 +660,10 @@ print_info_ffmpeglink() { exit 1 elif [ "$DISTRO" = "DEB" ]; then print_info_ffmpeglink_DEB + elif [ "$DISTRO" = "RPM" ]; then + print_info_ffmpeglink_RPM # XXX TODO! else INFO "" -# elif [ "$DISTRO" = "RPM" ]; then -# print_info_ffmpeglink_RPM # elif [ "$DISTRO" = "SUSE" ]; then # print_info_ffmpeglink_SUSE fi From 42db4fb50a847197ab83c00dd799d9645d761b01 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 14 Nov 2012 22:15:45 +0000 Subject: [PATCH 018/115] fix range map node clipping when max < min (useful for flipping the values inside the node) --- .../compositor/operations/COM_MapRangeOperation.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp index 3facaaebc9c..c25b056130b 100644 --- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp +++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp @@ -65,8 +65,14 @@ void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSam value = (value - source_min) / (source_max - source_min); value = dest_min + value * (dest_max - dest_min); - if (this->m_useClamp) - CLAMP(value, dest_min, dest_max); + if (this->m_useClamp) { + if (dest_max > dest_min) { + CLAMP(value, dest_min, dest_max); + } + else { + CLAMP(value, dest_max, dest_min); + } + } output[0] = value; } From 16f1c86953c32ad1c0691a87adcc432b9300abb1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 14 Nov 2012 22:45:44 +0000 Subject: [PATCH 019/115] Fix OSL build error on linux. --- intern/cycles/kernel/osl/osl_globals.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/intern/cycles/kernel/osl/osl_globals.h b/intern/cycles/kernel/osl/osl_globals.h index 80ced9dfd62..003e39ca3c3 100644 --- a/intern/cycles/kernel/osl/osl_globals.h +++ b/intern/cycles/kernel/osl/osl_globals.h @@ -22,12 +22,17 @@ #ifdef WITH_OSL #include +#include #include "util_map.h" #include "util_param.h" #include "util_thread.h" #include "util_vector.h" +#ifndef WIN32 +using std::isfinite; +#endif + CCL_NAMESPACE_BEGIN class OSLRenderServices; From 4a5e8bf24cadf6c5779540f26caf9db3bb96a29b Mon Sep 17 00:00:00 2001 From: Justin Dailey Date: Wed, 14 Nov 2012 23:10:19 +0000 Subject: [PATCH 020/115] Patch [#31006] Text editor undo buffer rework. --- source/blender/blenkernel/BKE_text.h | 22 +- source/blender/blenkernel/intern/text.c | 713 ++++++++----------- source/blender/editors/space_text/text_ops.c | 45 +- 3 files changed, 297 insertions(+), 483 deletions(-) diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 875903f2e20..aaf88e4924d 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -83,7 +83,7 @@ void txt_sel_line (struct Text *text); char* txt_sel_to_buf (struct Text *text); void txt_insert_buf (struct Text *text, const char *in_buffer); void txt_print_undo (struct Text *text); -void txt_undo_add_toop (struct Text *text, int op, unsigned int froml, unsigned short fromc, unsigned int tol, unsigned short toc); +void txt_undo_add_op (struct Text *text, int op); void txt_do_undo (struct Text *text); void txt_do_redo (struct Text *text); void txt_split_curline (struct Text *text); @@ -123,24 +123,6 @@ enum { /* Undo opcodes */ -/* Simple main cursor movement */ -#define UNDO_CLEFT 001 -#define UNDO_CRIGHT 002 -#define UNDO_CUP 003 -#define UNDO_CDOWN 004 - -/* Simple selection cursor movement */ -#define UNDO_SLEFT 005 -#define UNDO_SRIGHT 006 -#define UNDO_SUP 007 -#define UNDO_SDOWN 010 - -/* Complex movement (opcode is followed - * by 4 character line ID + a 2 character - * position ID and opcode (repeat)) */ -#define UNDO_CTO 011 -#define UNDO_STO 012 - /* Complex editing */ /* 1 - opcode is followed by 1 byte for ascii character and opcode (repeat)) */ /* 2 - opcode is followed by 2 bytes for utf-8 character and opcode (repeat)) */ @@ -169,8 +151,6 @@ enum { #define UNDO_IBLOCK 030 /* Insert block */ /* Misc */ -#define UNDO_SWAP 031 /* Swap cursors */ - #define UNDO_INDENT 032 #define UNDO_UNINDENT 033 #define UNDO_COMMENT 034 diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index d230cf8f1fe..076dc3a35d7 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -136,8 +136,7 @@ static void txt_pop_first(Text *text); static void txt_pop_last(Text *text); -static void txt_undo_add_op(Text *text, int op); -static void txt_undo_add_block(Text *text, int op, const char *buf); +static void txt_undo_add_blockop(Text *text, int op, const char *buf); static void txt_delete_line(Text *text, TextLine *line); static void txt_delete_sel(Text *text); static void txt_make_dirty(Text *text); @@ -785,23 +784,6 @@ static void txt_curs_sel(Text *text, TextLine ***linep, int **charp) *linep = &text->sell; *charp = &text->selc; } -static void txt_curs_first(Text *text, TextLine **linep, int *charp) -{ - if (text->curl == text->sell) { - *linep = text->curl; - if (text->curc < text->selc) *charp = text->curc; - else *charp = text->selc; - } - else if (txt_get_span(text->lines.first, text->curl) < txt_get_span(text->lines.first, text->sell)) { - *linep = text->curl; - *charp = text->curc; - } - else { - *linep = text->sell; - *charp = text->selc; - } -} - /*****************************/ /* Cursor movement functions */ /*****************************/ @@ -843,13 +825,11 @@ void txt_move_up(Text *text, short sel) { TextLine **linep; int *charp; - /* int old; */ /* UNUSED */ if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - /* old = *charp; */ /* UNUSED */ if ((*linep)->prev) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); @@ -857,8 +837,6 @@ void txt_move_up(Text *text, short sel) if (index > txt_utf8_len((*linep)->line)) *charp = (*linep)->len; else *charp = txt_utf8_index_to_offset((*linep)->line, index); - if (!undoing) - txt_undo_add_op(text, sel ? UNDO_SUP : UNDO_CUP); } else { txt_move_bol(text, sel); @@ -871,22 +849,17 @@ void txt_move_down(Text *text, short sel) { TextLine **linep; int *charp; - /* int old; */ /* UNUSED */ if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - /* old = *charp; */ /* UNUSED */ if ((*linep)->next) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); *linep = (*linep)->next; if (index > txt_utf8_len((*linep)->line)) *charp = (*linep)->len; else *charp = txt_utf8_index_to_offset((*linep)->line, index); - - if (!undoing) - txt_undo_add_op(text, sel ? UNDO_SDOWN : UNDO_CDOWN); } else { txt_move_eol(text, sel); @@ -898,7 +871,7 @@ void txt_move_down(Text *text, short sel) void txt_move_left(Text *text, short sel) { TextLine **linep; - int *charp, oundoing = undoing; + int *charp; int tabsize = 0, i = 0; if (!text) return; @@ -906,8 +879,6 @@ void txt_move_left(Text *text, short sel) else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - undoing = 1; - if (*charp == 0) { if ((*linep)->prev) { txt_move_up(text, sel); @@ -939,24 +910,19 @@ void txt_move_left(Text *text, short sel) } } - undoing = oundoing; - if (!undoing) txt_undo_add_op(text, sel ? UNDO_SLEFT : UNDO_CLEFT); - if (!sel) txt_pop_sel(text); } void txt_move_right(Text *text, short sel) { TextLine **linep; - int *charp, oundoing = undoing, do_tab = FALSE, i; + int *charp, do_tab = FALSE, i; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - undoing = 1; - if (*charp == (*linep)->len) { if ((*linep)->next) { txt_move_down(text, sel); @@ -984,124 +950,103 @@ void txt_move_right(Text *text, short sel) else (*charp) += BLI_str_utf8_size((*linep)->line + *charp); } - undoing = oundoing; - if (!undoing) txt_undo_add_op(text, sel ? UNDO_SRIGHT : UNDO_CRIGHT); - if (!sel) txt_pop_sel(text); } void txt_jump_left(Text *text, short sel) { TextLine **linep; - int *charp, oldc; + int *charp; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - oldc = *charp; BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, charp, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM); if (!sel) txt_pop_sel(text); - if (!undoing) { - int span = txt_get_span(text->lines.first, *linep); - txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, span, oldc, span, (unsigned short)*charp); - } } void txt_jump_right(Text *text, short sel) { TextLine **linep; - int *charp, oldc; + int *charp; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - oldc = *charp; BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, charp, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM); if (!sel) txt_pop_sel(text); - if (!undoing) { - int span = txt_get_span(text->lines.first, *linep); - txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, span, oldc, span, (unsigned short)*charp); - } } void txt_move_bol(Text *text, short sel) { TextLine **linep; - int *charp, old; + int *charp; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old = *charp; *charp = 0; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_eol(Text *text, short sel) { TextLine **linep; - int *charp, old; + int *charp; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old = *charp; - + *charp = (*linep)->len; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_bof(Text *text, short sel) { TextLine **linep; - int *charp, old; + int *charp; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old = *charp; *linep = text->lines.first; *charp = 0; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_eof(Text *text, short sel) { TextLine **linep; - int *charp, old; + int *charp; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old = *charp; *linep = text->lines.last; *charp = (*linep)->len; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_toline(Text *text, unsigned int line, short sel) @@ -1112,16 +1057,14 @@ void txt_move_toline(Text *text, unsigned int line, short sel) /* Moves to a certain byte in a line, not a certain utf8-character! */ void txt_move_to(Text *text, unsigned int line, unsigned int ch, short sel) { - TextLine **linep, *oldl; - int *charp, oldc; + TextLine **linep; + int *charp; unsigned int i; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - oldc = *charp; - oldl = *linep; *linep = text->lines.first; for (i = 0; i < line; i++) { @@ -1133,7 +1076,6 @@ void txt_move_to(Text *text, unsigned int line, unsigned int ch, short sel) *charp = ch; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } /****************************/ @@ -1152,8 +1094,6 @@ static void txt_curs_swap(Text *text) tmpc = text->curc; text->curc = text->selc; text->selc = tmpc; - - if (!undoing) txt_undo_add_op(text, UNDO_SWAP); } static void txt_pop_first(Text *text) @@ -1164,12 +1104,6 @@ static void txt_pop_first(Text *text) { txt_curs_swap(text); } - - if (!undoing) txt_undo_add_toop(text, UNDO_STO, - txt_get_span(text->lines.first, text->sell), - text->selc, - txt_get_span(text->lines.first, text->curl), - text->curc); txt_pop_sel(text); } @@ -1181,12 +1115,6 @@ static void txt_pop_last(Text *text) { txt_curs_swap(text); } - - if (!undoing) txt_undo_add_toop(text, UNDO_STO, - txt_get_span(text->lines.first, text->sell), - text->selc, - txt_get_span(text->lines.first, text->curl), - text->curc); txt_pop_sel(text); } @@ -1236,7 +1164,7 @@ static void txt_delete_sel(Text *text) if (!undoing) { buf = txt_sel_to_buf(text); - txt_undo_add_block(text, UNDO_DBLOCK, buf); + txt_undo_add_blockop(text, UNDO_DBLOCK, buf); MEM_freeN(buf); } @@ -1517,7 +1445,7 @@ void txt_insert_buf(Text *text, const char *in_buffer) buffer = BLI_strdupn(in_buffer, len); len += txt_extended_ascii_as_utf8(&buffer); - if (!undoing) txt_undo_add_block(text, UNDO_IBLOCK, buffer); + if (!undoing) txt_undo_add_blockop(text, UNDO_IBLOCK, buffer); u = undoing; undoing = 1; @@ -1599,6 +1527,7 @@ static void dump_buffer(Text *text) while (i++ < text->undo_pos) printf("%d: %d %c\n", i, text->undo_buf[i], text->undo_buf[i]); } +/* Note: this function is outdated and must be updated if needed for future use */ void txt_print_undo(Text *text) { int i = 0; @@ -1615,37 +1544,7 @@ void txt_print_undo(Text *text) while (i <= text->undo_pos) { op = text->undo_buf[i]; - if (op == UNDO_CLEFT) { - ops = "Cursor left"; - } - else if (op == UNDO_CRIGHT) { - ops = "Cursor right"; - } - else if (op == UNDO_CUP) { - ops = "Cursor up"; - } - else if (op == UNDO_CDOWN) { - ops = "Cursor down"; - } - else if (op == UNDO_SLEFT) { - ops = "Selection left"; - } - else if (op == UNDO_SRIGHT) { - ops = "Selection right"; - } - else if (op == UNDO_SUP) { - ops = "Selection up"; - } - else if (op == UNDO_SDOWN) { - ops = "Selection down"; - } - else if (op == UNDO_STO) { - ops = "Selection "; - } - else if (op == UNDO_CTO) { - ops = "Cursor "; - } - else if (op == UNDO_INSERT_1) { + if (op == UNDO_INSERT_1) { ops = "Insert ascii "; } else if (op == UNDO_INSERT_2) { @@ -1681,9 +1580,6 @@ void txt_print_undo(Text *text) else if (op == UNDO_DEL_4) { ops = "Delete unicode "; } - else if (op == UNDO_SWAP) { - ops = "Cursor swap"; - } else if (op == UNDO_DBLOCK) { ops = "Delete text block"; } @@ -1738,29 +1634,6 @@ void txt_print_undo(Text *text) } } } - else if (op == UNDO_STO || op == UNDO_CTO) { - i++; - - charp = text->undo_buf[i]; i++; - charp = charp + (text->undo_buf[i] << 8); i++; - - linep = text->undo_buf[i]; i++; - linep = linep + (text->undo_buf[i] << 8); i++; - linep = linep + (text->undo_buf[i] << 16); i++; - linep = linep + (text->undo_buf[i] << 24); i++; - - printf("to <%d, %d> ", linep, charp); - - charp = text->undo_buf[i]; i++; - charp = charp + (text->undo_buf[i] << 8); i++; - - linep = text->undo_buf[i]; i++; - linep = linep + (text->undo_buf[i] << 8); i++; - linep = linep + (text->undo_buf[i] << 16); i++; - linep = linep + (text->undo_buf[i] << 24); i++; - - printf("from <%d, %d>", linep, charp); - } else if (op == UNDO_DBLOCK || op == UNDO_IBLOCK) { i++; @@ -1811,16 +1684,6 @@ void txt_print_undo(Text *text) } } -static void txt_undo_add_op(Text *text, int op) -{ - if (!max_undo_test(text, 2)) - return; - - text->undo_pos++; - text->undo_buf[text->undo_pos] = op; - text->undo_buf[text->undo_pos + 1] = 0; -} - static void txt_undo_store_uint16(char *undo_buf, int *undo_pos, unsigned short value) { undo_buf[*undo_pos] = (value) & 0xff; @@ -1841,17 +1704,41 @@ static void txt_undo_store_uint32(char *undo_buf, int *undo_pos, unsigned int va (*undo_pos)++; } -static void txt_undo_add_block(Text *text, int op, const char *buf) +/* store the cur cursor to the undo buffer */ +static void txt_undo_store_cur(Text *text) +{ + txt_undo_store_uint16(text->undo_buf, &text->undo_pos, text->curc); + txt_undo_store_uint32(text->undo_buf, &text->undo_pos, txt_get_span(text->lines.first, text->curl)); +} + +/* store the sel cursor to the undo buffer */ +static void txt_undo_store_sel(Text *text) +{ + txt_undo_store_uint16(text->undo_buf, &text->undo_pos, text->selc); + txt_undo_store_uint32(text->undo_buf, &text->undo_pos, txt_get_span(text->lines.first, text->sell)); +} + +/* store both cursors to the undo buffer */ +static void txt_undo_store_cursors(Text *text) +{ + txt_undo_store_cur(text); + txt_undo_store_sel(text); +} + +/* store an operator along with a block of data */ +static void txt_undo_add_blockop(Text *text, int op, const char *buf) { unsigned int length = strlen(buf); - if (!max_undo_test(text, length + 11)) + if (!max_undo_test(text, length + 11 + 12)) return; text->undo_pos++; text->undo_buf[text->undo_pos] = op; text->undo_pos++; + txt_undo_store_cursors(text); + txt_undo_store_uint32(text->undo_buf, &text->undo_pos, length); strncpy(text->undo_buf + text->undo_pos, buf, length); @@ -1863,34 +1750,30 @@ static void txt_undo_add_block(Text *text, int op, const char *buf) text->undo_buf[text->undo_pos + 1] = 0; } -void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fromc, unsigned int tol, unsigned short toc) +/* store a regular operator */ +void txt_undo_add_op(Text *text, int op) { if (!max_undo_test(text, 15)) return; - if (froml == tol && fromc == toc) return; - text->undo_pos++; text->undo_buf[text->undo_pos] = op; text->undo_pos++; - txt_undo_store_uint16(text->undo_buf, &text->undo_pos, fromc); - txt_undo_store_uint32(text->undo_buf, &text->undo_pos, froml); - txt_undo_store_uint16(text->undo_buf, &text->undo_pos, toc); - txt_undo_store_uint32(text->undo_buf, &text->undo_pos, tol); + txt_undo_store_cursors(text); text->undo_buf[text->undo_pos] = op; - - text->undo_buf[text->undo_pos + 1] = 0; + text->undo_buf[text->undo_pos+1] = 0; } +/* store an operator for a single character */ static void txt_undo_add_charop(Text *text, int op_start, unsigned int c) { char utf8[BLI_UTF8_MAX]; size_t i, utf8_size = BLI_str_utf8_from_unicode(c, utf8); - if (!max_undo_test(text, 3 + utf8_size)) + if (!max_undo_test(text, 3 + utf8_size + 12)) return; text->undo_pos++; @@ -1899,6 +1782,8 @@ static void txt_undo_add_charop(Text *text, int op_start, unsigned int c) text->undo_buf[text->undo_pos] = op_start + utf8_size - 1; text->undo_pos++; + txt_undo_store_cur(text); + for (i = 0; i < utf8_size; i++) { text->undo_buf[text->undo_pos] = utf8[i]; text->undo_pos++; @@ -1909,6 +1794,9 @@ static void txt_undo_add_charop(Text *text, int op_start, unsigned int c) else { text->undo_buf[text->undo_pos] = op_start + 3; text->undo_pos++; + + txt_undo_store_cursors(text); + txt_undo_store_uint32(text->undo_buf, &text->undo_pos, c); text->undo_buf[text->undo_pos] = op_start + 3; } @@ -1934,6 +1822,29 @@ static unsigned int txt_undo_read_uint32(const char *undo_buf, int *undo_pos) return val; } +/* read the cur cursor from the undo buffer */ +static void txt_undo_read_cur(const char *undo_buf, int *undo_pos, unsigned int *curln, unsigned short *curc) +{ + *curln = txt_undo_read_uint32(undo_buf, undo_pos); + *curc = txt_undo_read_uint16(undo_buf, undo_pos); +} + +/* read the sel cursor from the undo buffer */ +static void txt_undo_read_sel(const char *undo_buf, int *undo_pos, unsigned int *selln, unsigned short *selc) +{ + *selln = txt_undo_read_uint32(undo_buf, undo_pos); + *selc = txt_undo_read_uint16(undo_buf, undo_pos); +} + +/* read both cursors from the undo buffer */ +static void txt_undo_read_cursors(const char *undo_buf, int *undo_pos, + unsigned int *curln, unsigned short *curc, + unsigned int *selln, unsigned short *selc) +{ + txt_undo_read_sel(undo_buf, undo_pos, selln, selc); + txt_undo_read_cur(undo_buf, undo_pos, curln, curc); +} + static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, short bytes) { unsigned int unicode; @@ -1986,6 +1897,29 @@ static unsigned int txt_redo_read_uint32(const char *undo_buf, int *undo_pos) return val; } +/* redo read cur cursor from the undo buffer */ +static void txt_redo_read_cur(const char *undo_buf, int *undo_pos, unsigned int *curln, unsigned short *curc) +{ + *curc = txt_redo_read_uint16(undo_buf, undo_pos); + *curln = txt_redo_read_uint32(undo_buf, undo_pos); +} + +/* redo read sel cursor from the undo buffer */ +static void txt_redo_read_sel(const char *undo_buf, int *undo_pos, unsigned int *selln, unsigned short *selc) +{ + *selc = txt_redo_read_uint16(undo_buf, undo_pos); + *selln = txt_redo_read_uint32(undo_buf, undo_pos); +} + +/* redo read both cursors from the undo buffer */ +static void txt_redo_read_cursors(const char *undo_buf, int *undo_pos, + unsigned int *curln, unsigned short *curc, + unsigned int *selln, unsigned short *selc) +{ + txt_redo_read_cur(undo_buf, undo_pos, curln, curc); + txt_redo_read_sel(undo_buf, undo_pos, selln, selc); +} + static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, short bytes) { unsigned int unicode; @@ -2024,9 +1958,10 @@ void txt_do_undo(Text *text) { int op = text->undo_buf[text->undo_pos]; unsigned int linep, i; + unsigned int uchar; + unsigned int curln, selln; + unsigned short curc, selc; unsigned short charp; - TextLine *holdl; - int holdc, holdln; char *buf; if (text->undo_pos < 0) { @@ -2038,88 +1973,60 @@ void txt_do_undo(Text *text) undoing = 1; switch (op) { - case UNDO_CLEFT: - txt_move_right(text, 0); - break; - - case UNDO_CRIGHT: - txt_move_left(text, 0); - break; - - case UNDO_CUP: - txt_move_down(text, 0); - break; - - case UNDO_CDOWN: - txt_move_up(text, 0); - break; - - case UNDO_SLEFT: - txt_move_right(text, 1); - break; - - case UNDO_SRIGHT: - txt_move_left(text, 1); - break; - - case UNDO_SUP: - txt_move_down(text, 1); - break; - - case UNDO_SDOWN: - txt_move_up(text, 1); - break; - - case UNDO_CTO: - case UNDO_STO: - text->undo_pos--; - text->undo_pos--; - text->undo_pos--; - text->undo_pos--; - - text->undo_pos--; - text->undo_pos--; - - linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); - charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); - - if (op == UNDO_CTO) { - txt_move_toline(text, linep, 0); - text->curc = charp; - txt_pop_sel(text); - } - else { - txt_move_toline(text, linep, 1); - text->selc = charp; - } - - text->undo_pos--; - break; - - case UNDO_INSERT_1: case UNDO_INSERT_2: case UNDO_INSERT_3: case UNDO_INSERT_4: - txt_backspace_char(text); + case UNDO_INSERT_1: + case UNDO_INSERT_2: + case UNDO_INSERT_3: + case UNDO_INSERT_4: text->undo_pos -= op - UNDO_INSERT_1 + 1; - text->undo_pos--; - break; - - case UNDO_BS_1: case UNDO_BS_2: case UNDO_BS_3: case UNDO_BS_4: - charp = op - UNDO_BS_1 + 1; - txt_add_char(text, txt_undo_read_unicode(text->undo_buf, &text->undo_pos, charp)); - text->undo_pos--; - break; - case UNDO_DEL_1: case UNDO_DEL_2: case UNDO_DEL_3: case UNDO_DEL_4: - charp = op - UNDO_DEL_1 + 1; - txt_add_char(text, txt_undo_read_unicode(text->undo_buf, &text->undo_pos, charp)); - txt_move_left(text, 0); + /* get and restore the cursors */ + txt_undo_read_cur(text->undo_buf, &text->undo_pos, &curln, &curc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, curln, curc, 1); + + txt_delete_char(text); + text->undo_pos--; break; - case UNDO_SWAP: - txt_curs_swap(text); + case UNDO_BS_1: + case UNDO_BS_2: + case UNDO_BS_3: + case UNDO_BS_4: + charp = op - UNDO_BS_1 + 1; + uchar = txt_undo_read_unicode(text->undo_buf, &text->undo_pos, charp); + + /* get and restore the cursors */ + txt_undo_read_cur(text->undo_buf, &text->undo_pos, &curln, &curc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, curln, curc, 1); + + txt_add_char(text, uchar); + + text->undo_pos--; + break; + + case UNDO_DEL_1: + case UNDO_DEL_2: + case UNDO_DEL_3: + case UNDO_DEL_4: + charp = op - UNDO_DEL_1 + 1; + uchar = txt_undo_read_unicode(text->undo_buf, &text->undo_pos, charp); + + /* get and restore the cursors */ + txt_undo_read_cur(text->undo_buf, &text->undo_pos, &curln, &curc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, curln, curc, 1); + + txt_add_char(text, uchar); + + txt_move_left(text, 0); + + text->undo_pos--; break; case UNDO_DBLOCK: + /* length of the string in the buffer */ linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); buf = MEM_mallocN(linep + 1, "dblock buffer"); @@ -2128,34 +2035,33 @@ void txt_do_undo(Text *text) text->undo_pos--; } buf[i] = 0; - - txt_curs_first(text, &holdl, &holdc); - holdln = txt_get_span(text->lines.first, holdl); - - txt_insert_buf(text, buf); - MEM_freeN(buf); - - text->curl = text->lines.first; - while (holdln > 0) { - if (text->curl->next) - text->curl = text->curl->next; - - holdln--; - } - text->curc = holdc; + /* skip over the length that was stored again */ text->undo_pos--; text->undo_pos--; text->undo_pos--; text->undo_pos--; + /* Get the cursor positions */ + txt_undo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc); + + /* move cur to location that needs buff inserted */ + txt_move_to(text, curln, curc, 0); + + txt_insert_buf(text, buf); + MEM_freeN(buf); + + /* restore the cursors */ + txt_move_to(text, curln, curc, 0); + txt_move_to(text, selln, selc, 1); + text->undo_pos--; break; case UNDO_IBLOCK: + /* length of the string in the buffer */ linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); - txt_delete_sel(text); /* txt_backspace_char removes utf8-characters, not bytes */ buf = MEM_mallocN(linep + 1, "iblock buffer"); @@ -2167,47 +2073,32 @@ void txt_do_undo(Text *text) linep = txt_utf8_len(buf); MEM_freeN(buf); - while (linep > 0) { - txt_backspace_char(text); - linep--; - } + /* skip over the length that was stored again */ + text->undo_pos--; + text->undo_pos--; + text->undo_pos--; + text->undo_pos--; + + /* get and restore the cursors */ + txt_undo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, curln, curc + linep, 1); + + txt_delete_selected(text); text->undo_pos--; - text->undo_pos--; - text->undo_pos--; - text->undo_pos--; - - text->undo_pos--; - break; case UNDO_INDENT: case UNDO_UNINDENT: case UNDO_COMMENT: case UNDO_UNCOMMENT: - linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); - //linep is now the end line of the selection - - charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); - //charp is the last char selected or text->line->len - - //set the selection for this now - text->selc = charp; - text->sell = text->lines.first; - for (i = 0; i < linep; i++) { - text->sell = text->sell->next; - } - - linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); - //first line to be selected - - charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); - //first postion to be selected - text->curc = charp; - text->curl = text->lines.first; - for (i = 0; i < linep; i++) { - text->curl = text->curl->next; - } - + case UNDO_DUPLICATE: + case UNDO_MOVE_LINES_UP: + case UNDO_MOVE_LINES_DOWN: + /* get and restore the cursors */ + txt_undo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, selln, selc, 1); if (op == UNDO_INDENT) { txt_unindent(text); @@ -2221,37 +2112,24 @@ void txt_do_undo(Text *text) else if (op == UNDO_UNCOMMENT) { txt_comment(text); } + else if (op == UNDO_DUPLICATE) { + txt_delete_line(text, text->curl->next); + } + else if (op == UNDO_MOVE_LINES_UP) { + txt_move_lines(text, TXT_MOVE_LINE_DOWN); + } + else if (op == UNDO_MOVE_LINES_DOWN) { + txt_move_lines(text, TXT_MOVE_LINE_UP); + } text->undo_pos--; break; - case UNDO_DUPLICATE: - txt_delete_line(text, text->curl->next); - break; - case UNDO_MOVE_LINES_UP: - txt_move_lines(text, TXT_MOVE_LINE_DOWN); - break; - case UNDO_MOVE_LINES_DOWN: - txt_move_lines(text, TXT_MOVE_LINE_UP); - break; default: //XXX error("Undo buffer error - resetting"); text->undo_pos = -1; break; } - - /* next undo step may need evaluating */ - if (text->undo_pos >= 0) { - switch (text->undo_buf[text->undo_pos]) { - case UNDO_STO: - txt_do_undo(text); - txt_do_redo(text); /* selections need restoring */ - break; - case UNDO_SWAP: - txt_do_undo(text); /* swaps should appear transparent */ - break; - } - } undoing = 0; } @@ -2259,9 +2137,12 @@ void txt_do_undo(Text *text) void txt_do_redo(Text *text) { char op; - unsigned int linep, i; - unsigned short charp; char *buf; + unsigned int linep; + unsigned short charp; + unsigned int uchar; + unsigned int curln, selln; + unsigned short curc, selc; text->undo_pos++; op = text->undo_buf[text->undo_pos]; @@ -2274,104 +2155,91 @@ void txt_do_redo(Text *text) undoing = 1; switch (op) { - case UNDO_CLEFT: - txt_move_left(text, 0); - break; - - case UNDO_CRIGHT: - txt_move_right(text, 0); - break; - - case UNDO_CUP: - txt_move_up(text, 0); - break; - - case UNDO_CDOWN: - txt_move_down(text, 0); - break; - - case UNDO_SLEFT: - txt_move_left(text, 1); - break; - - case UNDO_SRIGHT: - txt_move_right(text, 1); - break; - - case UNDO_SUP: - txt_move_up(text, 1); - break; - - case UNDO_SDOWN: - txt_move_down(text, 1); - break; - - case UNDO_INSERT_1: case UNDO_INSERT_2: case UNDO_INSERT_3: case UNDO_INSERT_4: + case UNDO_INSERT_1: + case UNDO_INSERT_2: + case UNDO_INSERT_3: + case UNDO_INSERT_4: text->undo_pos++; + + /* get and restore the cursors */ + txt_redo_read_cur(text->undo_buf, &text->undo_pos, &curln, &curc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, curln, curc, 1); + charp = op - UNDO_INSERT_1 + 1; - txt_add_char(text, txt_redo_read_unicode(text->undo_buf, &text->undo_pos, charp)); + uchar = txt_redo_read_unicode(text->undo_buf, &text->undo_pos, charp); + + txt_add_char(text, uchar); break; - case UNDO_BS_1: case UNDO_BS_2: case UNDO_BS_3: case UNDO_BS_4: + case UNDO_BS_1: + case UNDO_BS_2: + case UNDO_BS_3: + case UNDO_BS_4: text->undo_pos++; - txt_backspace_char(text); + + /* get and restore the cursors */ + txt_redo_read_cur(text->undo_buf, &text->undo_pos, &curln, &curc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, curln, curc, 1); + text->undo_pos += op - UNDO_BS_1 + 1; + + /* move right so we backspace the correct char */ + txt_move_right(text, 0); + txt_backspace_char(text); + break; - case UNDO_DEL_1: case UNDO_DEL_2: case UNDO_DEL_3: case UNDO_DEL_4: + case UNDO_DEL_1: + case UNDO_DEL_2: + case UNDO_DEL_3: + case UNDO_DEL_4: text->undo_pos++; - txt_delete_char(text); + + /* get and restore the cursors */ + txt_redo_read_cur(text->undo_buf, &text->undo_pos, &curln, &curc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, curln, curc, 1); + text->undo_pos += op - UNDO_DEL_1 + 1; - break; - case UNDO_SWAP: - txt_curs_swap(text); - txt_do_redo(text); /* swaps should appear transparent a*/ - break; - - case UNDO_CTO: - case UNDO_STO: - text->undo_pos++; - text->undo_pos++; - - text->undo_pos++; - text->undo_pos++; - text->undo_pos++; - text->undo_pos++; - - text->undo_pos++; - - charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); - linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - - if (op == UNDO_CTO) { - txt_move_toline(text, linep, 0); - text->curc = charp; - txt_pop_sel(text); - } - else { - txt_move_toline(text, linep, 1); - text->selc = charp; - } + txt_delete_char(text); break; case UNDO_DBLOCK: text->undo_pos++; + + /* get and restore the cursors */ + txt_redo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, selln, selc, 1); + + /* length of the block */ linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - txt_delete_sel(text); text->undo_pos += linep; + /* skip over the length that was stored again */ text->undo_pos++; text->undo_pos++; text->undo_pos++; text->undo_pos++; + txt_delete_sel(text); + break; case UNDO_IBLOCK: text->undo_pos++; + + /* get and restore the cursors */ + txt_redo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, curln, curc, 1); + + /* length of the block */ linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); buf = MEM_mallocN(linep + 1, "iblock buffer"); @@ -2382,40 +2250,27 @@ void txt_do_redo(Text *text) txt_insert_buf(text, buf); MEM_freeN(buf); + /* skip over the length that was stored again */ text->undo_pos++; text->undo_pos++; text->undo_pos++; text->undo_pos++; + break; case UNDO_INDENT: case UNDO_UNINDENT: case UNDO_COMMENT: case UNDO_UNCOMMENT: + case UNDO_DUPLICATE: + case UNDO_MOVE_LINES_UP: + case UNDO_MOVE_LINES_DOWN: text->undo_pos++; - charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); - //charp is the first char selected or 0 - - linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - //linep is now the first line of the selection - //set the selcetion for this now - text->curc = charp; - text->curl = text->lines.first; - for (i = 0; i < linep; i++) { - text->curl = text->curl->next; - } - - charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); - //last postion to be selected - - linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - //Last line to be selected - - text->selc = charp; - text->sell = text->lines.first; - for (i = 0; i < linep; i++) { - text->sell = text->sell->next; - } + + /* get and restore the cursors */ + txt_redo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc); + txt_move_to(text, curln, curc, 0); + txt_move_to(text, selln, selc, 1); if (op == UNDO_INDENT) { txt_indent(text); @@ -2429,15 +2284,28 @@ void txt_do_redo(Text *text) else if (op == UNDO_UNCOMMENT) { txt_uncomment(text); } - break; - case UNDO_DUPLICATE: - txt_duplicate_line(text); - break; - case UNDO_MOVE_LINES_UP: - txt_move_lines(text, TXT_MOVE_LINE_UP); - break; - case UNDO_MOVE_LINES_DOWN: - txt_move_lines(text, TXT_MOVE_LINE_DOWN); + else if (op == UNDO_DUPLICATE) { + txt_duplicate_line(text); + } + else if (op == UNDO_MOVE_LINES_UP) { + /* offset the cursor by + 1 */ + txt_move_to(text, curln + 1, curc, 0); + txt_move_to(text, selln + 1, selc, 1); + + txt_move_lines(text, TXT_MOVE_LINE_UP); + } + else if (op == UNDO_MOVE_LINES_DOWN) { + /* offset the cursor by - 1 */ + txt_move_to(text, curln - 1, curc, 0); + txt_move_to(text, selln - 1, selc, 1); + + txt_move_lines(text, TXT_MOVE_LINE_DOWN); + } + + /* re-restore the cursors since they got moved when redoing */ + txt_move_to(text, curln, curc, 0); + txt_move_to(text, selln, selc, 1); + break; default: //XXX error("Undo buffer error - resetting"); @@ -2767,6 +2635,8 @@ static int txt_add_char_intern(Text *text, unsigned int add, int replace_tabs) txt_delete_sel(text); + if (!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, add); + add_len = BLI_str_utf8_from_unicode(add, ch); mrk = txt_find_marker_region(text, text->curl, text->curc - 1, text->curl->len, 0, 0); if (mrk) { @@ -2793,7 +2663,6 @@ static int txt_add_char_intern(Text *text, unsigned int add, int replace_tabs) txt_make_dirty(text); txt_clean_text(text); - if (!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, add); return 1; } @@ -2854,8 +2723,8 @@ int txt_replace_char(Text *text, unsigned int add) /* Should probably create a new op for this */ if (!undoing) { - txt_undo_add_charop(text, UNDO_DEL_1, del); txt_undo_add_charop(text, UNDO_INSERT_1, add); + txt_undo_add_charop(text, UNDO_DEL_1, del); } return 1; } @@ -2924,7 +2793,7 @@ void txt_indent(Text *text) } if (!undoing) { - txt_undo_add_toop(text, UNDO_INDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc); + txt_undo_add_op(text, UNDO_INDENT); } } @@ -2982,7 +2851,7 @@ void txt_unindent(Text *text) } if (!undoing) { - txt_undo_add_toop(text, UNDO_UNINDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc); + txt_undo_add_op(text, UNDO_UNINDENT); } } @@ -3031,7 +2900,7 @@ void txt_comment(Text *text) } if (!undoing) { - txt_undo_add_toop(text, UNDO_COMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc); + txt_undo_add_op(text, UNDO_COMMENT); } } @@ -3076,7 +2945,7 @@ void txt_uncomment(Text *text) } if (!undoing) { - txt_undo_add_toop(text, UNDO_UNCOMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc); + txt_undo_add_op(text, UNDO_UNCOMMENT); } } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 1be50a54b68..53e731bf2c4 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1664,7 +1664,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, short sel) Text *text = st->text; TextLine **linep; int *charp; - int oldl, oldc, i, j, max, start, end, endj, chop, loop; + int oldc, i, j, max, start, end, endj, chop, loop; char ch; text_update_character_width(st); @@ -1673,7 +1673,6 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, short sel) else linep = &text->curl, charp = &text->curc; oldc = *charp; - oldl = txt_get_span(text->lines.first, *linep); max = wrap_width(st, ar); @@ -1724,7 +1723,6 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, short sel) } if (!sel) txt_pop_sel(text); - txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, oldl, oldc, oldl, *charp); } static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, short sel) @@ -1732,7 +1730,7 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, short sel) Text *text = st->text; TextLine **linep; int *charp; - int oldl, oldc, i, j, max, start, end, endj, chop, loop; + int oldc, i, j, max, start, end, endj, chop, loop; char ch; text_update_character_width(st); @@ -1741,7 +1739,6 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, short sel) else linep = &text->curl, charp = &text->curc; oldc = *charp; - oldl = txt_get_span(text->lines.first, *linep); max = wrap_width(st, ar); @@ -1790,7 +1787,6 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, short sel) } if (!sel) txt_pop_sel(text); - txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, oldl, oldc, oldl, *charp); } static void txt_wrap_move_up(SpaceText *st, ARegion *ar, short sel) @@ -1798,22 +1794,17 @@ static void txt_wrap_move_up(SpaceText *st, ARegion *ar, short sel) Text *text = st->text; TextLine **linep; int *charp; - int oldl, oldc, offl, offc, col, newl; + int offl, offc, col; text_update_character_width(st); if (sel) linep = &text->sell, charp = &text->selc; else linep = &text->curl, charp = &text->curc; - /* store previous position */ - oldc = *charp; - newl = oldl = txt_get_span(text->lines.first, *linep); - wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc); col = text_get_char_pos(st, (*linep)->line, *charp) + offc; if (offl) { *charp = text_get_cursor_rel(st, ar, *linep, offl - 1, col); - newl = BLI_findindex(&text->lines, linep); } else { if ((*linep)->prev) { @@ -1822,13 +1813,11 @@ static void txt_wrap_move_up(SpaceText *st, ARegion *ar, short sel) *linep = (*linep)->prev; visible_lines = text_get_visible_lines(st, ar, (*linep)->line); *charp = text_get_cursor_rel(st, ar, *linep, visible_lines - 1, col); - newl--; } else *charp = 0; } if (!sel) txt_pop_sel(text); - txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, oldl, oldc, newl, *charp); } static void txt_wrap_move_down(SpaceText *st, ARegion *ar, short sel) @@ -1836,35 +1825,28 @@ static void txt_wrap_move_down(SpaceText *st, ARegion *ar, short sel) Text *text = st->text; TextLine **linep; int *charp; - int oldl, oldc, offl, offc, col, newl, visible_lines; + int offl, offc, col, newl, visible_lines; text_update_character_width(st); if (sel) linep = &text->sell, charp = &text->selc; else linep = &text->curl, charp = &text->curc; - /* store previous position */ - oldc = *charp; - newl = oldl = txt_get_span(text->lines.first, *linep); - wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc); col = text_get_char_pos(st, (*linep)->line, *charp) + offc; visible_lines = text_get_visible_lines(st, ar, (*linep)->line); if (offl < visible_lines - 1) { *charp = text_get_cursor_rel(st, ar, *linep, offl + 1, col); - newl = BLI_findindex(&text->lines, linep); } else { if ((*linep)->next) { *linep = (*linep)->next; *charp = text_get_cursor_rel(st, ar, *linep, 0, col); - newl++; } else *charp = (*linep)->len; } if (!sel) txt_pop_sel(text); - txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, oldl, oldc, newl, *charp); } /* Moves the cursor vertically by the specified number of lines. @@ -1876,12 +1858,10 @@ static void txt_wrap_move_down(SpaceText *st, ARegion *ar, short sel) static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, int sel) { TextLine **linep; - int oldl, oldc, *charp; + int *charp; if (sel) linep = &text->sell, charp = &text->selc; else linep = &text->curl, charp = &text->curc; - oldl = txt_get_span(text->lines.first, *linep); - oldc = *charp; if (st && ar && st->wordwrap) { int rell, relc; @@ -1904,7 +1884,6 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, int s if (*charp > (*linep)->len) *charp = (*linep)->len; if (!sel) txt_pop_sel(text); - txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, oldl, oldc, txt_get_span(text->lines.first, *linep), *charp); } static int text_move_cursor(bContext *C, int type, int select) @@ -2696,7 +2675,6 @@ static void text_cursor_set_exit(bContext *C, wmOperator *op) SpaceText *st = CTX_wm_space_text(C); Text *text = st->text; SetSelection *ssel = op->customdata; - int linep2, charp2; char *buffer; if (txt_has_sel(text)) { @@ -2705,12 +2683,6 @@ static void text_cursor_set_exit(bContext *C, wmOperator *op) MEM_freeN(buffer); } - linep2 = txt_get_span(st->text->lines.first, st->text->sell); - charp2 = st->text->selc; - - if (ssel->sell != linep2 || ssel->selc != charp2) - txt_undo_add_toop(st->text, UNDO_STO, ssel->sell, ssel->selc, linep2, charp2); - text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); @@ -2786,19 +2758,12 @@ void TEXT_OT_selection_set(wmOperatorType *ot) static int text_cursor_set_exec(bContext *C, wmOperator *op) { SpaceText *st = CTX_wm_space_text(C); - Text *text = st->text; ARegion *ar = CTX_wm_region(C); int x = RNA_int_get(op->ptr, "x"); int y = RNA_int_get(op->ptr, "y"); - int oldl, oldc; - - oldl = txt_get_span(text->lines.first, text->curl); - oldc = text->curc; text_cursor_set_to_pos(st, ar, x, y, 0); - txt_undo_add_toop(text, UNDO_CTO, oldl, oldc, txt_get_span(text->lines.first, text->curl), text->curc); - text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); From c3ce2bbfdf67d1f8250e16ce2aab6c3eb665dbff Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 14 Nov 2012 23:20:16 +0000 Subject: [PATCH 021/115] looks like we need those libs as well to compile with static ffmpeg on fedora (by why in hell librt???)... --- build_files/build_environment/install_deps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 74c03c01686..bf738dfe1fc 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -50,7 +50,7 @@ version_ge() { # $1 should be at least as long as $2! version_match() { backIFS=$IFS - IFS='.' + IFS='.' # Split both version numbers into their numeric elements. arr1=( $1 ) @@ -71,7 +71,7 @@ version_match() { done fi - IFS=$backIFS + IFS=$backIFS return $ret } @@ -380,8 +380,8 @@ install_DEB() { if [ $? -eq 0 ]; then sudo apt-get install -y libvpx-dev vpx_version=`deb_version libvpx-dev` - if [ ! -z "$vpx_version" ]; then - if dpkg --compare-versions $vpx_version gt 0.9.7; then + if dpkg --compare-versions $vpx_version gt 0.9.7; then + if version_ge $vpx_version 0.9.7; then HASVPX=true fi fi @@ -624,7 +624,7 @@ print_info_ffmpeglink_DEB() { } print_info_ffmpeglink_RPM() { - _packages="libtheora-devel" + _packages="libtheora-devel libvorbis-devel" if $HASXVID; then _packages="$_packages $XVIDDEV" @@ -681,7 +681,7 @@ print_info() { if [ -d /opt/lib/ffmpeg ]; then INFO " -D WITH_CODEC_FFMPEG=ON" INFO " -D FFMPEG=/opt/lib/ffmpeg" - INFO " -D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;`print_info_ffmpeglink`'" + INFO " -D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;rt;`print_info_ffmpeglink`'" fi INFO "" From cd8584aad56eb7fcc94dc4ebfbcde034aebbe3cd Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Thu, 15 Nov 2012 02:05:32 +0000 Subject: [PATCH 022/115] Fix 'polygon eating' problem in bevel (bug #33141) which was due to almost-parallel lines. --- source/blender/bmesh/operators/bmo_bevel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index f812b6c5320..281ff44e358 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -110,6 +110,7 @@ typedef struct BevelParams { float offset; /* blender units to offset each side of a beveled edge */ int seg; /* number of segments in beveled edge profile */ } BevelParams; +#include "bevdebug.c" /* Make a new BoundVert of the given kind, insert it at the end of the circular linked * list with entry point bv->boundstart, and return it. */ @@ -378,9 +379,12 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, madd_v3_v3fl(off2a, norm_perp2, e2->offset); add_v3_v3v3(off2b, off2a, dir2); - if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) { + if (fabs(angle_v3v3(dir1, dir2)) < BEVEL_EPSILON) { /* lines are parallel; off1a is a good meet point */ copy_v3_v3(meetco, off1a); + } else if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) { + /* another test says they are parallel */ + copy_v3_v3(meetco, off1a); } } From 283ee53085b1e215cbd0d8af91b0000660406bfe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Nov 2012 02:11:40 +0000 Subject: [PATCH 023/115] fix for deleting lines hanging the text editor when no markers are used, presence of markers still hangs. also compiler warnings and some style edits. --- source/blender/blenkernel/intern/text.c | 35 +++++++++++-------- source/blender/bmesh/operators/bmo_bevel.c | 3 +- .../operations/COM_MapRangeOperation.cpp | 8 ++--- source/blender/editors/space_text/text_ops.c | 29 +++++++-------- 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 076dc3a35d7..d166592424d 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1764,7 +1764,7 @@ void txt_undo_add_op(Text *text, int op) txt_undo_store_cursors(text); text->undo_buf[text->undo_pos] = op; - text->undo_buf[text->undo_pos+1] = 0; + text->undo_buf[text->undo_pos + 1] = 0; } /* store an operator for a single character */ @@ -2386,20 +2386,22 @@ void txt_split_curline(Text *text) static void txt_delete_line(Text *text, TextLine *line) { TextMarker *mrk = NULL, *nxt; - int lineno = -1; if (!text) return; if (!text->curl) return; - lineno = txt_get_span(text->lines.first, line); - mrk = text->markers.first; - while (mrk) { - nxt = mrk->next; - if (mrk->lineno == lineno) - BLI_freelinkN(&text->markers, mrk); - else if (mrk->lineno > lineno) - mrk->lineno--; - mrk = nxt; + /* warning, this can be _slow_ when deleting many lines! */ + if ((mrk = text->markers.first)) { + int lineno = txt_get_span(text->lines.first, line); + mrk = text->markers.first; + while (mrk) { + nxt = mrk->next; + if (mrk->lineno == lineno) + BLI_freelinkN(&text->markers, mrk); + else if (mrk->lineno > lineno) + mrk->lineno--; + mrk = nxt; + } } BLI_remlink(&text->lines, line); @@ -2417,14 +2419,14 @@ static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb) { char *tmp; TextMarker *mrk = NULL; - int lineno = -1; - + if (!text) return; if (!linea || !lineb) return; mrk = txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0); if (mrk) { + int lineno; lineno = mrk->lineno; do { mrk->lineno--; @@ -2433,8 +2435,11 @@ static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb) mrk = mrk->next; } while (mrk && mrk->lineno == lineno); } - if (lineno == -1) lineno = txt_get_span(text->lines.first, lineb); - +#if 0 /* UNUSED */ + if (lineno == -1) + lineno = txt_get_span(text->lines.first, lineb); +#endif + tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string"); strcpy(tmp, linea->line); diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 281ff44e358..2209c60b280 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -110,7 +110,8 @@ typedef struct BevelParams { float offset; /* blender units to offset each side of a beveled edge */ int seg; /* number of segments in beveled edge profile */ } BevelParams; -#include "bevdebug.c" + +//#include "bevdebug.c" /* Make a new BoundVert of the given kind, insert it at the end of the circular linked * list with entry point bv->boundstart, and return it. */ diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp index c25b056130b..a18f418e48e 100644 --- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp +++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp @@ -51,10 +51,10 @@ void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSam float dest_min, dest_max; this->m_inputOperation->read(inputs, x, y, sampler); - this->m_sourceMinOperation->read(inputs+1, x, y, sampler); - this->m_sourceMaxOperation->read(inputs+2, x, y, sampler); - this->m_destMinOperation->read(inputs+3, x, y, sampler); - this->m_destMaxOperation->read(inputs+4, x, y, sampler); + this->m_sourceMinOperation->read(inputs + 1, x, y, sampler); + this->m_sourceMaxOperation->read(inputs + 2, x, y, sampler); + this->m_destMinOperation->read(inputs + 3, x, y, sampler); + this->m_destMaxOperation->read(inputs + 4, x, y, sampler); value = inputs[0]; source_min = inputs[1]; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 53e731bf2c4..105e20ffadb 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1135,7 +1135,8 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) tmp = text->lines.first; - //first convert to all space, this make it a lot easier to convert to tabs because there is no mixtures of ' ' && '\t' + /* first convert to all space, this make it a lot easier to convert to tabs + * because there is no mixtures of ' ' && '\t' */ while (tmp) { text_check_line = tmp->line; number = flatten_string(st, &fs, text_check_line) + 1; @@ -1669,8 +1670,8 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, short sel) text_update_character_width(st); - if (sel) linep = &text->sell, charp = &text->selc; - else linep = &text->curl, charp = &text->curc; + if (sel) { linep = &text->sell; charp = &text->selc; } + else { linep = &text->curl; charp = &text->curc; } oldc = *charp; @@ -1735,8 +1736,8 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, short sel) text_update_character_width(st); - if (sel) linep = &text->sell, charp = &text->selc; - else linep = &text->curl, charp = &text->curc; + if (sel) { linep = &text->sell; charp = &text->selc; } + else { linep = &text->curl; charp = &text->curc; } oldc = *charp; @@ -1798,8 +1799,8 @@ static void txt_wrap_move_up(SpaceText *st, ARegion *ar, short sel) text_update_character_width(st); - if (sel) linep = &text->sell, charp = &text->selc; - else linep = &text->curl, charp = &text->curc; + if (sel) { linep = &text->sell; charp = &text->selc; } + else { linep = &text->curl; charp = &text->curc; } wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc); col = text_get_char_pos(st, (*linep)->line, *charp) + offc; @@ -1825,12 +1826,12 @@ static void txt_wrap_move_down(SpaceText *st, ARegion *ar, short sel) Text *text = st->text; TextLine **linep; int *charp; - int offl, offc, col, newl, visible_lines; + int offl, offc, col, visible_lines; text_update_character_width(st); - if (sel) linep = &text->sell, charp = &text->selc; - else linep = &text->curl, charp = &text->curc; + if (sel) { linep = &text->sell; charp = &text->selc; } + else { linep = &text->curl; charp = &text->curc; } wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc); col = text_get_char_pos(st, (*linep)->line, *charp) + offc; @@ -1860,8 +1861,8 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, int s TextLine **linep; int *charp; - if (sel) linep = &text->sell, charp = &text->selc; - else linep = &text->curl, charp = &text->curc; + if (sel) { linep = &text->sell; charp = &text->selc; } + else { linep = &text->curl; charp = &text->curc; } if (st && ar && st->wordwrap) { int rell, relc; @@ -2590,7 +2591,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in if (linep && charp != -1) { if (sel) { text->sell = linep; text->selc = charp; } - else { text->curl = linep; text->curc = charp; } + else { text->curl = linep; text->curc = charp; } } } @@ -2615,7 +2616,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, int int w; if (sel) { linep = &text->sell; charp = &text->selc; } - else { linep = &text->curl; charp = &text->curc; } + else { linep = &text->curl; charp = &text->curc; } y -= txt_get_span(text->lines.first, *linep) - st->top; From 8d8c69406bd98f8020672eb0fb032d54b83e411a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Nov 2012 06:02:32 +0000 Subject: [PATCH 024/115] fix for 3d text input failing for non utf8 input. --- source/blender/editors/curve/editfont.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index fd87e6752f2..257dfca051f 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1289,6 +1289,13 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) insert_into_textbuf(obedit, ascii); accentcode = 0; } + else if (ascii) { + insert_into_textbuf(obedit, ascii); + accentcode = 0; + } + else { + BLI_assert(0); + } kill_selection(obedit, 1); text_update_edited(C, scene, obedit, 1, FO_EDIT); From 029d29e4f7da16c4736a3cbcd1081dc50b18694f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Nov 2012 06:10:09 +0000 Subject: [PATCH 025/115] fix [#33179] Can't delete centered edge loop if x-mirror is activated --- release/scripts/startup/bl_operators/wm.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 2bff11a686d..0945098bd1e 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -41,12 +41,17 @@ class MESH_OT_delete_edgeloop(Operator): return bpy.ops.transform.edge_slide.poll() def execute(self, context): + mesh = context.object.data + use_mirror_x = mesh.use_mirror_x + mesh.use_mirror_x = False if 'FINISHED' in bpy.ops.transform.edge_slide(value=1.0): bpy.ops.mesh.select_more() bpy.ops.mesh.remove_doubles() - return {'FINISHED'} - - return {'CANCELLED'} + ret = {'FINISHED'} + else: + ret = {'CANCELLED'} + mesh.use_mirror_x = use_mirror_x + return ret rna_path_prop = StringProperty( name="Context Attributes", From abeeea6a96dcb69451a394546f75501a61382b9d Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 15 Nov 2012 13:10:24 +0000 Subject: [PATCH 026/115] Z sampling for nodes backdrop As it turned out, the node space was the only place we have the option to sample the backdrop buffer RGB, but not the zed. This code is copied from image space. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now one can use the viewer node and sample the depth while looking at the color buffer (so Map Range Node works even better) Patch written during BlenderPRO 2012, Brasília ;) (reviewed by Lukas Toenne) --- source/blender/editors/space_node/node_view.c | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index ccf5c4b540f..a4ea2e3e630 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -330,6 +330,12 @@ typedef struct ImageSampleInfo { unsigned char col[4]; float colf[4]; + + int z; + float zf; + + int *zp; + float *zfp; int draw; int color_manage; @@ -343,8 +349,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) if (info->draw) { ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels, info->x, info->y, info->col, info->colf, - NULL, NULL /* zbuf - unused for nodes */ - ); + info->zp, info->zfp); } } @@ -443,6 +448,9 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->draw = 1; info->channels = ibuf->channels; + info->zp = NULL; + info->zfp = NULL; + if (ibuf->rect) { cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); @@ -468,6 +476,15 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->color_manage = TRUE; } + + if (ibuf->zbuf) { + info->z = ibuf->zbuf[y * ibuf->x + x]; + info->zp = &info->z; + } + if (ibuf->zbuf_float) { + info->zf = ibuf->zbuf_float[y * ibuf->x + x]; + info->zfp = &info->zf; + } ED_node_sample_set(info->colf); } From 9eccf40daa7edccc6ca9613611c12270cddbd773 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 15 Nov 2012 13:11:12 +0000 Subject: [PATCH 027/115] OSL Scons rules Initial support of OSL builds using SCons build system. Only tested on Linux now. No changes to configuration files themselves -- for now check how it's configured for linux buildbot (it was already horror to make all this changes and verify them, changes to linux-config.py could easily be done later). Currently WITH_BF_STATICOSL and WITH_BF_STATICLLVM are more like rudiments because linking against oslexec requires special trick with --whole-archive. We woul either need to find a way dealing with this oslexec less hackish or drop STATICOSL and STATICLLVM flags. Will keep dropping this flags for until we have "final" build rules for OSL. Still can not make 32bit linux rendering with OSL -- blender simply crashes when starting rendering. So for time being this issues are solving disabled OSL for 32bit build slaves. --- SConstruct | 16 +++++++ .../config/user-config-glibc211-i686.py | 19 +++++++++ .../config/user-config-glibc211-x86_64.py | 19 +++++++++ .../config/user-config-glibc27-i686.py | 19 +++++++++ .../config/user-config-glibc27-x86_64.py | 19 +++++++++ build_files/scons/tools/Blender.py | 17 ++++++++ build_files/scons/tools/btools.py | 26 ++++++++++-- intern/cycles/SConscript | 10 +++++ intern/cycles/kernel/osl/SConscript | 21 ++++++++++ intern/cycles/kernel/shaders/SConscript | 42 +++++++++++++++++++ 10 files changed, 205 insertions(+), 3 deletions(-) create mode 100644 intern/cycles/kernel/osl/SConscript create mode 100644 intern/cycles/kernel/shaders/SConscript diff --git a/SConstruct b/SConstruct index 4af85f51a4b..5e31fce00a4 100644 --- a/SConstruct +++ b/SConstruct @@ -725,6 +725,22 @@ if env['OURPLATFORM']!='darwin': cubin_file = os.path.join(kernel_build_dir, "kernel_%s.cubin" % arch) scriptinstall.append(env.Install(dir=dir,source=cubin_file)) + # osl shaders + if env['WITH_BF_CYCLES_OSL']: + dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'shader') + + osl_source_dir = Dir('./intern/cycles/kernel/shaders').srcnode().path + oso_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel/shaders') + + headers='node_color.h node_fresnel.h node_texture.h oslutil.h stdosl.h'.split() + source=['intern/cycles/kernel/shaders/'+s for s in headers] + scriptinstall.append(env.Install(dir=dir,source=source)) + + for f in os.listdir(osl_source_dir): + if f.endswith('.osl'): + oso_file = os.path.join(oso_build_dir, f.replace('.osl', '.oso')) + scriptinstall.append(env.Install(dir=dir,source=oso_file)) + if env['WITH_BF_OCIO']: colormanagement = os.path.join('release', 'datafiles', 'colormanagement') diff --git a/build_files/buildbot/config/user-config-glibc211-i686.py b/build_files/buildbot/config/user-config-glibc211-i686.py index e0e55909138..bbd58150fde 100644 --- a/build_files/buildbot/config/user-config-glibc211-i686.py +++ b/build_files/buildbot/config/user-config-glibc211-i686.py @@ -120,6 +120,24 @@ BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_JPEG}/lib/libjpeg.a' BF_OIIO_LIBPATH = '${BF_OIIO}/lib' +WITH_BF_CYCLES_OSL = False +WITH_BF_STATICOSL = False +BF_OSL = '/opt/lib/osl' +BF_OSL_INC = '${BF_OSL}/include' +# note oslexec would passed via program linkflags, which is needed to +# make llvm happy with osl_allocate_closure_component +BF_OSL_LIB = 'oslcomp oslexec oslquery' +BF_OSL_LIBPATH = '${BF_OSL}/lib' +BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' + +WITH_BF_LLVM = False +WITH_BF_STATICLLVM = False +BF_LLVM = '/opt/lib/llvm-3.1' +BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ + 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \ + 'LLVMTarget LLVMMC LLVMCore LLVMSupport' +BF_LLVM_LIBPATH = '${BF_LLVM}/lib' + # Color management WITH_BF_OCIO = True WITH_BF_STATICOCIO = True @@ -144,3 +162,4 @@ WITH_BF_OCEANSIM = True BF_DEBUG = False REL_CCFLAGS = ['-O2', '-msse', '-msse2'] # C & C++ PLATFORM_LINKFLAGS = ['-lrt'] +BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] diff --git a/build_files/buildbot/config/user-config-glibc211-x86_64.py b/build_files/buildbot/config/user-config-glibc211-x86_64.py index afff0451d5b..dbae44af66f 100644 --- a/build_files/buildbot/config/user-config-glibc211-x86_64.py +++ b/build_files/buildbot/config/user-config-glibc211-x86_64.py @@ -119,6 +119,24 @@ BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_JPEG}/lib/libjpeg.a' BF_OIIO_LIBPATH = '${BF_OIIO}/lib' +WITH_BF_CYCLES_OSL = True +WITH_BF_STATICOSL = False +BF_OSL = '/opt/lib/osl' +BF_OSL_INC = '${BF_OSL}/include' +# note oslexec would passed via program linkflags, which is needed to +# make llvm happy with osl_allocate_closure_component +BF_OSL_LIB = 'oslcomp oslexec oslquery' +BF_OSL_LIBPATH = '${BF_OSL}/lib' +BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' + +WITH_BF_LLVM = True +WITH_BF_STATICLLVM = False +BF_LLVM = '/opt/lib/llvm-3.1' +BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ + 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \ + 'LLVMTarget LLVMMC LLVMCore LLVMSupport' +BF_LLVM_LIBPATH = '${BF_LLVM}/lib' + # Color management WITH_BF_OCIO = True WITH_BF_STATICOCIO = True @@ -143,3 +161,4 @@ WITH_BF_OCEANSIM = True BF_DEBUG = False REL_CCFLAGS = ['-O2', '-msse', '-msse2'] # C & C++ PLATFORM_LINKFLAGS = ['-lrt'] +BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] diff --git a/build_files/buildbot/config/user-config-glibc27-i686.py b/build_files/buildbot/config/user-config-glibc27-i686.py index ec04533ecb3..ce13e136388 100644 --- a/build_files/buildbot/config/user-config-glibc27-i686.py +++ b/build_files/buildbot/config/user-config-glibc27-i686.py @@ -107,6 +107,24 @@ BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a' BF_OIIO_LIBPATH = '${BF_OIIO}/lib' +WITH_BF_CYCLES_OSL = False +WITH_BF_STATICOSL = False +BF_OSL = '/opt/osl' +BF_OSL_INC = '${BF_OSL}/include' +# note oslexec would passed via program linkflags, which is needed to +# make llvm happy with osl_allocate_closure_component +BF_OSL_LIB = 'oslcomp oslexec oslquery' +BF_OSL_LIBPATH = '${BF_OSL}/lib' +BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' + +WITH_BF_LLVM = False +WITH_BF_STATICLLVM = False +BF_LLVM = '/opt/llvm-3.1' +BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ + 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \ + 'LLVMTarget LLVMMC LLVMCore LLVMSupport' +BF_LLVM_LIBPATH = '${BF_LLVM}/lib' + # Color management WITH_BF_OCIO = True WITH_BF_STATICOCIO = True @@ -129,3 +147,4 @@ WITH_BF_OCEANSIM = True BF_DEBUG = False REL_CCFLAGS = ['-O2'] # C & C++ PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib32'] +BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] diff --git a/build_files/buildbot/config/user-config-glibc27-x86_64.py b/build_files/buildbot/config/user-config-glibc27-x86_64.py index 37bc946918b..9541908d4ed 100644 --- a/build_files/buildbot/config/user-config-glibc27-x86_64.py +++ b/build_files/buildbot/config/user-config-glibc27-x86_64.py @@ -106,6 +106,24 @@ BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a' BF_OIIO_LIBPATH = '${BF_OIIO}/lib' +WITH_BF_CYCLES_OSL = True +WITH_BF_STATICOSL = False +BF_OSL = '/opt/osl' +BF_OSL_INC = '${BF_OSL}/include' +# note oslexec would passed via program linkflags, which is needed to +# make llvm happy with osl_allocate_closure_component +BF_OSL_LIB = 'oslcomp oslexec oslquery' +BF_OSL_LIBPATH = '${BF_OSL}/lib' +BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' + +WITH_BF_LLVM = True +WITH_BF_STATICLLVM = False +BF_LLVM = '/opt/llvm-3.1' +BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ + 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \ + 'LLVMTarget LLVMMC LLVMCore LLVMSupport' +BF_LLVM_LIBPATH = '${BF_LLVM}/lib' + # Color management WITH_BF_OCIO = True WITH_BF_STATICOCIO = True @@ -128,3 +146,4 @@ WITH_BF_OCEANSIM = True BF_DEBUG = False REL_CCFLAGS = ['-O2', '-msse', '-msse2'] # C & C++ PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib64'] +BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index a5e47a50d10..23e732370ce 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -222,6 +222,16 @@ def setup_staticlibs(lenv): if lenv['WITH_BF_STATICBOOST']: statlibs += Split(lenv['BF_BOOST_LIB_STATIC']) + if lenv['WITH_BF_CYCLES_OSL']: + libincs += Split(lenv['BF_OSL_LIBPATH']) + if lenv['WITH_BF_STATICOSL']: + statlibs += Split(lenv['BF_OSL_LIB_STATIC']) + + if lenv['WITH_BF_LLVM']: + libincs += Split(lenv['BF_LLVM_LIBPATH']) + if lenv['WITH_BF_STATICLLVM']: + statlibs += Split(lenv['BF_LLVM_LIB_STATIC']) + # setting this last so any overriding of manually libs could be handled if lenv['OURPLATFORM'] not in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross', 'win64-mingw'): libincs.append('/usr/lib') @@ -314,6 +324,12 @@ def setup_syslibs(lenv): if lenv['WITH_BF_INTERNATIONAL']: syslibs += Split(lenv['BF_BOOST_LIB_INTERNATIONAL']) + if lenv['WITH_BF_CYCLES_OSL'] and not lenv['WITH_BF_STATICOSL']: + syslibs += Split(lenv['BF_OSL_LIB']) + + if lenv['WITH_BF_LLVM'] and not lenv['WITH_BF_STATICLLVM']: + syslibs += Split(lenv['BF_LLVM_LIB']) + if not lenv['WITH_BF_STATICJPEG']: syslibs += Split(lenv['BF_JPEG_LIB']) @@ -883,6 +899,7 @@ class BlenderEnvironment(SConsEnvironment): print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC lenv = self.Clone() lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS']) + lenv.Append(LINKFLAGS = lenv['BF_PROGRAM_LINKFLAGS']) if lenv['OURPLATFORM'] in ('win32-mingw', 'win64-mingw', 'linuxcross', 'cygwin', 'linux'): lenv.Replace(LINK = '$CXX') if lenv['OURPLATFORM'] in ('win32-vc', 'cygwin', 'win64-vc'): diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 4e50f0dc313..5b1c1571bed 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -164,7 +164,9 @@ def validate_arguments(args, bc): 'WITH_BF_OIIO', 'WITH_BF_STATICOIIO', 'BF_OIIO', 'BF_OIIO_INC', 'BF_OIIO_LIB', 'BF_OIIO_LIB_STATIC', 'BF_OIIO_LIBPATH', 'WITH_BF_OCIO', 'WITH_BF_STATICOCIO', 'BF_OCIO', 'BF_OCIO_INC', 'BF_OCIO_LIB', 'BF_OCIO_LIB_STATIC', 'BF_OCIO_LIBPATH', 'WITH_BF_BOOST', 'WITH_BF_STATICBOOST', 'BF_BOOST', 'BF_BOOST_INC', 'BF_BOOST_LIB', 'BF_BOOST_LIB_INTERNATIONAL', 'BF_BOOST_LIB_STATIC', 'BF_BOOST_LIBPATH', - 'WITH_BF_LIBMV' + 'WITH_BF_LIBMV', + 'WITH_BF_CYCLES_OSL', 'WITH_BF_STATICOSL', 'BF_OSL', 'BF_OSL_INC', 'BF_OSL_LIB', 'BF_OSL_LIBPATH', 'BF_OSL_LIB_STATIC', 'BF_OSL_COMPILER', + 'WITH_BF_LLVM', 'WITH_BF_STATICLLVM', 'BF_LLVM', 'BF_LLVM_LIB', 'BF_LLVM_LIBPATH', 'BF_LLVM_LIB_STATIC', 'BF_PROGRAM_LINKFLAGS' ] # Have options here that scons expects to be lists @@ -178,7 +180,7 @@ def validate_arguments(args, bc): 'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS', 'C_WARN', 'CC_WARN', 'CXX_WARN', 'LLIBS', 'PLATFORM_LINKFLAGS','MACOSX_ARCHITECTURE', 'MACOSX_SDK_CHECK', 'XCODE_CUR_VER', - 'BF_CYCLES_CUDA_BINARIES_ARCH', + 'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS' ] @@ -595,7 +597,25 @@ def read_opts(env, cfg, args): ('BF_BOOST_LIB_STATIC', 'Boost static library', ''), (BoolVariable('WITH_GHOST_XDND', 'Build with drag-n-drop support on Linux platforms using XDND protocol', True)), - (BoolVariable('WITH_BF_COMPOSITOR_LEGACY', 'Enable the legacy compositor', False)) + (BoolVariable('WITH_BF_COMPOSITOR_LEGACY', 'Enable the legacy compositor', False)), + + (BoolVariable('WITH_BF_CYCLES_OSL', 'Build with OSL sypport in Cycles', False)), + (BoolVariable('WITH_BF_STATICOSL', 'Staticly link to OSL', False)), + ('BF_OSL', 'OSL root path', ''), + ('BF_OSL_INC', 'OSL include path', ''), + ('BF_OSL_LIB', 'OSL library', ''), + ('BF_OSL_LIBPATH', 'OSL library path', ''), + ('BF_OSL_LIB_STATIC', 'OSL static library', ''), + ('BF_OSL_COMPILER', 'OSL compiler', ''), + + (BoolVariable('WITH_BF_LLVM', 'Build with LLVM sypport (required for OSL)', False)), + (BoolVariable('WITH_BF_STATICLLVM', 'Staticly link to LLVM', False)), + ('BF_LLVM', 'LLVM root path', ''), + ('BF_LLVM_LIB', 'LLVM library', ''), + ('BF_LLVM_LIBPATH', 'LLVM library path', ''), + ('BF_LLVM_LIB_STATIC', 'LLVM static library', ''), + + ('BF_PROGRAM_LINKFLAGS', 'Link flags applied only to final binaries (blender and blenderplayer, not makesrna/makesdna)', '') ) # end of opts.AddOptions() return localopts diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript index c7d7720e0fe..9a4df809732 100644 --- a/intern/cycles/SConscript +++ b/intern/cycles/SConscript @@ -23,6 +23,10 @@ defs.append('WITH_OPENCL') defs.append('WITH_MULTI') defs.append('WITH_CUDA') +if env['WITH_BF_CYCLES_OSL']: + defs.append('WITH_OSL') + incs.append(cycles['BF_OSL_INC']) + if env['WITH_BF_CYCLES_CUDA_BINARIES']: defs.append('WITH_CUDA_BINARIES') @@ -62,6 +66,12 @@ if env['WITH_BF_RAYOPTIMIZATION']: cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], cxx_compileflags=cxxflags) +if env['WITH_BF_CYCLES_OSL']: + oso_files = SConscript(['kernel/shaders/SConscript']) + cycles.Depends("kernel/osl/osl_shader.o", oso_files) + + SConscript(['kernel/osl/SConscript']) + # cuda kernel binaries if env['WITH_BF_CYCLES_CUDA_BINARIES']: kernel_binaries = SConscript(['kernel/SConscript']) diff --git a/intern/cycles/kernel/osl/SConscript b/intern/cycles/kernel/osl/SConscript new file mode 100644 index 00000000000..a66d2447720 --- /dev/null +++ b/intern/cycles/kernel/osl/SConscript @@ -0,0 +1,21 @@ +#!/usr/bin/python + +Import('env') + +defs = [] +sources = env.Glob('*.cpp') + +incs = '. .. ../svm ../../render ../../util ../../device' + +incs += ' ' + env['BF_OIIO_INC'] +incs += ' ' + env['BF_BOOST_INC'] +incs += ' ' + env['BF_OSL_INC'] + +defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {') +defs.append('CCL_NAMESPACE_END=}') +defs.append('WITH_OSL') + +cxxflags = env['CXXFLAGS'] +cxxflags = "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" + +env.BlenderLib ('cycles_kernel_osl', sources, Split(incs), defs, libtype=['intern'], priority=[10], cxx_compileflags=Split(cxxflags)) diff --git a/intern/cycles/kernel/shaders/SConscript b/intern/cycles/kernel/shaders/SConscript new file mode 100644 index 00000000000..8dfd5a304f3 --- /dev/null +++ b/intern/cycles/kernel/shaders/SConscript @@ -0,0 +1,42 @@ +#!/usr/bin/python +import sys +import os +import Blender as B + +def normpath(path): + return os.path.abspath(os.path.normpath(path)) + +Import ('env') + +oso_files = [] + +if env['WITH_BF_CYCLES_OSL']: + shaders = env.Clone() + + # cuda info + osl_compiler = env['BF_OSL_COMPILER'] + + # build directory + root_build_dir = normpath(env['BF_BUILDDIR']) + build_dir = os.path.join(root_build_dir, 'intern/cycles/kernel/shaders') + + # source directories and files + source_dir = Dir('.').srcnode().path + + # dependencies + dependencies = shaders.Glob('*.h') + + for f in os.listdir(source_dir): + if f.endswith('.osl'): + osl_file = os.path.join(source_dir, f) + oso_file = os.path.join(build_dir, f.replace('.osl', '.oso')) + + command = "%s -O2 -I%s -o %s %s" % (osl_compiler, source_dir, oso_file, osl_file) + + shaders.Command(oso_file, f, command) + shaders.Depends(oso_file, [f] + dependencies) + + oso_files.append(oso_file) + + +Return('oso_files') From 987f6a7d4f8637441cadf1bfe162070b965dbf96 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Nov 2012 13:24:14 +0000 Subject: [PATCH 028/115] code cleanup: move local math functions into math_geom.c, math_vector.c, no functional changes. --- source/blender/blenlib/BLI_math_geom.h | 4 +++ source/blender/blenlib/BLI_math_vector.h | 1 + source/blender/blenlib/intern/math_geom.c | 27 +++++++++++++++++ source/blender/blenlib/intern/math_vector.c | 7 +++++ source/blender/bmesh/operators/bmo_bevel.c | 21 ++++++-------- source/blender/editors/object/object_bake.c | 32 ++------------------- source/blender/makesdna/DNA_text_types.h | 1 - 7 files changed, 50 insertions(+), 43 deletions(-) diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 80169e952bf..509927e589c 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -187,6 +187,10 @@ int barycentric_inside_triangle_v2(const float w[3]); void resolve_tri_uv(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2]); void resolve_quad_uv(float uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]); +/* use to find the point of a UV on a face */ +void interp_bilinear_quad_v3(float data[4][3], float u, float v, float res[3]); +void interp_barycentric_tri_v3(float data[3][3], float u, float v, float res[3]); + /***************************** View & Projection *****************************/ void lookat_m4(float mat[4][4], float vx, float vy, diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 77c0ec0a88f..5f80d1e52d7 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -169,6 +169,7 @@ void interp_v4_v4v4v4v4(float p[4], const float v1[4], const float v2[4], const void mid_v3_v3v3(float r[3], const float a[3], const float b[3]); void mid_v2_v2v2(float r[2], const float a[2], const float b[2]); +void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]); /********************************* Comparison ********************************/ diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index e10229f11da..cd726179f56 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2399,6 +2399,33 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const #undef IS_ZERO +/* reverse of the functions above */ +void interp_bilinear_quad_v3(float data[4][3], float u, float v, float res[3]) +{ + float vec[3]; + + copy_v3_v3(res, data[0]); + mul_v3_fl(res, (1 - u) * (1 - v)); + copy_v3_v3(vec, data[1]); + mul_v3_fl(vec, u * (1 - v)); add_v3_v3(res, vec); + copy_v3_v3(vec, data[2]); + mul_v3_fl(vec, u * v); add_v3_v3(res, vec); + copy_v3_v3(vec, data[3]); + mul_v3_fl(vec, (1 - u) * v); add_v3_v3(res, vec); +} + +void interp_barycentric_tri_v3(float data[3][3], float u, float v, float res[3]) +{ + float vec[3]; + + copy_v3_v3(res, data[0]); + mul_v3_fl(res, u); + copy_v3_v3(vec, data[1]); + mul_v3_fl(vec, v); add_v3_v3(res, vec); + copy_v3_v3(vec, data[2]); + mul_v3_fl(vec, 1.0f - u - v); add_v3_v3(res, vec); +} + /***************************** View & Projection *****************************/ void orthographic_m4(float matrix[][4], const float left, const float right, const float bottom, const float top, diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 976895fe6fc..7f578fe305d 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -115,6 +115,13 @@ void mid_v2_v2v2(float v[2], const float v1[2], const float v2[2]) v[1] = 0.5f * (v1[1] + v2[1]); } +void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]) +{ + v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f; + v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f; + v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f; +} + /********************************** Angles ***********************************/ /* Return the angle in radians between vecs 1-2 and 2-3 in radians diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 2209c60b280..4b1ea5298a3 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -115,7 +115,7 @@ typedef struct BevelParams { /* Make a new BoundVert of the given kind, insert it at the end of the circular linked * list with entry point bv->boundstart, and return it. */ -static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, float co[3]) +static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float co[3]) { BoundVert *ans = (BoundVert *)BLI_memarena_alloc(mem_arena, sizeof(BoundVert)); @@ -383,7 +383,8 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, if (fabs(angle_v3v3(dir1, dir2)) < BEVEL_EPSILON) { /* lines are parallel; off1a is a good meet point */ copy_v3_v3(meetco, off1a); - } else if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) { + } + else if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) { /* another test says they are parallel */ copy_v3_v3(meetco, off1a); } @@ -392,7 +393,7 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, /* Offset by e->offset in plane with normal plane_no, on left if left==TRUE, * else on right. If no is NULL, choose an arbitrary plane different * from eh's direction. */ -static void offset_in_plane(EdgeHalf *e, float plane_no[3], int left, float r[3]) +static void offset_in_plane(EdgeHalf *e, const float plane_no[3], int left, float r[3]) { float dir[3], no[3]; BMVert *v; @@ -434,7 +435,7 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3]) } /* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */ -static void project_to_edge(BMEdge *e, float co_a[3], float co_b[3], float projco[3]) +static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], float projco[3]) { float otherco[3]; @@ -471,7 +472,7 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f) * of that segment in r. */ static void get_point_on_round_profile(float r[3], float offset, int i, int count, - float va[3], float v[3], float vb[3]) + const float va[3], const float v[3], const float vb[3]) { float vva[3], vvb[3], angle, center[3], rv[3], axis[3], co[3]; @@ -514,7 +515,8 @@ static void get_point_on_round_profile(float r[3], float offset, int i, int coun * If va, vmid, and vb are all on the same plane, just interpolate between va and vb. */ static void get_point_on_round_edge(EdgeHalf *e, int i, - float va[3], float vmid[3], float vb[3], float profileco[3]) + const float va[3], const float vmid[3], const float vb[3], + float profileco[3]) { float vva[3], vvb[3], point[3], dir[3], vaadj[3], vbadj[3], p2[3], pn[3]; int n = e->seg; @@ -547,13 +549,6 @@ static void get_point_on_round_edge(EdgeHalf *e, int i, } } -static void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]) -{ - v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f; - v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f; - v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f; -} - /* Make a circular list of BoundVerts for bv, each of which has the coordinates * of a vertex on the the boundary of the beveled vertex bv->v. * Also decide on the mesh pattern that will be used inside the boundary. diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index ee3c66b6eac..032314d06f3 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -451,32 +451,6 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, MPassKnownData } } -static void interp_bilinear_quad_data(float data[4][3], float u, float v, float res[3]) -{ - float vec[3]; - - copy_v3_v3(res, data[0]); - mul_v3_fl(res, (1 - u) * (1 - v)); - copy_v3_v3(vec, data[1]); - mul_v3_fl(vec, u * (1 - v)); add_v3_v3(res, vec); - copy_v3_v3(vec, data[2]); - mul_v3_fl(vec, u * v); add_v3_v3(res, vec); - copy_v3_v3(vec, data[3]); - mul_v3_fl(vec, (1 - u) * v); add_v3_v3(res, vec); -} - -static void interp_barycentric_tri_data(float data[3][3], float u, float v, float res[3]) -{ - float vec[3]; - - copy_v3_v3(res, data[0]); - mul_v3_fl(res, u); - copy_v3_v3(vec, data[1]); - mul_v3_fl(vec, v); add_v3_v3(res, vec); - copy_v3_v3(vec, data[2]); - mul_v3_fl(vec, 1.0f - u - v); add_v3_v3(res, vec); -} - /* mode = 0: interpolate normals, * mode = 1: interpolate coord */ static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float crn_y, int mode, float res[3]) @@ -507,7 +481,7 @@ static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float copy_v3_v3(data[3], CCG_grid_elem_co(key, grid, x0, y1)); } - interp_bilinear_quad_data(data, u, v, res); + interp_bilinear_quad_v3(data, u, v, res); } static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, @@ -579,7 +553,7 @@ static void interp_bilinear_mface(DerivedMesh *dm, MFace *mface, const float u, dm->getVertCo(dm, mface->v4, data[3]); } - interp_bilinear_quad_data(data, u, v, res); + interp_bilinear_quad_v3(data, u, v, res); } /* mode = 0: interpolate normals, @@ -599,7 +573,7 @@ static void interp_barycentric_mface(DerivedMesh *dm, MFace *mface, const float dm->getVertCo(dm, mface->v3, data[2]); } - interp_barycentric_tri_data(data, u, v, res); + interp_barycentric_tri_v3(data, u, v, res); } static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) diff --git a/source/blender/makesdna/DNA_text_types.h b/source/blender/makesdna/DNA_text_types.h index cf26dae402d..810628ac29b 100644 --- a/source/blender/makesdna/DNA_text_types.h +++ b/source/blender/makesdna/DNA_text_types.h @@ -78,7 +78,6 @@ typedef struct Text { /* text flags */ #define TXT_ISDIRTY 0x0001 -#define TXT_DEPRECATED 0x0004 /* deprecated ISTMP flag */ #define TXT_ISMEM 0x0004 #define TXT_ISEXT 0x0008 #define TXT_ISSCRIPT 0x0010 /* used by space handler scriptlinks */ From b89026a3028c3a4f1b6e205c249242d17a878f72 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 15 Nov 2012 13:26:32 +0000 Subject: [PATCH 029/115] Correction to 32bit buildslaves --- build_files/buildbot/config/user-config-glibc211-i686.py | 4 +++- build_files/buildbot/config/user-config-glibc27-i686.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build_files/buildbot/config/user-config-glibc211-i686.py b/build_files/buildbot/config/user-config-glibc211-i686.py index bbd58150fde..98ae49eeeea 100644 --- a/build_files/buildbot/config/user-config-glibc211-i686.py +++ b/build_files/buildbot/config/user-config-glibc211-i686.py @@ -162,4 +162,6 @@ WITH_BF_OCEANSIM = True BF_DEBUG = False REL_CCFLAGS = ['-O2', '-msse', '-msse2'] # C & C++ PLATFORM_LINKFLAGS = ['-lrt'] -BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] + +if WITH_BF_CYCLES_OSL: + BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] diff --git a/build_files/buildbot/config/user-config-glibc27-i686.py b/build_files/buildbot/config/user-config-glibc27-i686.py index ce13e136388..78a2725c456 100644 --- a/build_files/buildbot/config/user-config-glibc27-i686.py +++ b/build_files/buildbot/config/user-config-glibc27-i686.py @@ -147,4 +147,6 @@ WITH_BF_OCEANSIM = True BF_DEBUG = False REL_CCFLAGS = ['-O2'] # C & C++ PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib32'] -BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] + +if WITH_BF_CYCLES_OSL: + BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] From 1c410ab6e79b140f912b257863b42ec2028d6b23 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Nov 2012 14:08:46 +0000 Subject: [PATCH 030/115] Fix #33183: cycles bump mapping was not executed with only an AO node in a material. --- intern/cycles/kernel/shaders/node_ambient_occlusion.osl | 1 + intern/cycles/render/nodes.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/intern/cycles/kernel/shaders/node_ambient_occlusion.osl b/intern/cycles/kernel/shaders/node_ambient_occlusion.osl index 57a06f35461..b9423344e73 100644 --- a/intern/cycles/kernel/shaders/node_ambient_occlusion.osl +++ b/intern/cycles/kernel/shaders/node_ambient_occlusion.osl @@ -19,6 +19,7 @@ #include "stdosl.h" shader node_ambient_occlusion( + normal NormalIn = N, color Color = color(0.8, 0.8, 0.8), output closure color AO = ambient_occlusion()) { diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 82afab4dc1a..cdc3b555a51 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1578,6 +1578,8 @@ void HoldoutNode::compile(OSLCompiler& compiler) AmbientOcclusionNode::AmbientOcclusionNode() : ShaderNode("ambient_occlusion") { + add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, true); + add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); add_output("AO", SHADER_SOCKET_CLOSURE); } From 613cf7ae376b0994c9bd7c57b13123d72831bd3a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Nov 2012 15:37:58 +0000 Subject: [PATCH 031/115] Cycles: ambient occlusion now takes per-BSDF normals into account. --- intern/cycles/kernel/kernel_path.h | 35 ++++++++++++++-------------- intern/cycles/kernel/kernel_shader.h | 20 +++++++++++++--- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 585068ce8e2..b893aa4d03d 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -331,12 +331,15 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample, float bsdf_u = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_U); float bsdf_v = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_V); + float ao_factor = kernel_data.background.ao_factor; + float3 ao_N; + float3 ao_bsdf = shader_bsdf_ao(kg, &sd, ao_factor, &ao_N); float3 ao_D; float ao_pdf; - sample_cos_hemisphere(sd.N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); + sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); - if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f) { + if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f && average(ao_bsdf) != 0.0f) { Ray light_ray; float3 ao_shadow; @@ -347,11 +350,8 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample, light_ray.time = sd.time; #endif - if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) { - float3 ao_bsdf = shader_bsdf_diffuse(kg, &sd)*kernel_data.background.ao_factor; - ao_bsdf += shader_bsdf_ao(kg, &sd); + if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) path_radiance_accum_ao(&L, throughput, ao_bsdf, ao_shadow, state.bounce); - } } } #endif @@ -509,12 +509,15 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray float bsdf_u = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_U); float bsdf_v = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_V); + float ao_factor = kernel_data.background.ao_factor; + float3 ao_N; + float3 ao_bsdf = shader_bsdf_ao(kg, &sd, ao_factor, &ao_N); float3 ao_D; float ao_pdf; - sample_cos_hemisphere(sd.N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); + sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); - if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f) { + if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f && average(ao_bsdf) != 0.0f) { Ray light_ray; float3 ao_shadow; @@ -525,11 +528,8 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray light_ray.time = sd.time; #endif - if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) { - float3 ao_bsdf = shader_bsdf_diffuse(kg, &sd)*kernel_data.background.ao_factor; - ao_bsdf += shader_bsdf_ao(kg, &sd); + if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) path_radiance_accum_ao(L, throughput, ao_bsdf, ao_shadow, state.bounce); - } } } #endif @@ -712,6 +712,8 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam int num_samples = kernel_data.integrator.ao_samples; float num_samples_inv = 1.0f/num_samples; float ao_factor = kernel_data.background.ao_factor; + float3 ao_N; + float3 ao_bsdf = shader_bsdf_ao(kg, &sd, ao_factor, &ao_N); for(int j = 0; j < num_samples; j++) { /* todo: solve correlation */ @@ -721,9 +723,9 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam float3 ao_D; float ao_pdf; - sample_cos_hemisphere(sd.N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); + sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); - if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f) { + if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f && average(ao_bsdf) != 0.0f) { Ray light_ray; float3 ao_shadow; @@ -734,11 +736,8 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam light_ray.time = sd.time; #endif - if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) { - float3 ao_bsdf = shader_bsdf_diffuse(kg, &sd)*ao_factor; - ao_bsdf += shader_bsdf_ao(kg, &sd); + if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) path_radiance_accum_ao(&L, throughput*num_samples_inv, ao_bsdf, ao_shadow, state.bounce); - } } } } diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 1af5e048ad9..a2a741935a1 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -599,21 +599,35 @@ __device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd) #endif } -__device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd) +__device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N) { #ifdef __MULTI_CLOSURE__ float3 eval = make_float3(0.0f, 0.0f, 0.0f); + *N = make_float3(0.0f, 0.0f, 0.0f); + for(int i = 0; i< sd->num_closure; i++) { ShaderClosure *sc = &sd->closure[i]; - if(CLOSURE_IS_AMBIENT_OCCLUSION(sc->type)) + if(CLOSURE_IS_BSDF_DIFFUSE(sc->type)) { + eval += sc->weight*ao_factor; + *N += sc->N*average(sc->weight); + } + if(CLOSURE_IS_AMBIENT_OCCLUSION(sc->type)) { eval += sc->weight; + *N += sd->N*average(sc->weight); + } } + *N = normalize(*N); + return eval; #else - if(CLOSURE_IS_AMBIENT_OCCLUSION(sd->closure.type)) + *N = sd->N; + + if(CLOSURE_IS_DIFFUSE(sd->closure.type)) + return sd->closure.weight*ao_factor; + else if(CLOSURE_IS_AMBIENT_OCCLUSION(sd->closure.type)) return sd->closure.weight; else return make_float3(0.0f, 0.0f, 0.0f); From 5c6f6301b02a68c6569e14a70b3968a69fa099e7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 15 Nov 2012 15:59:58 +0000 Subject: [PATCH 032/115] Image thread safe improvements This commit makes BKE_image_acquire_ibuf referencing result, which means once some area requested for image buffer, it'll be guaranteed this buffer wouldn't be freed by image signal. To de-reference buffer BKE_image_release_ibuf should now always be used. To make referencing working correct we can not rely on result of image_get_ibuf_threadsafe called outside from thread lock. This is so because we need to guarantee getting image buffer from list of loaded buffers and it's referencing happens atomic. Without lock here it is possible that between call of image_get_ibuf_threadsafe and referencing the buffer IMA_SIGNAL_FREE would be called. Image signal handling too is blocking now to prevent such a situation. Threads are locking by spinlock, which are faster than mutexes. There were some slowdown reports in the past about render slowdown when using OSX on Xeon CPU. It shouldn't happen with spin locks, but more tests on different hardware would be really welcome. So far can not see speed regressions on own computers. This commit also removes BKE_image_get_ibuf, because it was not so intuitive when get_ibuf and acquire_ibuf should be used. Thanks to Ton and Brecht for discussion/review :) --- intern/cycles/kernel/kernel_shader.h | 2 +- source/blender/blenkernel/BKE_image.h | 10 +- source/blender/blenkernel/intern/blender.c | 2 + source/blender/blenkernel/intern/brush.c | 2 - source/blender/blenkernel/intern/image.c | 257 ++++++++++-------- source/blender/blenlib/BLI_threads.h | 17 ++ source/blender/blenlib/intern/threads.c | 36 +++ source/blender/blenloader/intern/readfile.c | 2 +- source/blender/collada/ImageExporter.cpp | 4 +- .../compositor/nodes/COM_ImageNode.cpp | 3 +- .../operations/COM_ImageOperation.cpp | 5 +- .../operations/COM_ViewerBaseOperation.cpp | 10 +- source/blender/editors/include/ED_image.h | 2 +- source/blender/editors/object/object_bake.c | 46 ++-- source/blender/editors/object/object_edit.c | 4 +- .../blender/editors/render/render_internal.c | 2 +- source/blender/editors/render/render_opengl.c | 4 +- .../blender/editors/render/render_preview.c | 4 +- .../editors/sculpt_paint/paint_image.c | 72 +++-- .../editors/space_image/image_buttons.c | 5 +- .../blender/editors/space_image/image_draw.c | 11 +- .../blender/editors/space_image/image_edit.c | 16 +- .../blender/editors/space_image/image_ops.c | 55 ++-- .../blender/editors/space_image/space_image.c | 2 +- source/blender/editors/space_info/info_ops.c | 8 +- source/blender/editors/space_node/drawnode.c | 6 +- source/blender/editors/space_node/node_view.c | 8 +- .../blender/editors/space_view3d/drawmesh.c | 2 +- .../blender/editors/space_view3d/drawobject.c | 4 +- .../editors/space_view3d/view3d_draw.c | 3 +- source/blender/gpu/intern/gpu_draw.c | 14 +- source/blender/gpu/intern/gpu_material.c | 3 +- source/blender/makesrna/intern/rna_image.c | 27 +- .../blender/makesrna/intern/rna_image_api.c | 19 +- source/blender/makesrna/intern/rna_space.c | 4 +- .../composite/nodes/node_composite_image.c | 22 +- .../nodes/node_composite_splitViewer.c | 2 +- .../composite/nodes/node_composite_viewer.c | 2 +- .../nodes/node_shader_tex_environment.c | 3 +- .../shader/nodes/node_shader_tex_image.c | 3 +- .../nodes/shader/nodes/node_shader_texture.c | 3 +- .../nodes/texture/nodes/node_texture_image.c | 4 +- source/blender/render/intern/source/envmap.c | 3 +- .../render/intern/source/imagetexture.c | 81 +++++- .../blender/render/intern/source/pipeline.c | 1 + .../render/intern/source/render_texture.c | 30 +- .../blender/render/intern/source/rendercore.c | 28 +- .../blender/render/intern/source/voxeldata.c | 11 +- .../windowmanager/intern/wm_playanim.c | 2 + source/creator/creator.c | 1 + .../gameengine/GamePlayer/ghost/GPG_ghost.cpp | 3 + source/gameengine/Ketsji/BL_Texture.cpp | 20 +- 52 files changed, 601 insertions(+), 289 deletions(-) diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index a2a741935a1..f935858f8ba 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -625,7 +625,7 @@ __device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_facto #else *N = sd->N; - if(CLOSURE_IS_DIFFUSE(sd->closure.type)) + if(CLOSURE_IS_BSDF_DIFFUSE(sd->closure.type)) return sd->closure.weight*ao_factor; else if(CLOSURE_IS_AMBIENT_OCCLUSION(sd->closure.type)) return sd->closure.weight; diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 1875fd66628..1f9630d9fce 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -48,6 +48,9 @@ struct Main; #define IMA_MAX_SPACE 64 +void BKE_images_init(void); +void BKE_images_exit(void); + /* call from library */ void BKE_image_free(struct Image *me); @@ -133,14 +136,13 @@ enum { #define IMA_CHAN_FLAG_RGB 2 #define IMA_CHAN_FLAG_ALPHA 4 -/* depending Image type, and (optional) ImageUser setting it returns ibuf */ -/* always call to make signals work */ -struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser); +/* checks whether there's an image buffer for given image and user */ +int BKE_image_has_ibuf(struct Image *ima, struct ImageUser *iuser); /* same as above, but can be used to retrieve images being rendered in * a thread safe way, always call both acquire and release */ struct ImBuf *BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **lock_r); -void BKE_image_release_ibuf(struct Image *ima, void *lock); +void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock); /* returns a new image or NULL if it can't load */ struct Image *BKE_image_load(const char *filepath); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index e1e868b234e..40cd5b3d403 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -70,6 +70,7 @@ #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_idprop.h" +#include "BKE_image.h" #include "BKE_ipo.h" #include "BKE_library.h" #include "BKE_main.h" @@ -113,6 +114,7 @@ void free_blender(void) BKE_spacetypes_free(); /* after free main, it uses space callbacks */ IMB_exit(); + BKE_images_exit(); BLI_callback_global_finalize(); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 98b206712d6..f310895f590 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1287,8 +1287,6 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) texcache = MEM_callocN(sizeof(int) * side * side, "Brush texture cache"); - BKE_image_get_ibuf(mtex->tex->ima, NULL); - /*do normalized cannonical view coords for texture*/ for (y = -1.0, iy = 0; iy < side; iy++, y += step) { for (x = -1.0, ix = 0; ix < side; ix++, x += step) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 55d37c91859..993d72ab2e7 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -100,6 +100,8 @@ #include "WM_api.h" +static SpinLock image_spin; + /* max int, to indicate we don't store sequences in ibuf */ #define IMA_NO_INDEX 0x7FEFEFEF @@ -108,6 +110,16 @@ #define IMA_INDEX_FRAME(index) (index >> 10) #define IMA_INDEX_PASS(index) (index & ~1023) +void BKE_images_init(void) +{ + BLI_spin_init(&image_spin); +} + +void BKE_images_exit(void) +{ + BLI_spin_end(&image_spin); +} + /* ******** IMAGE PROCESSING ************* */ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ @@ -168,13 +180,14 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ void BKE_image_de_interlace(Image *ima, int odd) { - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ibuf) { if (odd) de_interlace_st(ibuf); else de_interlace_ng(ibuf); } + BKE_image_release_ibuf(ima, ibuf, NULL); } /* ***************** ALLOC & FREE, DATA MANAGING *************** */ @@ -260,8 +273,9 @@ static ImBuf *image_get_ibuf(Image *ima, int index, int frame) /* this function is intended to be thread safe. with IMA_NO_INDEX this * should be OK, but when iterating over the list this is more tricky * */ - if (index == IMA_NO_INDEX) + if (index == IMA_NO_INDEX) { return ima->ibufs.first; + } else { ImBuf *ibuf; @@ -269,9 +283,9 @@ static ImBuf *image_get_ibuf(Image *ima, int index, int frame) for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) if (ibuf->index == index) return ibuf; - - return NULL; } + + return NULL; } /* no ima->ibuf anymore, but listbase */ @@ -534,7 +548,7 @@ int BKE_image_scale(Image *image, int width, int height) ibuf->userflags |= IB_BITMAPDIRTY; } - BKE_image_release_ibuf(image, lock); + BKE_image_release_ibuf(image, ibuf, lock); return (ibuf != NULL); } @@ -2081,6 +2095,8 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) if (ima == NULL) return; + BLI_spin_lock(&image_spin); + switch (signal) { case IMA_SIGNAL_FREE: image_free_buffers(ima); @@ -2167,6 +2183,8 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } } } + + BLI_spin_unlock(&image_spin); } /* if layer or pass changes, we need an index for the imbufs list */ @@ -2320,7 +2338,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) if (ibuf) { #ifdef WITH_OPENEXR - /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ + /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_acquire_ibuf */ if (ibuf->ftype == OPENEXR && ibuf->userdata) { image_create_multilayer(ima, ibuf, frame); ima->type = IMA_TYPE_MULTILAYER; @@ -2482,7 +2500,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) } if (ibuf) { - /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ + /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_acquire_ibuf */ if (ibuf->ftype == OPENEXR && ibuf->userdata) { image_create_multilayer(ima, ibuf, cfra); ima->type = IMA_TYPE_MULTILAYER; @@ -2751,38 +2769,32 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame * a big bottleneck */ } - *frame_r = frame; - *index_r = index; + if (frame_r) + *frame_r = frame; + + if (index_r) + *index_r = index; return ibuf; } -/* Checks optional ImageUser and verifies/creates ImBuf. */ -/* use this one if you want to get a render result in progress, - * if not, use BKE_image_get_ibuf which doesn't require a release */ -ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) +/* Checks optional ImageUser and verifies/creates ImBuf. + * + * not thread-safe, so callee should worry about thread locks + */ +static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) { ImBuf *ibuf = NULL; float color[] = {0, 0, 0, 1}; int frame = 0, index = 0; - /* This function is intended to be thread-safe. It postpones the mutex lock - * until it needs to load the image, if the image is already there it - * should just get the pointer and return. The reason is that a lot of mutex - * locks appears to be very slow on certain multicore macs, causing a render - * with image textures to actually slow down as more threads are used. - * - * Note that all the image loading functions should also make sure they do - * things in a threadsafe way for image_get_ibuf_threadsafe to work correct. - * That means, the last two steps must be, 1) add the ibuf to the list and - * 2) set ima/iuser->ok to 0 to IMA_OK_LOADED */ - if (lock_r) *lock_r = NULL; /* quick reject tests */ if (ima == NULL) return NULL; + if (iuser) { if (iuser->ok == 0) return NULL; @@ -2790,95 +2802,71 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) else if (ima->ok == 0) return NULL; - /* try to get the ibuf without locking */ ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index); if (ibuf == NULL) { - /* couldn't get ibuf and image is not ok, so let's lock and try to - * load the image */ - BLI_lock_thread(LOCK_IMAGE); - - /* need to check ok flag and loading ibuf again, because the situation - * might have changed in the meantime */ - if (iuser) { - if (iuser->ok == 0) { - BLI_unlock_thread(LOCK_IMAGE); - return NULL; + /* we are sure we have to load the ibuf, using source and type */ + if (ima->source == IMA_SRC_MOVIE) { + /* source is from single file, use flipbook to store ibuf */ + ibuf = image_load_movie_file(ima, iuser, frame); + } + else if (ima->source == IMA_SRC_SEQUENCE) { + if (ima->type == IMA_TYPE_IMAGE) { + /* regular files, ibufs in flipbook, allows saving */ + ibuf = image_load_sequence_file(ima, iuser, frame); + } + /* no else; on load the ima type can change */ + if (ima->type == IMA_TYPE_MULTILAYER) { + /* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */ + ibuf = image_load_sequence_multilayer(ima, iuser, frame); } } - else if (ima->ok == 0) { - BLI_unlock_thread(LOCK_IMAGE); - return NULL; + else if (ima->source == IMA_SRC_FILE) { + + if (ima->type == IMA_TYPE_IMAGE) + ibuf = image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */ + /* no else; on load the ima type can change */ + if (ima->type == IMA_TYPE_MULTILAYER) + /* keeps render result, stores ibufs in listbase, allows saving */ + ibuf = image_get_ibuf_multilayer(ima, iuser); + } - - ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index); - - if (ibuf == NULL) { - /* we are sure we have to load the ibuf, using source and type */ - if (ima->source == IMA_SRC_MOVIE) { - /* source is from single file, use flipbook to store ibuf */ - ibuf = image_load_movie_file(ima, iuser, frame); + else if (ima->source == IMA_SRC_GENERATED) { + /* generated is: ibuf is allocated dynamically */ + /* UV testgrid or black or solid etc */ + if (ima->gen_x == 0) ima->gen_x = 1024; + if (ima->gen_y == 0) ima->gen_y = 1024; + ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, + color, &ima->colorspace_settings); + image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); + ima->ok = IMA_OK_LOADED; + } + else if (ima->source == IMA_SRC_VIEWER) { + if (ima->type == IMA_TYPE_R_RESULT) { + /* always verify entirely, and potentially + * returns pointer to release later */ + ibuf = image_get_render_result(ima, iuser, lock_r); } - else if (ima->source == IMA_SRC_SEQUENCE) { - if (ima->type == IMA_TYPE_IMAGE) { - /* regular files, ibufs in flipbook, allows saving */ - ibuf = image_load_sequence_file(ima, iuser, frame); - } - /* no else; on load the ima type can change */ - if (ima->type == IMA_TYPE_MULTILAYER) { - /* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */ - ibuf = image_load_sequence_multilayer(ima, iuser, frame); - } - } - else if (ima->source == IMA_SRC_FILE) { + else if (ima->type == IMA_TYPE_COMPOSITE) { + /* requires lock/unlock, otherwise don't return image */ + if (lock_r) { + /* unlock in BKE_image_release_ibuf */ + BLI_lock_thread(LOCK_VIEWER); + *lock_r = ima; - if (ima->type == IMA_TYPE_IMAGE) - ibuf = image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */ - /* no else; on load the ima type can change */ - if (ima->type == IMA_TYPE_MULTILAYER) - /* keeps render result, stores ibufs in listbase, allows saving */ - ibuf = image_get_ibuf_multilayer(ima, iuser); + /* XXX anim play for viewer nodes not yet supported */ + frame = 0; // XXX iuser?iuser->framenr:0; + ibuf = image_get_ibuf(ima, 0, frame); - } - else if (ima->source == IMA_SRC_GENERATED) { - /* generated is: ibuf is allocated dynamically */ - /* UV testgrid or black or solid etc */ - if (ima->gen_x == 0) ima->gen_x = 1024; - if (ima->gen_y == 0) ima->gen_y = 1024; - ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, - color, &ima->colorspace_settings); - image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - ima->ok = IMA_OK_LOADED; - } - else if (ima->source == IMA_SRC_VIEWER) { - if (ima->type == IMA_TYPE_R_RESULT) { - /* always verify entirely, and potentially - * returns pointer to release later */ - ibuf = image_get_render_result(ima, iuser, lock_r); - } - else if (ima->type == IMA_TYPE_COMPOSITE) { - /* requires lock/unlock, otherwise don't return image */ - if (lock_r) { - /* unlock in BKE_image_release_ibuf */ - BLI_lock_thread(LOCK_VIEWER); - *lock_r = ima; - - /* XXX anim play for viewer nodes not yet supported */ - frame = 0; // XXX iuser?iuser->framenr:0; - ibuf = image_get_ibuf(ima, 0, frame); - - if (!ibuf) { - /* Composite Viewer, all handled in compositor */ - /* fake ibuf, will be filled in compositor */ - ibuf = IMB_allocImBuf(256, 256, 32, IB_rect); - image_assign_ibuf(ima, ibuf, 0, frame); - } + if (!ibuf) { + /* Composite Viewer, all handled in compositor */ + /* fake ibuf, will be filled in compositor */ + ibuf = IMB_allocImBuf(256, 256, 32, IB_rect); + image_assign_ibuf(ima, ibuf, 0, frame); } } } } - - BLI_unlock_thread(LOCK_IMAGE); } BKE_image_tag_time(ima); @@ -2886,23 +2874,66 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) return ibuf; } -void BKE_image_release_ibuf(Image *ima, void *lock) +/* return image buffer for given image and user + * + * - will lock render result if image type is render result and lock is not NULL + * - will return NULL if image type if render or composite result and lock is NULL + * + * references the result, BKE_image_release_ibuf should be used to de-reference + */ +ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) { - /* for getting image during threaded render / compositing, need to release */ - if (lock == ima) { - BLI_unlock_thread(LOCK_VIEWER); /* viewer image */ + ImBuf *ibuf; + + BLI_spin_lock(&image_spin); + + ibuf = image_acquire_ibuf(ima, iuser, lock_r); + + if (ibuf) + IMB_refImBuf(ibuf); + + BLI_spin_unlock(&image_spin); + + return ibuf; +} + +void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock) +{ + if (lock) { + /* for getting image during threaded render / compositing, need to release */ + if (lock == ima) { + BLI_unlock_thread(LOCK_VIEWER); /* viewer image */ + } + else if (lock) { + RE_ReleaseResultImage(lock); /* render result */ + BLI_unlock_thread(LOCK_VIEWER); /* view image imbuf */ + } } - else if (lock) { - RE_ReleaseResultImage(lock); /* render result */ - BLI_unlock_thread(LOCK_VIEWER); /* view image imbuf */ + + if (ibuf) { + BLI_spin_lock(&image_spin); + IMB_freeImBuf(ibuf); + BLI_spin_unlock(&image_spin); } } -/* warning, this can allocate generated images */ -ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) +/* checks whether there's an image buffer for given image and user */ +int BKE_image_has_ibuf(Image *ima, ImageUser *iuser) { - /* here (+fie_ima/2-1) makes sure that division happens correctly */ - return BKE_image_acquire_ibuf(ima, iuser, NULL); + ImBuf *ibuf = image_get_ibuf_threadsafe(ima, iuser, NULL, NULL); + + if (!ibuf) { + BLI_spin_lock(&image_spin); + + ibuf = image_get_ibuf_threadsafe(ima, iuser, NULL, NULL); + + if (!ibuf) + ibuf = image_acquire_ibuf(ima, iuser, NULL); + + BLI_spin_unlock(&image_spin); + } + + return ibuf != NULL; } int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range) @@ -3020,7 +3051,7 @@ int BKE_image_has_alpha(struct Image *image) ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); planes = (ibuf ? ibuf->planes : 0); - BKE_image_release_ibuf(image, lock); + BKE_image_release_ibuf(image, ibuf, lock); if (planes == 32) return 1; @@ -3044,7 +3075,7 @@ void BKE_image_get_size(Image *image, ImageUser *iuser, int *width, int *height) *height = IMG_SIZE_FALLBACK; } - BKE_image_release_ibuf(image, lock); + BKE_image_release_ibuf(image, ibuf, lock); } void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float size[2]) diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 9cd801f819d..ec8e567c0ef 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -37,6 +37,10 @@ extern "C" { #include +#ifdef __APPLE__ +#include +#endif + /* for tables, button in UI, etc */ #define BLENDER_MAX_THREADS 64 @@ -92,6 +96,19 @@ void BLI_mutex_lock(ThreadMutex *mutex); void BLI_mutex_unlock(ThreadMutex *mutex); void BLI_mutex_end(ThreadMutex *mutex); +/* Spin Lock */ + +#ifdef __APPLE__ +typedef OSSpinLock SpinLock; +#else +typedef pthread_spinlock_t SpinLock; +#endif + +void BLI_spin_init(SpinLock *spin); +void BLI_spin_lock(SpinLock *spin); +void BLI_spin_unlock(SpinLock *spin); +void BLI_spin_end(SpinLock *spin); + /* Read/Write Mutex Lock */ #define THREAD_LOCK_READ 1 diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 66527b9b92a..146e1d531f1 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -400,6 +400,42 @@ void BLI_mutex_end(ThreadMutex *mutex) pthread_mutex_destroy(mutex); } +/* Spin Locks */ + +void BLI_spin_init(SpinLock *spin) +{ +#ifdef __APPLE__ + *spin = OS_SPINLOCK_INIT; +#else + pthread_spin_init(spin, 0); +#endif +} + +void BLI_spin_lock(SpinLock *spin) +{ +#ifdef __APPLE__ + OSSpinLockLock(spin); +#else + pthread_spin_lock(spin); +#endif +} + +void BLI_spin_unlock(SpinLock *spin) +{ +#ifdef __APPLE__ + OSSpinLockUnlock(spin); +#else + pthread_spin_unlock(spin); +#endif +} + +void BLI_spin_end(SpinLock *spin) +{ +#ifndef __APPLE__ + pthread_spin_destroy(spin); +#endif +} + /* Read/Write Mutex Lock */ void BLI_rw_mutex_init(ThreadRWMutex *mutex) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 30331713463..03e5a1d2525 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3043,7 +3043,7 @@ static void direct_link_image(FileData *fd, Image *ima) link_ibuf_list(fd, &ima->ibufs); else ima->ibufs.first = ima->ibufs.last = NULL; - + /* if not restored, we keep the binded opengl index */ if (ima->ibufs.first == NULL) { ima->bindcode = 0; diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index 2e0c0f1ea57..aba290f5ce4 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -61,7 +61,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) if (not_yet_exported) { - ImBuf *imbuf = BKE_image_get_ibuf(image, NULL); + ImBuf *imbuf = BKE_image_acquire_ibuf(image, NULL, NULL); if (!imbuf) { fprintf(stderr, "Collada export: image does not exist:\n%s\n", image->name); return; @@ -147,6 +147,8 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) img.add(mSW); fprintf(stdout, "Collada export: Added image: %s\n", export_file); mImages.push_back(translated_name); + + BKE_image_release_ibuf(image, imbuf, NULL); } } diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp index 4ebd28d710a..729cb1b70a0 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.cpp +++ b/source/blender/compositor/nodes/COM_ImageNode.cpp @@ -73,7 +73,7 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c /* force a load, we assume iuser index will be set OK anyway */ if (image && image->type == IMA_TYPE_MULTILAYER) { bool is_multilayer_ok = false; - BKE_image_get_ibuf(image, imageuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, NULL); if (image->rr) { RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer); if (rl) { @@ -118,6 +118,7 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c } } } + BKE_image_release_ibuf(image, ibuf, NULL); /* without this, multilayer that fail to load will crash blender [#32490] */ if (is_multilayer_ok == false) { diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp index fb3efbb67ed..a7743cd7668 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cpp +++ b/source/blender/compositor/operations/COM_ImageOperation.cpp @@ -65,7 +65,7 @@ ImBuf *BaseImageOperation::getImBuf() { ImBuf *ibuf; - ibuf = BKE_image_get_ibuf(this->m_image, this->m_imageUser); + ibuf = BKE_image_acquire_ibuf(this->m_image, this->m_imageUser, NULL); if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) { return NULL; } @@ -93,6 +93,7 @@ void BaseImageOperation::initExecution() void BaseImageOperation::deinitExecution() { this->m_imageBuffer = NULL; + IMB_freeImBuf(this->m_buffer); } void BaseImageOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) @@ -106,6 +107,8 @@ void BaseImageOperation::determineResolution(unsigned int resolution[2], unsigne resolution[0] = stackbuf->x; resolution[1] = stackbuf->y; } + + IMB_freeImBuf(stackbuf); } void ImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp index 4d4c1199f3e..cc313512316 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp @@ -87,20 +87,16 @@ void ViewerBaseOperation::initImage() /* now we combine the input with ibuf */ this->m_outputBuffer = ibuf->rect_float; - /* needed for display buffer update - * - * no need to lock / reference the image buffer because it's seems - * to be the single place which changes buffers of viewer image - * which is this node - */ + /* needed for display buffer update */ this->m_ibuf = ibuf; if (m_doDepthBuffer) { this->m_depthBuffer = ibuf->zbuf_float; } - BKE_image_release_ibuf(this->m_image, this->m_lock); + BKE_image_release_ibuf(this->m_image, this->m_ibuf, this->m_lock); } + void ViewerBaseOperation:: updateImage(rcti *rect) { IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, NULL, getWidth(), 0, 0, diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index a50b33966c6..9b726cea56c 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -49,7 +49,7 @@ void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sim int ED_space_image_color_sample(struct SpaceImage *sima, struct ARegion *ar, int mval[2], float r_col[3]); struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r); -void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock); +void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock); int ED_space_image_has_buffer(struct SpaceImage *sima); void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 032314d06f3..e144c38a350 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -114,7 +114,7 @@ typedef struct { } MultiresBakeRender; typedef void (*MPassKnownData)(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data, - const int face_index, const int lvl, const float st[2], + ImBuf *ibuf, const int face_index, const int lvl, const float st[2], float tangmat[3][3], const int x, const int y); typedef void * (*MInitBakeData)(MultiresBakeRender *bkr, Image *ima); @@ -133,6 +133,7 @@ typedef struct { DerivedMesh *lores_dm, *hires_dm; int lvl; void *bake_data; + ImBuf *ibuf; MPassKnownData pass_data; } MResolvePixelData; @@ -257,7 +258,7 @@ static void flush_pixel(const MResolvePixelData *data, const int x, const int y) /* sequence end */ data->pass_data(data->lores_dm, data->hires_dm, data->bake_data, - data->face_index, data->lvl, st, to_tang, x, y); + data->ibuf, data->face_index, data->lvl, st, to_tang, x, y); } static void set_rast_triangle(const MBakeRast *bake_rast, const int x, const int y) @@ -368,7 +369,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, MPassKnownData MInitBakeData initBakeData, MApplyBakeData applyBakeData, MFreeBakeData freeBakeData) { DerivedMesh *dm = bkr->lores_dm; - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); const int lvl = bkr->lvl; const int tot_face = dm->getNumTessFaces(dm); MVert *mvert = dm->getVertArray(dm); @@ -414,6 +415,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, MPassKnownData continue; data.face_index = f; + data.ibuf = ibuf; /* might support other forms of diagonal splits later on such as * split by shortest diagonal.*/ @@ -449,6 +451,8 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, MPassKnownData if (freeBakeData) freeBakeData(data.bake_data); } + + BKE_image_release_ibuf(ima, ibuf, NULL); } /* mode = 0: interpolate normals, @@ -579,7 +583,7 @@ static void interp_barycentric_mface(DerivedMesh *dm, MFace *mface, const float static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) { MHeightBakeData *height_data; - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); DerivedMesh *lodm = bkr->lores_dm; height_data = MEM_callocN(sizeof(MHeightBakeData), "MultiresBake heightData"); @@ -609,6 +613,8 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) height_data->orig_index_mf_to_mpoly = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); height_data->orig_index_mp_to_orig = lodm->getPolyDataArray(lodm, CD_ORIGINDEX); + BKE_image_release_ibuf(ima, ibuf, NULL); + return (void *)height_data; } @@ -635,7 +641,7 @@ static void free_normal_data(void *bake_data) static void apply_heights_data(void *bake_data) { MHeightBakeData *height_data = (MHeightBakeData *)bake_data; - ImBuf *ibuf = BKE_image_get_ibuf(height_data->ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(height_data->ima, NULL, NULL); int x, y, i; float height, *heights = height_data->heights; float min = height_data->height_min, max = height_data->height_max; @@ -667,6 +673,8 @@ static void apply_heights_data(void *bake_data) } ibuf->userflags = IB_RECT_INVALID | IB_DISPLAY_BUFFER_INVALID; + + BKE_image_release_ibuf(height_data->ima, ibuf, NULL); } static void free_heights_data(void *bake_data) @@ -687,13 +695,11 @@ static void free_heights_data(void *bake_data) * mesh to make texture smoother) let's call this point p0 and n. * - height wound be dot(n, p1-p0) */ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data, - const int face_index, const int lvl, const float st[2], + ImBuf *ibuf, const int face_index, const int lvl, const float st[2], float UNUSED(tangmat[3][3]), const int x, const int y) { MTFace *mtface = CustomData_get_layer(&lores_dm->faceData, CD_MTFACE); MFace mface; - Image *ima = mtface[face_index].tpage; - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); MHeightBakeData *height_data = (MHeightBakeData *)bake_data; float uv[2], *st0, *st1, *st2, *st3; int pixel = ibuf->x * y + x; @@ -764,13 +770,11 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, * - multiply it by tangmat * - vector in color space would be norm(vec) /2 + (0.5, 0.5, 0.5) */ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data, - const int face_index, const int lvl, const float st[2], + ImBuf *ibuf, const int face_index, const int lvl, const float st[2], float tangmat[3][3], const int x, const int y) { MTFace *mtface = CustomData_get_layer(&lores_dm->faceData, CD_MTFACE); MFace mface; - Image *ima = mtface[face_index].tpage; - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); MNormalBakeData *normal_data = (MNormalBakeData *)bake_data; float uv[2], *st0, *st1, *st2, *st3; int pixel = ibuf->x * y + x; @@ -853,7 +857,7 @@ static void bake_images(MultiresBakeRender *bkr) for (link = bkr->image.first; link; link = link->next) { Image *ima = (Image *)link->data; - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ibuf->x > 0 && ibuf->y > 0) { ibuf->userdata = MEM_callocN(ibuf->y * ibuf->x, "MultiresBake imbuf mask"); @@ -869,6 +873,8 @@ static void bake_images(MultiresBakeRender *bkr) } } + BKE_image_release_ibuf(ima, ibuf, NULL); + ima->id.flag |= LIB_DOIT; } } @@ -879,7 +885,7 @@ static void finish_images(MultiresBakeRender *bkr) for (link = bkr->image.first; link; link = link->next) { Image *ima = (Image *)link->data; - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ibuf->x <= 0 || ibuf->y <= 0) continue; @@ -900,6 +906,8 @@ static void finish_images(MultiresBakeRender *bkr) MEM_freeN(ibuf->userdata); ibuf->userdata = NULL; } + + BKE_image_release_ibuf(ima, ibuf, NULL); } } @@ -974,7 +982,7 @@ static int multiresbake_check(bContext *C, wmOperator *op) ok = 0; } else { - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (!ibuf) { BKE_report(op->reports, RPT_ERROR, "Baking should happen to image with image buffer"); @@ -991,6 +999,8 @@ static int multiresbake_check(bContext *C, wmOperator *op) if (!ok) BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type"); } + + BKE_image_release_ibuf(ima, ibuf, NULL); } } } @@ -1061,10 +1071,12 @@ static void clear_images(MTFace *mtface, int totface) Image *ima = mtface[a].tpage; if ((ima->id.flag & LIB_DOIT) == 0) { - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); ima->id.flag |= LIB_DOIT; + + BKE_image_release_ibuf(ima, ibuf, NULL); } } @@ -1358,7 +1370,7 @@ static void finish_bake_internal(BakeRender *bkr) /* force OpenGL reload and mipmap recalc */ for (ima = G.main->image.first; ima; ima = ima->id.next) { - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); /* some of the images could have been changed during bake, * so recreate mipmaps regardless bake result status @@ -1383,6 +1395,8 @@ static void finish_bake_internal(BakeRender *bkr) ibuf->userdata = NULL; } } + + BKE_image_release_ibuf(ima, ibuf, NULL); } } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index c0c2195592b..4d6b9ed10bb 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1380,7 +1380,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d) if (ma->mtex[b] && ma->mtex[b]->tex) { tex = ma->mtex[b]->tex; if (tex->type == TEX_IMAGE && tex->ima) { - ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, NULL, NULL); /* texturespace */ space = 1.0; @@ -1402,6 +1402,8 @@ static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d) done = TRUE; DAG_id_tag_update(&ob->id, OB_RECALC_OB); + + BKE_image_release_ibuf(tex->ima, ibuf, NULL); } } if (done) break; diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 4b177629f72..7b67f63c646 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -375,7 +375,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec /* make jobs timer to send notifier */ *(rj->do_update) = TRUE; } - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); } static void render_startjob(void *rjv, short *stop, short *do_update, float *progress) diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index e4592a4f77e..effb984c083 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -288,7 +288,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) } } - BKE_image_release_ibuf(oglrender->ima, lock); + BKE_image_release_ibuf(oglrender->ima, ibuf, lock); } static int screen_opengl_render_init(bContext *C, wmOperator *op) @@ -613,7 +613,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) IMB_freeImBuf(ibuf); } - BKE_image_release_ibuf(oglrender->ima, lock); + BKE_image_release_ibuf(oglrender->ima, ibuf, lock); /* movie stats prints have no line break */ printf("\n"); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index b119165fbd0..a864fe306b3 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -934,13 +934,15 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat /* elubie: this needs to be changed: here image is always loaded if not * already there. Very expensive for large images. Need to find a way to * only get existing ibuf */ - ibuf = BKE_image_get_ibuf(ima, &iuser); + ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL); if (ibuf == NULL || ibuf->rect == NULL) return; icon_copy_rect(ibuf, sp->sizex, sp->sizey, sp->pr_rect); *do_update = TRUE; + + BKE_image_release_ibuf(ima, ibuf, NULL); } else if (idtype == ID_BR) { Brush *br = (Brush *)id; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 4b400623920..192ad35109a 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -500,7 +500,7 @@ static void image_undo_restore(bContext *C, ListBase *lb) ima = BLI_findstring(&bmain->image, tile->idname, offsetof(ID, name)); } - ibuf = BKE_image_get_ibuf(ima, NULL); + ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ima && ibuf && strcmp(tile->ibufname, ibuf->name) != 0) { /* current ImBuf filename was changed, probably current frame @@ -508,19 +508,27 @@ static void image_undo_restore(bContext *C, ListBase *lb) * full image user (which isn't so obvious, btw) try to find ImBuf with * matched file name in list of already loaded images */ + BKE_image_release_ibuf(ima, ibuf, NULL); + ibuf = BLI_findstring(&ima->ibufs, tile->ibufname, offsetof(ImBuf, name)); } - if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) + if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) { + BKE_image_release_ibuf(ima, ibuf, NULL); continue; + } - if (ima->gen_type != tile->gen_type || ima->source != tile->source) + if (ima->gen_type != tile->gen_type || ima->source != tile->source) { + BKE_image_release_ibuf(ima, ibuf, NULL); continue; + } use_float = ibuf->rect_float ? 1 : 0; - if (use_float != tile->use_float) + if (use_float != tile->use_float) { + BKE_image_release_ibuf(ima, ibuf, NULL); continue; + } undo_copy_tile(tile, tmpibuf, ibuf, 1); @@ -530,6 +538,8 @@ static void image_undo_restore(bContext *C, ListBase *lb) if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + + BKE_image_release_ibuf(ima, ibuf, NULL); } IMB_freeImBuf(tmpibuf); @@ -1398,8 +1408,8 @@ static float project_paint_uvpixel_mask( Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_stencil, face_index); const MTFace *tf_other = ps->dm_mtface_stencil + face_index; - if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) { - /* BKE_image_get_ibuf - TODO - this may be slow */ + if (other_tpage && (ibuf_other = BKE_image_acquire_ibuf(other_tpage, NULL, NULL))) { + /* BKE_image_acquire_ibuf - TODO - this may be slow */ unsigned char rgba_ub[4]; float rgba_f[4]; @@ -1411,7 +1421,9 @@ static float project_paint_uvpixel_mask( else { /* from char to float */ mask = ((rgba_ub[0] + rgba_ub[1] + rgba_ub[2]) / (256 * 3.0f)) * (rgba_ub[3] / 256.0f); } - + + BKE_image_release_ibuf(other_tpage, ibuf_other, NULL); + if (!ps->do_layer_stencil_inv) /* matching the gimps layer mask black/white rules, white==full opacity */ mask = (1.0f - mask); @@ -1579,8 +1591,8 @@ static ProjPixel *project_paint_uvpixel_init( Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_clone, face_index); const MTFace *tf_other = ps->dm_mtface_clone + face_index; - if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) { - /* BKE_image_get_ibuf - TODO - this may be slow */ + if (other_tpage && (ibuf_other = BKE_image_acquire_ibuf(other_tpage, NULL, NULL))) { + /* BKE_image_acquire_ibuf - TODO - this may be slow */ if (ibuf->rect_float) { if (ibuf_other->rect_float) { /* from float to float */ @@ -1602,6 +1614,8 @@ static ProjPixel *project_paint_uvpixel_init( project_face_pixel(tf_other, ibuf_other, w, side, ((ProjPixelClone *)projPixel)->clonepx.ch, NULL); } } + + BKE_image_release_ibuf(other_tpage, ibuf_other, NULL); } else { if (ibuf->rect_float) { @@ -3408,7 +3422,7 @@ static void project_paint_begin(ProjPaintState *ps) image_index = BLI_linklist_index(image_LinkList, tpage); - if (image_index == -1 && BKE_image_get_ibuf(tpage, NULL)) { /* MemArena dosnt have an append func */ + if (image_index == -1 && BKE_image_has_ibuf(tpage, NULL)) { /* MemArena dosnt have an append func */ BLI_linklist_append(&image_LinkList, tpage); image_index = ps->image_tot; ps->image_tot++; @@ -3431,7 +3445,7 @@ static void project_paint_begin(ProjPaintState *ps) for (node = image_LinkList, i = 0; node; node = node->next, i++, projIma++) { projIma->ima = node->link; projIma->touch = 0; - projIma->ibuf = BKE_image_get_ibuf(projIma->ima, NULL); + projIma->ibuf = BKE_image_acquire_ibuf(projIma->ima, NULL, NULL); projIma->partRedrawRect = BLI_memarena_alloc(arena, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED); memset(projIma->partRedrawRect, 0, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED); } @@ -3458,6 +3472,7 @@ static void project_paint_begin_clone(ProjPaintState *ps, int mouse[2]) static void project_paint_end(ProjPaintState *ps) { int a; + ProjPaintImage *projIma; /* build undo data from original pixel colors */ if (U.uiflag & USER_GLOBALUNDO) { @@ -3545,7 +3560,14 @@ static void project_paint_end(ProjPaintState *ps) if (tmpibuf_float) IMB_freeImBuf(tmpibuf_float); } /* done calculating undo data */ - + + /* dereference used image buffers */ + for (a = 0, projIma = ps->projImages; a < ps->image_tot; a++, projIma++) { + BKE_image_release_ibuf(projIma->ima, projIma->ibuf, NULL); + } + + BKE_image_release_ibuf(ps->reproject_image, ps->reproject_ibuf, NULL); + MEM_freeN(ps->screenCoords); MEM_freeN(ps->bucketRect); MEM_freeN(ps->bucketFaces); @@ -4672,7 +4694,7 @@ static int texpaint_break_stroke(float *prevuv, float *fwuv, float *bkuv, float static int imapaint_canvas_set(ImagePaintState *s, Image *ima) { - ImBuf *ibuf = BKE_image_get_ibuf(ima, s->sima ? &s->sima->iuser : NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, s->sima ? &s->sima->iuser : NULL, NULL); /* verify that we can paint and set canvas */ if (ima == NULL) { @@ -4695,10 +4717,12 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) /* set clone canvas */ if (s->tool == PAINT_TOOL_CLONE) { ima = s->brush->clone.image; - ibuf = BKE_image_get_ibuf(ima, s->sima ? &s->sima->iuser : NULL); + ibuf = BKE_image_acquire_ibuf(ima, s->sima ? &s->sima->iuser : NULL, NULL); - if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) + if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) { + BKE_image_release_ibuf(ima, ibuf, NULL); return 0; + } s->clonecanvas = ibuf; @@ -4713,13 +4737,15 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) return 1; } -static void imapaint_canvas_free(ImagePaintState *UNUSED(s)) +static void imapaint_canvas_free(ImagePaintState *s) { + BKE_image_release_ibuf(s->image, s->canvas, NULL); + BKE_image_release_ibuf(s->brush->clone.image, s->clonecanvas, NULL); } static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, Image *image, short texpaint, float *uv, double time, int update, float pressure) { - ImBuf *ibuf = BKE_image_get_ibuf(image, s->sima ? &s->sima->iuser : NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(image, s->sima ? &s->sima->iuser : NULL, NULL); float pos[2]; int is_data; @@ -4739,9 +4765,13 @@ static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, is_data == FALSE)) { if (update) imapaint_image_update(s->scene, s->sima, image, ibuf, texpaint); + BKE_image_release_ibuf(image, ibuf, NULL); return 1; } - else return 0; + else { + BKE_image_release_ibuf(image, ibuf, NULL); + return 0; + } } static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPainter *painter, short texpaint, const int prevmval[2], const int mval[2], double time, float pressure) @@ -4759,7 +4789,7 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint ImBuf *ibuf; newimage = imapaint_face_image(s, newfaceindex); - ibuf = BKE_image_get_ibuf(newimage, s->sima ? &s->sima->iuser : NULL); + ibuf = BKE_image_acquire_ibuf(newimage, s->sima ? &s->sima->iuser : NULL, NULL); if (ibuf && ibuf->rect) imapaint_pick_uv(s->scene, s->ob, newfaceindex, mval, newuv); @@ -4767,6 +4797,8 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint newimage = NULL; newuv[0] = newuv[1] = 0.0f; } + + BKE_image_release_ibuf(newimage, ibuf, NULL); } else newuv[0] = newuv[1] = 0.0f; @@ -5890,7 +5922,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) } ps.reproject_image = image; - ps.reproject_ibuf = BKE_image_get_ibuf(image, NULL); + ps.reproject_ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); if (ps.reproject_ibuf == NULL || ps.reproject_ibuf->rect == NULL) { BKE_report(op->reports, RPT_ERROR, "Image data could not be found"); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index ae7a718ab5b..0a3db59096a 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -593,7 +593,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (ima->source == IMA_SRC_VIEWER) { ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); uiItemL(layout, ima->id.name + 2, ICON_NONE); uiItemL(layout, str, ICON_NONE); @@ -663,7 +663,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (compact == 0) { ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); uiItemL(layout, str, ICON_NONE); } } @@ -722,7 +722,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char split = uiLayoutSplit(layout, 0.0f, FALSE); col = uiLayoutColumn(split, TRUE); - uiLayoutSetEnabled(col, 0); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 9fc2b981547..d565e6f9e9a 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -652,7 +652,7 @@ static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int if (!brush || !brush->clone.image) return NULL; - ibuf = BKE_image_get_ibuf(brush->clone.image, NULL); + ibuf = BKE_image_acquire_ibuf(brush->clone.image, NULL, NULL); if (!ibuf) return NULL; @@ -660,6 +660,7 @@ static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); if (!display_buffer) { + BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); IMB_display_buffer_release(cache_handle); return NULL; @@ -669,8 +670,10 @@ static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int IMB_display_buffer_release(cache_handle); - if (!rect) + if (!rect) { + BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); return NULL; + } *width = ibuf->x; *height = ibuf->y; @@ -684,6 +687,8 @@ static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int cp += 4; } + BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); + return rect; } @@ -799,7 +804,7 @@ void draw_image_main(const bContext *C, ARegion *ar) } #endif - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); if (show_viewer) { BLI_unlock_thread(LOCK_DRAW_IMAGE); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 4ca2f8888f8..c4e2230e7a7 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -117,8 +117,12 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r) #endif ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r); - if (ibuf && (ibuf->rect || ibuf->rect_float)) - return ibuf; + if (ibuf) { + if (ibuf->rect || ibuf->rect_float) + return ibuf; + + BKE_image_release_ibuf(sima->image, ibuf, NULL); + } } else *lock_r = NULL; @@ -126,10 +130,10 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r) return NULL; } -void ED_space_image_release_buffer(SpaceImage *sima, void *lock) +void ED_space_image_release_buffer(SpaceImage *sima, ImBuf *ibuf, void *lock) { if (sima && sima->image) - BKE_image_release_ibuf(sima->image, lock); + BKE_image_release_ibuf(sima->image, ibuf, lock); } int ED_space_image_has_buffer(SpaceImage *sima) @@ -140,7 +144,7 @@ int ED_space_image_has_buffer(SpaceImage *sima) ibuf = ED_space_image_acquire_buffer(sima, &lock); has_buffer = (ibuf != NULL); - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); return has_buffer; } @@ -175,7 +179,7 @@ void ED_space_image_get_size(SpaceImage *sima, int *width, int *height) *height = IMG_SIZE_FALLBACK; } - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); } void ED_space_image_get_size_fl(SpaceImage *sima, float size[2]) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index ce3c6e1fd26..d4f24babff6 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -167,7 +167,7 @@ static int space_image_file_exists_poll(bContext *C) ret = TRUE; } } - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); return ret; } @@ -1188,7 +1188,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, BKE_color_managed_view_settings_copy(&simopts->im_format.view_settings, &scene->view_settings); } - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); return (ibuf != NULL); } @@ -1328,7 +1328,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI IMB_freeImBuf(colormanaged_ibuf); } - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); } static void image_save_as_free(wmOperator *op) @@ -1743,17 +1743,14 @@ void IMAGE_OT_new(wmOperatorType *ot) static int image_invert_poll(bContext *C) { Image *ima = CTX_data_edit_image(C); - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); - - if (ibuf != NULL) - return 1; - return 0; + + return BKE_image_has_ibuf(ima, NULL); } static int image_invert_exec(bContext *C, wmOperator *op) { Image *ima = CTX_data_edit_image(C); - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); /* flags indicate if this channel should be inverted */ const short r = RNA_boolean_get(op->ptr, "invert_r"); @@ -1792,6 +1789,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) } } else { + BKE_image_release_ibuf(ima, ibuf, NULL); return OPERATOR_CANCELLED; } @@ -1800,6 +1798,9 @@ static int image_invert_exec(bContext *C, wmOperator *op) ibuf->userflags |= IB_MIPMAP_INVALID; WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); + + BKE_image_release_ibuf(ima, ibuf, NULL); + return OPERATOR_FINISHED; } @@ -1848,7 +1849,7 @@ static int image_pack_exec(bContext *C, wmOperator *op) { struct Main *bmain = CTX_data_main(C); Image *ima = CTX_data_edit_image(C); - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); int as_png = RNA_boolean_get(op->ptr, "as_png"); if (!image_pack_test(C, op)) @@ -1865,30 +1866,38 @@ static int image_pack_exec(bContext *C, wmOperator *op) ima->packedfile = newPackedFile(op->reports, ima->name, ID_BLEND_PATH(bmain, &ima->id)); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); - + + BKE_image_release_ibuf(ima, ibuf, NULL); + return OPERATOR_FINISHED; } static int image_pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Image *ima = CTX_data_edit_image(C); - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf; uiPopupMenu *pup; uiLayout *layout; int as_png = RNA_boolean_get(op->ptr, "as_png"); if (!image_pack_test(C, op)) return OPERATOR_CANCELLED; - + + ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); + if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { pup = uiPupMenuBegin(C, "OK", ICON_QUESTION); layout = uiPupMenuLayout(pup); uiItemBooleanO(layout, "Can't pack edited image from disk. Pack as internal PNG?", ICON_NONE, op->idname, "as_png", 1); uiPupMenuEnd(C, pup); + BKE_image_release_ibuf(ima, ibuf, NULL); + return OPERATOR_CANCELLED; } + BKE_image_release_ibuf(ima, ibuf, NULL); + return image_pack_exec(C, op); } @@ -2032,7 +2041,7 @@ int ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], floa int ret = FALSE; if (ibuf == NULL) { - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); return FALSE; } @@ -2058,7 +2067,7 @@ int ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], floa } } - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); return ret; } @@ -2074,7 +2083,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) CurveMapping *curve_mapping = scene->view_settings.curve_mapping; if (ibuf == NULL) { - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); info->draw = 0; return; } @@ -2175,7 +2184,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->draw = 0; } - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); ED_area_tag_redraw(CTX_wm_area(C)); } @@ -2266,12 +2275,12 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) float x1f, y1f, x2f, y2f; if (ibuf == NULL) { - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); return OPERATOR_CANCELLED; } /* hmmmm */ if (ibuf->channels < 3) { - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); return OPERATOR_CANCELLED; } @@ -2288,7 +2297,7 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) /* reset y zoom */ hist->ymax = 1.0f; - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); ED_area_tag_redraw(CTX_wm_area(C)); @@ -2383,11 +2392,13 @@ static int image_record_composite_apply(bContext *C, wmOperator *op) ED_area_tag_redraw(CTX_wm_area(C)); - ibuf = BKE_image_get_ibuf(sima->image, &sima->iuser); + ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, NULL); /* save memory in flipbooks */ if (ibuf) imb_freerectfloatImBuf(ibuf); - + + BKE_image_release_ibuf(sima->image, ibuf, NULL); + scene->r.cfra++; return (scene->r.cfra <= rcd->efra); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 4131cbfdd0d..ea696772957 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -780,7 +780,7 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar) } scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); } - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); ED_region_panels(C, ar, 1, NULL, -1); } diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 131908bc9db..48b5eaf7b44 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -87,10 +87,14 @@ static int pack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) // first check for dirty images for (ima = bmain->image.first; ima; ima = ima->id.next) { if (ima->ibufs.first) { /* XXX FIX */ - ibuf = BKE_image_get_ibuf(ima, NULL); + ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); - if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) { + BKE_image_release_ibuf(ima, ibuf, NULL); break; + } + + BKE_image_release_ibuf(ima, ibuf, NULL); } } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index f808a08d5d2..e842bb5f262 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3313,7 +3313,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) glPopMatrix(); } - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); } } @@ -3326,7 +3326,7 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode) if (snode->flag & SNODE_BACKDRAW) { Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); - ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ibuf) { int x, y; float zoom = 1.0; @@ -3362,6 +3362,8 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode) glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); + + BKE_image_release_ibuf(ima, ibuf, NULL); } } } diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index a4ea2e3e630..f386657c460 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -241,7 +241,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf == NULL) { - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); return OPERATOR_CANCELLED; } @@ -255,7 +255,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) nvm->ymin = -(ar->winy / 2) - (ibuf->y * (0.5f * snode->zoom)) + pad; nvm->ymax = (ar->winy / 2) + (ibuf->y * (0.5f * snode->zoom)) - pad; - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -403,7 +403,7 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float } } - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); return ret; } @@ -493,7 +493,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) ED_node_sample_set(NULL); } - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); ED_area_tag_redraw(CTX_wm_area(C)); } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index cb5556396dd..f35a844afc9 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -728,7 +728,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) BKE_bproperty_set_valstr(prop, string); characters = strlen(string); - if (!BKE_image_get_ibuf(mtpoly->tpage, NULL)) + if (!BKE_image_has_ibuf(mtpoly->tpage, NULL)) characters = 0; if (!mf_smooth) { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 729f810eb87..08ba4fb59bc 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -530,7 +530,7 @@ void drawaxes(float size, char drawtype) static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4]) { Image *ima = (Image *)ob->data; - ImBuf *ibuf = ima ? BKE_image_get_ibuf(ima, NULL) : NULL; + ImBuf *ibuf = ima ? BKE_image_acquire_ibuf(ima, NULL, NULL) : NULL; float scale, ofs_x, ofs_y, sca_x, sca_y; int ima_x, ima_y; @@ -615,6 +615,8 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char /* Reset GL settings */ glMatrixMode(GL_MODELVIEW); glPopMatrix(); + + BKE_image_release_ibuf(ima, ibuf, NULL); } static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, float tmat[][4]) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 24fc6adae6d..a9b3823e6a2 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1561,7 +1561,8 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, ibuf = NULL; /* frame is out of range, dont show */ } else { - ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); + ibuf = BKE_image_acquire_ibuf(ima, &bgpic->iuser, NULL); + freeibuf = ibuf; } image_aspect[0] = ima->aspx; diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7bd72430969..e3ba4cb1f95 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -318,7 +318,7 @@ static void gpu_make_repbind(Image *ima) { ImBuf *ibuf; - ibuf = BKE_image_get_ibuf(ima, NULL); + ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ibuf==NULL) return; @@ -333,6 +333,8 @@ static void gpu_make_repbind(Image *ima) if (ima->totbind>1) ima->repbind= MEM_callocN(sizeof(int)*ima->totbind, "repbind"); + + BKE_image_release_ibuf(ima, ibuf, NULL); } static void gpu_clear_tpage(void) @@ -479,7 +481,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int return 0; /* check if we have a valid image buffer */ - ibuf= BKE_image_get_ibuf(ima, iuser); + ibuf= BKE_image_acquire_ibuf(ima, iuser, NULL); if (ibuf==NULL) return 0; @@ -574,6 +576,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (*bind != 0) { /* enable opengl drawing with textures */ glBindTexture(GL_TEXTURE_2D, *bind); + BKE_image_release_ibuf(ima, ibuf, NULL); return *bind; } @@ -635,6 +638,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (srgb_frect) MEM_freeN(srgb_frect); + BKE_image_release_ibuf(ima, ibuf, NULL); + return *bind; } @@ -896,7 +901,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) { ImBuf *ibuf; - ibuf = BKE_image_get_ibuf(ima, NULL); + ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ima->repbind || (GPU_get_mipmap() && !GTS.gpu_mipmap) || !ima->bindcode || !ibuf || (!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) || @@ -935,6 +940,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; } + BKE_image_release_ibuf(ima, ibuf, NULL); return; } @@ -959,6 +965,8 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; } } + + BKE_image_release_ibuf(ima, ibuf, NULL); } void GPU_update_images_framechange(void) diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index ef73764753c..497105d94ec 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1165,13 +1165,14 @@ static void do_material_tex(GPUShadeInput *shi) // resolve texture resolution if ( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) { - ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser); + ImBuf *ibuf= BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL); ima_x= 512.0f; ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only if (ibuf) { ima_x= ibuf->x; ima_y= ibuf->y; aspect = ((float) ima_y) / ima_x; } + BKE_image_release_ibuf(tex->ima, ibuf, NULL); } // The negate on norfac is done because the diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index f8af2427827..9fedbee41ff 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -113,7 +113,7 @@ static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); } - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); } static void rna_Image_free_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -187,8 +187,12 @@ static EnumPropertyItem *rna_Image_source_itemf(bContext *UNUSED(C), PointerRNA static int rna_Image_file_format_get(PointerRNA *ptr) { Image *image = (Image *)ptr->data; - ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); - return BKE_ftype_to_imtype(ibuf ? ibuf->ftype : 0); + ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); + int imtype = BKE_ftype_to_imtype(ibuf ? ibuf->ftype : 0); + + BKE_image_release_ibuf(image, ibuf, NULL); + + return imtype; } static void rna_Image_file_format_set(PointerRNA *ptr, int value) @@ -199,12 +203,13 @@ static void rna_Image_file_format_set(PointerRNA *ptr, int value) int ftype = BKE_imtype_to_ftype(value); #if 0 - ibuf = BKE_image_get_ibuf(image, NULL); + ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); if (ibuf) ibuf->ftype = ftype; #endif /* to be safe change all buffer file types */ + /* TODO: this is never threadsafe */ for (ibuf = image->ibufs.first; ibuf; ibuf = ibuf->next) { ibuf->ftype = ftype; } @@ -237,7 +242,7 @@ static void rna_Image_size_get(PointerRNA *ptr, int *values) values[1] = 0; } - BKE_image_release_ibuf(im, lock); + BKE_image_release_ibuf(im, ibuf, lock); } static void rna_Image_resolution_get(PointerRNA *ptr, float *values) @@ -256,7 +261,7 @@ static void rna_Image_resolution_get(PointerRNA *ptr, float *values) values[1] = 0; } - BKE_image_release_ibuf(im, lock); + BKE_image_release_ibuf(im, ibuf, lock); } static void rna_Image_resolution_set(PointerRNA *ptr, const float *values) @@ -271,7 +276,7 @@ static void rna_Image_resolution_set(PointerRNA *ptr, const float *values) ibuf->ppm[1] = values[1]; } - BKE_image_release_ibuf(im, lock); + BKE_image_release_ibuf(im, ibuf, lock); } static int rna_Image_depth_get(PointerRNA *ptr) @@ -290,7 +295,7 @@ static int rna_Image_depth_get(PointerRNA *ptr) else planes = ibuf->planes; - BKE_image_release_ibuf(im, lock); + BKE_image_release_ibuf(im, ibuf, lock); return planes; } @@ -317,7 +322,7 @@ static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY else length[0] = 0; - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); return length[0]; } @@ -343,7 +348,7 @@ static void rna_Image_pixels_get(PointerRNA *ptr, float *values) } } - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); } static void rna_Image_pixels_set(PointerRNA *ptr, const float *values) @@ -369,7 +374,7 @@ static void rna_Image_pixels_set(PointerRNA *ptr, const float *values) ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID; } - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); } #else diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index cb5c515ce1f..686e6c80f1d 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -99,7 +99,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports IMB_freeImBuf(write_ibuf); } - BKE_image_release_ibuf(image, lock); + BKE_image_release_ibuf(image, ibuf, lock); } else { BKE_report(reports, RPT_ERROR, "Scene not in context, could not get save parameters"); @@ -108,7 +108,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports static void rna_Image_save(Image *image, ReportList *reports) { - ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); if (ibuf) { char filename[FILE_MAX]; BLI_strncpy(filename, image->name, sizeof(filename)); @@ -136,11 +136,13 @@ static void rna_Image_save(Image *image, ReportList *reports) else { BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); } + + BKE_image_release_ibuf(image, ibuf, NULL); } static void rna_Image_pack(Image *image, ReportList *reports, int as_png) { - ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { BKE_report(reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG"); @@ -153,6 +155,8 @@ static void rna_Image_pack(Image *image, ReportList *reports, int as_png) image->packedfile = newPackedFile(reports, image->name, ID_BLEND_PATH(G.main, &image->id)); } } + + BKE_image_release_ibuf(image, ibuf, NULL); } static void rna_Image_unpack(Image *image, ReportList *reports, int method) @@ -177,7 +181,7 @@ static void rna_Image_reload(Image *image) static void rna_Image_update(Image *image, ReportList *reports) { - ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); if (ibuf == NULL) { BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); @@ -188,6 +192,8 @@ static void rna_Image_update(Image *image, ReportList *reports) IMB_rect_from_float(ibuf); ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + + BKE_image_release_ibuf(image, ibuf, NULL); } static void rna_Image_scale(Image *image, ReportList *reports, int width, int height) @@ -206,10 +212,11 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int if (*bind) return error; - ibuf = BKE_image_get_ibuf(image, NULL); + ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); if (ibuf == NULL || ibuf->rect == NULL) { BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); + BKE_image_release_ibuf(image, ibuf, NULL); return (int)GL_INVALID_OPERATION; } @@ -238,6 +245,8 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int image->bindcode = 0; } + BKE_image_release_ibuf(image, ibuf, NULL); + return error; } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 962a92223eb..caa81dafa0e 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -598,7 +598,7 @@ static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *UNUS alpha = ibuf && (ibuf->channels == 4); zbuf = ibuf && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1)); - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); if (alpha && zbuf) return draw_channels_items; @@ -678,7 +678,7 @@ static void rna_SpaceImageEditor_scopes_update(Main *UNUSED(bmain), Scene *scene scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); WM_main_add_notifier(NC_IMAGE, sima->image); } - ED_space_image_release_buffer(sima, lock); + ED_space_image_release_buffer(sima, ibuf, lock); } /* Space Text Editor */ diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 150382c1f8f..88d78df190f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -173,9 +173,10 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node) Image *ima= (Image *)node->id; if (ima) { ImageUser *iuser= node->storage; + ImBuf *ibuf; /* make sure ima->type is correct */ - BKE_image_get_ibuf(ima, iuser); + ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); if (ima->rr) { RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer); @@ -191,6 +192,8 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node) } else cmp_node_image_add_render_pass_outputs(ntree, node, RRES_OUT_IMAGE|RRES_OUT_ALPHA|RRES_OUT_Z); + + BKE_image_release_ibuf(ima, ibuf, NULL); } else cmp_node_image_add_render_pass_outputs(ntree, node, RRES_OUT_IMAGE|RRES_OUT_ALPHA); @@ -312,7 +315,7 @@ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) } /* note: this function is used for multilayer too, to ensure uniform - * handling with BKE_image_get_ibuf() */ + * handling with BKE_image_acquire_ibuf() */ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *iuser) { ImBuf *ibuf; @@ -322,7 +325,7 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i float *rect; int alloc= FALSE; - ibuf= BKE_image_get_ibuf(ima, iuser); + ibuf= BKE_image_acquire_ibuf(ima, iuser, NULL); if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) { return NULL; } @@ -374,12 +377,15 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i } } #endif + + BKE_image_release_ibuf(ima, ibuf, NULL); + return stackbuf; } static CompBuf *node_composit_get_zimage(bNode *node, RenderData *rd) { - ImBuf *ibuf= BKE_image_get_ibuf((Image *)node->id, node->storage); + ImBuf *ibuf= BKE_image_acquire_ibuf((Image *)node->id, node->storage, NULL); CompBuf *zbuf= NULL; if (ibuf && ibuf->zbuf_float) { @@ -391,6 +397,9 @@ static CompBuf *node_composit_get_zimage(bNode *node, RenderData *rd) zbuf->rect= ibuf->zbuf_float; } } + + BKE_image_release_ibuf((Image *)node->id, ibuf, NULL); + return zbuf; } @@ -418,13 +427,14 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE RenderData *rd= data; Image *ima= (Image *)node->id; ImageUser *iuser= (ImageUser *)node->storage; + ImBuf *ibuf = NULL; /* first set the right frame number in iuser */ BKE_image_user_frame_calc(iuser, rd->cfra, 0); /* force a load, we assume iuser index will be set OK anyway */ if (ima->type==IMA_TYPE_MULTILAYER) - BKE_image_get_ibuf(ima, iuser); + ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); if (ima->type==IMA_TYPE_MULTILAYER && ima->rr) { RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer); @@ -505,6 +515,8 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE generate_preview(data, node, stackbuf); } } + + BKE_image_release_ibuf(ima, ibuf, NULL); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index 73cf039c6df..81f2f9b05a9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -128,7 +128,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * composit3_pixel_processor(node, cbuf, buf1, in[0]->vec, buf2, in[1]->vec, mask, NULL, do_copy_split_rgba, CB_RGBA, CB_RGBA, CB_VAL); - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); generate_preview(data, node, cbuf); free_compbuf(cbuf); diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index 938f75cf3f5..b186a9aeaf9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -112,7 +112,7 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, free_compbuf(zbuf); } - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); generate_preview(data, node, cbuf); free_compbuf(cbuf); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index abe8e0190c8..d2d0870e2ed 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -75,12 +75,13 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod ret = GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser, isdata)); if (ret) { - ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && GPU_material_do_color_management(mat)) { GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); } + BKE_image_release_ibuf(ima, ibuf, NULL); } return ret; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index 9b17f76bd47..49b38434246 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -75,12 +75,13 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack ret = GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); if (ret) { - ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && GPU_material_do_color_management(mat)) { GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); } + BKE_image_release_ibuf(ima, ibuf, NULL); } return ret; diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index 6d1b3ff6dba..b77c7d07407 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -128,12 +128,13 @@ static int gpu_shader_texture(GPUMaterial *mat, bNode *node, GPUNodeStack *in, G int ret = GPU_stack_link(mat, "texture_image", in, out, texlink); if (ret) { - ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL); if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) ==0 && GPU_material_do_color_management(mat)) { GPU_link(mat, "srgb_to_linearrgb", out[1].link, &out[1].link); } + BKE_image_release_ibuf(tex->ima, ibuf, NULL); } return ret; diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index f3fdaf0bb64..2ef1669a266 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -46,7 +46,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i ImageUser *iuser= (ImageUser *)node->storage; if ( ima ) { - ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); if ( ibuf ) { float xsize, ysize; float xoff, yoff; @@ -77,6 +77,8 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i result = ibuf->rect_float + py*ibuf->x*4 + px*4; copy_v4_v4(out, result); + + BKE_image_release_ibuf(ima, ibuf, NULL); } } } diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 28f70211a9c..c3126e57b53 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -687,11 +687,12 @@ int envmaptex(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int o env->ima = tex->ima; if (env->ima && env->ima->ok) { if (env->cube[1] == NULL) { - ImBuf *ibuf_ima = BKE_image_get_ibuf(env->ima, NULL); + ImBuf *ibuf_ima = BKE_image_acquire_ibuf(env->ima, NULL, NULL); if (ibuf_ima) envmap_split_ima(env, ibuf_ima); else env->ok = 0; + BKE_image_release_ibuf(env->ima, ibuf_ima, NULL); } } } diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index db1454fd82f..cd06839b004 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -124,13 +124,16 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul /* hack for icon render */ if (ima->ibufs.first==NULL && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval; - - ibuf= BKE_image_get_ibuf(ima, &tex->iuser); + + ibuf= BKE_image_acquire_ibuf(ima, &tex->iuser, NULL); ima->flag|= IMA_USED_FOR_RENDER; } - if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) + if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; + } /* setup mapping */ if (tex->imaflag & TEX_IMAROT) { @@ -155,11 +158,17 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul /* pass */ } else { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; } } if ( (tex->flag & TEX_CHECKER_EVEN)==0) { - if ((xs+ys) & 1) return retval; + if ((xs+ys) & 1) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + return retval; + } } /* scale around center, (0.5, 0.5) */ if (tex->checkerdist<1.0f) { @@ -173,11 +182,15 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul if (tex->extend == TEX_CLIPCUBE) { if (x<0 || y<0 || x>=ibuf->x || y>=ibuf->y || texvec[2]<-1.0f || texvec[2]>1.0f) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; } } else if ( tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) { if (x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; } } @@ -287,6 +300,9 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul texres->tb*= fx; } + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + BRICONTRGB; return retval; @@ -1056,10 +1072,14 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (ima) { /* hack for icon render */ if ((ima->ibufs.first == NULL) && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval; - ibuf = BKE_image_get_ibuf(ima, &tex->iuser); + ibuf = BKE_image_acquire_ibuf(ima, &tex->iuser, NULL); } - if ((ibuf == NULL) || ((ibuf->rect == NULL) && (ibuf->rect_float == NULL))) return retval; + if ((ibuf == NULL) || ((ibuf->rect == NULL) && (ibuf->rect_float == NULL))) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + return retval; + } if (ima) { ima->flag |= IMA_USED_FOR_RENDER; @@ -1172,8 +1192,16 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex } } else { - if ((tex->flag & TEX_CHECKER_ODD) == 0 && ((xs + ys) & 1) == 0) return retval; - if ((tex->flag & TEX_CHECKER_EVEN) == 0 && (xs + ys) & 1) return retval; + if ((tex->flag & TEX_CHECKER_ODD) == 0 && ((xs + ys) & 1) == 0) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + return retval; + } + if ((tex->flag & TEX_CHECKER_EVEN) == 0 && (xs + ys) & 1) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + return retval; + } fx -= xs; fy -= ys; } @@ -1189,10 +1217,18 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex } if (tex->extend == TEX_CLIPCUBE) { - if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f || texvec[2] < -1.f || texvec[2] > 1.f) return retval; + if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f || texvec[2] < -1.f || texvec[2] > 1.f) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + return retval; + } } else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) { - if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f) return retval; + if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + return retval; + } } else { if (tex->extend == TEX_EXTEND) { @@ -1413,6 +1449,9 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex texres->tb *= fx; } + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + BRICONTRGB; return retval; @@ -1449,12 +1488,15 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const if (ima->ibufs.first==NULL && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval; - ibuf= BKE_image_get_ibuf(ima, &tex->iuser); + ibuf= BKE_image_acquire_ibuf(ima, &tex->iuser, NULL); ima->flag|= IMA_USED_FOR_RENDER; } - if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) + if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; + } /* mipmap test */ image_mipmap_test(tex, ibuf); @@ -1565,11 +1607,15 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const /* pass */ } else { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; } } if ( (tex->flag & TEX_CHECKER_EVEN)==0) { if ((xs + ys) & 1) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; } } @@ -1605,11 +1651,15 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const if (tex->extend == TEX_CLIPCUBE) { if (fx+minx<0.0f || fy+miny<0.0f || fx-minx>1.0f || fy-miny>1.0f || texvec[2]<-1.0f || texvec[2]>1.0f) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; } } else if (tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) { if (fx+minx<0.0f || fy+miny<0.0f || fx-minx>1.0f || fy-miny>1.0f) { + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); return retval; } } @@ -1804,6 +1854,9 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const mul_v3_fl(&texres->tr, 1.0f / texres->ta); } + if (ima) + BKE_image_release_ibuf(ima, ibuf, NULL); + BRICONTRGB; return retval; @@ -1812,7 +1865,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const void image_sample(Image *ima, float fx, float fy, float dx, float dy, float result[4]) { TexResult texres; - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, NULL); if (UNLIKELY(ibuf == NULL)) { zero_v4(result); @@ -1830,6 +1883,8 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float resu ibuf->rect-= (ibuf->x*ibuf->y); ima->flag|= IMA_USED_FOR_RENDER; + + BKE_image_release_ibuf(ima, ibuf, NULL); } void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float result[4]) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index f2549f04659..1b237d61e81 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -63,6 +63,7 @@ #include "BLI_string.h" #include "BLI_path_util.h" #include "BLI_fileops.h" +#include "BLI_threads.h" #include "BLI_rand.h" #include "BLI_callbacks.h" diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index c507d6595e0..e6daa5f9094 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1233,11 +1233,13 @@ int multitex_nodes(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int os rgbnor = multitex(tex, texvec, dxt, dyt, osatex, texres, thread, which_output); if (mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { - ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL); /* don't linearize float buffers, assumed to be linear */ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage) IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace); + + BKE_image_release_ibuf(tex->ima, ibuf, NULL); } } else { @@ -1264,11 +1266,13 @@ int multitex_nodes(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int os rgbnor= multitex(tex, texvec_l, dxt_l, dyt_l, osatex, texres, thread, which_output); { - ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL); /* don't linearize float buffers, assumed to be linear */ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage) IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace); + + BKE_image_release_ibuf(tex->ima, ibuf, NULL); } } @@ -1723,11 +1727,12 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, if (!shi->osatex && (tex->type == TEX_IMAGE) && tex->ima) { /* in case we have no proper derivatives, fall back to * computing du/dv it based on image size */ - ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL); if (ibuf) { du = 1.f/(float)ibuf->x; dv = 1.f/(float)ibuf->y; } + BKE_image_release_ibuf(tex->ima, ibuf, NULL); } else if (shi->osatex) { /* we have derivatives, can compute proper du/dv */ @@ -1900,12 +1905,13 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T /* resolve image dimensions */ if (found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) { - ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL); if (ibuf) { dimx = ibuf->x; dimy = ibuf->y; aspect = ((float) dimy) / dimx; } + BKE_image_release_ibuf(tex->ima, ibuf, NULL); } if (found_deriv_map) { @@ -2396,11 +2402,13 @@ void do_material_tex(ShadeInput *shi, Render *re) /* inverse gamma correction */ if (tex->type==TEX_IMAGE) { Image *ima = tex->ima; - ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &tex->iuser, NULL); /* don't linearize float buffers, assumed to be linear */ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage) IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace); + + BKE_image_release_ibuf(ima, ibuf, NULL); } if (mtex->mapto & MAP_COL) { @@ -2928,11 +2936,13 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) /* inverse gamma correction */ if (mtex->tex->type==TEX_IMAGE) { Image *ima = mtex->tex->ima; - ImBuf *ibuf = BKE_image_get_ibuf(ima, &mtex->tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &mtex->tex->iuser, NULL); /* don't linearize float buffers, assumed to be linear */ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage) IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace); + + BKE_image_release_ibuf(ima, ibuf, NULL); } fact= texres.tin*mtex->colfac; @@ -3147,11 +3157,13 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h /* inverse gamma correction */ if (tex->type==TEX_IMAGE) { Image *ima = tex->ima; - ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &tex->iuser, NULL); /* don't linearize float buffers, assumed to be linear */ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage) IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace); + + BKE_image_release_ibuf(ima, ibuf, NULL); } if (mtex->mapto & WOMAP_HORIZ) { @@ -3361,11 +3373,13 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r /* inverse gamma correction */ if (tex->type==TEX_IMAGE) { Image *ima = tex->ima; - ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &tex->iuser, NULL); /* don't linearize float buffers, assumed to be linear */ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage) IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace); + + BKE_image_release_ibuf(ima, ibuf, NULL); } /* lamp colors were premultiplied with this */ diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 9fe2620747c..3431c3ff5de 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2506,21 +2506,26 @@ static int get_next_bake_face(BakeShade *bs) if (tface && tface->tpage) { Image *ima= tface->tpage; - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, NULL); const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; if (ibuf==NULL) continue; - if (ibuf->rect==NULL && ibuf->rect_float==NULL) + if (ibuf->rect==NULL && ibuf->rect_float==NULL) { + BKE_image_release_ibuf(ima, ibuf, NULL); continue; + } - if (ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4)) + if (ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4)) { + BKE_image_release_ibuf(ima, ibuf, NULL); continue; + } if (ima->flag & IMA_USED_FOR_RENDER) { ima->id.flag &= ~LIB_DOIT; + BKE_image_release_ibuf(ima, ibuf, NULL); continue; } @@ -2548,6 +2553,9 @@ static int get_next_bake_face(BakeShade *bs) v++; BLI_unlock_thread(LOCK_CUSTOM1); + + BKE_image_release_ibuf(ima, ibuf, NULL); + return 1; } } @@ -2571,8 +2579,10 @@ static void shade_tface(BakeShade *bs) /* check valid zspan */ if (ima!=bs->ima) { + BKE_image_release_ibuf(bs->ima, bs->ibuf, NULL); + bs->ima= ima; - bs->ibuf= BKE_image_get_ibuf(ima, NULL); + bs->ibuf= BKE_image_acquire_ibuf(ima, NULL, NULL); /* note, these calls only free/fill contents of zspan struct, not zspan itself */ zbuf_free_span(bs->zspan); zbuf_alloc_span(bs->zspan, bs->ibuf->x, bs->ibuf->y, R.clipcrop); @@ -2638,7 +2648,9 @@ static void *do_bake_thread(void *bs_v) *bs->do_update= TRUE; } bs->ready= 1; - + + BKE_image_release_ibuf(bs->ima, bs->ibuf, NULL); + return NULL; } @@ -2689,12 +2701,13 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up /* baker uses this flag to detect if image was initialized */ for (ima= G.main->image.first; ima; ima= ima->id.next) { - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, NULL); ima->id.flag |= LIB_DOIT; ima->flag&= ~IMA_USED_FOR_RENDER; if (ibuf) { ibuf->userdata = NULL; /* use for masking if needed */ } + BKE_image_release_ibuf(ima, ibuf, NULL); } BLI_init_threads(&threads, do_bake_thread, re->r.threads); @@ -2747,7 +2760,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up /* filter and refresh images */ for (ima= G.main->image.first; ima; ima= ima->id.next) { if ((ima->id.flag & LIB_DOIT)==0) { - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, NULL); if (ima->flag & IMA_USED_FOR_RENDER) result= BAKE_RESULT_FEEDBACK_LOOP; @@ -2758,6 +2771,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, re->r.bake_filter); ibuf->userflags |= IB_BITMAPDIRTY; + BKE_image_release_ibuf(ima, ibuf, NULL); } } diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 42849a01971..77d6644479a 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -157,10 +157,10 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) /* find the first valid ibuf and use it to initialize the resolution of the data set */ /* need to do this in advance so we know how much memory to allocate */ - ibuf = BKE_image_get_ibuf(ima, &iuser); + ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL); while (!ibuf && (iuser.framenr < iuser.frames)) { iuser.framenr++; - ibuf = BKE_image_get_ibuf(ima, &iuser); + ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL); } if (!ibuf) return; if (!ibuf->rect_float) IMB_float_from_rect(ibuf); @@ -175,7 +175,8 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) /* get a new ibuf for each frame */ if (z > 0) { iuser.framenr++; - ibuf = BKE_image_get_ibuf(ima, &iuser); + BKE_image_release_ibuf(ima, ibuf, NULL); + ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL); if (!ibuf) break; if (!ibuf->rect_float) IMB_float_from_rect(ibuf); } @@ -191,7 +192,9 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) BKE_image_free_anim_ibufs(ima, iuser.framenr); } - + + BKE_image_release_ibuf(ima, ibuf, NULL); + vd->ok = 1; return; } diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 96bbedfee1b..fba45065fbe 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -61,6 +61,7 @@ #include "BKE_blender.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -1082,6 +1083,7 @@ void WM_main_playanim(int argc, const char **argv) /* we still miss freeing a lot!, * but many areas could skip initialization too for anim play */ IMB_exit(); + BKE_images_exit(); BLF_exit(); #endif GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window); diff --git a/source/creator/creator.c b/source/creator/creator.c index ca3deaf70a4..fc2f555227f 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1270,6 +1270,7 @@ int main(int argc, const char **argv) initglobals(); /* blender.c */ IMB_init(); + BKE_images_init(); #ifdef WITH_FFMPEG IMB_ffmpeg_init(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 3e8755c41ce..4451c78b99c 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -60,6 +60,7 @@ extern "C" #include "BKE_blender.h" #include "BKE_global.h" #include "BKE_icons.h" +#include "BKE_image.h" #include "BKE_node.h" #include "BKE_report.h" #include "BKE_library.h" @@ -446,6 +447,7 @@ int main(int argc, char** argv) G.main = NULL; IMB_init(); + BKE_images_init(); // Setup builtin font for BLF (mostly copied from creator.c, wm_init_exit.c and interface_style.c) BLF_init(11, U.dpi); @@ -1067,6 +1069,7 @@ int main(int argc, char** argv) #endif IMB_exit(); + BKE_images_exit(); free_nodesystem(); SYS_DeleteSystem(syshandle); diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 26523df8db3..66423ed820e 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -109,7 +109,7 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) return mOk; } - ibuf= BKE_image_get_ibuf(img, NULL); + ibuf= BKE_image_acquire_ibuf(img, NULL, NULL); if (ibuf==NULL) { img->ok = 0; @@ -128,6 +128,7 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) if (mTexture != 0) { glBindTexture(GL_TEXTURE_2D, mTexture ); Validate(); + BKE_image_release_ibuf(img, ibuf, NULL); return mOk; } @@ -140,6 +141,7 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) mTexture = mapLook->second.gl_texture; glBindTexture(GL_TEXTURE_2D, mTexture); mOk = IsValid(); + BKE_image_release_ibuf(img, ibuf, NULL); return mOk; } } @@ -166,6 +168,9 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) glDisable(GL_TEXTURE_2D); ActivateUnit(0); Validate(); + + BKE_image_release_ibuf(img, ibuf, NULL); + return mOk; } @@ -251,7 +256,7 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) return mOk; } - ImBuf *ibuf= BKE_image_get_ibuf(cubemap->ima, NULL); + ImBuf *ibuf= BKE_image_acquire_ibuf(cubemap->ima, NULL, NULL); if (ibuf==0) { cubemap->ima->ok = 0; @@ -274,6 +279,7 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) mTexture = mapLook->second.gl_texture; glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mTexture); mOk = IsValid(); + BKE_image_release_ibuf(cubemap->ima, ibuf, NULL); return mOk; } } @@ -307,6 +313,7 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) my_free_envmapdata(cubemap); mOk = false; + BKE_image_release_ibuf(cubemap->ima, ibuf, NULL); return mOk; } @@ -341,6 +348,9 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) ActivateUnit(0); mOk = IsValid(); + + BKE_image_release_ibuf(cubemap->ima, ibuf, NULL); + return mOk; } @@ -646,9 +656,11 @@ int BL_Texture::GetPow2(int n) void BL_Texture::SplitEnvMap(EnvMap *map) { if (!map || !map->ima || (map->ima && !map->ima->ok)) return; - ImBuf *ibuf= BKE_image_get_ibuf(map->ima, NULL); - if (ibuf) + ImBuf *ibuf= BKE_image_acquire_ibuf(map->ima, NULL, NULL); + if (ibuf) { my_envmap_split_ima(map, ibuf); + BKE_image_release_ibuf(map->ima, ibuf, NULL); + } } unsigned int BL_Texture::mDisableState = 0; From 1c9b548d92e8a76ac0a3c730bff5634d4628e971 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 15 Nov 2012 16:34:22 +0000 Subject: [PATCH 033/115] Windows / Scons OSL: * Initial support, still commented. --- build_files/scons/config/win32-vc-config.py | 13 +++++++++++++ build_files/scons/config/win64-vc-config.py | 13 +++++++++++++ intern/cycles/kernel/shaders/SConscript | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index a2b76bbed88..be30053c314 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -150,6 +150,19 @@ WITH_BF_OPENMP = True #Cycles WITH_BF_CYCLES = True +#OSL +''' +WITH_BF_CYCLES_OSL = True +WITH_BF_STATICOSL = True +BF_OSL = LIBDIR + '/osl' +BF_OSL_INC = '${BF_OSL}/include' +# note oslexec would passed via program linkflags, which is needed to +# make llvm happy with osl_allocate_closure_component +BF_OSL_LIB = 'oslcomp oslexec oslquery' +BF_OSL_LIBPATH = '${BF_OSL}/lib' +BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' +''' + WITH_BF_OIIO = True BF_OIIO = '${LIBDIR}/openimageio' BF_OIIO_INC = '${BF_OIIO}/include' diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index a0c37f0b73f..8d49e178ddb 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -146,6 +146,19 @@ WITH_BF_OPENMP = True #Cycles WITH_BF_CYCLES = True +#OSL +''' +WITH_BF_CYCLES_OSL = True +WITH_BF_STATICOSL = True +BF_OSL = LIBDIR + '/osl' +BF_OSL_INC = '${BF_OSL}/include' +# note oslexec would passed via program linkflags, which is needed to +# make llvm happy with osl_allocate_closure_component +BF_OSL_LIB = 'oslcomp oslexec oslquery' +BF_OSL_LIBPATH = '${BF_OSL}/lib' +BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' +''' + WITH_BF_OIIO = True BF_OIIO = '${LIBDIR}/openimageio' BF_OIIO_INC = '${BF_OIIO}/include' diff --git a/intern/cycles/kernel/shaders/SConscript b/intern/cycles/kernel/shaders/SConscript index 8dfd5a304f3..924aff4fc22 100644 --- a/intern/cycles/kernel/shaders/SConscript +++ b/intern/cycles/kernel/shaders/SConscript @@ -13,7 +13,7 @@ oso_files = [] if env['WITH_BF_CYCLES_OSL']: shaders = env.Clone() - # cuda info + # osl compiler info osl_compiler = env['BF_OSL_COMPILER'] # build directory From 2324c80f50f9cb95435b66ea370d38fd9617760b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Nov 2012 17:16:27 +0000 Subject: [PATCH 034/115] Cycles OSL: windows build system changes to support static OSL/OIIO. --- CMakeLists.txt | 11 +++++++++-- SConstruct | 4 +++- build_files/cmake/macros.cmake | 6 +++++- build_files/scons/config/win32-vc-config.py | 2 +- intern/cycles/blender/addon/osl.py | 7 ++++--- intern/cycles/kernel/shaders/CMakeLists.txt | 2 +- source/creator/CMakeLists.txt | 20 +++----------------- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70a75773d16..45bc7a6d2fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,7 +403,7 @@ if(WITH_CYCLES OR WITH_MOD_BOOLEAN OR WITH_AUDASPACE OR WITH_INTERNATIONAL) endif() # auto enable llvm for cycles_osl -if(WITH_CYCLES_OSL AND NOT WIN32) +if(WITH_CYCLES_OSL) set(WITH_LLVM ON CACHE BOOL "ON" FORCE) endif() @@ -942,6 +942,13 @@ elseif(WIN32) endif() endif() + if(WITH_LLVM) + set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") + file(GLOB LLVM_LIBRARY ${LLVM_DIRECTORY}/lib/*.lib) + set(LLVM_STATIC YES) + endif() + + if(MSVC) set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid) @@ -1675,7 +1682,7 @@ if(WITH_CYCLES) message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES") endif() - if(WITH_CYCLES_OSL AND NOT WIN32) + if(WITH_CYCLES_OSL) if(NOT WITH_LLVM) message(FATAL_ERROR "Cycles OSL reqires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL") endif() diff --git a/SConstruct b/SConstruct index 5e31fce00a4..bda361a0a9d 100644 --- a/SConstruct +++ b/SConstruct @@ -887,7 +887,9 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'): dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll') if env['WITH_BF_OIIO'] and env['OURPLATFORM'] != 'win32-mingw': - dllsources.append('${LCGDIR}/openimageio/bin/OpenImageIO.dll') + dllpath = '${LCGDIR}/openimageio/bin/OpenImageIO.dll' + if os.path.exists(env.subst(dllpath)): + dllsources.append(dllpath) if env['WITH_BF_OCIO']: if not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'): diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 2d9de5a5792..4f1d34f993c 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -700,7 +700,11 @@ macro(delayed_install destination) foreach(f ${files}) - set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${base}/${f}) + if(IS_ABSOLUTE ${f}) + set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${f}) + else() + set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${base}/${f}) + endif() set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_DESTINATIONS ${destination}) endforeach() endmacro() diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index be30053c314..74ae186d54b 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -217,7 +217,7 @@ C_WARN = [] CC_WARN = [] CXX_WARN = [] -LLIBS = ['ws2_32', 'vfw32', 'winmm', 'kernel32', 'user32', 'gdi32', 'comdlg32', 'advapi32', 'shfolder', 'shell32', 'ole32', 'oleaut32', 'uuid'] +LLIBS = ['ws2_32', 'vfw32', 'winmm', 'kernel32', 'user32', 'gdi32', 'comdlg32', 'advapi32', 'shfolder', 'shell32', 'ole32', 'oleaut32', 'uuid', 'psapi'] PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:IX86','/STACK:2097152','/INCREMENTAL:NO', '/LARGEADDRESSAWARE', '/NODEFAULTLIB:msvcrt.lib', '/NODEFAULTLIB:msvcmrt.lib', '/NODEFAULTLIB:msvcurt.lib', '/NODEFAULTLIB:msvcrtd.lib'] diff --git a/intern/cycles/blender/addon/osl.py b/intern/cycles/blender/addon/osl.py index aac1e2422b9..79ce3df20c3 100644 --- a/intern/cycles/blender/addon/osl.py +++ b/intern/cycles/blender/addon/osl.py @@ -79,12 +79,13 @@ def update_script_node(node, report): if script.is_in_memory or script.is_dirty or script.is_modified or not os.path.exists(osl_path): # write text datablock contents to temporary file - osl_file = tempfile.NamedTemporaryFile(mode='w', suffix=".osl", delete=True) + osl_file = tempfile.NamedTemporaryFile(mode='w', suffix=".osl", delete=False) osl_file.write(script.as_string()) - osl_file.flush() + osl_file.close() + ok, oso_path = osl_compile(osl_file.name, report) oso_file_remove = False - osl_file.close() + os.remove(osl_file.name) else: # compile text datablock from disk directly ok, oso_path = osl_compile(osl_path, report) diff --git a/intern/cycles/kernel/shaders/CMakeLists.txt b/intern/cycles/kernel/shaders/CMakeLists.txt index 4f5a97c1bb6..f7fec62fd6d 100644 --- a/intern/cycles/kernel/shaders/CMakeLists.txt +++ b/intern/cycles/kernel/shaders/CMakeLists.txt @@ -89,7 +89,7 @@ foreach(_file ${SRC_OSL}) list(APPEND SRC_OSO ${_OSO_FILE} ) - + unset(_OSL_FILE) unset(_OSO_FILE) endforeach() diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index b61466e8fe2..4d1620a8bb8 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -621,11 +621,11 @@ elseif(WIN32) ) if(WITH_OPENIMAGEIO) - if(NOT MINGW) - set(OIIOBIN ${LIBDIR}/openimageio/bin) + set(OIIODLL ${LIBDIR}/openimageio/bin/OpenImageIO.dll) + if(NOT MINGW AND EXISTS ${OIIODLL}) install( FILES - ${OIIOBIN}/OpenImageIO.dll + ${OIIODLL} DESTINATION ${TARGETDIR} ) endif() @@ -648,20 +648,6 @@ elseif(WIN32) endif() endif() - if(WITH_CYCLES AND WITH_CYCLES_OSL) - if(NOT MINGW) - set(OSLBIN ${LIBDIR}/osl/bin) - install( - FILES - ${OSLBIN}/oslexec.dll - ${OSLBIN}/oslquery.dll - ${OSLBIN}/oslcomp.dll - DESTINATION ${TARGETDIR} - ) - endif() - endif() - - elseif(APPLE) # handy install macro to exclude files, we use \$ escape for the "to" From 7d6417bbb3e304d9e7aaa61b6731ecafc3329d4e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 15 Nov 2012 17:31:18 +0000 Subject: [PATCH 035/115] Another nuch of fixes/improvements to install_deps script, among which: *New $INST variable to easily change the installation root dir of compiled libs. *Better handling of versions for debian (DEB) too (and fix a bug for fedora (RPM) ones). *Enhancements/fixes to compile_FOO funcs: **Most notable, we now can force a recompile when we change something into these funcs, so user will always have latest-instructions compiled libs (else, he would have have to manually remove lib dirs under $INST...) *General naming cleanup inside script (still wip). Also adding boost date_time lib to linux in cmake file (why wasn't it there???). --- CMakeLists.txt | 2 +- build_files/build_environment/install_deps.sh | 530 ++++++++++++------ 2 files changed, 351 insertions(+), 181 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45bc7a6d2fe..75401edbd93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -661,7 +661,7 @@ if(UNIX AND NOT APPLE) else() set(Boost_USE_MULTITHREADED ON) endif() - set(__boost_packages filesystem regex system thread) + set(__boost_packages filesystem regex system thread date_time) if (WITH_INTERNATIONAL) list(APPEND __boost_packages locale) endif() diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index bf738dfe1fc..72211a52e72 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -2,25 +2,58 @@ DISTRO="" SRC="$HOME/src/blender-deps" +INST="/opt/lib" CWD=$PWD THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"` PYTHON_VERSION="3.3.0" -BOOST_VERSION="1_51_0" -OIIO_VERSION="1.1.0" +PYTHON_VERSION_MIN="3.3" +PYTHON_SOURCE="http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.bz2" + +BOOST_VERSION="1.51.0" +_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'` +BOOST_SOURCE="http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download" +BOOST_VERSION_MIN="1.49" + OCIO_VERSION="1.0.7" +OCIO_SOURCE="https://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION" +OCIO_VERSION_MIN="1.0" + +OIIO_VERSION="1.1.0" +OIIO_SOURCE="https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_VERSION" +OIIO_VERSION_MIN="1.1" + +LLVM_VERSION="3.1" +LLVM_VERSION_MIN="3.0" + +# OSL needs to be compiled for now! +OSL_VERSION="1.2.0" +OSL_SOURCE="https://github.com/DingTo/OpenShadingLanguage/archive/blender-fixes.zip" + FFMPEG_VERSION="1.0" +FFMPEG_SOURCE="http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" +FFMPEG_VERSION_MIN="0.7.6" _ffmpeg_list_sep=";" -# XXX Looks like ubuntu has libxvidcore4-dev, while debian has libxvidcore-dev... -HASXVID=false -XVIDDEV="" -HASVPX=false -HASMP3LAME=false -HASX264=false -HASOPENJPEG=false -HASSCHRO=false +# FFMPEG optional libs. +VORBIS_USE=false +VORBIS_DEV="" +SCHRO_USE=false +SCRHO_DEV="" +THEORA_USE=false +THEORA_DEV="" +XVID_USE=false +XVID_DEV="" +X264_USE=false +X264_DEV="" +VPX_USE=false +VPX_VERSION_MIN=0.9.7 +VPX_DEV="" +MP3LAME_USE=false +MP3LAME_DEV="" +OPENJPEG_USE=false +OPENJPEG_DEV="" # Switch to english language, else some things (like check_package_DEB()) won't work! LANG_BACK=$LANG @@ -35,17 +68,17 @@ INFO() { echo "${@}" } -# Return 1 if $1 >= $2, else 0. +# Return 0 if $1 >= $2, else 1. # $1 and $2 should be version numbers made of numbers only. version_ge() { if [ $(echo -e "$1\n$2" | sort --version-sort | head --lines=1) = "$1" ]; then - return 0 - else return 1 + else + return 0 fi } -# Return 1 if $1 is into $2 (e.g. 3.3.2 is into 3.3, but not 3.3.0 or 3.3.5) +# Return 0 if $1 is into $2 (e.g. 3.3.2 is into 3.3, but not 3.3.0 or 3.3.5), else 1. # $1 and $2 should be version numbers made of numbers only. # $1 should be at least as long as $2! version_match() { @@ -56,16 +89,16 @@ version_match() { arr1=( $1 ) arr2=( $2 ) - ret=0 + ret=1 count1=${#arr1[@]} count2=${#arr2[@]} if [ $count1 -ge $count2 ]; then - ret=1 + ret=0 for (( i=0; $i < $count2; i++ )) do if [ $(( 10#${arr1[$i]} )) -ne $(( 10#${arr2[$i]} )) ]; then - ret=0 + ret=1 break fi done @@ -86,21 +119,44 @@ detect_distro() { } prepare_opt() { - INFO "Ensuring /opt/lib exists and writable by us" - sudo mkdir -p /opt/lib - sudo chown $USER /opt/lib - sudo chmod 775 /opt/lib + INFO "Ensuring $INST exists and is writable by us" + sudo mkdir -p $INST + sudo chown $USER $INST + sudo chmod 775 $INST +} + +# Check whether the current package needs to be recompiled, based on a dummy file containing a magic number in its name... +magic_compile_check() { + if [ -f $INST/.$1-magiccheck-$2 ]; then + return 0 + else + return 1 + fi +} + +magic_compile_set() { + rm -f $INST/.$1-magiccheck-* + touch $INST/.$1-magiccheck-$2 } compile_Python() { - if [ ! -d /opt/lib/python-$PYTHON_VERSION ]; then + # To be changed each time we make edits that would modify the compiled result! + py_magic=0 + + # Clean install if needed! + magic_compile_check python-$PYTHON_VERSION $py_magic + if [ $? -eq 1 ]; then + rm -rf $INST/python-$PYTHON_VERSION + fi + + if [ ! -d $INST/python-$PYTHON_VERSION ]; then INFO "Building Python-$PYTHON_VERSION" prepare_opt if [ ! -d $SRC/Python-$PYTHON_VERSION ]; then mkdir -p $SRC - wget -c http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.bz2 -P $SRC + wget -c $PYTHON_SOURCE -P $SRC INFO "Unpacking Python-$PYTHON_VERSION" tar -C $SRC -xf $SRC/Python-$PYTHON_VERSION.tar.bz2 @@ -108,7 +164,7 @@ compile_Python() { cd $SRC/Python-$PYTHON_VERSION - ./configure --prefix=/opt/lib/python-$PYTHON_VERSION --enable-ipv6 \ + ./configure --prefix=$INST/python-$PYTHON_VERSION --enable-ipv6 \ --enable-loadable-sqlite-extensions --with-dbmliborder=bdb \ --with-computed-gotos --with-pymalloc @@ -116,61 +172,88 @@ compile_Python() { make install make clean - rm -f /opt/lib/python-3.3 - ln -s python-$PYTHON_VERSION /opt/lib/python-3.3 + rm -f $INST/python-3.3 + ln -s python-$PYTHON_VERSION $INST/python-3.3 + + magic_compile_set python-$PYTHON_VERSION $py_magic cd $CWD + else + INFO "Own Python-$PYTHON_VERSION is up to date, nothing to do!" fi } compile_Boost() { - INFO "Building boost" + # To be changed each time we make edits that would modify the compiled result! + boost_magic=7 - version_dots=`echo "$BOOST_VERSION" | sed -r 's/_/./g'` + # Clean install if needed! + magic_compile_check boost-$BOOST_VERSION $boost_magic + if [ $? -eq 1 ]; then + rm -rf $INST/boost-$BOOST_VERSION + fi - if [ ! -d /opt/lib/boost-$version_dots ]; then - INFO "Building Boost-$version_dots" + if [ ! -d $INST/boost-$BOOST_VERSION ]; then + INFO "Building Boost-$BOOST_VERSION" prepare_opt - if [ ! -d $SRC/boost_$BOOST_VERSION ]; then - INFO "Downloading Boost-$version_dots" + if [ ! -d $SRC/boost-$BOOST_VERSION ]; then + INFO "Downloading Boost-$BOOST_VERSION" mkdir -p $SRC - wget -c http://sourceforge.net/projects/boost/files/boost/$version_dots/boost_$BOOST_VERSION.tar.bz2/download \ - -O $SRC/boost_$BOOST_VERSION.tar.bz2 - tar -C $SRC -xf $SRC/boost_$BOOST_VERSION.tar.bz2 + wget -c $BOOST_SOURCE -O $SRC/boost-$BOOST_VERSION.tar.bz2 + tar -C $SRC --transform "s,(.*/?)boost_1_[^/]+(.*),\1boost-$BOOST_VERSION\2,x" -xf $SRC/boost-$BOOST_VERSION.tar.bz2 fi - cd $SRC/boost_$BOOST_VERSION - ./bootstrap.sh --with-libraries=system,filesystem,thread,regex,locale,date-time --prefix=/opt/lib/boost-$version_dots - ./b2 install + cd $SRC/boost-$BOOST_VERSION + if [ ! -f $SRC/boost-$BOOST_VERSION/b2 ]; then + ./bootstrap.sh + fi + ./b2 -j$THREADS -a --with-system --with_filesystem --with-thread --with-regex --with-locale --with-date_time \ + --prefix=$INST/boost-$BOOST_VERSION --disable-icu boost.locale.icu=off install ./b2 --clean - rm -f /opt/lib/boost - ln -s boost-$version_dots /opt/lib/boost + rm -f $INST/boost + ln -s boost-$BOOST_VERSION $INST/boost + + magic_compile_set boost-$BOOST_VERSION $boost_magic cd $CWD + else + INFO "Own Boost-$BOOST_VERSION is up to date, nothing to do!" fi } compile_OCIO() { - if [ ! -d /opt/lib/ocio-$OCIO_VERSION ]; then + # To be changed each time we make edits that would modify the compiled result! + ocio_magic=1 + + # Clean install if needed! + magic_compile_check ocio-$OCIO_VERSION $ocio_magic + if [ $? -eq 1 ]; then + rm -rf $INST/ocio-$OCIO_VERSION + fi + + if [ ! -d $INST/ocio-$OCIO_VERSION ]; then INFO "Building OpenColorIO-$OCIO_VERSION" prepare_opt if [ ! -d $SRC/OpenColorIO-$OCIO_VERSION ]; then - INFO "Downloading OpenColorIO-$OCIO_VERSION" - mkdir -p $SRC - wget -c http://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION \ - -O $SRC/OpenColorIO-$OCIO_VERSION.tar.gz + INFO "Downloading OpenColorIO-$OCIO_VERSION" + mkdir -p $SRC + wget -c $OCIO_SOURCE -O $SRC/OpenColorIO-$OCIO_VERSION.tar.gz - INFO "Unpacking OpenColorIO-$OCIO_VERSION" - tar -C "$SRC" -xf $SRC/OpenColorIO-$OCIO_VERSION.tar.gz - mv $SRC/imageworks-OpenColorIO* $SRC/OpenColorIO-$OCIO_VERSION + INFO "Unpacking OpenColorIO-$OCIO_VERSION" + tar -C $SRC --transform "s,(.*/?)imageworks-OpenColorIO[^/]*(.*),\1OpenColorIO-$OCIO_VERSION\2,x" \ + -xf $SRC/OpenColorIO-$OCIO_VERSION.tar.gz fi cd $SRC/OpenColorIO-$OCIO_VERSION + # Always refresh the whole build! + if [ -d build ]; then + rm -rf build + fi mkdir build cd build @@ -181,8 +264,8 @@ compile_OCIO() { fi cmake -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_PREFIX_PATH=/opt/lib/ocio-$OCIO_VERSION \ - -D CMAKE_INSTALL_PREFIX=/opt/lib/ocio-$OCIO_VERSION \ + -D CMAKE_PREFIX_PATH=$INST/ocio-$OCIO_VERSION \ + -D CMAKE_INSTALL_PREFIX=$INST/ocio-$OCIO_VERSION \ -D CMAKE_CXX_FLAGS="$cflags" \ -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \ .. @@ -190,43 +273,59 @@ compile_OCIO() { make -j$THREADS make install - # Force linking against sttaic libs - rm -f /opt/lib/ocio-$OCIO_VERSION/lib/*.so* + # Force linking against static libs + rm -f $INST/ocio-$OCIO_VERSION/lib/*.so* # Additional depencencies - cp ext/dist/lib/libtinyxml.a /opt/lib/ocio-$OCIO_VERSION/lib - cp ext/dist/lib/libyaml-cpp.a /opt/lib/ocio-$OCIO_VERSION/lib + cp ext/dist/lib/libtinyxml.a $INST/ocio-$OCIO_VERSION/lib + cp ext/dist/lib/libyaml-cpp.a $INST/ocio-$OCIO_VERSION/lib make clean - rm -f /opt/lib/ocio - ln -s ocio-$OCIO_VERSION /opt/lib/ocio + rm -f $INST/ocio + ln -s ocio-$OCIO_VERSION $INST/ocio + + magic_compile_set ocio-$OCIO_VERSION $ocio_magic cd $CWD + else + INFO "Own OpenColorIO-$OCIO_VERSION is up to date, nothing to do!" fi } compile_OIIO() { - if [ ! -d /opt/lib/oiio-$OIIO_VERSION ]; then + # To be changed each time we make edits that would modify the compiled result! + oiio_magic=1 + + # Clean install if needed! + magic_compile_check oiio-$OIIO_VERSION $oiio_magic + if [ $? -eq 1 ]; then + rm -rf $INST/oiio-$OIIO_VERSION + fi + + if [ ! -d $INST/oiio-$OIIO_VERSION ]; then INFO "Building OpenImageIO-$OIIO_VERSION" prepare_opt if [ ! -d $SRC/OpenImageIO-$OIIO_VERSION ]; then - wget -c https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_VERSION \ - -O "$SRC/OpenImageIO-$OIIO_VERSION.tar.gz" + wget -c $OIIO_SOURCE -O "$SRC/OpenImageIO-$OIIO_VERSION.tar.gz" INFO "Unpacking OpenImageIO-$OIIO_VERSION" - tar -C $SRC -xf $SRC/OpenImageIO-$OIIO_VERSION.tar.gz - mv $SRC/OpenImageIO-oiio* $SRC/OpenImageIO-$OIIO_VERSION + tar -C $SRC --transform "s,(.*/?)OpenImageIO-oiio[^/]*(.*),\1OpenImageIO-$OIIO_VERSION\2,x" \ + -xf $SRC/OpenImageIO-$OIIO_VERSION.tar.gz fi cd $SRC/OpenImageIO-$OIIO_VERSION + # Always refresh the whole build! + if [ -d build ]; then + rm -rf build + fi mkdir build cd build - if [ -d /opt/lib/boost ]; then - boost_root="/opt/lib/boost" + if [ -d $INST/boost ]; then + boost_root="$INST/boost" else boost_root="/usr" fi @@ -238,36 +337,49 @@ compile_OIIO() { fi cmake -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_PREFIX_PATH=/opt/lib/oiio-$OIIO_VERSION \ - -D CMAKE_INSTALL_PREFIX=/opt/lib/oiio-$OIIO_VERSION \ - -D BUILDSTATIC=ON \ - -D CMAKE_CXX_FLAGS="$cflags" \ - -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \ - -D BOOST_ROOT="$boost_root" \ - ../src + -D CMAKE_PREFIX_PATH=$INST/oiio-$OIIO_VERSION \ + -D CMAKE_INSTALL_PREFIX=$INST/oiio-$OIIO_VERSION \ + -D BUILDSTATIC=ON \ + -D CMAKE_CXX_FLAGS="$cflags" \ + -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \ + -D BOOST_ROOT="$boost_root" \ + ../src make -j$THREADS make install make clean - rm -f /opt/lib/oiio - ln -s oiio-$OIIO_VERSION /opt/lib/oiio + rm -f $INST/oiio + ln -s oiio-$OIIO_VERSION $INST/oiio + + magic_compile_set oiio-$OIIO_VERSION $oiio_magic cd $CWD + else + INFO "Own OpenImageIO-$OIIO_VERSION is up to date, nothing to do!" fi } compile_FFmpeg() { - if [ ! -d /opt/lib/ffmpeg-$FFMPEG_VERSION ]; then - INFO "Building FFmpeg-$FFMPEG_VERSION" + # To be changed each time we make edits that would modify the compiled result! + ffmpeg_magic=0 + + # Clean install if needed! + magic_compile_check ffmpeg-$FFMPEG_VERSION $ffmpeg_magic + if [ $? -eq 1 ]; then + rm -rf $INST/ffmpeg-$FFMPEG_VERSION + fi + + if [ ! -d $INST/ffmpeg-$FFMPEG_VERSION ]; then + INFO "Building ffmpeg-$FFMPEG_VERSION" prepare_opt if [ ! -d $SRC/ffmpeg-$FFMPEG_VERSION ]; then - INFO "Downloading FFmpeg-$FFMPEG_VERSION" - wget -c http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 -P $SRC + INFO "Downloading ffmpeg-$FFMPEG_VERSION" + wget -c $FFMPEG_SOURCE -P $SRC - INFO "Unpacking FFmpeg-$FFMPEG_VERSION" + INFO "Unpacking ffmpeg-$FFMPEG_VERSION" tar -C $SRC -xf $SRC/ffmpeg-$FFMPEG_VERSION.tar.bz2 fi @@ -275,34 +387,42 @@ compile_FFmpeg() { extra="" - if $HASXVID; then - extra="$extra --enable-libxvid" + if $VORBIS_USE; then + extra="$extra --enable-libvorbis" fi - if $HASVPX; then - extra="$extra --enable-libvpx" + if $THEORA_USE; then + extra="$extra --enable-libtheora" fi - if $HASMP3LAME; then - extra="$extra --enable-libmp3lame" - fi - - if $HASX264; then - extra="$extra --enable-libx264" - fi - - if $HASOPENJPEG; then - extra="$extra --enable-libopenjpeg" - fi - - if $HASSCHRO; then + if $SCHRO_USE; then extra="$extra --enable-libschroedinger" fi + if $XVID_USE; then + extra="$extra --enable-libxvid" + fi + + if $X264_USE; then + extra="$extra --enable-libx264" + fi + + if $VPX_USE; then + extra="$extra --enable-libvpx" + fi + + if $MP3LAME_USE; then + extra="$extra --enable-libmp3lame" + fi + + if $OPENJPEG_USE; then + extra="$extra --enable-libopenjpeg" + fi + ./configure --cc="gcc -Wl,--as-needed" --extra-ldflags="-pthread -static-libgcc" \ - --prefix=/opt/lib/ffmpeg-$FFMPEG_VERSION --enable-static --enable-avfilter --disable-vdpau \ - --disable-bzlib --disable-libgsm --disable-libspeex --enable-libtheora \ - --enable-libvorbis --enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \ + --prefix=$INST/ffmpeg-$FFMPEG_VERSION --enable-static --enable-avfilter --disable-vdpau \ + --disable-bzlib --disable-libgsm --disable-libspeex \ + --enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \ --disable-vaapi --disable-libfaac --disable-nonfree --enable-gpl \ --disable-postproc --disable-x11grab --disable-librtmp --disable-libopencore-amrnb \ --disable-libopencore-amrwb --disable-libdc1394 --disable-version3 --disable-outdev=sdl \ @@ -313,10 +433,14 @@ compile_FFmpeg() { make install make clean - rm -f /opt/lib/ffmpeg - ln -s ffmpeg-$FFMPEG_VERSION /opt/lib/ffmpeg + rm -f $INST/ffmpeg + ln -s ffmpeg-$FFMPEG_VERSION $INST/ffmpeg + + magic_compile_set ffmpeg-$FFMPEG_VERSION $ffmpeg_magic cd $CWD + else + INFO "Own ffmpeg-$FFMPEG_VERSION is up to date, nothing to do!" fi } @@ -334,59 +458,91 @@ check_package_DEB() { fi } +check_package_version_match_DEB() { + v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*(([0-9]+\.?)+).*/\1/'` + + if [ -z "$v" ]; then + return 1 + fi + + version_match $v $2 + return $? +} + +check_package_version_ge_DEB() { + v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*(([0-9]+\.?)+).*/\1/'` + + if [ -z "$v" ]; then + return 1 + fi + + version_ge $v $2 + return $? +} + install_DEB() { - INFO "Installing dependencies for DEB-based distributive" + INFO "Installing dependencies for DEB-based distribution" + INFO "Source code of dependencies needed to be compiled will be downloaded and extracted into $SRC" + INFO "Built libs of dependencies needed to be compiled will be installed into $INST" + INFO "Please edit \$SRC and/or \$INST variables at the begining of this script if you want to use other paths!" sudo apt-get update # XXX Why in hell? Let's let this stuff to the user's responsability!!! # sudo apt-get -y upgrade + # These libs should always be available in debian/ubuntu official repository... + OPENJPEG_DEV="libopenjpeg-dev" + SCHRO_DEV="libschroedinger-dev" + VORBIS_DEV="libvorbis-dev" + THEORA_DEV="libtheora-dev" + sudo apt-get install -y cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \ libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \ - libssl-dev liblzma-dev libreadline-dev libopenjpeg-dev libopenexr-dev libopenal-dev \ - libglew-dev yasm libschroedinger-dev libtheora-dev libvorbis-dev libsdl1.2-dev \ - libfftw3-dev libjack-dev python-dev patch + libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV libopenexr-dev libopenal-dev \ + libglew-dev yasm $SCHRO_DEV $THEORA_DEV $VORBIS_DEV libsdl1.2-dev \ + libfftw3-dev libjack-dev python-dev patch flex bison - HASOPENJPEG=true - HASSCHRO=true + OPENJPEG_USE=true + SCHRO_USE=true + VORBIS_USE=true + THEORA_USE=true - check_package_DEB libxvidcore-dev + # Grmpf, debian is libxvidcore-dev and ubuntu libxvidcore4-dev! + XVID_DEV="libxvidcore-dev" + check_package_DEB $XVID_DEV if [ $? -eq 0 ]; then - sudo apt-get install -y libxvidcore-dev - HASXVID=true - XVIDDEV="libxvidcore-dev" - fi - - check_package_DEB libxvidcore4-dev - if [ $? -eq 0 ]; then - sudo apt-get install -y libxvidcore4-dev - HASXVID=true - XVIDDEV="libxvidcore4-dev" - fi - - check_package_DEB libmp3lame-dev - if [ $? -eq 0 ]; then - sudo apt-get install -y libmp3lame-dev - HASMP3LAME=true - fi - - check_package_DEB libx264-dev - if [ $? -eq 0 ]; then - sudo apt-get install -y libx264-dev - HASX264=true - fi - - check_package_DEB libvpx-dev - if [ $? -eq 0 ]; then - sudo apt-get install -y libvpx-dev - vpx_version=`deb_version libvpx-dev` - if dpkg --compare-versions $vpx_version gt 0.9.7; then - if version_ge $vpx_version 0.9.7; then - HASVPX=true - fi + sudo apt-get install -y $XVID_DEV + XVID_USE=true + else + XVID_DEV="libxvidcore4-dev" + check_package_DEB $XVID_DEV + if [ $? -eq 0 ]; then + sudo apt-get install -y $XVID_DEV + XVID_USE=true fi fi + MP3LAME_DEV="libmp3lame-dev" + check_package_DEB $MP3LAME_DEV + if [ $? -eq 0 ]; then + sudo apt-get install -y $MP3LAME_DEV + MP3LAME_USE=true + fi + + X264_DEV="libx264-dev" + check_package_DEB $X264_DEV + if [ $? -eq 0 ]; then + sudo apt-get install -y $X264_DEV + X264_USE=true + fi + + VPX_DEV="libvpx-dev" + check_package_version_ge_DEB $VPX_DEV $VPX_VERSION_MIN + if [ $? -eq 0 ]; then + sudo apt-get install -y $VPX_DEV + VPX_USE=true + fi + check_package_DEB libspnav-dev if [ $? -eq 0 ]; then sudo apt-get install -y libspnav-dev @@ -399,7 +555,7 @@ install_DEB() { compile_Python fi - check_package_DEB libboost-dev + check_package_version_ge_DEB libboost-dev $BOOST_VERSION_MIN if [ $? -eq 0 ]; then sudo apt-get install -y libboost-dev @@ -416,14 +572,14 @@ install_DEB() { compile_Boost fi - check_package_DEB libopencolorio-dev + check_package_version_ge_DEB libopencolorio-dev $OCIO_VERSION_MIN if [ $? -eq 0 ]; then sudo apt-get install -y libopencolorio-dev else compile_OCIO fi - check_package_DEB libopenimageio-dev + check_package_version_ge_DEB libopenimageio-dev $OIIO_VERSION_MIN if [ $? -eq 0 ]; then sudo apt-get install -y libopenimageio-dev else @@ -461,6 +617,10 @@ check_package_RPM() { check_package_version_match_RPM() { v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'` + if [ -z "$v" ]; then + return 1 + fi + version_match $v $2 return $? } @@ -468,12 +628,19 @@ check_package_version_match_RPM() { check_package_version_ge_RPM() { v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'` + if [ -z "$v" ]; then + return 1 + fi + version_ge $v $2 return $? } install_RPM() { - INFO "Installing dependencies for RPM-based distributive" + INFO "Installing dependencies for RPM-based distribution" + INFO "Source code of dependencies needed to be compiled will be downloaded and extracted into $SRC" + INFO "Built libs of dependencies needed to be compiled will be installed into $INST" + INFO "Please edit \$SRC and/or \$INST variables at the begining of this script if you want to use other paths!" sudo yum -y update @@ -484,36 +651,36 @@ install_RPM() { fftw-devel lame-libs jack-audio-connection-kit-devel libspnav-devel \ libjpeg-devel patch python-devel - HASOPENJPEG=true - HASSCHRO=true + OPENJPEG_USE=true + SCHRO_USE=true check_package_RPM x264-devel if [ $? -eq 0 ]; then sudo yum install -y x264-devel - HASX264=true + X264_USE=true fi check_package_RPM xvidcore-devel if [ $? -eq 0 ]; then sudo yum install -y xvidcore-devel - HASXVID=true - XVIDDEV="xvidcore-devel" + XVID_USE=true + XVID_DEV="xvidcore-devel" fi check_package_version_ge_RPM libvpx-devel 0.9.7 - if [ $? -eq 1 ]; then + if [ $? -eq 0 ]; then sudo yum install -y libvpx-devel - HASVPX=true + VPX_USE=true fi check_package_RPM lame-devel if [ $? -eq 0 ]; then sudo yum install -y lame-devel - HASMP3LAME=true + MP3LAME_USE=true fi check_package_version_match_RPM python3-devel 3.3 - if [ $? -eq 1 ]; then + if [ $? -eq 0 ]; then sudo yum install -y python-devel else compile_Python @@ -568,7 +735,10 @@ check_package_version_SUSE() { } install_SUSE() { - INFO "Installing dependencies for SuSE-based distributive" + INFO "Installing dependencies for SuSE-based distribution" + INFO "Source code of dependencies needed to be compiled will be downloaded and extracted into $SRC" + INFO "Built libs of dependencies needed to be compiled will be installed into $INST" + INFO "Please edit \$SRC and/or \$INST variables at the begining of this script if you want to use other paths!" sudo zypper --non-interactive update --auto-agree-with-licenses @@ -596,27 +766,27 @@ install_SUSE() { print_info_ffmpeglink_DEB() { _packages="libtheora-dev" - if $HASXVID; then - _packages="$_packages $XVIDDEV" + if $XVID_USE; then + _packages="$_packages $XVID_DEV" fi - if $HASVPX; then + if $VPX_USE; then _packages="$_packages libvpx-dev" fi - if $HASMP3LAME; then + if $MP3LAME_USE; then _packages="$_packages libmp3lame-dev" fi - if $HASX264; then + if $X264_USE; then _packages="$_packages libx264-dev" fi - if $HASOPENJPEG; then + if $OPENJPEG_USE; then _packages="$_packages libopenjpeg-dev" fi - if $HASSCHRO; then + if $SCHRO_USE; then _packages="$_packages libschroedinger-dev" fi @@ -626,27 +796,27 @@ print_info_ffmpeglink_DEB() { print_info_ffmpeglink_RPM() { _packages="libtheora-devel libvorbis-devel" - if $HASXVID; then - _packages="$_packages $XVIDDEV" + if $XVID_USE; then + _packages="$_packages $XVID_DEV" fi - if $HASVPX; then + if $VPX_USE; then _packages="$_packages libvpx-devel" fi - if $HASMP3LAME; then + if $MP3LAME_USE; then _packages="$_packages lame-devel" fi - if $HASX264; then + if $X264_USE; then _packages="$_packages x264-devel" fi - if $HASOPENJPEG; then + if $OPENJPEG_USE; then _packages="$_packages openjpeg-devel" fi - if $HASSCHRO; then + if $SCHRO_USE; then _packages="$_packages schroedinger-devel" fi @@ -673,39 +843,39 @@ print_info() { INFO "" INFO "If you're using CMake add this to your configuration flags:" - if [ -d /opt/lib/boost ]; then - INFO " -D BOOST_ROOT=/opt/lib/boost" + if [ -d $INST/boost ]; then + INFO " -D BOOST_ROOT=$INST/boost" INFO " -D Boost_NO_SYSTEM_PATHS=ON" fi - if [ -d /opt/lib/ffmpeg ]; then + if [ -d $INST/ffmpeg ]; then INFO " -D WITH_CODEC_FFMPEG=ON" - INFO " -D FFMPEG=/opt/lib/ffmpeg" + INFO " -D FFMPEG=$INST/ffmpeg" INFO " -D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;rt;`print_info_ffmpeglink`'" fi INFO "" INFO "If you're using SCons add this to your user-config:" - if [ -d /opt/lib/python-3.3 ]; then - INFO "BF_PYTHON='/opt/lib/python-3.3'" + if [ -d $INST/python-3.3 ]; then + INFO "BF_PYTHON='$INST/python-3.3'" INFO "BF_PYTHON_ABI_FLAGS='m'" fi - if [ -d /opt/lib/ocio ]; then - INFO "BF_OCIO='/opt/lib/ocio'" + if [ -d $INST/ocio ]; then + INFO "BF_OCIO='$INST/ocio'" fi - if [ -d /opt/lib/oiio ]; then - INFO "BF_OIIO='/opt/lib/oiio'" + if [ -d $INST/oiio ]; then + INFO "BF_OIIO='$INST/oiio'" fi - if [ -d /opt/lib/boost ]; then - INFO "BF_BOOST='/opt/lib/boost'" + if [ -d $INST/boost ]; then + INFO "BF_BOOST='$INST/boost'" fi - if [ -d /opt/lib/ffmpeg ]; then - INFO "BF_FFMPEG='/opt/lib/ffmpeg'" + if [ -d $INST/ffmpeg ]; then + INFO "BF_FFMPEG='$INST/ffmpeg'" _ffmpeg_list_sep=" " INFO "BF_FFMPEG_LIB='avformat avcodec swscale avutil avdevice `print_info_ffmpeglink`'" fi From fcc978b7cf59d2065171677fdec7f2ec97adba59 Mon Sep 17 00:00:00 2001 From: Dan Eicher Date: Thu, 15 Nov 2012 17:55:11 +0000 Subject: [PATCH 036/115] Add some missing Node rna update calls --- source/blender/makesrna/intern/rna_nodetree.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 46eca04a00b..1da9a450c2c 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4651,18 +4651,22 @@ static void rna_def_node(BlenderRNA *brna) prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_SELECT); RNA_def_property_ui_text(prop, "Select", ""); + RNA_def_property_update(prop, NC_NODE | NA_SELECTED, NULL); prop = RNA_def_property(srna, "show_options", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_OPTIONS); RNA_def_property_ui_text(prop, "Show Options", ""); + RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL); prop = RNA_def_property(srna, "show_preview", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_PREVIEW); RNA_def_property_ui_text(prop, "Show Preview", ""); + RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL); prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_HIDDEN); RNA_def_property_ui_text(prop, "Hide", ""); + RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL); prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_MUTED); From 2007ba687fb7d26d94769b7de0251ee21e191c2c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 15 Nov 2012 19:26:11 +0000 Subject: [PATCH 037/115] Enable OSL for linux 32 bit builders, it should work now --- build_files/buildbot/config/user-config-glibc211-i686.py | 8 +++----- build_files/buildbot/config/user-config-glibc27-i686.py | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/build_files/buildbot/config/user-config-glibc211-i686.py b/build_files/buildbot/config/user-config-glibc211-i686.py index 98ae49eeeea..2b1af356773 100644 --- a/build_files/buildbot/config/user-config-glibc211-i686.py +++ b/build_files/buildbot/config/user-config-glibc211-i686.py @@ -120,7 +120,7 @@ BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_JPEG}/lib/libjpeg.a' BF_OIIO_LIBPATH = '${BF_OIIO}/lib' -WITH_BF_CYCLES_OSL = False +WITH_BF_CYCLES_OSL = True WITH_BF_STATICOSL = False BF_OSL = '/opt/lib/osl' BF_OSL_INC = '${BF_OSL}/include' @@ -130,7 +130,7 @@ BF_OSL_LIB = 'oslcomp oslexec oslquery' BF_OSL_LIBPATH = '${BF_OSL}/lib' BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' -WITH_BF_LLVM = False +WITH_BF_LLVM = True WITH_BF_STATICLLVM = False BF_LLVM = '/opt/lib/llvm-3.1' BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ @@ -162,6 +162,4 @@ WITH_BF_OCEANSIM = True BF_DEBUG = False REL_CCFLAGS = ['-O2', '-msse', '-msse2'] # C & C++ PLATFORM_LINKFLAGS = ['-lrt'] - -if WITH_BF_CYCLES_OSL: - BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] +BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] diff --git a/build_files/buildbot/config/user-config-glibc27-i686.py b/build_files/buildbot/config/user-config-glibc27-i686.py index 78a2725c456..c8e144e8a7f 100644 --- a/build_files/buildbot/config/user-config-glibc27-i686.py +++ b/build_files/buildbot/config/user-config-glibc27-i686.py @@ -107,7 +107,7 @@ BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a' BF_OIIO_LIBPATH = '${BF_OIIO}/lib' -WITH_BF_CYCLES_OSL = False +WITH_BF_CYCLES_OSL = True WITH_BF_STATICOSL = False BF_OSL = '/opt/osl' BF_OSL_INC = '${BF_OSL}/include' @@ -117,7 +117,7 @@ BF_OSL_LIB = 'oslcomp oslexec oslquery' BF_OSL_LIBPATH = '${BF_OSL}/lib' BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' -WITH_BF_LLVM = False +WITH_BF_LLVM = True WITH_BF_STATICLLVM = False BF_LLVM = '/opt/llvm-3.1' BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ @@ -147,6 +147,4 @@ WITH_BF_OCEANSIM = True BF_DEBUG = False REL_CCFLAGS = ['-O2'] # C & C++ PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib32'] - -if WITH_BF_CYCLES_OSL: - BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] +BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive'] From 17e506a83ef38c7b9bcc3f8a87e6e28815bcc617 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 15 Nov 2012 19:37:29 +0000 Subject: [PATCH 038/115] Windows OIIO: * bin/OpenImageIO.dll not needed anymore, now statically linked. --- SConstruct | 5 ----- source/creator/CMakeLists.txt | 13 +------------ 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/SConstruct b/SConstruct index bda361a0a9d..0bbe06eb21e 100644 --- a/SConstruct +++ b/SConstruct @@ -886,11 +886,6 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'): dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll') dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll') - if env['WITH_BF_OIIO'] and env['OURPLATFORM'] != 'win32-mingw': - dllpath = '${LCGDIR}/openimageio/bin/OpenImageIO.dll' - if os.path.exists(env.subst(dllpath)): - dllsources.append(dllpath) - if env['WITH_BF_OCIO']: if not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'): dllsources.append('${LCGDIR}/opencolorio/bin/OpenColorIO.dll') diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 4d1620a8bb8..66c3beeebad 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -618,18 +618,7 @@ elseif(WIN32) install( # x86 builds can run on x64 Windows, so this is required at all times FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll DESTINATION ${TARGETDIR} - ) - - if(WITH_OPENIMAGEIO) - set(OIIODLL ${LIBDIR}/openimageio/bin/OpenImageIO.dll) - if(NOT MINGW AND EXISTS ${OIIODLL}) - install( - FILES - ${OIIODLL} - DESTINATION ${TARGETDIR} - ) - endif() - endif() + ) if(WITH_OPENCOLORIO) set(OCIOBIN ${LIBDIR}/opencolorio/bin) From c408d41fc8ece38d1731358a2d24ec53c1b5a5c7 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 15 Nov 2012 19:45:37 +0000 Subject: [PATCH 039/115] Windows / CMake: * Disable Debug Boost detection in cmake. Debug libs for boost will be removed, they are quite huge in svn. Keeping the lines here though, so devs with own debug libs can compile with it. --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75401edbd93..68c87a81114 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1119,23 +1119,23 @@ elseif(WIN32) if(MSVC10) set(BOOST_LIBPATH ${BOOST}/vc2010/lib) set(BOOST_POSTFIX "vc100-mt-s-1_49.lib") - set(BOOST_DEBUG_POSTFIX "vc100-mt-sgd-1_49.lib") + #set(BOOST_DEBUG_POSTFIX "vc100-mt-sgd-1_49.lib") else() set(BOOST_LIBPATH ${BOOST}/lib) set(BOOST_POSTFIX "vc90-mt-s-1_49.lib") - set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib") + #set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib") endif() set(BOOST_LIBRARIES optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX} optimized libboost_regex-${BOOST_POSTFIX} optimized libboost_system-${BOOST_POSTFIX} optimized libboost_thread-${BOOST_POSTFIX} - debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX} - debug libboost_regex-${BOOST_DEBUG_POSTFIX} - debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX}) + #debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX} + #debug libboost_regex-${BOOST_DEBUG_POSTFIX} + #debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX}) if(WITH_INTERNATIONAL) set(BOOST_LIBRARIES ${BOOST_LIBRARIES} optimized libboost_locale-${BOOST_POSTFIX} - debug libboost_locale-${BOOST_DEBUG_POSTFIX}) + #debug libboost_locale-${BOOST_DEBUG_POSTFIX}) endif(WITH_INTERNATIONAL) set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") endif() From dc4ffd8a8617459f4c8468b36a9ee0bba48af54c Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 15 Nov 2012 20:21:33 +0000 Subject: [PATCH 040/115] * Fix typo in cmake, own fault. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68c87a81114..25e258419e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1128,14 +1128,14 @@ elseif(WIN32) set(BOOST_LIBRARIES optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX} optimized libboost_regex-${BOOST_POSTFIX} - optimized libboost_system-${BOOST_POSTFIX} optimized libboost_thread-${BOOST_POSTFIX} + optimized libboost_system-${BOOST_POSTFIX} optimized libboost_thread-${BOOST_POSTFIX}) #debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX} #debug libboost_regex-${BOOST_DEBUG_POSTFIX} - #debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX}) + #debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX} if(WITH_INTERNATIONAL) set(BOOST_LIBRARIES ${BOOST_LIBRARIES} - optimized libboost_locale-${BOOST_POSTFIX} - #debug libboost_locale-${BOOST_DEBUG_POSTFIX}) + optimized libboost_locale-${BOOST_POSTFIX}) + #debug libboost_locale-${BOOST_DEBUG_POSTFIX} endif(WITH_INTERNATIONAL) set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") endif() From 724574595561cf49d09f13b2515f754b24e61aef Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 15 Nov 2012 20:50:48 +0000 Subject: [PATCH 041/115] Fix #33192: Opening Blender breaks drag-and-drop support on the KDE desktop Do not set root window as DND aware. --- extern/xdnd/xdnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/xdnd/xdnd.c b/extern/xdnd/xdnd.c index 9bdee89c1ce..50d1fec4969 100644 --- a/extern/xdnd/xdnd.c +++ b/extern/xdnd/xdnd.c @@ -347,7 +347,7 @@ void xdnd_set_dnd_aware (DndClass * dnd, Window window, Atom * typelist) &nchildren_return); if (children_return) XFree (children_return); - if (r) + if (r && parent != root_return) xdnd_set_dnd_aware (dnd, parent, typelist); } From 7e97cd4b49b2ec639ab92083c23a73fbbfedeb43 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Nov 2012 21:32:05 +0000 Subject: [PATCH 042/115] Fix #33188: AO pass wrong after recent change. --- intern/cycles/kernel/kernel_path.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index b893aa4d03d..70a9b372ebc 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -339,7 +339,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample, sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); - if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f && average(ao_bsdf) != 0.0f) { + if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f) { Ray light_ray; float3 ao_shadow; @@ -517,7 +517,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); - if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f && average(ao_bsdf) != 0.0f) { + if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f) { Ray light_ray; float3 ao_shadow; @@ -725,7 +725,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); - if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f && average(ao_bsdf) != 0.0f) { + if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f) { Ray light_ray; float3 ao_shadow; From 69320ea5954696ccf80eef33ecfe2dda88f579f0 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Thu, 15 Nov 2012 21:35:25 +0000 Subject: [PATCH 043/115] OSX/scons/osl: initial osl compiling, todo: fix shader compile and copy to bundle --- SConstruct | 3 +++ build_files/scons/config/darwin-config.py | 18 ++++++++++++++++++ intern/cycles/SConscript | 1 + intern/cycles/kernel/osl/SConscript | 1 + 4 files changed, 23 insertions(+) diff --git a/SConstruct b/SConstruct index 0bbe06eb21e..01e83a7bacc 100644 --- a/SConstruct +++ b/SConstruct @@ -306,6 +306,9 @@ if env['OURPLATFORM']=='darwin': else: env.Append(LINKFLAGS=['-Xlinker','-weak_framework','-Xlinker','Jackmp']) + if env['WITH_BF_CYCLES_OSL'] == 1: + env.Append(LINKFLAGS=['-force_load','../lib/darwin-9.x.universal/osl/lib/liboslexec.a']) + if env['WITH_BF_OPENMP'] == 1: if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): env['CCFLAGS'].append('/openmp') diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 79027ee13b8..73cd92ccb4c 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -276,6 +276,24 @@ BF_PCRE_LIBPATH = '${BF_PCRE}/lib' # Cycles WITH_BF_CYCLES = True +#OSL + +WITH_BF_CYCLES_OSL = True +BF_OSL = LIBDIR + '/osl' +BF_OSL_INC = '${BF_OSL}/include' +# note oslexec would passed via program linkflags, which is needed to +# make llvm happy with osl_allocate_closure_component +BF_OSL_LIB = 'oslcomp oslquery' +BF_OSL_LIBPATH = '${BF_OSL}/lib' +BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' + +WITH_BF_LLVM = True +BF_LLVM = LIBDIR + '/llvm' +BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ + 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \ + 'LLVMTarget LLVMMC LLVMCore LLVMSupport' +BF_LLVM_LIBPATH = '${BF_LLVM}/lib' + WITH_BF_OIIO = True BF_OIIO = LIBDIR + '/openimageio' BF_OIIO_INC = '${BF_OIIO}/include' diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript index 9a4df809732..1a127e364fe 100644 --- a/intern/cycles/SConscript +++ b/intern/cycles/SConscript @@ -36,6 +36,7 @@ incs.extend('#source/blender/blenloader ../../source/blender/makesrna/intern'.sp incs.extend('#extern/glew/include #intern/mikktspace'.split()) incs.append(cycles['BF_OIIO_INC']) incs.append(cycles['BF_BOOST_INC']) +incs.append(cycles['BF_OPENEXR_INC'].split()) incs.extend(cycles['BF_PYTHON_INC'].split()) if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): diff --git a/intern/cycles/kernel/osl/SConscript b/intern/cycles/kernel/osl/SConscript index a66d2447720..2060422ba13 100644 --- a/intern/cycles/kernel/osl/SConscript +++ b/intern/cycles/kernel/osl/SConscript @@ -10,6 +10,7 @@ incs = '. .. ../svm ../../render ../../util ../../device' incs += ' ' + env['BF_OIIO_INC'] incs += ' ' + env['BF_BOOST_INC'] incs += ' ' + env['BF_OSL_INC'] +incs += ' ' + env['BF_OPENEXR_INC'] defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {') defs.append('CCL_NAMESPACE_END=}') From 104a7bfb90cfb7ae4fa477a031172bd6694afb43 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Nov 2012 21:52:17 +0000 Subject: [PATCH 044/115] Fix #33170: cycles viewport update issue with motion blur enabled (which is supposed to do nothing in this case). --- intern/cycles/blender/blender_sync.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 9ebdcfd04bd..d0e8b508df6 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -179,12 +179,14 @@ void BlenderSync::sync_integrator() integrator->sample_clamp = get_float(cscene, "sample_clamp"); #ifdef __CAMERA_MOTION__ - if(integrator->motion_blur != r.use_motion_blur()) { - scene->object_manager->tag_update(scene); - scene->camera->tag_update(); - } + if(!preview) { + if(integrator->motion_blur != r.use_motion_blur()) { + scene->object_manager->tag_update(scene); + scene->camera->tag_update(); + } - integrator->motion_blur = (!preview && r.use_motion_blur()); + integrator->motion_blur = r.use_motion_blur(); + } #endif integrator->diffuse_samples = get_int(cscene, "diffuse_samples"); From e2fe7751d6ce07b6fa9f30a395444bd78cd62d46 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Nov 2012 22:20:18 +0000 Subject: [PATCH 045/115] code cleanup: replace most DO_MINMAX2 -> minmax_v2v2_v2 also add UNPACK macros's. handy for printing vectors for eg. --- source/blender/blenkernel/intern/customdata.c | 4 ++-- source/blender/blenkernel/intern/mask_evaluate.c | 6 +++--- source/blender/blenkernel/intern/tracking.c | 10 +++++----- source/blender/blenlib/BLI_utildefines.h | 9 +++++++++ .../operations/COM_KeyingScreenOperation.cpp | 6 +++--- .../blender/editors/sculpt_paint/paint_image.c | 16 ++++++++-------- source/blender/editors/space_clip/clip_draw.c | 2 +- source/blender/editors/space_clip/clip_editor.c | 2 +- source/blender/editors/space_node/node_group.c | 9 +++++++-- .../editors/transform/transform_conversions.c | 2 +- source/blender/editors/uvedit/uvedit_ops.c | 4 ++-- .../blender/editors/uvedit/uvedit_parametrizer.c | 8 ++++---- .../blender/editors/uvedit/uvedit_unwrap_ops.c | 2 +- 13 files changed, 47 insertions(+), 33 deletions(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 93c776ae30e..b2f8db0dcce 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -761,7 +761,7 @@ static void layerDoMinMax_mloopuv(void *data, void *vmin, void *vmax) { MLoopUV *min = vmin, *max = vmax, *luv = data; - DO_MINMAX2(luv->uv, min->uv, max->uv); + minmax_v2v2_v2(min->uv, max->uv, luv->uv); } static void layerAdd_mloopuv(void *data1, void *data2) @@ -833,7 +833,7 @@ static void layerDoMinMax_mloop_origspace(void *data, void *vmin, void *vmax) { OrigSpaceLoop *min = vmin, *max = vmax, *luv = data; - DO_MINMAX2(luv->uv, min->uv, max->uv); + minmax_v2v2_v2(min->uv, max->uv, luv->uv); } static void layerAdd_mloop_origspace(void *data1, void *data2) diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c index 7d89678d36f..a2f6b3c1929 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.c +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -289,10 +289,10 @@ static void feather_bucket_check_intersect(float (*feather_points)[2], int tot_f /* collapse loop with smaller AABB */ for (k = 0; k < tot_feather_point; k++) { if (k >= check_b && k <= cur_a) { - DO_MINMAX2(feather_points[k], min_a, max_a); + minmax_v2v2_v2(min_a, max_a, feather_points[k]); } else { - DO_MINMAX2(feather_points[k], min_b, max_b); + minmax_v2v2_v2(min_b, max_b, feather_points[k]); } } @@ -379,7 +379,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*fe int next = i + 1; float delta; - DO_MINMAX2(feather_points[i], min, max); + minmax_v2v2_v2(min, max, feather_points[i]); if (next == tot_feather_point) { if (spline->flag & MASK_SPLINE_CYCLIC) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index b174f27b7e1..30b48401046 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1124,10 +1124,10 @@ void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float { INIT_MINMAX2(min, max); - DO_MINMAX2(marker->pattern_corners[0], min, max); - DO_MINMAX2(marker->pattern_corners[1], min, max); - DO_MINMAX2(marker->pattern_corners[2], min, max); - DO_MINMAX2(marker->pattern_corners[3], min, max); + minmax_v2v2_v2(min, max, marker->pattern_corners[0]); + minmax_v2v2_v2(min, max, marker->pattern_corners[1]); + minmax_v2v2_v2(min, max, marker->pattern_corners[2]); + minmax_v2v2_v2(min, max, marker->pattern_corners[3]); } void BKE_tracking_marker_get_subframe_position(MovieTrackingTrack *track, float framenr, float pos[2]) @@ -3161,7 +3161,7 @@ static int stabilization_median_point_get(MovieTracking *tracking, int framenr, if (track->flag & TRACK_USE_2D_STAB) { MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); - DO_MINMAX2(marker->pos, min, max); + minmax_v2v2_v2(min, max, marker->pos); ok = TRUE; } diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 056fa916da1..a22aa0c13d7 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -257,6 +257,15 @@ #define IN_RANGE(a, b, c) ((b < c) ? ((b < a && a < c) ? 1 : 0) : ((c < a && a < b) ? 1 : 0)) #define IN_RANGE_INCL(a, b, c) ((b < c) ? ((b <= a && a <= c) ? 1 : 0) : ((c <= a && a <= b) ? 1 : 0)) +/* unpack vector for args */ +#define UNPACK2(a) ((a)[0]), ((a)[1]) +#define UNPACK3(a) ((a)[0]), ((a)[1]), ((a)[2]) +#define UNPACK4(a) ((a)[0]), ((a)[1]), ((a)[2]), ((a)[3]) +/* op may be '&' or '*' */ +#define UNPACK2OP(a, op) op((a)[0]), op((a)[1]) +#define UNPACK3OP(a, op) op((a)[0]), op((a)[1]), op((a)[2]) +#define UNPACK4OP(a, op) op((a)[0]), op((a)[1]), op((a)[2]), op((a)[3]) + /* array helpers */ #define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) \ (arr_dtype *)((char *)arr_start + (elem_size * (tot - 1))) diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index 0874e2f59be..201dc99eb9e 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -202,9 +202,9 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri INIT_MINMAX2(min, max); - DO_MINMAX2(a->co, min, max); - DO_MINMAX2(b->co, min, max); - DO_MINMAX2(c->co, min, max); + minmax_v2v2_v2(min, max, a->co); + minmax_v2v2_v2(min, max, b->co); + minmax_v2v2_v2(min, max, c->co); rect->xmin = min[0]; rect->ymin = min[1]; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 192ad35109a..676f033af32 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1059,11 +1059,11 @@ static int pixel_bounds_uv( INIT_MINMAX2(min_uv, max_uv); - DO_MINMAX2(uv1, min_uv, max_uv); - DO_MINMAX2(uv2, min_uv, max_uv); - DO_MINMAX2(uv3, min_uv, max_uv); + minmax_v2v2_v2(min_uv, max_uv, uv1); + minmax_v2v2_v2(min_uv, max_uv, uv2); + minmax_v2v2_v2(min_uv, max_uv, uv3); if (is_quad) - DO_MINMAX2(uv4, min_uv, max_uv); + minmax_v2v2_v2(min_uv, max_uv, uv4); bounds_px->xmin = (int)(ibuf_x * min_uv[0]); bounds_px->ymin = (int)(ibuf_y * min_uv[1]); @@ -1089,7 +1089,7 @@ static int pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x, INIT_MINMAX2(min_uv, max_uv); while (tot--) { - DO_MINMAX2((*uv), min_uv, max_uv); + minmax_v2v2_v2(min_uv, max_uv, (*uv)); uv++; } @@ -2940,7 +2940,7 @@ static void project_paint_delayed_face_init(ProjPaintState *ps, const MFace *mf, fidx = mf->v4 ? 3 : 2; do { vCoSS = ps->screenCoords[*(&mf->v1 + fidx)]; - DO_MINMAX2(vCoSS, min, max); + minmax_v2v2_v2(min, max, vCoSS); } while (fidx--); project_paint_bucket_bounds(ps, min, max, bucketMin, bucketMax); @@ -3205,7 +3205,7 @@ static void project_paint_begin(ProjPaintState *ps) /* screen space, not clamped */ projScreenCo[0] = (float)(ps->winx / 2.0f) + (ps->winx / 2.0f) * projScreenCo[0]; projScreenCo[1] = (float)(ps->winy / 2.0f) + (ps->winy / 2.0f) * projScreenCo[1]; - DO_MINMAX2(projScreenCo, ps->screenMin, ps->screenMax); + minmax_v2v2_v2(ps->screenMin, ps->screenMax, projScreenCo); } } else { @@ -3220,7 +3220,7 @@ static void project_paint_begin(ProjPaintState *ps) projScreenCo[0] = (float)(ps->winx / 2.0f) + (ps->winx / 2.0f) * projScreenCo[0] / projScreenCo[3]; projScreenCo[1] = (float)(ps->winy / 2.0f) + (ps->winy / 2.0f) * projScreenCo[1] / projScreenCo[3]; projScreenCo[2] = projScreenCo[2] / projScreenCo[3]; /* Use the depth for bucket point occlusion */ - DO_MINMAX2(projScreenCo, ps->screenMin, ps->screenMax); + minmax_v2v2_v2(ps->screenMin, ps->screenMax, projScreenCo); } else { /* TODO - deal with cases where 1 side of a face goes behind the view ? diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index d523d598925..9cf389c4508 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1284,7 +1284,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, BKE_tracking_undistort_v2(tracking, pos, tpos); - DO_MINMAX2(tpos, min, max); + minmax_v2v2_v2(min, max, tpos); } copy_v2_v2(pos, min); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 71589517c83..1a62af39600 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -349,7 +349,7 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) mul_v3_m4v3(pos, sc->stabmat, pos); - DO_MINMAX2(pos, min, max); + minmax_v2v2_v2(min, max, pos); ok = TRUE; } diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 5f8b5db7766..4dd9c89375d 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -29,13 +29,18 @@ * \ingroup spnode */ +#include + #include "MEM_guardedalloc.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_anim_types.h" -#include "BLI_blenlib.h" +#include "BLI_listbase.h" +#include "BLI_string.h" +#include "BLI_rect.h" +#include "BLI_math.h" #include "BKE_action.h" #include "BKE_animsys.h" @@ -865,7 +870,7 @@ static void node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, if (node == gnode) continue; if (node->flag & NODE_SELECT) { - DO_MINMAX2((&node->locx), min, max); + minmax_v2v2_v2(min, max, &node->locx); } } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 9bbd3f59cbf..5b79b69f7ec 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2486,7 +2486,7 @@ int clipUVTransform(TransInfo *t, float *vec, int resize) max[0] = aspx; max[1] = aspy; for (a = 0, td = t->data; a < t->total; a++, td++) { - DO_MINMAX2(td->loc, min, max); + minmax_v2v2_v2(min, max, td->loc); } if (resize) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index a37a1e77454..6664f8e860e 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -616,7 +616,7 @@ int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float r_min[2], f BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (uvedit_uv_select_test(em, scene, l)) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - DO_MINMAX2(luv->uv, r_min, r_max); + minmax_v2v2_v2(r_min, r_max, luv->uv); sel = 1; } } @@ -1327,7 +1327,7 @@ static void weld_align_uv(bContext *C, int tool) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (uvedit_uv_select_test(em, scene, l)) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - DO_MINMAX2(luv->uv, min, max); + minmax_v2v2_v2(min, max, luv->uv); } } } diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 5b6125b558b..8703234122a 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -450,7 +450,7 @@ static void p_chart_uv_bbox(PChart *chart, float minv[2], float maxv[2]) INIT_MINMAX2(minv, maxv); for (v = chart->verts; v; v = v->nextlink) { - DO_MINMAX2(v->uv, minv, maxv); + minmax_v2v2_v2(minv, maxv, v->uv); } } @@ -3891,9 +3891,9 @@ static void p_smooth(PChart *chart) INIT_MINMAX2(fmin, fmax); - DO_MINMAX2(e1->vert->uv, fmin, fmax); - DO_MINMAX2(e2->vert->uv, fmin, fmax); - DO_MINMAX2(e3->vert->uv, fmin, fmax); + minmax_v2v2_v2(fmin, fmax, e1->vert->uv); + minmax_v2v2_v2(fmin, fmax, e2->vert->uv); + minmax_v2v2_v2(fmin, fmax, e3->vert->uv); bx1 = (int)((fmin[0] - minv[0]) * invmedian); by1 = (int)((fmin[1] - minv[1]) * invmedian); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index fc60c5a3a0f..efe9d1fedfe 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1089,7 +1089,7 @@ static void uv_map_clip_correct(Scene *scene, Object *ob, BMEditMesh *em, wmOper BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - DO_MINMAX2(luv->uv, min, max); + minmax_v2v2_v2(min, max, luv->uv); } } From 8270592fa4f82b9ea51f95b13a00b3bac6660a2d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Nov 2012 22:32:29 +0000 Subject: [PATCH 046/115] code cleanup: some renaming to avoid confusion. --- source/blender/bmesh/operators/bmo_bevel.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 4b1ea5298a3..89f2c448f24 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -471,7 +471,7 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f) * angle va - center -vb, and put the endpoint * of that segment in r. */ -static void get_point_on_round_profile(float r[3], float offset, int i, int count, +static void get_point_on_round_profile(float r_co[3], float offset, int k, int count, const float va[3], const float v[3], const float vb[3]) { float vva[3], vvb[3], angle, center[3], rv[3], axis[3], co[3]; @@ -498,14 +498,14 @@ static void get_point_on_round_profile(float r[3], float offset, int i, int coun sub_v3_v3v3(vvb, vb, center); angle = angle_v3v3(vva, vvb); - rotate_v3_v3v3fl(co, rv, axis, angle * (float)(i) / (float)(count)); + rotate_v3_v3v3fl(co, rv, axis, angle * (float)k / (float)count); add_v3_v3(co, center); - copy_v3_v3(r, co); + copy_v3_v3(r_co, co); } /* - * Find the point (i/n) of the way around the round profile for e, + * Find the point (/n) of the way around the round profile for e, * where start point is va, midarc point is vmid, and end point is vb. * Return the answer in profileco. * Method: @@ -514,9 +514,9 @@ static void get_point_on_round_profile(float r[3], float offset, int i, int coun * back onto original va - vmid - vb plane. * If va, vmid, and vb are all on the same plane, just interpolate between va and vb. */ -static void get_point_on_round_edge(EdgeHalf *e, int i, +static void get_point_on_round_edge(EdgeHalf *e, int k, const float va[3], const float vmid[3], const float vb[3], - float profileco[3]) + float r_co[3]) { float vva[3], vvb[3], point[3], dir[3], vaadj[3], vbadj[3], p2[3], pn[3]; int n = e->seg; @@ -534,18 +534,18 @@ static void get_point_on_round_edge(EdgeHalf *e, int i, copy_v3_v3(vbadj, vb); madd_v3_v3fl(vbadj, dir, -len_v3(vvb) * cosf(angle_v3v3(vvb, dir))); - get_point_on_round_profile(point, e->offset, i, n, vaadj, vmid, vbadj); + get_point_on_round_profile(point, e->offset, k, n, vaadj, vmid, vbadj); add_v3_v3v3(p2, point, dir); cross_v3_v3v3(pn, vva, vvb); - if (!isect_line_plane_v3(profileco, point, p2, vmid, pn, 0)) { + if (!isect_line_plane_v3(r_co, point, p2, vmid, pn, 0)) { /* TODO: track down why this sometimes fails */ - copy_v3_v3(profileco, point); + copy_v3_v3(r_co, point); } } else { /* planar case */ - interp_v3_v3v3(profileco, va, vb, (float) i / (float) n); + interp_v3_v3v3(r_co, va, vb, (float)k / (float)n); } } From b3f6c1213697b152c14837f280b469af9c499651 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Nov 2012 23:21:21 +0000 Subject: [PATCH 047/115] bevel: wip ifdef'd code to test an alternative method of placing corner vertices. --- source/blender/bmesh/operators/bmo_bevel.c | 131 ++++++++++++++++++++- 1 file changed, 129 insertions(+), 2 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 89f2c448f24..93e69909ff9 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -36,6 +36,9 @@ #include "intern/bmesh_operators_private.h" /* own include */ +/* experemental - Campbell */ +// #define USE_ALTERNATE_ADJ + #define BEVEL_FLAG 1 #define EDGE_SELECTED 2 @@ -434,6 +437,7 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3]) madd_v3_v3fl(slideco, dir, -d); } +#ifndef USE_ALTERNATE_ADJ /* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */ static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], float projco[3]) { @@ -444,7 +448,7 @@ static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], copy_v3_v3(projco, e->v1->co); } } - +#endif /* return 1 if a and b are in CCW order on the normal side of f, * and -1 if they are reversed, and 0 if there is no shared face f */ @@ -461,6 +465,68 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f) return lb->next == la ? 1 : -1; } +#ifdef USE_ALTERNATE_ADJ + +static void vmesh_cent(VMesh *vm, float r_cent[3]) +{ + BoundVert *v; + int tot = 0; + zero_v3(r_cent); + + v = vm->boundstart; + do { + add_v3_v3(r_cent, v->nv.co); + tot++; + } while ((v = v->next) != vm->boundstart); + mul_v3_fl(r_cent, 1.0f / (float)tot); +} + +/** + * + * This example shows a tri fan of quads, + * but could be an NGon fan of quads too. + *
+ *      The whole triangle   X
+ *      represents the      / \
+ *      new bevel face.    /   \
+ *                        /     \
+ *       Split into      /       \
+ *       a quad fan.    /         \
+ *                     /           \
+ *                    /             \
+ *                   /               \
+ *          co_prev +-.             .-+
+ *                 /   `-._     _.-'   \
+ *                / co_cent`-+-'        \
+ *               /           |           \
+ * Quad of      /            |            \
+ * interest -- / ---> X      |             \
+ *            /              |              \
+ *           /               |               \
+ *          /         co_next|                \
+ * co_orig +-----------------+-----------------+
+ *
+ *         For each quad, calcualte UV's based on the following:
+ *           U = k    / (vm->seg * 2)
+ *           V = ring / (vm->seg * 2)
+ *           quad = (co_orig, co_prev, co_cent, co_next)
+ *           ... note that co_cent is the same for all quads in the fan.
+ * 
+ * + */ + +static void get_point_on_round_edge(EdgeHalf *e, int ring, int k, + float quad[4][3], + float r_co[3]) +{ + const float n = e->seg; + const float uv[2] = {(ring / n) * 2.0f, (k / n) * 2.0f}; + + interp_bilinear_quad_v3(quad, uv[0], uv[1], r_co); +} + +#else /* USE_ALTERNATE_ADJ */ + /* * calculation of points on the round profile * r - result, coordinate of point on round profile @@ -549,6 +615,8 @@ static void get_point_on_round_edge(EdgeHalf *e, int k, } } +#endif /* !USE_ALTERNATE_ADJ */ + /* Make a circular list of BoundVerts for bv, each of which has the coordinates * of a vertex on the the boundary of the beveled vertex bv->v. * Also decide on the mesh pattern that will be used inside the boundary. @@ -693,6 +761,13 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) BMFace *f; float co[3], coa[3], cob[3], midco[3]; +#ifdef USE_ALTERNATE_ADJ + /* ordered as follows (orig, prev, center, next)*/ + float quad[4][3]; + /* the rest are initialized inline, this remains the same for all */ + vmesh_cent(vm, quad[2]); +#endif + n = vm->count; ns = vm->seg; ns2 = ns / 2; @@ -702,6 +777,7 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) * BoundVert for i has a bevel, 0 <= r <= ns2, 0 <= k <= ns */ for (ring = 1; ring <= ns2; ring++) { v = vm->boundstart; + do { i = v->index; if (v->ebev) { @@ -728,6 +804,19 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) copy_v3_v3(nv->co, cob); nv->v = nvnext->v; +#ifdef USE_ALTERNATE_ADJ + copy_v3_v3(quad[0], v->nv.co); + mid_v3_v3v3(quad[1], v->nv.co, v->prev->nv.co); + /* quad[2] is set */ + mid_v3_v3v3(quad[3], v->nv.co, v->next->nv.co); +#endif + +#ifdef USE_ALTERNATE_ADJ + for (k = 1; k < ns; k++) { + get_point_on_round_edge(v->ebev, ring, k, quad, co); + copy_v3_v3(mesh_vert(vm, i, ring, k)->co, co); + } +#else /* TODO: better calculation of new midarc point? */ project_to_edge(v->ebev->e, coa, cob, midco); @@ -735,6 +824,7 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) get_point_on_round_edge(v->ebev, k, coa, midco, cob, co); copy_v3_v3(mesh_vert(vm, i, ring, k)->co, co); } +#endif } } while ((v = v->next) != vm->boundstart); } @@ -759,7 +849,9 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) nv = mesh_vert(vm, i, ring, k); nvprev = mesh_vert(vm, vprev->index, k, ns - ring); mid_v3_v3v3(co, nv->co, nvprev->co); +#ifndef USE_ALTERNATE_ADJ copy_v3_v3(nv->co, co); +#endif BLI_assert(nv->v == NULL && nvprev->v == NULL); create_mesh_bmvert(bm, vm, i, ring, k, bv->v); copy_mesh_vert(vm, vprev->index, k, ns - ring, i, ring, k); @@ -806,7 +898,9 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) nvnext = mesh_vert(vm, vnext->index, ns2, k); if (vprev->ebev && vnext->ebev) { mid_v3_v3v3v3(co, nvprev->co, nv->co, nvnext->co); +#ifndef USE_ALTERNATE_ADJ copy_v3_v3(nv->co, co); +#endif create_mesh_bmvert(bm, vm, i, k, ns2, bv->v); copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2); copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2); @@ -814,7 +908,9 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) } else if (vprev->ebev) { mid_v3_v3v3(co, nvprev->co, nv->co); +#ifndef USE_ALTERNATE_ADJ copy_v3_v3(nv->co, co); +#endif create_mesh_bmvert(bm, vm, i, k, ns2, bv->v); copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2); @@ -822,7 +918,9 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) } else if (vnext->ebev) { mid_v3_v3v3(co, nv->co, nvnext->co); +#ifndef USE_ALTERNATE_ADJ copy_v3_v3(nv->co, co); +#endif create_mesh_bmvert(bm, vm, i, k, ns2, bv->v); copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2); @@ -1088,7 +1186,19 @@ static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) VMesh *vm = bv->vmesh; BoundVert *v, *weld1, *weld2; int n, ns, ns2, i, k, weld; - float *va, *vb, co[3], midco[3]; + float *va, *vb, co[3]; + +#ifdef USE_ALTERNATE_ADJ + /* ordered as follows (orig, prev, center, next)*/ + float quad[4][3]; +#else + float midco[3]; +#endif + +#ifdef USE_ALTERNATE_ADJ + /* the rest are initialized inline, this remains the same for all */ + vmesh_cent(vm, quad[2]); +#endif n = vm->count; ns = vm->seg; @@ -1118,9 +1228,25 @@ static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) /* copy other ends to (i, 0, ns) for all i, and fill in profiles for beveled edges */ v = vm->boundstart; do { + +#ifdef USE_ALTERNATE_ADJ + copy_v3_v3(quad[0], v->nv.co); + mid_v3_v3v3(quad[1], v->nv.co, v->prev->nv.co); + /* quad[2] is set */ + mid_v3_v3v3(quad[3], v->nv.co, v->next->nv.co); +#endif + i = v->index; copy_mesh_vert(vm, i, 0, ns, v->next->index, 0, 0); if (v->ebev) { +#ifdef USE_ALTERNATE_ADJ + for (k = 1; k < ns; k++) { + get_point_on_round_edge(v->ebev, 0, k, quad, co); + copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co); + if (!weld) + create_mesh_bmvert(bm, vm, i, 0, k, bv->v); + } +#else va = mesh_vert(vm, i, 0, 0)->co; vb = mesh_vert(vm, i, 0, ns)->co; project_to_edge(v->ebev->e, va, vb, midco); @@ -1130,6 +1256,7 @@ static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) if (!weld) create_mesh_bmvert(bm, vm, i, 0, k, bv->v); } +#endif } } while ((v = v->next) != vm->boundstart); From 4ece50723bf82af2dedf99f41d761827e668ad7e Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 16 Nov 2012 00:43:28 +0000 Subject: [PATCH 048/115] OSX/scons/osl: ready for compile now, little hack to be resolved, todo:fix a crash with shadercompile --- build_files/scons/tools/Blender.py | 8 ++++++++ intern/cycles/kernel/shaders/SConscript | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 23e732370ce..27e8feaea80 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -652,6 +652,14 @@ def AppIt(target=None, source=None, env=None): cmd = 'cp -R %s/../intern/cycles/kernel/*.cubin %s/lib/' % (builddir, cinstalldir) commands.getoutput(cmd) + if env['WITH_BF_CYCLES_OSL']: + cmd = 'mkdir %s/shader' % (cinstalldir) + commands.getoutput(cmd) + cmd = 'cp -R %s/kernel/shaders/*.h %s/shader' % (croot, cinstalldir) + commands.getoutput(cmd) + cmd = 'cp -R %s/../intern/cycles/kernel/shaders/*.oso %s/shader' % (builddir, cinstalldir) + commands.getoutput(cmd) + if env['WITH_OSX_STATICPYTHON']: cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/python/'%(installdir,binary, VERSION) commands.getoutput(cmd) diff --git a/intern/cycles/kernel/shaders/SConscript b/intern/cycles/kernel/shaders/SConscript index 924aff4fc22..1d446205d92 100644 --- a/intern/cycles/kernel/shaders/SConscript +++ b/intern/cycles/kernel/shaders/SConscript @@ -14,7 +14,10 @@ if env['WITH_BF_CYCLES_OSL']: shaders = env.Clone() # osl compiler info - osl_compiler = env['BF_OSL_COMPILER'] + if env['OURPLATFORM']=='darwin': + osl_compiler = '../lib/darwin-9.x.universal/osl/bin/oslc' # temporary hack to get the leading "#" away that breaks shadercompile + else: + osl_compiler = env['BF_OSL_COMPILER'] # build directory root_build_dir = normpath(env['BF_BUILDDIR']) From be6ea8ff2c51a421536cde6f550f6f1edd71e617 Mon Sep 17 00:00:00 2001 From: Justin Dailey Date: Fri, 16 Nov 2012 01:12:01 +0000 Subject: [PATCH 049/115] fix [#33180] text editor line height issue Added small space between lines in the text editor. --- source/blender/editors/space_text/text_draw.c | 44 ++++++++++--------- .../blender/editors/space_text/text_intern.h | 1 + source/blender/editors/space_text/text_ops.c | 6 +-- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index f463b015bf5..76908e5b369 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1494,6 +1494,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar) Text *text = st->text; int vcurl, vcurc, vsell, vselc, hidden = 0; int x, y, w, i; + int lheight = st->lheight + TXT_LINE_SPACING; /* Draw the selection */ if (text->curl != text->sell || text->curc != text->selc) { @@ -1514,11 +1515,11 @@ static void draw_cursor(SpaceText *st, ARegion *ar) y = ar->winy - 2; if (vcurl == vsell) { - y -= vcurl * st->lheight; + y -= vcurl * lheight; if (vcurc < vselc) - glRecti(x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - st->lheight); + glRecti(x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - lheight + TXT_LINE_SPACING); else - glRecti(x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - st->lheight); + glRecti(x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - lheight + TXT_LINE_SPACING); } else { int froml, fromc, tol, toc; @@ -1532,12 +1533,12 @@ static void draw_cursor(SpaceText *st, ARegion *ar) fromc = vselc; toc = vcurc; } - y -= froml * st->lheight; - glRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - st->lheight); y -= st->lheight; + y -= froml * lheight; + glRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - lheight); y -= lheight; for (i = froml + 1; i < tol; i++) - glRecti(x - 4, y, ar->winx, y - st->lheight), y -= st->lheight; + glRecti(x - 4, y, ar->winx, y - lheight), y -= lheight; - glRecti(x - 4, y, x + toc * st->cwidth, y - st->lheight); y -= st->lheight; + glRecti(x - 4, y, x + toc * st->cwidth, y - lheight + TXT_LINE_SPACING); y -= lheight; } } else { @@ -1561,12 +1562,12 @@ static void draw_cursor(SpaceText *st, ARegion *ar) wrap_offset_in_line(st, ar, text->sell, text->selc, &offl, &offc); - y1 = ar->winy - 2 - (vsell - offl) * st->lheight; - y2 = y1 - st->lheight * visible_lines + 1; + y1 = ar->winy - 2 - (vsell - offl) * lheight; + y2 = y1 - lheight * visible_lines + 1; } else { - y1 = ar->winy - 2 - vsell * st->lheight; - y2 = y1 - st->lheight + 1; + y1 = ar->winy - 2 - vsell * lheight; + y2 = y1 - lheight + 1; } if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */ @@ -1577,7 +1578,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - glRecti(x1 - 4, y1, x2, y2); + glRecti(x1 - 4, y1, x2, y2 + TXT_LINE_SPACING); glDisable(GL_BLEND); } } @@ -1586,20 +1587,21 @@ static void draw_cursor(SpaceText *st, ARegion *ar) /* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */ x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; x += vselc * st->cwidth; - y = ar->winy - 2 - vsell * st->lheight; + y = ar->winy - 2 - vsell * lheight; if (st->overwrite) { char ch = text->sell->line[text->selc]; + y += TXT_LINE_SPACING; w = st->cwidth; if (ch == '\t') w *= st->tabnumber - (vselc + st->left) % st->tabnumber; UI_ThemeColor(TH_HILITE); - glRecti(x, y - st->lheight - 1, x + w, y - st->lheight + 1); + glRecti(x, y - lheight - 1, x + w, y - lheight + 1); } else { UI_ThemeColor(TH_HILITE); - glRecti(x - 1, y, x + 1, y - st->lheight); + glRecti(x - 1, y, x + 1, y - lheight + TXT_LINE_SPACING); } } } @@ -1714,8 +1716,8 @@ static void draw_brackets(SpaceText *st, ARegion *ar) if (viewc >= 0) { viewl = txt_get_span(text->lines.first, startl) - st->top + offl; - text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * st->lheight, ch); - text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * st->lheight, ch); + text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * (st->lheight + TXT_LINE_SPACING), ch); + text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * (st->lheight + TXT_LINE_SPACING), ch); } /* draw closing bracket */ @@ -1726,8 +1728,8 @@ static void draw_brackets(SpaceText *st, ARegion *ar) if (viewc >= 0) { viewl = txt_get_span(text->lines.first, endl) - st->top + offl; - text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * st->lheight, ch); - text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * st->lheight, ch); + text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * (st->lheight + TXT_LINE_SPACING), ch); + text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * (st->lheight + TXT_LINE_SPACING), ch); } } @@ -1743,7 +1745,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) int wraplinecount = 0, wrap_skip = 0; int margin_column_x; - if (st->lheight) st->viewlines = (int)ar->winy / st->lheight; + if (st->lheight) st->viewlines = (int)ar->winy / (st->lheight + TXT_LINE_SPACING); else st->viewlines = 0; /* if no text, nothing to do */ @@ -1839,6 +1841,8 @@ void draw_text_main(SpaceText *st, ARegion *ar) text_draw(st, tmp->line, st->left, ar->winx / st->cwidth, 1, x, y, tmp->format); y -= st->lheight; } + + y-= TXT_LINE_SPACING; wrap_skip = 0; } diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 4f973e7076b..d687f4cdd8a 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -57,6 +57,7 @@ void text_update_cursor_moved(struct bContext *C); #define TXT_OFFSET 15 #define TXT_SCROLL_WIDTH 20 #define TXT_SCROLL_SPACE 2 +#define TXT_LINE_SPACING 4 /* space between lines */ #define TEXTXLOC (st->cwidth * st->linenrs_tot) diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 105e20ffadb..ae5de4c6a25 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2202,10 +2202,10 @@ static void text_scroll_apply(bContext *C, wmOperator *op, wmEvent *event) if (!tsc->scrollbar) { txtdelta[0] = -tsc->delta[0] / st->cwidth; - txtdelta[1] = tsc->delta[1] / st->lheight; + txtdelta[1] = tsc->delta[1] / (st->lheight + TXT_LINE_SPACING); tsc->delta[0] %= st->cwidth; - tsc->delta[1] %= st->lheight; + tsc->delta[1] %= (st->lheight + TXT_LINE_SPACING); } else { txtdelta[1] = -tsc->delta[1] * st->pix_per_line; @@ -2599,7 +2599,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, int { Text *text = st->text; text_update_character_width(st); - y = (ar->winy - 2 - y) / st->lheight; + y = (ar->winy - 2 - y) / (st->lheight + TXT_LINE_SPACING); if (st->showlinenrs) x -= TXT_OFFSET + TEXTXLOC; else x -= TXT_OFFSET; From b67e52ae3acc98db8a9dd67e7c1cf19894d0667a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 03:23:46 +0000 Subject: [PATCH 050/115] minor edits so new bevel operator can be used from the modifier (testing only, still disabled by default) --- source/blender/modifiers/intern/MOD_bevel.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 3e3bcb73491..66e188693a6 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -92,7 +92,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) #ifdef USE_BM_BEVEL_OP_AS_MOD -#define EDGE_MARK 1 +#define GEOM_MARK 1 /* BMESH_TODO * @@ -116,7 +116,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), BMIter iter; BMEdge *e; BevelModifierData *bmd = (BevelModifierData *) md; - float threshold = cos((bmd->bevel_angle + 0.00001f) * M_PI / 180.0f); + float threshold = cos((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f); + const int segments = 16; /* XXX */ bm = DM_to_bmesh(dm); @@ -131,7 +132,9 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), (l2 = e->l->radial_next) != l1) { if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { - BMO_elem_flag_enable(bm, e, EDGE_MARK); + BMO_elem_flag_enable(bm, e, GEOM_MARK); + BMO_elem_flag_enable(bm, e->v1, GEOM_MARK); + BMO_elem_flag_enable(bm, e->v2, GEOM_MARK); } } } @@ -139,13 +142,15 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), else { /* crummy, is there a way just to operator on all? - campbell */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - BMO_elem_flag_enable(bm, e, EDGE_MARK); + BMO_elem_flag_enable(bm, e, GEOM_MARK); + BMO_elem_flag_enable(bm, e->v1, GEOM_MARK); + BMO_elem_flag_enable(bm, e->v2, GEOM_MARK); } } BMO_op_callf(bm, BMO_FLAG_DEFAULTS, - "bevel geom=%fe percent=%f use_even=%b use_dist=%b", - EDGE_MARK, bmd->value, (bmd->flags & BME_BEVEL_EVEN) != 0, (bmd->flags & BME_BEVEL_DIST) != 0); + "bevel geom=%fve offset=%f segments=%i", + GEOM_MARK, bmd->value, segments); BMO_pop(bm); result = CDDM_from_bmesh(bm, TRUE); From 328dd3f0336c1f3b1ff69669c0fcec7df18404f4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 07:56:47 +0000 Subject: [PATCH 051/115] debug utility for drawing in the 3d viewport (uncomment define to use), helpful for debugging modifiers/bmesh code, especially other peoples :) --- .../editors/space_view3d/view3d_draw.c | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index a9b3823e6a2..b3e7fa15523 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -95,6 +95,16 @@ #include "view3d_intern.h" /* own include */ +/* handy utility for drawing shapes in the viewport for arbitrary code. + * could add lines and points too */ +// #define DEBUG_DRAW +#ifdef DEBUG_DRAW +static void bl_debug_draw(void); +/* add these locally when using these functions for testing */ +extern void bl_debug_draw_quad_clear(void); +extern void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const float v2[3], const float v3[3]); +extern void bl_debug_draw_edge_add(const float v0[3], const float v1[3]); +#endif static void star_stuff_init_func(void) { @@ -3207,6 +3217,9 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) /* draw viewport using opengl */ if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(C) || draw_border) { view3d_main_area_draw_objects(C, ar, &grid_unit); +#ifdef DEBUG_DRAW + bl_debug_draw(); +#endif ED_region_pixelspace(ar); } @@ -3219,3 +3232,57 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) v3d->flag |= V3D_INVALID_BACKBUF; } +#ifdef DEBUG_DRAW +/* debug drawing */ +#define _DEBUG_DRAW_QUAD_TOT 1024 +static float _bl_debug_draw_quads[_DEBUG_DRAW_QUAD_TOT][4][3]; +static int _bl_debug_draw_quads_tot = 0; + +void bl_debug_draw_quad_clear(void) +{ + _bl_debug_draw_quads_tot = 0; +} +void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const float v2[3], const float v3[3]) +{ + if (_bl_debug_draw_quads_tot >= _DEBUG_DRAW_QUAD_TOT) { + printf("%s: max quad count hit %d!", __func__, _bl_debug_draw_quads_tot); + } + else { + float *pt = &_bl_debug_draw_quads[_bl_debug_draw_quads_tot][0][0]; + copy_v3_v3(pt, v0); pt += 3; + copy_v3_v3(pt, v1); pt += 3; + copy_v3_v3(pt, v2); pt += 3; + copy_v3_v3(pt, v3); pt += 3; + _bl_debug_draw_quads_tot++; + } +} +void bl_debug_draw_edge_add(const float v0[3], const float v1[3]) +{ + if (_bl_debug_draw_quads_tot >= _DEBUG_DRAW_QUAD_TOT) { + printf("%s: max edge count hit %d!", __func__, _bl_debug_draw_quads_tot); + } + else { + float *pt = &_bl_debug_draw_quads[_bl_debug_draw_quads_tot][0][0]; + copy_v3_v3(pt, v0); pt += 3; + copy_v3_v3(pt, v1); pt += 3; + copy_v3_v3(pt, v0); pt += 3; + copy_v3_v3(pt, v1); pt += 3; + _bl_debug_draw_quads_tot++; + } +} +static void bl_debug_draw(void) +{ + if (_bl_debug_draw_quads_tot) { + int i; + cpack(0x00FF0000); + glBegin(GL_LINE_LOOP); + for(i=0; i < _bl_debug_draw_quads_tot; i ++) { + glVertex3fv(_bl_debug_draw_quads[i][0]); + glVertex3fv(_bl_debug_draw_quads[i][1]); + glVertex3fv(_bl_debug_draw_quads[i][2]); + glVertex3fv(_bl_debug_draw_quads[i][3]); + } + glEnd(); + } +} +#endif From f5b356bf188528fd618cacaa22f6c72b3a625e09 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 08:12:06 +0000 Subject: [PATCH 052/115] wip - alternate bevel curve calculation (still disabled) now USE_ALTERNATE_ADJ works, giving more stable corners that don't flicker and glitch out as the offset changes. The shape is not a circle though and doesnt look quite as nice as the existing method. --- source/blender/bmesh/operators/bmo_bevel.c | 128 +++++++++++++++++---- 1 file changed, 103 insertions(+), 25 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 93e69909ff9..28e28b67399 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -437,7 +437,6 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3]) madd_v3_v3fl(slideco, dir, -d); } -#ifndef USE_ALTERNATE_ADJ /* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */ static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], float projco[3]) { @@ -448,7 +447,6 @@ static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], copy_v3_v3(projco, e->v1->co); } } -#endif /* return 1 if a and b are in CCW order on the normal side of f, * and -1 if they are reversed, and 0 if there is no shared face f */ @@ -515,13 +513,26 @@ static void vmesh_cent(VMesh *vm, float r_cent[3]) * */ -static void get_point_on_round_edge(EdgeHalf *e, int ring, int k, +static void get_point_uv(float uv[2], + /* all these args are int's originally + * but pass as floats to the function */ + const float seg, const float ring, const float k) +{ + uv[0] = (ring / seg) * 2.0f; + uv[1] = (k / seg) * 2.0f; +} + +/* TODO: make this a lot smarter!, + * this is the main reason USE_ALTERNATE_ADJ isn't so good right now :S */ +static float get_point_uv_factor(const float uv[2]) +{ + return sinf(1.0f - max_ff(uv[0], uv[1]) / 2.0f); +} + +static void get_point_on_round_edge(const float uv[2], float quad[4][3], float r_co[3]) { - const float n = e->seg; - const float uv[2] = {(ring / n) * 2.0f, (k / n) * 2.0f}; - interp_bilinear_quad_v3(quad, uv[0], uv[1], r_co); } @@ -763,9 +774,15 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) #ifdef USE_ALTERNATE_ADJ /* ordered as follows (orig, prev, center, next)*/ - float quad[4][3]; + float quad_plane[4][3]; + float quad_orig[4][3]; +#endif + + +#ifdef USE_ALTERNATE_ADJ /* the rest are initialized inline, this remains the same for all */ - vmesh_cent(vm, quad[2]); + vmesh_cent(vm, quad_plane[2]); + copy_v3_v3(quad_orig[2], bv->v->co); #endif n = vm->count; @@ -805,15 +822,33 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv) nv->v = nvnext->v; #ifdef USE_ALTERNATE_ADJ - copy_v3_v3(quad[0], v->nv.co); - mid_v3_v3v3(quad[1], v->nv.co, v->prev->nv.co); + /* plane */ + copy_v3_v3(quad_plane[0], v->nv.co); + mid_v3_v3v3(quad_plane[1], v->nv.co, v->prev->nv.co); /* quad[2] is set */ - mid_v3_v3v3(quad[3], v->nv.co, v->next->nv.co); + mid_v3_v3v3(quad_plane[3], v->nv.co, v->next->nv.co); + + /* orig */ + copy_v3_v3(quad_orig[0], v->nv.co); /* only shared location between 2 quads */ + project_to_edge(v->ebev->prev->e, v->nv.co, v->prev->nv.co, quad_orig[1]); + project_to_edge(v->ebev->e, v->nv.co, v->next->nv.co, quad_orig[3]); + + //bl_debug_draw_quad_add(UNPACK4(quad_plane)); + //bl_debug_draw_quad_add(UNPACK4(quad_orig)); #endif #ifdef USE_ALTERNATE_ADJ for (k = 1; k < ns; k++) { - get_point_on_round_edge(v->ebev, ring, k, quad, co); + float uv[2]; + float fac; + float co_plane[3]; + float co_orig[3]; + + get_point_uv(uv, v->ebev->seg, ring, k); + get_point_on_round_edge(uv, quad_plane, co_plane); + get_point_on_round_edge(uv, quad_orig, co_orig); + fac = get_point_uv_factor(uv); + interp_v3_v3v3(co, co_plane, co_orig, fac); copy_v3_v3(mesh_vert(vm, i, ring, k)->co, co); } #else @@ -1190,14 +1225,20 @@ static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) #ifdef USE_ALTERNATE_ADJ /* ordered as follows (orig, prev, center, next)*/ - float quad[4][3]; + float quad_plane[4][3]; + float quad_orig_a[4][3]; + float quad_orig_b[4][3]; + const int is_odd = (vm->seg % 2); #else float midco[3]; #endif #ifdef USE_ALTERNATE_ADJ /* the rest are initialized inline, this remains the same for all */ - vmesh_cent(vm, quad[2]); + /* NOTE; in this usage we only interpolate on the 'V' so cent and next points are unused (2,3)*/ + vmesh_cent(vm, quad_plane[2]); + copy_v3_v3(quad_orig_a[2], bv->v->co); + copy_v3_v3(quad_orig_b[2], bv->v->co); #endif n = vm->count; @@ -1228,25 +1269,62 @@ static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) /* copy other ends to (i, 0, ns) for all i, and fill in profiles for beveled edges */ v = vm->boundstart; do { - -#ifdef USE_ALTERNATE_ADJ - copy_v3_v3(quad[0], v->nv.co); - mid_v3_v3v3(quad[1], v->nv.co, v->prev->nv.co); - /* quad[2] is set */ - mid_v3_v3v3(quad[3], v->nv.co, v->next->nv.co); -#endif - i = v->index; copy_mesh_vert(vm, i, 0, ns, v->next->index, 0, 0); if (v->ebev) { + +#ifdef USE_ALTERNATE_ADJ + copy_v3_v3(quad_plane[0], v->nv.co); + mid_v3_v3v3(quad_plane[1], v->nv.co, v->prev->nv.co); + /* quad[2] is set */ + mid_v3_v3v3(quad_plane[3], v->nv.co, v->next->nv.co); + + /* orig 'A' */ + copy_v3_v3(quad_orig_a[0], v->nv.co); /* only shared location between 2 quads */ + project_to_edge(v->ebev->prev->e, v->nv.co, v->prev->nv.co, quad_orig_a[1]); + project_to_edge(v->ebev->e, v->nv.co, v->next->nv.co, quad_orig_a[3]); + + /* orig 'B' */ + copy_v3_v3(quad_orig_b[3], v->next->nv.co); /* only shared location between 2 quads */ + project_to_edge(v->ebev->prev->e, v->nv.co, v->prev->nv.co, quad_orig_b[1]); + project_to_edge(v->ebev->e, v->nv.co, v->next->nv.co, quad_orig_b[0]); + + //bl_debug_draw_quad_add(UNPACK4(quad_plane)); + //bl_debug_draw_quad_add(UNPACK4(quad_orig_a)); + //bl_debug_draw_quad_add(UNPACK4(quad_orig_b)); +#endif /* USE_ALTERNATE_ADJ */ + #ifdef USE_ALTERNATE_ADJ for (k = 1; k < ns; k++) { - get_point_on_round_edge(v->ebev, 0, k, quad, co); + float uv[2]; + float fac; + float co_plane[3]; + float co_orig[3]; + + /* quad_plane */ + get_point_uv(uv, v->ebev->seg, 0, k); + get_point_on_round_edge(uv, quad_plane, co_plane); + + /* quad_orig */ + /* each half has different UV's */ + if (k <= ns2) { + get_point_uv(uv, v->ebev->seg, 0, k); + get_point_on_round_edge(uv, quad_orig_a, co_orig); + } + else { + get_point_uv(uv, v->ebev->seg, 0, (k - ns2) - (is_odd ? 0.5f : 0.0f)); + get_point_on_round_edge(uv, quad_orig_b, co_orig); + uv[1] = 1.0f - uv[1]; /* so we can get the factor */ + } + fac = get_point_uv_factor(uv); + + /* done. interp */ + interp_v3_v3v3(co, co_plane, co_orig, fac); copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co); if (!weld) create_mesh_bmvert(bm, vm, i, 0, k, bv->v); } -#else +#else /* USE_ALTERNATE_ADJ */ va = mesh_vert(vm, i, 0, 0)->co; vb = mesh_vert(vm, i, 0, ns)->co; project_to_edge(v->ebev->e, va, vb, midco); @@ -1256,7 +1334,7 @@ static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) if (!weld) create_mesh_bmvert(bm, vm, i, 0, k, bv->v); } -#endif +#endif /* !USE_ALTERNATE_ADJ */ } } while ((v = v->next) != vm->boundstart); From 3edbd1d0e2b8b09af60cec4e058b795fc0c2a1f7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 10:15:25 +0000 Subject: [PATCH 053/115] bevel: save some memory by aligning struct members. --- source/blender/bmesh/operators/bmo_bevel.c | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 28e28b67399..47295a44a84 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -37,17 +37,21 @@ #include "intern/bmesh_operators_private.h" /* own include */ /* experemental - Campbell */ -// #define USE_ALTERNATE_ADJ +//#define USE_ALTERNATE_ADJ #define BEVEL_FLAG 1 #define EDGE_SELECTED 2 #define BEVEL_EPSILON 1e-6 +/* for testing */ +// #pragma GCC diagnostic error "-Wpadded" + /* Constructed vertex, sometimes later instantiated as BMVert */ typedef struct NewVert { BMVert *v; float co[3]; + int _pad; } NewVert; struct BoundVert; @@ -56,28 +60,34 @@ struct BoundVert; typedef struct EdgeHalf { struct EdgeHalf *next, *prev; /* in CCW order */ BMEdge *e; /* original mesh edge */ - int isbev; /* is this edge beveled? */ - int isrev; /* is e->v2 the vertex at this end? */ - int seg; /* how many segments for the bevel */ - float offset; /* offset for this edge */ BMFace *fprev; /* face between this edge and previous, if any */ BMFace *fnext; /* face between this edge and next, if any */ struct BoundVert *leftv; /* left boundary vert (looking along edge to end) */ struct BoundVert *rightv; /* right boundary vert, if beveled */ + short isbev; /* is this edge beveled? */ + short isrev; /* is e->v2 the vertex at this end? */ + int seg; /* how many segments for the bevel */ + float offset; /* offset for this edge */ +// int _pad; } EdgeHalf; /* An element in a cyclic boundary of a Vertex Mesh (VMesh) */ typedef struct BoundVert { struct BoundVert *next, *prev; /* in CCW order */ - int index; /* used for vmesh indexing */ NewVert nv; EdgeHalf *efirst; /* first of edges attached here: in CCW order */ EdgeHalf *elast; EdgeHalf *ebev; /* beveled edge whose left side is attached here, if any */ + int index; /* used for vmesh indexing */ +// int _pad; } BoundVert; /* Mesh structure replacing a vertex */ typedef struct VMesh { + NewVert *mesh; /* allocated array - size and structure depends on kind */ + BoundVert *boundstart; /* start of boundary double-linked list */ + int count; /* number of vertices in the boundary */ + int seg; /* common # of segments for segmented edges */ enum { M_NONE, /* no polygon mesh needed */ M_POLY, /* a simple polygon */ @@ -86,10 +96,7 @@ typedef struct VMesh { M_TRI_FAN, /* a simple polygon - fan filled */ M_QUAD_STRIP, /* a simple polygon - cut into paralelle strips */ } mesh_kind; - int count; /* number of vertices in the boundary */ - int seg; /* common # of segments for segmented edges */ - BoundVert *boundstart; /* start of boundary double-linked list */ - NewVert *mesh; /* allocated array - size and structure depends on kind */ +// int _pad; } VMesh; /* Data for a vertex involved in a bevel */ @@ -101,9 +108,7 @@ typedef struct BevVert { VMesh *vmesh; /* mesh structure for replacing vertex */ } BevVert; -/* - * Bevel parameters and state - */ +/* Bevel parameters and state */ typedef struct BevelParams { /* hash of BevVert for each vertex involved in bevel * GHash: (key=(BMVert *), value=(BevVert *)) */ @@ -114,6 +119,8 @@ typedef struct BevelParams { int seg; /* number of segments in beveled edge profile */ } BevelParams; +// #pragma GCC diagnostic ignored "-Wpadded" + //#include "bevdebug.c" /* Make a new BoundVert of the given kind, insert it at the end of the circular linked From 88b26f24e42c5e6427d9709a3332ad903cb9d7c4 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 16 Nov 2012 12:18:47 +0000 Subject: [PATCH 054/115] Windows x64: * Fix compile after recent OIIO changes. --- build_files/scons/config/win64-vc-config.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index 8d49e178ddb..86b9984b7e3 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -164,14 +164,12 @@ BF_OIIO = '${LIBDIR}/openimageio' BF_OIIO_INC = '${BF_OIIO}/include' BF_OIIO_LIB = 'OpenImageIO' BF_OIIO_LIBPATH = '${BF_OIIO}/lib' -BF_OIIO_LIBPATH = '${BF_OIIO}/lib' WITH_BF_OCIO = True BF_OCIO = '${LIBDIR}/opencolorio' BF_OCIO_INC = '${BF_OCIO}/include' BF_OCIO_LIB = 'OpenColorIO' BF_OCIO_LIBPATH = '${BF_OCIO}/lib' -BF_OCIO_LIBPATH = '${BF_OCIO}/lib' WITH_BF_BOOST = True BF_BOOST = '${LIBDIR}/boost' @@ -216,7 +214,7 @@ C_WARN = [] CC_WARN = [] CXX_WARN = [] -LLIBS = ['ws2_32', 'vfw32', 'winmm', 'kernel32', 'user32', 'gdi32', 'comdlg32', 'advapi32', 'shfolder', 'shell32', 'ole32', 'oleaut32', 'uuid'] +LLIBS = ['ws2_32', 'vfw32', 'winmm', 'kernel32', 'user32', 'gdi32', 'comdlg32', 'advapi32', 'shfolder', 'shell32', 'ole32', 'oleaut32', 'uuid', 'psapi'] PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:X64','/STACK:2097152','/OPT:NOREF','/INCREMENTAL:NO', '/NODEFAULTLIB:msvcrt.lib', '/NODEFAULTLIB:msvcmrt.lib', '/NODEFAULTLIB:msvcurt.lib', '/NODEFAULTLIB:msvcrtd.lib'] From 6b0c200403fe37478a169add18efd706db46960f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 12:25:15 +0000 Subject: [PATCH 055/115] code cleanup: remove unneeded normalize (face normal), and unneeded call to len_v3v3 --- source/blender/bmesh/operators/bmo_bevel.c | 39 +++++++++++----------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 47295a44a84..656fef28393 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -37,7 +37,7 @@ #include "intern/bmesh_operators_private.h" /* own include */ /* experemental - Campbell */ -//#define USE_ALTERNATE_ADJ +// #define USE_ALTERNATE_ADJ #define BEVEL_FLAG 1 #define EDGE_SELECTED 2 @@ -64,8 +64,8 @@ typedef struct EdgeHalf { BMFace *fnext; /* face between this edge and next, if any */ struct BoundVert *leftv; /* left boundary vert (looking along edge to end) */ struct BoundVert *rightv; /* right boundary vert, if beveled */ - short isbev; /* is this edge beveled? */ - short isrev; /* is e->v2 the vertex at this end? */ + short is_bev; /* is this edge beveled? */ + short is_rev; /* is e->v2 the vertex at this end? */ int seg; /* how many segments for the bevel */ float offset; /* offset for this edge */ // int _pad; @@ -199,7 +199,7 @@ static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e) from_e = &bv->edges[bv->edgecount - 1]; e = from_e; do { - if (e->isbev) { + if (e->is_bev) { return e; } } while ((e = e->next) != from_e); @@ -338,7 +338,6 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, /* get vectors perp to each edge, perp to norm_v, and pointing into face */ if (f) { copy_v3_v3(norm_v, f->no); - normalize_v3(norm_v); } cross_v3_v3v3(norm_perp1, dir1, norm_v); cross_v3_v3v3(norm_perp2, dir2, norm_v); @@ -408,7 +407,7 @@ static void offset_in_plane(EdgeHalf *e, const float plane_no[3], int left, floa float dir[3], no[3]; BMVert *v; - v = e->isrev ? e->e->v1 : e->e->v2; + v = e->is_rev ? e->e->v1 : e->e->v2; sub_v3_v3v3(dir, BM_edge_other_vert(e->e, v)->co, v->co); normalize_v3(dir); @@ -436,8 +435,7 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3]) float dir[3], len; sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co); - len = len_v3(dir); - normalize_v3(dir); + len = normalize_v3(dir); if (d > len) d = len - (float)(50 * BEVEL_EPSILON); copy_v3_v3(slideco, v->co); @@ -607,7 +605,7 @@ static void get_point_on_round_edge(EdgeHalf *e, int k, sub_v3_v3v3(vva, va, vmid); sub_v3_v3v3(vvb, vb, vmid); - if (e->isrev) + if (e->is_rev) sub_v3_v3v3(dir, e->e->v1->co, e->e->v2->co); else sub_v3_v3v3(dir, e->e->v2->co, e->e->v1->co); @@ -644,7 +642,8 @@ static void build_boundary(MemArena *mem_arena, BevVert *bv) EdgeHalf *efirst, *e; BoundVert *v; VMesh *vm; - float co[3], *no; + float co[3]; + const float *no; float lastd; e = efirst = next_bev(bv, NULL); @@ -675,9 +674,9 @@ static void build_boundary(MemArena *mem_arena, BevVert *bv) lastd = e->offset; vm->boundstart = NULL; do { - if (e->isbev) { + if (e->is_bev) { /* handle only left side of beveled edge e here: next iteration should do right side */ - if (e->prev->isbev) { + if (e->prev->is_bev) { BLI_assert(e->prev != e); /* see: wire edge special case */ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co); v = add_new_bound_vert(mem_arena, vm, co); @@ -688,7 +687,7 @@ static void build_boundary(MemArena *mem_arena, BevVert *bv) } else { /* e->prev is not beveled */ - if (e->prev->prev->isbev) { + if (e->prev->prev->is_bev) { BLI_assert(e->prev->prev != e); /* see: edgecount 2, selcount 1 case */ /* find meet point between e->prev->prev and e and attach e->prev there */ /* TODO: fix case when one or both faces in following are NULL */ @@ -715,11 +714,11 @@ static void build_boundary(MemArena *mem_arena, BevVert *bv) } else { /* e is not beveled */ - if (e->next->isbev) { + if (e->next->is_bev) { /* next iteration will place e between beveled previous and next edges */ /* do nothing... */ } - else if (e->prev->isbev) { + else if (e->prev->is_bev) { /* on-edge meet between e->prev and e */ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co); v = add_new_bound_vert(mem_arena, vm, co); @@ -1447,15 +1446,15 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) bme = e->e; BMO_elem_flag_enable(bm, bme, BEVEL_FLAG); if (BMO_elem_flag_test(bm, bme, EDGE_SELECTED)) { - e->isbev = 1; + e->is_bev = TRUE; e->seg = bp->seg; } else { - e->isbev = 0; + e->is_bev = FALSE; e->seg = 0; } - e->isrev = (bme->v2 == v); - e->offset = e->isbev ? bp->offset : 0.0f; + e->is_rev = (bme->v2 == v); + e->offset = e->is_bev ? bp->offset : 0.0f; } /* find wrap-around shared face */ BM_ITER_ELEM (f, &iter2, bme, BM_FACES_OF_EDGE) { @@ -1524,7 +1523,7 @@ static void rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) eprev = find_edge_half(bv, lprev->e); BLI_assert(e != NULL && eprev != NULL); vstart = eprev->leftv; - if (e->isbev) + if (e->is_bev) vend = e->rightv; else vend = e->leftv; From b7dbf83d19a9e2f6e1109948f7fa81b338f3a7b3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 12:33:24 +0000 Subject: [PATCH 056/115] more minor improvements to bevel use of math functions --- source/blender/bmesh/operators/bmo_bevel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 656fef28393..076ff0b75cb 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -389,7 +389,7 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, madd_v3_v3fl(off2a, norm_perp2, e2->offset); add_v3_v3v3(off2b, off2a, dir2); - if (fabs(angle_v3v3(dir1, dir2)) < BEVEL_EPSILON) { + if (angle_v3v3(dir1, dir2) < (float)BEVEL_EPSILON) { /* lines are parallel; off1a is a good meet point */ copy_v3_v3(meetco, off1a); } @@ -437,7 +437,7 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3]) sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co); len = normalize_v3(dir); if (d > len) - d = len - (float)(50 * BEVEL_EPSILON); + d = len - (float)(50.0 * BEVEL_EPSILON); copy_v3_v3(slideco, v->co); madd_v3_v3fl(slideco, dir, -d); } @@ -562,7 +562,7 @@ static void get_point_on_round_profile(float r_co[3], float offset, int k, int c sub_v3_v3v3(vvb, vb, v); normalize_v3(vva); normalize_v3(vvb); - angle = angle_v3v3(vva, vvb); + angle = angle_normalized_v3v3(vva, vvb); add_v3_v3v3(center, vva, vvb); normalize_v3(center); From 276c842096e1e1b1407b226965c9fd8c472a8ca4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 12:41:40 +0000 Subject: [PATCH 057/115] BLI_assert() when math functions that require are normalize vector are called without one. --- source/blender/blenlib/intern/math_vector.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 7f578fe305d..812e2b3e63d 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -208,6 +208,13 @@ float angle_signed_v2v2(const float v1[2], const float v2[2]) float angle_normalized_v3v3(const float v1[3], const float v2[3]) { + /* double check they are normalized */ +#ifdef DEBUG + float test; + BLI_assert(fabsf((test = len_squared_v3(v1)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); + BLI_assert(fabsf((test = len_squared_v3(v2)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); +#endif + /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */ if (dot_v3v3(v1, v2) < 0.0f) { float vec[3]; @@ -224,6 +231,13 @@ float angle_normalized_v3v3(const float v1[3], const float v2[3]) float angle_normalized_v2v2(const float v1[2], const float v2[2]) { + /* double check they are normalized */ +#ifdef DEBUG + float test; + BLI_assert(fabsf((test = len_squared_v2(v1)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); + BLI_assert(fabsf((test = len_squared_v2(v2)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); +#endif + /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */ if (dot_v2v2(v1, v2) < 0.0f) { float vec[2]; @@ -408,6 +422,12 @@ void rotate_normalized_v3_v3v3fl(float r[3], const float p[3], const float axis[ const float costheta = cos(angle); const float sintheta = sin(angle); + /* double check they are normalized */ +#ifdef DEBUG + float test; + BLI_assert(fabsf((test = len_squared_v3(axis)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); +#endif + r[0] = ((costheta + (1 - costheta) * axis[0] * axis[0]) * p[0]) + (((1 - costheta) * axis[0] * axis[1] - axis[2] * sintheta) * p[1]) + (((1 - costheta) * axis[0] * axis[2] + axis[1] * sintheta) * p[2]); From 366b60c6cb62722173c09f440af34c05052c53d7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 16 Nov 2012 12:42:01 +0000 Subject: [PATCH 058/115] First atempt to add OSL. DEB only for now: installs needed deps (LLVM & co), downloads OSL source and compiles the lib. However, blender linking fails currently... :/ --- build_files/build_environment/install_deps.sh | 122 ++++++++++++++---- 1 file changed, 94 insertions(+), 28 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 72211a52e72..7c2dcbfa068 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -29,7 +29,7 @@ LLVM_VERSION_MIN="3.0" # OSL needs to be compiled for now! OSL_VERSION="1.2.0" -OSL_SOURCE="https://github.com/DingTo/OpenShadingLanguage/archive/blender-fixes.zip" +OSL_SOURCE="https://github.com/DingTo/OpenShadingLanguage/archive/blender-fixes.tar.gz" FFMPEG_VERSION="1.0" FFMPEG_SOURCE="http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" @@ -264,11 +264,11 @@ compile_OCIO() { fi cmake -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_PREFIX_PATH=$INST/ocio-$OCIO_VERSION \ - -D CMAKE_INSTALL_PREFIX=$INST/ocio-$OCIO_VERSION \ - -D CMAKE_CXX_FLAGS="$cflags" \ - -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \ - .. + -D CMAKE_PREFIX_PATH=$INST/ocio-$OCIO_VERSION \ + -D CMAKE_INSTALL_PREFIX=$INST/ocio-$OCIO_VERSION \ + -D CMAKE_CXX_FLAGS="$cflags" \ + -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \ + .. make -j$THREADS make install @@ -295,7 +295,7 @@ compile_OCIO() { compile_OIIO() { # To be changed each time we make edits that would modify the compiled result! - oiio_magic=1 + oiio_magic=5 # Clean install if needed! magic_compile_check oiio-$OIIO_VERSION $oiio_magic @@ -324,26 +324,27 @@ compile_OIIO() { mkdir build cd build + cmake_d="-D CMAKE_BUILD_TYPE=Release \ + -D CMAKE_PREFIX_PATH=$INST/oiio-$OIIO_VERSION \ + -D CMAKE_INSTALL_PREFIX=$INST/oiio-$OIIO_VERSION \ + -D BUILDSTATIC=ON" + if [ -d $INST/boost ]; then - boost_root="$INST/boost" - else - boost_root="/usr" + cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost" fi + # Looks like we do not need ocio in oiio for now... +# if [ -d $INST/ocio ]; then +# cmake_d="$cmake_d -D OCIO_PATH=$INST/ocio" +# fi + if file /bin/cp | grep -q '32-bit'; then cflags="-fPIC -m32 -march=i686" else cflags="-fPIC" fi - cmake -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_PREFIX_PATH=$INST/oiio-$OIIO_VERSION \ - -D CMAKE_INSTALL_PREFIX=$INST/oiio-$OIIO_VERSION \ - -D BUILDSTATIC=ON \ - -D CMAKE_CXX_FLAGS="$cflags" \ - -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \ - -D BOOST_ROOT="$boost_root" \ - ../src + cmake $cmake_d -D CMAKE_CXX_FLAGS="$cflags" -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" ../src make -j$THREADS make install @@ -360,6 +361,67 @@ compile_OIIO() { fi } +compile_OSL() { + # To be changed each time we make edits that would modify the compiled result! + osl_magic=0 + + # Clean install if needed! + magic_compile_check osl-$OSL_VERSION $osl_magic + if [ $? -eq 1 ]; then + rm -rf $INST/osl-$OSL_VERSION + fi + + if [ ! -d $INST/osl-$OSL_VERSION ]; then + INFO "Building OpenShadingLanguage-$OSL_VERSION" + + prepare_opt + + if [ ! -d $SRC/OpenShadingLanguage-$OSL_VERSION ]; then + wget -c $OSL_SOURCE -O "$SRC/OpenShadingLanguage-$OSL_VERSION.tar.gz" + + INFO "Unpacking OpenShadingLanguage-$OSL_VERSION" + tar -C $SRC --transform "s,(.*/?)OpenShadingLanguage-[^/]*(.*),\1OpenShadingLanguage-$OSL_VERSION\2,x" \ + -xf $SRC/OpenShadingLanguage-$OSL_VERSION.tar.gz + fi + + cd $SRC/OpenShadingLanguage-$OSL_VERSION + # Always refresh the whole build! +# if [ -d build ]; then +# rm -rf build +# fi +# mkdir build + cd build + + cmake_d="-D CMAKE_BUILD_TYPE=Release \ + -D CMAKE_INSTALL_PREFIX=$INST/osl-$OSL_VERSION + -D BUILDSTATIC=ON \ + -D BUILD_TESTING=OFF" + + if [ -d $INST/boost ]; then + cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost" + fi + + if [ -d $INST/oiio ]; then + cmake_d="$cmake_d -D OPENIMAGEIOHOME=$INST/oiio" + fi + + cmake $cmake_d -D CMAKE_CXX_FLAGS="-Wall" ../src + + make -j$THREADS + make install + make clean + + rm -f $INST/osl + ln -s osl-$OSL_VERSION $INST/osl + + magic_compile_set osl-$OSL_VERSION $osl_magic + + cd $CWD + else + INFO "Own OpenShadingLanguage-$OSL_VERSION is up to date, nothing to do!" + fi +} + compile_FFmpeg() { # To be changed each time we make edits that would modify the compiled result! ffmpeg_magic=0 @@ -500,7 +562,7 @@ install_DEB() { libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \ libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV libopenexr-dev libopenal-dev \ libglew-dev yasm $SCHRO_DEV $THEORA_DEV $VORBIS_DEV libsdl1.2-dev \ - libfftw3-dev libjack-dev python-dev patch flex bison + libfftw3-dev libjack-dev python-dev patch flex bison llvm-dev clang libtbb-dev OPENJPEG_USE=true SCHRO_USE=true @@ -564,7 +626,8 @@ install_DEB() { check_package_DEB libboost-locale$boost_version-dev if [ $? -eq 0 ]; then sudo apt-get install -y libboost-locale$boost_version-dev libboost-filesystem$boost_version-dev \ - libboost-regex$boost_version-dev libboost-system$boost_version-dev libboost-thread$boost_version-dev + libboost-regex$boost_version-dev libboost-system$boost_version-dev \ + libboost-thread$boost_version-dev else compile_Boost fi @@ -586,6 +649,9 @@ install_DEB() { compile_OIIO fi + # No package currently! + compile_OSL + # XXX Debian features libav packages as ffmpeg, those are not really compatible with blender code currently :/ # So for now, always build our own ffmpeg. # check_package_DEB ffmpeg @@ -617,23 +683,23 @@ check_package_RPM() { check_package_version_match_RPM() { v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'` - if [ -z "$v" ]; then + if [ $v -ge 1 ]; then + version_match $v $2 + return $? + else return 1 fi - - version_match $v $2 - return $? } check_package_version_ge_RPM() { v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'` - if [ -z "$v" ]; then + if [ $v -ge 1 ]; then + version_ge $v $2 + return $? + else return 1 fi - - version_ge $v $2 - return $? } install_RPM() { From 8928344bf7cb1319aa6ab1b0089fad474e796ce6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 13:41:21 +0000 Subject: [PATCH 059/115] fix for own bug in quad-stip fill method, quad strips were skewed. --- source/blender/bmesh/operators/bmo_bevel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 076ff0b75cb..d8a3e3fbb3e 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -1193,7 +1193,10 @@ static void bevel_build_quadstrip(BMesh *bm, BevVert *bv) if (f) { /* we have a polygon which we know starts at this vertex, make it into strips */ - BMVert *v_first = bv->vmesh->boundstart->efirst->next->next->leftv->nv.v; /* magic? */ + EdgeHalf *efirst = bv->vmesh->boundstart->efirst; + BMVert *v_first = efirst->is_bev ? + efirst->next->leftv->nv.v : + efirst->next->next->leftv->nv.v; /* magic? */ //BMLoop *l_start = BM_FACE_FIRST_LOOP(f); BMLoop *l_start = BM_face_vert_share_loop(f, v_first); BMLoop *l_a = l_start->prev, *l_a_step; From dc06523622e90ce236bf7bf32bebb45968bc51ae Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 14:28:37 +0000 Subject: [PATCH 060/115] rework the bevel quad strip logic to work with ngons correctly, previously it only worked properly with triangles. --- source/blender/bmesh/operators/bmo_bevel.c | 57 +++++++++++++++------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index d8a3e3fbb3e..1b1fc53011f 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -1193,32 +1193,53 @@ static void bevel_build_quadstrip(BMesh *bm, BevVert *bv) if (f) { /* we have a polygon which we know starts at this vertex, make it into strips */ - EdgeHalf *efirst = bv->vmesh->boundstart->efirst; - BMVert *v_first = efirst->is_bev ? - efirst->next->leftv->nv.v : - efirst->next->next->leftv->nv.v; /* magic? */ - //BMLoop *l_start = BM_FACE_FIRST_LOOP(f); - BMLoop *l_start = BM_face_vert_share_loop(f, v_first); - BMLoop *l_a = l_start->prev, *l_a_step; - BMLoop *l_b = l_start->next, *l_b_step; + EdgeHalf *eh_first, *eh_iter; + EdgeHalf *eh_a = NULL, *eh_b = NULL; + BMVert *v_a_first, *v_b_first; + + BMLoop *l_a; + BMLoop *l_b; + + /* find both edges */ + eh_iter = eh_first = bv->vmesh->boundstart->efirst; + do { + if (eh_iter->seg) { + if (eh_a == NULL) { + eh_a = eh_iter; + } + else if (eh_b == NULL) { + eh_b = eh_iter; + break; + } + } + } while ((eh_iter = eh_iter->next) != NULL); + + v_a_first = eh_a->rightv->nv.v; + v_b_first = eh_b->leftv->nv.v; + + l_a = BM_face_vert_share_loop(f, v_a_first); + l_b = BM_face_vert_share_loop(f, v_b_first); + if (l_a == l_b) { + /* step once around if we hit the same loop */ + l_a = l_a->prev; + l_b = l_b->next; + } while (f->len > 4) { - // BMLoop *l_new; - BMFace *f_new; + BMLoop *l_new; BLI_assert(l_a->f == f); BLI_assert(l_b->f == f); - l_a_step = l_a->prev; - l_b_step = l_b->next; + BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, FALSE); - f_new = BM_face_split(bm, f, l_a->v, l_b->v, NULL, NULL, FALSE); - - if (f_new->len > f->len) { - f = f_new; + if (l_new->f->len < l_new->radial_next->f->len) { + l_new = l_new->radial_next; } + f = l_new->f; - l_a = l_a_step; - l_b = l_b_step; + /* walk around the new face to get the next verts to split */ + l_a = l_new->prev; + l_b = l_new->next->next; } } } From d017f34c5dda6f0940c0ba13271113881b7108b5 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 16 Nov 2012 14:42:04 +0000 Subject: [PATCH 061/115] OSX/scons/osl: working but not optimally designed atm --- SConstruct | 6 ++++-- build_files/scons/config/darwin-config.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index 01e83a7bacc..7a4b74de5aa 100644 --- a/SConstruct +++ b/SConstruct @@ -307,8 +307,10 @@ if env['OURPLATFORM']=='darwin': env.Append(LINKFLAGS=['-Xlinker','-weak_framework','-Xlinker','Jackmp']) if env['WITH_BF_CYCLES_OSL'] == 1: - env.Append(LINKFLAGS=['-force_load','../lib/darwin-9.x.universal/osl/lib/liboslexec.a']) - + # this is kinda hardcoded atm due not understood path issues, also look that we need 2 variants of passing the oslexec with the force_load option, why ? + env.Append(LINKFLAGS=['-L../lib/darwin-9.x.universal/osl/lib','-loslcomp','-force_load ../lib/darwin-9.x.universal/osl/lib/liboslexec.a','-loslquery']) + env.Append(BF_PROGRAM_LINKFLAGS=['-loslcomp','-force_load','../lib/darwin-9.x.universal/osl/lib/liboslexec.a']) + if env['WITH_BF_OPENMP'] == 1: if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): env['CCFLAGS'].append('/openmp') diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 73cd92ccb4c..3c051dbe242 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -283,7 +283,7 @@ BF_OSL = LIBDIR + '/osl' BF_OSL_INC = '${BF_OSL}/include' # note oslexec would passed via program linkflags, which is needed to # make llvm happy with osl_allocate_closure_component -BF_OSL_LIB = 'oslcomp oslquery' +#BF_OSL_LIB = 'oslcomp oslquery' BF_OSL_LIBPATH = '${BF_OSL}/lib' BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' From cf64a5b622151dbcfd7162e7ee93fd7afc88b24f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 16 Nov 2012 15:15:40 +0000 Subject: [PATCH 062/115] Python/Context: do not allow any UI context access from threads like render or baking. This basically means you will only have access to bpy.data and bpy.context.scene, not current window, active object, etc, as those are not thread safe anyway and were likely to cause issues already. This fixes #30858, where the UI would lose buttons due to context getting corrupted when editing objects in pre/post render or using luxrender. The context access they did (indirectly) was only using the current scene or data so they still work. --- source/blender/blenkernel/intern/context.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 719ae7357b4..ffb93139358 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -44,6 +44,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_threads.h" #include "BLI_utildefines.h" #include "BKE_context.h" @@ -245,6 +246,10 @@ static void *ctx_wm_python_context_get(const bContext *C, const char *member, vo (void)C, (void)member; #endif + /* don't allow UI context access from non-main threads */ + if (!BLI_thread_is_main()) + return NULL; + return fall_through; } @@ -264,6 +269,11 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res // return 1; } #endif + + /* don't allow UI context access from non-main threads */ + if (!BLI_thread_is_main()) + return done; + /* we check recursion to ensure that we do not get infinite * loops requesting data from ourselfs in a context callback */ From 749469803173556e43311399cd446322d1392395 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 16 Nov 2012 15:18:14 +0000 Subject: [PATCH 063/115] OSX/scons/osl: use Xlinker for the BF_PROGRAM_LINKFLAGS, so we can alternative again compile with gcc-4.6 --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 7a4b74de5aa..42be4ac191b 100644 --- a/SConstruct +++ b/SConstruct @@ -309,7 +309,7 @@ if env['OURPLATFORM']=='darwin': if env['WITH_BF_CYCLES_OSL'] == 1: # this is kinda hardcoded atm due not understood path issues, also look that we need 2 variants of passing the oslexec with the force_load option, why ? env.Append(LINKFLAGS=['-L../lib/darwin-9.x.universal/osl/lib','-loslcomp','-force_load ../lib/darwin-9.x.universal/osl/lib/liboslexec.a','-loslquery']) - env.Append(BF_PROGRAM_LINKFLAGS=['-loslcomp','-force_load','../lib/darwin-9.x.universal/osl/lib/liboslexec.a']) + env.Append(BF_PROGRAM_LINKFLAGS=['-loslcomp','-Xlinker','-force_load','-Xlinker','../lib/darwin-9.x.universal/osl/lib/liboslexec.a']) if env['WITH_BF_OPENMP'] == 1: if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): From abc122205a00aac4623b868fe8b3fe7890a2bdfb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 16 Nov 2012 17:14:01 +0000 Subject: [PATCH 064/115] More fixes and cleanup... Now OSL should work for DEB-like systems with CMake (not yet tested with scones, nor fedora). Fedora version-checking bug should be fixed. Also simplified a bit compile_FOO funcs code. --- build_files/build_environment/install_deps.sh | 169 +++++++++++------- 1 file changed, 103 insertions(+), 66 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 7c2dcbfa068..bc0c39e3040 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -29,7 +29,7 @@ LLVM_VERSION_MIN="3.0" # OSL needs to be compiled for now! OSL_VERSION="1.2.0" -OSL_SOURCE="https://github.com/DingTo/OpenShadingLanguage/archive/blender-fixes.tar.gz" +OSL_SOURCE="https://github.com/mont29/OpenShadingLanguage/archive/blender-fixes.tar.gz" FFMPEG_VERSION="1.0" FFMPEG_SOURCE="http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" @@ -143,28 +143,31 @@ compile_Python() { # To be changed each time we make edits that would modify the compiled result! py_magic=0 + _src=$SRC/Python-$PYTHON_VERSION + _inst=$INST/python-$PYTHON_VERSION + # Clean install if needed! magic_compile_check python-$PYTHON_VERSION $py_magic if [ $? -eq 1 ]; then - rm -rf $INST/python-$PYTHON_VERSION + rm -rf $_inst fi - if [ ! -d $INST/python-$PYTHON_VERSION ]; then + if [ ! -d $_inst ]; then INFO "Building Python-$PYTHON_VERSION" prepare_opt - if [ ! -d $SRC/Python-$PYTHON_VERSION ]; then + if [ ! -d $_src ]; then mkdir -p $SRC - wget -c $PYTHON_SOURCE -P $SRC + wget -c $PYTHON_SOURCE -O $_src.tar.bz2 INFO "Unpacking Python-$PYTHON_VERSION" - tar -C $SRC -xf $SRC/Python-$PYTHON_VERSION.tar.bz2 + tar -C $SRC -xf $_src.tar.bz2 fi - cd $SRC/Python-$PYTHON_VERSION + cd $_src - ./configure --prefix=$INST/python-$PYTHON_VERSION --enable-ipv6 \ + ./configure --prefix=$_inst --enable-ipv6 \ --enable-loadable-sqlite-extensions --with-dbmliborder=bdb \ --with-computed-gotos --with-pymalloc @@ -180,6 +183,7 @@ compile_Python() { cd $CWD else INFO "Own Python-$PYTHON_VERSION is up to date, nothing to do!" + INFO "If you want to force rebuild of this lib, delete the '$_src' directory." fi } @@ -187,30 +191,33 @@ compile_Boost() { # To be changed each time we make edits that would modify the compiled result! boost_magic=7 + _src=$SRC/boost-$BOOST_VERSION + _inst=$INST/boost-$BOOST_VERSION + # Clean install if needed! magic_compile_check boost-$BOOST_VERSION $boost_magic if [ $? -eq 1 ]; then - rm -rf $INST/boost-$BOOST_VERSION + rm -rf $_inst fi - if [ ! -d $INST/boost-$BOOST_VERSION ]; then + if [ ! -d $_inst ]; then INFO "Building Boost-$BOOST_VERSION" prepare_opt - if [ ! -d $SRC/boost-$BOOST_VERSION ]; then + if [ ! -d $_src ]; then INFO "Downloading Boost-$BOOST_VERSION" mkdir -p $SRC - wget -c $BOOST_SOURCE -O $SRC/boost-$BOOST_VERSION.tar.bz2 - tar -C $SRC --transform "s,(.*/?)boost_1_[^/]+(.*),\1boost-$BOOST_VERSION\2,x" -xf $SRC/boost-$BOOST_VERSION.tar.bz2 + wget -c $BOOST_SOURCE -O $_src.tar.bz2 + tar -C $SRC --transform "s,(.*/?)boost_1_[^/]+(.*),\1boost-$BOOST_VERSION\2,x" -xf $_src.tar.bz2 fi - cd $SRC/boost-$BOOST_VERSION - if [ ! -f $SRC/boost-$BOOST_VERSION/b2 ]; then + cd $_src + if [ ! -f $_src/b2 ]; then ./bootstrap.sh fi ./b2 -j$THREADS -a --with-system --with_filesystem --with-thread --with-regex --with-locale --with-date_time \ - --prefix=$INST/boost-$BOOST_VERSION --disable-icu boost.locale.icu=off install + --prefix=$_inst --disable-icu boost.locale.icu=off install ./b2 --clean rm -f $INST/boost @@ -221,6 +228,7 @@ compile_Boost() { cd $CWD else INFO "Own Boost-$BOOST_VERSION is up to date, nothing to do!" + INFO "If you want to force rebuild of this lib, delete the '$_src' directory." fi } @@ -228,28 +236,31 @@ compile_OCIO() { # To be changed each time we make edits that would modify the compiled result! ocio_magic=1 + _src=$SRC/OpenColorIO-$OCIO_VERSION + _inst=$INST/ocio-$OCIO_VERSION + # Clean install if needed! magic_compile_check ocio-$OCIO_VERSION $ocio_magic if [ $? -eq 1 ]; then - rm -rf $INST/ocio-$OCIO_VERSION + rm -rf $_inst fi - if [ ! -d $INST/ocio-$OCIO_VERSION ]; then + if [ ! -d $_inst ]; then INFO "Building OpenColorIO-$OCIO_VERSION" prepare_opt - if [ ! -d $SRC/OpenColorIO-$OCIO_VERSION ]; then + if [ ! -d $_src ]; then INFO "Downloading OpenColorIO-$OCIO_VERSION" mkdir -p $SRC - wget -c $OCIO_SOURCE -O $SRC/OpenColorIO-$OCIO_VERSION.tar.gz + wget -c $OCIO_SOURCE -O $_src.tar.gz INFO "Unpacking OpenColorIO-$OCIO_VERSION" tar -C $SRC --transform "s,(.*/?)imageworks-OpenColorIO[^/]*(.*),\1OpenColorIO-$OCIO_VERSION\2,x" \ - -xf $SRC/OpenColorIO-$OCIO_VERSION.tar.gz + -xf $_src.tar.gz fi - cd $SRC/OpenColorIO-$OCIO_VERSION + cd $_src # Always refresh the whole build! if [ -d build ]; then rm -rf build @@ -264,8 +275,8 @@ compile_OCIO() { fi cmake -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_PREFIX_PATH=$INST/ocio-$OCIO_VERSION \ - -D CMAKE_INSTALL_PREFIX=$INST/ocio-$OCIO_VERSION \ + -D CMAKE_PREFIX_PATH=$_inst \ + -D CMAKE_INSTALL_PREFIX=$_inst \ -D CMAKE_CXX_FLAGS="$cflags" \ -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \ .. @@ -274,11 +285,11 @@ compile_OCIO() { make install # Force linking against static libs - rm -f $INST/ocio-$OCIO_VERSION/lib/*.so* + rm -f $_inst/lib/*.so* # Additional depencencies - cp ext/dist/lib/libtinyxml.a $INST/ocio-$OCIO_VERSION/lib - cp ext/dist/lib/libyaml-cpp.a $INST/ocio-$OCIO_VERSION/lib + cp ext/dist/lib/libtinyxml.a $_inst/lib + cp ext/dist/lib/libyaml-cpp.a $_inst/lib make clean @@ -290,6 +301,7 @@ compile_OCIO() { cd $CWD else INFO "Own OpenColorIO-$OCIO_VERSION is up to date, nothing to do!" + INFO "If you want to force rebuild of this lib, delete the '$_src' directory." fi } @@ -297,26 +309,29 @@ compile_OIIO() { # To be changed each time we make edits that would modify the compiled result! oiio_magic=5 + _src=$SRC/OpenImageIO-$OIIO_VERSION + _inst=$INST/oiio-$OIIO_VERSION + # Clean install if needed! magic_compile_check oiio-$OIIO_VERSION $oiio_magic if [ $? -eq 1 ]; then - rm -rf $INST/oiio-$OIIO_VERSION + rm -rf $_inst fi - if [ ! -d $INST/oiio-$OIIO_VERSION ]; then + if [ ! -d $_inst ]; then INFO "Building OpenImageIO-$OIIO_VERSION" prepare_opt - if [ ! -d $SRC/OpenImageIO-$OIIO_VERSION ]; then - wget -c $OIIO_SOURCE -O "$SRC/OpenImageIO-$OIIO_VERSION.tar.gz" + if [ ! -d $_src ]; then + wget -c $OIIO_SOURCE -O "$_src.tar.gz" INFO "Unpacking OpenImageIO-$OIIO_VERSION" tar -C $SRC --transform "s,(.*/?)OpenImageIO-oiio[^/]*(.*),\1OpenImageIO-$OIIO_VERSION\2,x" \ - -xf $SRC/OpenImageIO-$OIIO_VERSION.tar.gz + -xf $_src.tar.gz fi - cd $SRC/OpenImageIO-$OIIO_VERSION + cd $_src # Always refresh the whole build! if [ -d build ]; then rm -rf build @@ -325,8 +340,8 @@ compile_OIIO() { cd build cmake_d="-D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_PREFIX_PATH=$INST/oiio-$OIIO_VERSION \ - -D CMAKE_INSTALL_PREFIX=$INST/oiio-$OIIO_VERSION \ + -D CMAKE_PREFIX_PATH=$_inst \ + -D CMAKE_INSTALL_PREFIX=$_inst \ -D BUILDSTATIC=ON" if [ -d $INST/boost ]; then @@ -358,42 +373,54 @@ compile_OIIO() { cd $CWD else INFO "Own OpenImageIO-$OIIO_VERSION is up to date, nothing to do!" + INFO "If you want to force rebuild of this lib, delete the '$_src' directory." fi } compile_OSL() { # To be changed each time we make edits that would modify the compiled result! - osl_magic=0 + osl_magic=4 + + _src=$SRC/OpenShadingLanguage-$OSL_VERSION + _inst=$INST/osl-$OSL_VERSION # Clean install if needed! magic_compile_check osl-$OSL_VERSION $osl_magic if [ $? -eq 1 ]; then - rm -rf $INST/osl-$OSL_VERSION + rm -rf $_inst fi - if [ ! -d $INST/osl-$OSL_VERSION ]; then + if [ ! -d $_inst ]; then INFO "Building OpenShadingLanguage-$OSL_VERSION" prepare_opt - if [ ! -d $SRC/OpenShadingLanguage-$OSL_VERSION ]; then - wget -c $OSL_SOURCE -O "$SRC/OpenShadingLanguage-$OSL_VERSION.tar.gz" + if [ ! -d $_src ]; then + # XXX Using git on my own repo for now, looks like archives are not updated immediately... :/ +# wget -c $OSL_SOURCE -O "$_src.tar.gz" - INFO "Unpacking OpenShadingLanguage-$OSL_VERSION" - tar -C $SRC --transform "s,(.*/?)OpenShadingLanguage-[^/]*(.*),\1OpenShadingLanguage-$OSL_VERSION\2,x" \ - -xf $SRC/OpenShadingLanguage-$OSL_VERSION.tar.gz +# INFO "Unpacking OpenShadingLanguage-$OSL_VERSION" +# tar -C $SRC --transform "s,(.*/?)OpenShadingLanguage-[^/]*(.*),\1OpenShadingLanguage-$OSL_VERSION\2,x" \ +# -xf $_src.tar.gz + git clone https://github.com/mont29/OpenShadingLanguage.git $_src + cd $_src + git checkout blender-fixes + cd $CWD fi - cd $SRC/OpenShadingLanguage-$OSL_VERSION + cd $_src + # XXX For now, always update from latest repo... + git checkout . + # Always refresh the whole build! -# if [ -d build ]; then -# rm -rf build -# fi -# mkdir build + if [ -d build ]; then + rm -rf build + fi + mkdir build cd build cmake_d="-D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_INSTALL_PREFIX=$INST/osl-$OSL_VERSION + -D CMAKE_INSTALL_PREFIX=$_inst -D BUILDSTATIC=ON \ -D BUILD_TESTING=OFF" @@ -405,7 +432,7 @@ compile_OSL() { cmake_d="$cmake_d -D OPENIMAGEIOHOME=$INST/oiio" fi - cmake $cmake_d -D CMAKE_CXX_FLAGS="-Wall" ../src + cmake $cmake_d ../src make -j$THREADS make install @@ -419,6 +446,7 @@ compile_OSL() { cd $CWD else INFO "Own OpenShadingLanguage-$OSL_VERSION is up to date, nothing to do!" + INFO "If you want to force rebuild of this lib, delete the '$_src' directory." fi } @@ -426,26 +454,29 @@ compile_FFmpeg() { # To be changed each time we make edits that would modify the compiled result! ffmpeg_magic=0 + _src=$SRC/ffmpeg-$FFMPEG_VERSION + _inst=$INST/ffmpeg-$FFMPEG_VERSION + # Clean install if needed! magic_compile_check ffmpeg-$FFMPEG_VERSION $ffmpeg_magic if [ $? -eq 1 ]; then - rm -rf $INST/ffmpeg-$FFMPEG_VERSION + rm -rf $_inst fi - if [ ! -d $INST/ffmpeg-$FFMPEG_VERSION ]; then + if [ ! -d $_inst ]; then INFO "Building ffmpeg-$FFMPEG_VERSION" prepare_opt - if [ ! -d $SRC/ffmpeg-$FFMPEG_VERSION ]; then + if [ ! -d $_src ]; then INFO "Downloading ffmpeg-$FFMPEG_VERSION" - wget -c $FFMPEG_SOURCE -P $SRC + wget -c $FFMPEG_SOURCE -O "$_src.tar.bz2" INFO "Unpacking ffmpeg-$FFMPEG_VERSION" - tar -C $SRC -xf $SRC/ffmpeg-$FFMPEG_VERSION.tar.bz2 + tar -C $SRC -xf $_src.tar.bz2 fi - cd $SRC/ffmpeg-$FFMPEG_VERSION + cd $_src extra="" @@ -482,7 +513,7 @@ compile_FFmpeg() { fi ./configure --cc="gcc -Wl,--as-needed" --extra-ldflags="-pthread -static-libgcc" \ - --prefix=$INST/ffmpeg-$FFMPEG_VERSION --enable-static --enable-avfilter --disable-vdpau \ + --prefix=$_inst --enable-static --enable-avfilter --disable-vdpau \ --disable-bzlib --disable-libgsm --disable-libspeex \ --enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \ --disable-vaapi --disable-libfaac --disable-nonfree --enable-gpl \ @@ -503,6 +534,7 @@ compile_FFmpeg() { cd $CWD else INFO "Own ffmpeg-$FFMPEG_VERSION is up to date, nothing to do!" + INFO "If you want to force rebuild of this lib, delete the '$_src' directory." fi } @@ -562,7 +594,7 @@ install_DEB() { libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \ libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV libopenexr-dev libopenal-dev \ libglew-dev yasm $SCHRO_DEV $THEORA_DEV $VORBIS_DEV libsdl1.2-dev \ - libfftw3-dev libjack-dev python-dev patch flex bison llvm-dev clang libtbb-dev + libfftw3-dev libjack-dev python-dev patch flex bison llvm-dev clang libtbb-dev git OPENJPEG_USE=true SCHRO_USE=true @@ -683,23 +715,23 @@ check_package_RPM() { check_package_version_match_RPM() { v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'` - if [ $v -ge 1 ]; then - version_match $v $2 - return $? - else + if [ -z "$v" ]; then return 1 fi + + version_match $v $2 + return $? } check_package_version_ge_RPM() { v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'` - if [ $v -ge 1 ]; then - version_ge $v $2 - return $? - else + if [ -z "$v" ]; then return 1 fi + + version_ge $v $2 + return $? } install_RPM() { @@ -914,6 +946,11 @@ print_info() { INFO " -D Boost_NO_SYSTEM_PATHS=ON" fi + if [ -d $INST/osl ]; then + INFO " -D CYCLES_OSL=$INST/osl" + INFO " -D WITH_CYCLES_OSL=ON" + fi + if [ -d $INST/ffmpeg ]; then INFO " -D WITH_CODEC_FFMPEG=ON" INFO " -D FFMPEG=$INST/ffmpeg" From 6de13de7ab6a8b625dedd8a46de2d6181328f7cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 21:05:27 +0000 Subject: [PATCH 065/115] more straightforward way to implement quad-strip face filling suggested by Howard Trickey, also some other changes - no need to check the new loops face is larger and no longer split up the ngon more times then there are subdivisions in the face strip (now ngons will remain on both sides). --- source/blender/bmesh/operators/bmo_bevel.c | 40 ++++++++-------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 1b1fc53011f..c76693d5347 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -1193,48 +1193,38 @@ static void bevel_build_quadstrip(BMesh *bm, BevVert *bv) if (f) { /* we have a polygon which we know starts at this vertex, make it into strips */ - EdgeHalf *eh_first, *eh_iter; - EdgeHalf *eh_a = NULL, *eh_b = NULL; - BMVert *v_a_first, *v_b_first; + EdgeHalf *eh_a = bv->vmesh->boundstart->elast; + EdgeHalf *eh_b = next_bev(bv, eh_a->next); /* since (selcount == 2) we know this is valid */ + BMLoop *l_a = BM_face_vert_share_loop(f, eh_a->rightv->nv.v); + BMLoop *l_b = BM_face_vert_share_loop(f, eh_b->leftv->nv.v); + int seg_count = bv->vmesh->seg; /* ensure we don't walk past the segments */ - BMLoop *l_a; - BMLoop *l_b; - - /* find both edges */ - eh_iter = eh_first = bv->vmesh->boundstart->efirst; - do { - if (eh_iter->seg) { - if (eh_a == NULL) { - eh_a = eh_iter; - } - else if (eh_b == NULL) { - eh_b = eh_iter; - break; - } - } - } while ((eh_iter = eh_iter->next) != NULL); - - v_a_first = eh_a->rightv->nv.v; - v_b_first = eh_b->leftv->nv.v; - - l_a = BM_face_vert_share_loop(f, v_a_first); - l_b = BM_face_vert_share_loop(f, v_b_first); if (l_a == l_b) { /* step once around if we hit the same loop */ l_a = l_a->prev; l_b = l_b->next; + seg_count--; } + BLI_assert(l_a != l_b); + while (f->len > 4) { BMLoop *l_new; BLI_assert(l_a->f == f); BLI_assert(l_b->f == f); BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, FALSE); + if (seg_count-- == 0) { + break; + } + /* turns out we don't need this, + * because of how BM_face_split works we always get the loop of the larger face */ +#if 0 if (l_new->f->len < l_new->radial_next->f->len) { l_new = l_new->radial_next; } +#endif f = l_new->f; /* walk around the new face to get the next verts to split */ From c3c14f862b552a1536c5f4deae7e68c14f1d6e92 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Nov 2012 21:25:11 +0000 Subject: [PATCH 066/115] use quad-strip for filling even when no segments are being added, this gives quad-loops along the bevel whereas before it made ngons. --- source/blender/bmesh/operators/bmo_bevel.c | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index c76693d5347..3854bca5d44 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -92,7 +92,7 @@ typedef struct VMesh { M_NONE, /* no polygon mesh needed */ M_POLY, /* a simple polygon */ M_ADJ, /* "adjacent edges" mesh pattern */ - M_CROSS, /* "cross edges" mesh pattern */ +// M_CROSS, /* "cross edges" mesh pattern */ M_TRI_FAN, /* a simple polygon - fan filled */ M_QUAD_STRIP, /* a simple polygon - cut into paralelle strips */ } mesh_kind; @@ -745,6 +745,9 @@ static void build_boundary(MemArena *mem_arena, BevVert *bv) if (vm->count == 2 && bv->edgecount == 3) { vm->mesh_kind = M_NONE; } + else if (bv->selcount == 2) { + vm->mesh_kind = M_QUAD_STRIP; + } else if (efirst->seg == 1 || bv->selcount == 1) { if (vm->count == 3 && bv->selcount == 1) { vm->mesh_kind = M_TRI_FAN; @@ -754,12 +757,7 @@ static void build_boundary(MemArena *mem_arena, BevVert *bv) } } else { - if (bv->selcount == 2) { - vm->mesh_kind = M_QUAD_STRIP; - } - else { - vm->mesh_kind = M_ADJ; - } + vm->mesh_kind = M_ADJ; } /* TODO: if vm->count == 4 and bv->selcount == 4, use M_CROSS pattern */ } @@ -1219,7 +1217,7 @@ static void bevel_build_quadstrip(BMesh *bm, BevVert *bv) } /* turns out we don't need this, - * because of how BM_face_split works we always get the loop of the larger face */ + * because of how BM_face_split works we always get the loop of the next face */ #if 0 if (l_new->f->len < l_new->radial_next->f->len) { l_new = l_new->radial_next; @@ -1371,14 +1369,23 @@ static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) copy_mesh_vert(vm, weld2->index, 0, ns - k, weld1->index, 0, k); } - if (vm->mesh_kind == M_ADJ) - bevel_build_rings(bm, bv); - else if (vm->mesh_kind == M_POLY) - bevel_build_poly(bm, bv); - else if (vm->mesh_kind == M_TRI_FAN) - bevel_build_trifan(bm, bv); - else if (vm->mesh_kind == M_QUAD_STRIP) - bevel_build_quadstrip(bm, bv); + switch (vm->mesh_kind) { + case M_NONE: + /* do nothing */ + break; + case M_POLY: + bevel_build_poly(bm, bv); + break; + case M_ADJ: + bevel_build_rings(bm, bv); + break; + case M_TRI_FAN: + bevel_build_trifan(bm, bv); + break; + case M_QUAD_STRIP: + bevel_build_quadstrip(bm, bv); + break; + } } /* From 654ddfa4d2cbf2519c0bc4b187a259314e420e68 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Nov 2012 01:15:28 +0000 Subject: [PATCH 067/115] fix for 'Playanim' playing past the last frame of an animation. also print -s and -e in help message. --- .../startup/bl_operators/screen_play_rendered_anim.py | 8 ++++++-- source/blender/windowmanager/intern/wm_playanim.c | 2 +- source/creator/creator.c | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 694412e51d7..6d1f35fe937 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -116,8 +116,12 @@ class PlayRenderedAnim(Operator): cmd = [player_path] # extra options, fps controls etc. if preset in {'BLENDER24', 'INTERNAL'}: - opts = ["-a", "-f", str(rd.fps), str(rd.fps_base), - "-j", str(scene.frame_step), file] + opts = ["-a", + "-f", str(rd.fps), str(rd.fps_base), + "-s", str(scene.frame_start), + "-e", str(scene.frame_end), + "-j", str(scene.frame_step), + file] cmd.extend(opts) elif preset == 'DJV': opts = [file, "-playback_speed", "%d" % int(rd.fps / rd.fps_base)] diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index fba45065fbe..008768dc18e 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -235,7 +235,7 @@ static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fon { if (ibuf == NULL) { - printf("no ibuf !\n"); + printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->name : ""); return; } if (ibuf->rect == NULL && ibuf->rect_float) { diff --git a/source/creator/creator.c b/source/creator/creator.c index fc2f555227f..ff67fe09896 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1077,7 +1077,9 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) "\n\t\t-p \tOpen with lower left corner at , " "\n\t\t-m\t\tRead from disk (Don't buffer)" "\n\t\t-f \t\tSpecify FPS to start with" - "\n\t\t-j \tSet frame step to "; + "\n\t\t-j \tSet frame step to " + "\n\t\t-s \tPlay from " + "\n\t\t-j \tPlay until "; static char game_doc[] = "Game Engine specific options" "\n\t-g fixedtime\t\tRun on 50 hertz without dropping frames" From 79f651a2e5ed52f7ff2041d66b707b886e80b617 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Nov 2012 04:47:33 +0000 Subject: [PATCH 068/115] animation playback window now pauses properly. --- .../blender/windowmanager/intern/wm_playanim.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 008768dc18e..dbdc77f6478 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -433,6 +433,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) ps->stopped = FALSE; } + if (ps->wait2) { + pupdate_time(); + ptottime = 0; + } + switch (type) { case GHOST_kEventKeyDown: case GHOST_kEventKeyUp: @@ -940,6 +945,7 @@ void WM_main_playanim(int argc, const char **argv) if (ptottime > 0.0) ptottime = 0.0; while (ps.picture) { + int hasevent; #ifndef USE_IMB_CACHE if (ibuf != NULL && ibuf->ftype == 0) IMB_freeImBuf(ibuf); #endif @@ -993,21 +999,12 @@ void WM_main_playanim(int argc, const char **argv) ps.next = ps.direction; - { - int hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0); + while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0) || ps.wait2 != 0)) { if (hasevent) { GHOST_DispatchEvents(g_WS.ghost_system); } } - /* XXX25 - we should not have to do this, but it makes scrubbing functional! */ - if (g_WS.qual & WS_QUAL_LMOUSE) { - ps.next = 0; - } - else { - ps.sstep = 0; - } - ps.wait2 = ps.sstep; if (ps.wait2 == 0 && ps.stopped == 0) { From 38eee0104b78e25963569d17116f1917b74f5419 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Nov 2012 05:16:54 +0000 Subject: [PATCH 069/115] quiet scons deprecation warnings and correct --with_filesystem --> --with-filesystem in install_deps.sh --- SConstruct | 6 +++--- build_files/build_environment/install_deps.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 42be4ac191b..d6d48fcdefe 100644 --- a/SConstruct +++ b/SConstruct @@ -582,11 +582,11 @@ B.init_lib_dict() Export('env') -BuildDir(B.root_build_dir+'/source', 'source', duplicate=0) +VariantDir(B.root_build_dir+'/source', 'source', duplicate=0) SConscript(B.root_build_dir+'/source/SConscript') -BuildDir(B.root_build_dir+'/intern', 'intern', duplicate=0) +VariantDir(B.root_build_dir+'/intern', 'intern', duplicate=0) SConscript(B.root_build_dir+'/intern/SConscript') -BuildDir(B.root_build_dir+'/extern', 'extern', duplicate=0) +VariantDir(B.root_build_dir+'/extern', 'extern', duplicate=0) SConscript(B.root_build_dir+'/extern/SConscript') # now that we have read all SConscripts, we know what diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index bc0c39e3040..575e79c3b3f 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -216,7 +216,7 @@ compile_Boost() { if [ ! -f $_src/b2 ]; then ./bootstrap.sh fi - ./b2 -j$THREADS -a --with-system --with_filesystem --with-thread --with-regex --with-locale --with-date_time \ + ./b2 -j$THREADS -a --with-system --with-filesystem --with-thread --with-regex --with-locale --with-date_time \ --prefix=$_inst --disable-icu boost.locale.icu=off install ./b2 --clean From 3b008503ab4dc6de7893806408e77f5ae63bccf5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Nov 2012 06:05:37 +0000 Subject: [PATCH 070/115] playanim move zooming into a static function, the switch statement passthrough was unnecessarily confusing. --- .../windowmanager/intern/wm_playanim.c | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index dbdc77f6478..c5df42b6c1e 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -75,6 +75,9 @@ #include "WM_api.h" /* only for WM_main_playanim */ +struct PlayState; +static void playanim_window_zoom(const struct PlayState *ps, const float zoom_offset); + typedef struct PlayState { /* playback state */ @@ -596,27 +599,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) break; case GHOST_kKeyNumpadPlus: if (val == 0) break; - zoomx += 2.0f; - zoomy += 2.0f; - /* no break??? - is this intentional? - campbell XXX25 */ + playanim_window_zoom(ps, 1.0f); + break; case GHOST_kKeyNumpadMinus: { - int sizex, sizey; - /* int ofsx, ofsy; */ /* UNUSED */ - if (val == 0) break; - if (zoomx > 1.0f) zoomx -= 1.0f; - if (zoomy > 1.0f) zoomy -= 1.0f; - // playanim_window_get_position(&ofsx, &ofsy); - playanim_window_get_size(&sizex, &sizey); - /* ofsx += sizex / 2; */ /* UNUSED */ - /* ofsy += sizey / 2; */ /* UNUSED */ - sizex = zoomx * ps->ibufx; - sizey = zoomy * ps->ibufy; - /* ofsx -= sizex / 2; */ /* UNUSED */ - /* ofsy -= sizey / 2; */ /* UNUSED */ - // window_set_position(g_WS.ghost_window,sizex,sizey); - GHOST_SetClientSize(g_WS.ghost_window, sizex, sizey); + playanim_window_zoom(ps, -1.0f); break; } case GHOST_kKeyEsc: @@ -722,6 +710,25 @@ static void playanim_window_open(const char *title, int posx, int posy, int size FALSE /* no stereo */, FALSE); } +static void playanim_window_zoom(const PlayState *ps, const float zoom_offset) +{ + int sizex, sizey; + /* int ofsx, ofsy; */ /* UNUSED */ + + if (zoomx + zoom_offset > 0.0f) zoomx += zoom_offset; + if (zoomy + zoom_offset > 0.0f) zoomy += zoom_offset; + + // playanim_window_get_position(&ofsx, &ofsy); + playanim_window_get_size(&sizex, &sizey); + /* ofsx += sizex / 2; */ /* UNUSED */ + /* ofsy += sizey / 2; */ /* UNUSED */ + sizex = zoomx * ps->ibufx; + sizey = zoomy * ps->ibufy; + /* ofsx -= sizex / 2; */ /* UNUSED */ + /* ofsy -= sizey / 2; */ /* UNUSED */ + // window_set_position(g_WS.ghost_window,sizex,sizey); + GHOST_SetClientSize(g_WS.ghost_window, sizex, sizey); +} void WM_main_playanim(int argc, const char **argv) { @@ -742,7 +749,7 @@ void WM_main_playanim(int argc, const char **argv) /* ps.doubleb = TRUE;*/ /* UNUSED */ ps.go = TRUE; ps.direction = TRUE; - ps.next = TRUE; + ps.next = 1; ps.once = FALSE; ps.turbo = FALSE; ps.pingpong = FALSE; From c063194c6a65b396145e21c1786c810b05c7032a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 06:14:25 +0000 Subject: [PATCH 071/115] Fix #33204: Blur node ignores Gamma setting Gamma correction option was ignored by new compositor system. Also new compositor was doing alpha premul in a wrong way. In fact, not sure if it should do premul -- old compositor didn't do that.. --- .../blender/compositor/nodes/COM_BlurNode.cpp | 48 ++++++++++++++----- .../operations/COM_GammaCorrectOperation.cpp | 26 ++++------ 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp index 4f120ea5a6e..6a4987c2075 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -31,6 +31,7 @@ #include "COM_FastGaussianBlurOperation.h" #include "COM_MathBaseOperation.h" #include "COM_SetValueOperation.h" +#include "COM_GammaCorrectOperation.h" BlurNode::BlurNode(bNode *editorNode) : Node(editorNode) { @@ -48,16 +49,17 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co const float size = ((const bNodeSocketValueFloat *)sock->default_value)->value; CompositorQuality quality = context->getQuality(); - + NodeOperation *input_operation = NULL, *output_operation = NULL; + if (data->filtertype == R_FILTER_FAST_GAUSS) { FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); operationfgb->setData(data); operationfgb->setbNode(editorNode); - this->getInputSocket(0)->relinkConnections(operationfgb->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph); - this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0)); graph->addOperation(operationfgb); - addPreviewOperation(graph, context, operationfgb->getOutputSocket()); + + input_operation = operationfgb; + output_operation = operationfgb; } else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) { MathAddOperation *clamp = new MathAddOperation(); @@ -93,48 +95,68 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setData(data); operation->setbNode(editorNode); operation->setQuality(quality); - this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); addLink(graph, operationy->getOutputSocket(), operation->getInputSocket(1)); graph->addOperation(operation); - this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - addPreviewOperation(graph, context, operation->getOutputSocket()); + + output_operation = operation; + input_operation = operation; } else if (!data->bokeh) { GaussianXBlurOperation *operationx = new GaussianXBlurOperation(); operationx->setData(data); operationx->setbNode(editorNode); operationx->setQuality(quality); - this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); graph->addOperation(operationx); GaussianYBlurOperation *operationy = new GaussianYBlurOperation(); operationy->setData(data); operationy->setbNode(editorNode); operationy->setQuality(quality); - this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket()); + graph->addOperation(operationy); addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); - addPreviewOperation(graph, context, operationy->getOutputSocket()); if (!connectedSizeSocket) { operationx->setSize(size); operationy->setSize(size); } + + input_operation = operationx; + output_operation = operationy; } else { GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation(); operation->setData(data); operation->setbNode(editorNode); - this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); operation->setQuality(quality); graph->addOperation(operation); - this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - addPreviewOperation(graph, context, operation->getOutputSocket()); if (!connectedSizeSocket) { operation->setSize(size); } + + input_operation = operation; + output_operation = operation; + } + + if (data->gamma) { + GammaCorrectOperation *correct = new GammaCorrectOperation(); + GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); + + this->getInputSocket(0)->relinkConnections(correct->getInputSocket(0), 0, graph); + addLink(graph, correct->getOutputSocket(), input_operation->getInputSocket(0)); + addLink(graph, output_operation->getOutputSocket(), inverse->getInputSocket(0)); + this->getOutputSocket()->relinkConnections(inverse->getOutputSocket()); + graph->addOperation(correct); + graph->addOperation(inverse); + + addPreviewOperation(graph, context, inverse->getOutputSocket()); + } + else { + this->getInputSocket(0)->relinkConnections(input_operation->getInputSocket(0), 0, graph); + this->getOutputSocket()->relinkConnections(output_operation->getOutputSocket()); + addPreviewOperation(graph, context, output_operation->getOutputSocket()); } } diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp index af990f4f3e0..c36a6f896c2 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp @@ -49,14 +49,11 @@ void GammaCorrectOperation::executePixel(float output[4], float x, float y, Pixe output[1] = inputColor[1] > 0.0f ? inputColor[1] * inputColor[1] : 0.0f; output[2] = inputColor[2] > 0.0f ? inputColor[2] * inputColor[2] : 0.0f; - inputColor[0] *= inputColor[3]; - inputColor[1] *= inputColor[3]; - inputColor[2] *= inputColor[3]; - - output[0] = inputColor[0]; - output[1] = inputColor[1]; - output[2] = inputColor[2]; - output[3] = inputColor[3]; + if (inputColor[3] > 0.0f) { + output[0] *= inputColor[3]; + output[1] *= inputColor[3]; + output[2] *= inputColor[3]; + } } void GammaCorrectOperation::deinitExecution() @@ -90,14 +87,11 @@ void GammaUncorrectOperation::executePixel(float output[4], float x, float y, Pi output[1] = inputColor[1] > 0.0f ? sqrtf(inputColor[1]) : 0.0f; output[2] = inputColor[2] > 0.0f ? sqrtf(inputColor[2]) : 0.0f; - inputColor[0] *= inputColor[3]; - inputColor[1] *= inputColor[3]; - inputColor[2] *= inputColor[3]; - - output[0] = inputColor[0]; - output[1] = inputColor[1]; - output[2] = inputColor[2]; - output[3] = inputColor[3]; + if (inputColor[3] > 0.0f) { + output[0] *= inputColor[3]; + output[1] *= inputColor[3]; + output[2] *= inputColor[3]; + } } void GammaUncorrectOperation::deinitExecution() From 62cba2ca23fe75a251db8f834b81c1c24e8a57ad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Nov 2012 06:32:35 +0000 Subject: [PATCH 072/115] playanim: make alphanumeric +/- and numpad +/- work the same way. better for users without a numpad. - Ctrl +/-: Zooms - +/-: Controls playback speed --- .../windowmanager/intern/wm_playanim.c | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index c5df42b6c1e..0da3774d9a4 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -136,6 +136,7 @@ typedef enum eWS_Qual { WS_QUAL_ALT = (WS_QUAL_LALT | WS_QUAL_RALT), WS_QUAL_LCTRL = (1 << 4), WS_QUAL_RCTRL = (1 << 5), + WS_QUAL_CTRL = (WS_QUAL_LCTRL | WS_QUAL_RCTRL), WS_QUAL_LMOUSE = (1 << 16), WS_QUAL_MMOUSE = (1 << 17), WS_QUAL_RMOUSE = (1 << 18), @@ -183,12 +184,12 @@ static void playanim_event_qual_update(void) /* Alt */ GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyLeftAlt, &val); - if (val) g_WS.qual |= WS_QUAL_LCTRL; - else g_WS.qual &= ~WS_QUAL_LCTRL; + if (val) g_WS.qual |= WS_QUAL_LALT; + else g_WS.qual &= ~WS_QUAL_LALT; GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyRightAlt, &val); - if (val) g_WS.qual |= WS_QUAL_RCTRL; - else g_WS.qual &= ~WS_QUAL_RCTRL; + if (val) g_WS.qual |= WS_QUAL_RALT; + else g_WS.qual &= ~WS_QUAL_RALT; /* LMB */ GHOST_GetButtonState(g_WS.ghost_system, GHOST_kButtonMaskLeft, &val); @@ -548,28 +549,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) } } break; - case GHOST_kKeyEqual: - if (val) { - if (g_WS.qual & WS_QUAL_SHIFT) { - ps->pause++; - printf("pause:%d\n", ps->pause); - } - else { - swaptime /= 1.1; - } - } - break; - case GHOST_kKeyMinus: - if (val) { - if (g_WS.qual & WS_QUAL_SHIFT) { - ps->pause--; - printf("pause:%d\n", ps->pause); - } - else { - swaptime *= 1.1; - } - } - break; case GHOST_kKeyNumpad0: if (val) { if (ps->once) { @@ -597,14 +576,28 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) } } break; + case GHOST_kKeyEqual: case GHOST_kKeyNumpadPlus: + { if (val == 0) break; - playanim_window_zoom(ps, 1.0f); + if (g_WS.qual & WS_QUAL_CTRL) { + playanim_window_zoom(ps, 1.0f); + } + else { + swaptime /= 1.1; + } break; + } + case GHOST_kKeyMinus: case GHOST_kKeyNumpadMinus: { if (val == 0) break; - playanim_window_zoom(ps, -1.0f); + if (g_WS.qual & WS_QUAL_CTRL) { + playanim_window_zoom(ps, -1.0f); + } + else { + swaptime *= 1.1; + } break; } case GHOST_kKeyEsc: @@ -1010,6 +1003,18 @@ void WM_main_playanim(int argc, const char **argv) if (hasevent) { GHOST_DispatchEvents(g_WS.ghost_system); } + if (ps.wait2) { + if (hasevent) { + if (ibuf) { + while (pupdate_time()) PIL_sleep_ms(1); + ptottime -= swaptime; + playanim_toscreen(ps.picture, ibuf, ps.fontid, ps.fstep); + } + } + } + if (!ps.go) { + break; + } } ps.wait2 = ps.sstep; From 0071ce502261dd68c621e62637b18c9297630952 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 11:07:46 +0000 Subject: [PATCH 073/115] Fix #33209: Opening an image with image node on Compositing freezes Blender Own mistake in image threading commit. --- source/blender/blenkernel/intern/image.c | 4 ++-- source/blender/compositor/operations/COM_ImageOperation.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 993d72ab2e7..d98c2bc2f8b 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2173,6 +2173,8 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) break; } + BLI_spin_unlock(&image_spin); + /* don't use notifiers because they are not 100% sure to succeeded * this also makes sure all scenes are accounted for. */ { @@ -2183,8 +2185,6 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } } } - - BLI_spin_unlock(&image_spin); } /* if layer or pass changes, we need an index for the imbufs list */ diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp index a7743cd7668..d4c35f5afaa 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cpp +++ b/source/blender/compositor/operations/COM_ImageOperation.cpp @@ -67,6 +67,7 @@ ImBuf *BaseImageOperation::getImBuf() ibuf = BKE_image_acquire_ibuf(this->m_image, this->m_imageUser, NULL); if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) { + BKE_image_release_ibuf(this->m_image, ibuf, NULL); return NULL; } @@ -93,7 +94,7 @@ void BaseImageOperation::initExecution() void BaseImageOperation::deinitExecution() { this->m_imageBuffer = NULL; - IMB_freeImBuf(this->m_buffer); + BKE_image_release_ibuf(this->m_image, this->m_buffer, NULL); } void BaseImageOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) From c98be502cd609e5ec3cd950081f5710338bdd0f8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 11:23:53 +0000 Subject: [PATCH 074/115] Install dependencies: made it sure llvm-3.1 or llvm-3.0 is installing llvm-dev could be a meta-package for older version of llvm --- build_files/build_environment/install_deps.sh | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 575e79c3b3f..540c2cb2f8a 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -590,11 +590,13 @@ install_DEB() { VORBIS_DEV="libvorbis-dev" THEORA_DEV="libtheora-dev" + have_llvm=false + sudo apt-get install -y cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \ libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \ libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV libopenexr-dev libopenal-dev \ libglew-dev yasm $SCHRO_DEV $THEORA_DEV $VORBIS_DEV libsdl1.2-dev \ - libfftw3-dev libjack-dev python-dev patch flex bison llvm-dev clang libtbb-dev git + libfftw3-dev libjack-dev python-dev patch flex bison libtbb-dev git OPENJPEG_USE=true SCHRO_USE=true @@ -681,8 +683,22 @@ install_DEB() { compile_OIIO fi - # No package currently! - compile_OSL + check_package_DEB llvm-$LLVM_VERSION-dev + if [ $? -eq 0 ]; then + sudo apt-get install -y llvm-$LLVM_VERSION-dev clang + have_llvm=true + else + check_package_DEB llvm-$LLVM_VERSION_MIN-dev + if [ $? -eq 0 ]; then + sudo apt-get install -y llvm-$LLVM_VERSION_MIN-dev clang + have_llvm=true + fi + fi + + if $have_llvm; then + # No package currently! + compile_OSL + fi # XXX Debian features libav packages as ffmpeg, those are not really compatible with blender code currently :/ # So for now, always build our own ffmpeg. From b20cb616072a58b5f6e97c40aaa5fa3c299e6edb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 11:28:12 +0000 Subject: [PATCH 075/115] Made sure open OIIO does not use system's boost in cases it was compiled from sources --- build_files/build_environment/install_deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 540c2cb2f8a..cda18344184 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -345,7 +345,7 @@ compile_OIIO() { -D BUILDSTATIC=ON" if [ -d $INST/boost ]; then - cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost" + cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost -D Boost_NO_SYSTEM_PATHS=ON" fi # Looks like we do not need ocio in oiio for now... From 70308d51f19599b894abd266d6c1cb5bede51fbf Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 11:35:13 +0000 Subject: [PATCH 076/115] Install dependencies: use OIIO 1.1.1 where SHA crap seems to be solved --- build_files/build_environment/install_deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index cda18344184..b163e7e8e60 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -20,7 +20,7 @@ OCIO_VERSION="1.0.7" OCIO_SOURCE="https://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION" OCIO_VERSION_MIN="1.0" -OIIO_VERSION="1.1.0" +OIIO_VERSION="1.1.1" OIIO_SOURCE="https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_VERSION" OIIO_VERSION_MIN="1.1" From d00e6dcc3a517f09f0ad0f9dd8c700ce93592381 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 11:42:37 +0000 Subject: [PATCH 077/115] Install dependencies: dead links should not occur --- build_files/build_environment/install_deps.sh | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index b163e7e8e60..b8ce10891eb 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -171,12 +171,13 @@ compile_Python() { --enable-loadable-sqlite-extensions --with-dbmliborder=bdb \ --with-computed-gotos --with-pymalloc - make -j$THREADS - make install + make -j$THREADS && make install make clean - rm -f $INST/python-3.3 - ln -s python-$PYTHON_VERSION $INST/python-3.3 + if [ -d $_inst ]; then + rm -f $INST/python-3.3 + ln -s python-$PYTHON_VERSION $INST/python-3.3 + fi magic_compile_set python-$PYTHON_VERSION $py_magic @@ -220,8 +221,10 @@ compile_Boost() { --prefix=$_inst --disable-icu boost.locale.icu=off install ./b2 --clean - rm -f $INST/boost - ln -s boost-$BOOST_VERSION $INST/boost + if [ -d $_inst ]; then + rm -f $INST/boost + ln -s boost-$BOOST_VERSION $INST/boost + fi magic_compile_set boost-$BOOST_VERSION $boost_magic @@ -281,8 +284,7 @@ compile_OCIO() { -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \ .. - make -j$THREADS - make install + make -j$THREADS && make install # Force linking against static libs rm -f $_inst/lib/*.so* @@ -293,8 +295,10 @@ compile_OCIO() { make clean - rm -f $INST/ocio - ln -s ocio-$OCIO_VERSION $INST/ocio + if [ -d $_inst ]; then + rm -f $INST/ocio + ln -s ocio-$OCIO_VERSION $INST/ocio + fi magic_compile_set ocio-$OCIO_VERSION $ocio_magic @@ -361,12 +365,13 @@ compile_OIIO() { cmake $cmake_d -D CMAKE_CXX_FLAGS="$cflags" -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" ../src - make -j$THREADS - make install + make -j$THREADS && make install make clean - rm -f $INST/oiio - ln -s oiio-$OIIO_VERSION $INST/oiio + if [ -d $_inst ]; then + rm -f $INST/oiio + ln -s oiio-$OIIO_VERSION $INST/oiio + fi magic_compile_set oiio-$OIIO_VERSION $oiio_magic @@ -434,12 +439,13 @@ compile_OSL() { cmake $cmake_d ../src - make -j$THREADS - make install + make -j$THREADS && make install make clean - rm -f $INST/osl - ln -s osl-$OSL_VERSION $INST/osl + if [ -d $_inst ]; then + rm -f $INST/osl + ln -s osl-$OSL_VERSION $INST/osl + fi magic_compile_set osl-$OSL_VERSION $osl_magic @@ -522,12 +528,13 @@ compile_FFmpeg() { --disable-outdev=alsa --disable-indev=sdl --disable-indev=alsa --disable-indev=jack \ --disable-indev=lavfi $extra - make -j$THREADS - make install + make -j$THREADS && make install make clean - rm -f $INST/ffmpeg - ln -s ffmpeg-$FFMPEG_VERSION $INST/ffmpeg + if [ -d $_inst ]; then + rm -f $INST/ffmpeg + ln -s ffmpeg-$FFMPEG_VERSION $INST/ffmpeg + fi magic_compile_set ffmpeg-$FFMPEG_VERSION $ffmpeg_magic From eae0174b0404aebe9eea5cc10910b626555af250 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 11:57:10 +0000 Subject: [PATCH 078/115] Install dependencies: disable OSL for now It's really horror even for me to compile it on release environment, i do not want anybody to spend time trying to support this lib in automatic script or make it so user's are easily frustrated by some hack added to OSL repository. If you REALLY want to build OSL with this script, set BUILD_OSL to truth (it's in the top of the script). --- build_files/build_environment/install_deps.sh | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index b8ce10891eb..9cbd6cd636b 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -5,6 +5,11 @@ SRC="$HOME/src/blender-deps" INST="/opt/lib" CWD=$PWD +# OSL is horror for manual building even +# i would want it to be setteled for manual build first, +# and only then do it automatically +BUILD_OSL=false + THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"` PYTHON_VERSION="3.3.0" @@ -597,8 +602,6 @@ install_DEB() { VORBIS_DEV="libvorbis-dev" THEORA_DEV="libtheora-dev" - have_llvm=false - sudo apt-get install -y cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \ libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \ libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV libopenexr-dev libopenal-dev \ @@ -690,21 +693,25 @@ install_DEB() { compile_OIIO fi - check_package_DEB llvm-$LLVM_VERSION-dev - if [ $? -eq 0 ]; then - sudo apt-get install -y llvm-$LLVM_VERSION-dev clang - have_llvm=true - else - check_package_DEB llvm-$LLVM_VERSION_MIN-dev - if [ $? -eq 0 ]; then - sudo apt-get install -y llvm-$LLVM_VERSION_MIN-dev clang - have_llvm=true - fi - fi + if $BUILD_OSL; then + have_llvm=false - if $have_llvm; then - # No package currently! - compile_OSL + check_package_DEB llvm-$LLVM_VERSION-dev + if [ $? -eq 0 ]; then + sudo apt-get install -y llvm-$LLVM_VERSION-dev clang + have_llvm=true + else + check_package_DEB llvm-$LLVM_VERSION_MIN-dev + if [ $? -eq 0 ]; then + sudo apt-get install -y llvm-$LLVM_VERSION_MIN-dev clang + have_llvm=true + fi + fi + + if $have_llvm; then + # No package currently! + compile_OSL + fi fi # XXX Debian features libav packages as ffmpeg, those are not really compatible with blender code currently :/ From 3cf8dd529606e600d4ab3139b12d750c95db7852 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 17 Nov 2012 12:09:50 +0000 Subject: [PATCH 079/115] OSX/scons: little cleanup to BF_PROGRAM_LINKFLAGS --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index d6d48fcdefe..a765488d3f1 100644 --- a/SConstruct +++ b/SConstruct @@ -309,7 +309,7 @@ if env['OURPLATFORM']=='darwin': if env['WITH_BF_CYCLES_OSL'] == 1: # this is kinda hardcoded atm due not understood path issues, also look that we need 2 variants of passing the oslexec with the force_load option, why ? env.Append(LINKFLAGS=['-L../lib/darwin-9.x.universal/osl/lib','-loslcomp','-force_load ../lib/darwin-9.x.universal/osl/lib/liboslexec.a','-loslquery']) - env.Append(BF_PROGRAM_LINKFLAGS=['-loslcomp','-Xlinker','-force_load','-Xlinker','../lib/darwin-9.x.universal/osl/lib/liboslexec.a']) + env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker','../lib/darwin-9.x.universal/osl/lib/liboslexec.a']) if env['WITH_BF_OPENMP'] == 1: if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): From fd15b39438bab198976e1f3a305b5b261441a13e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 12:10:35 +0000 Subject: [PATCH 080/115] Install dependencies: abort script if compilation of some component failed --- build_files/build_environment/install_deps.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 9cbd6cd636b..75cc41d02be 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -182,6 +182,9 @@ compile_Python() { if [ -d $_inst ]; then rm -f $INST/python-3.3 ln -s python-$PYTHON_VERSION $INST/python-3.3 + else + ERROR "Python--$PYTHON_VERSION failed to compile, exiting" + exit 1 fi magic_compile_set python-$PYTHON_VERSION $py_magic @@ -229,6 +232,9 @@ compile_Boost() { if [ -d $_inst ]; then rm -f $INST/boost ln -s boost-$BOOST_VERSION $INST/boost + else + ERROR "Boost-$BOOST_VERSION failed to compile, exiting" + exit 1 fi magic_compile_set boost-$BOOST_VERSION $boost_magic @@ -303,6 +309,9 @@ compile_OCIO() { if [ -d $_inst ]; then rm -f $INST/ocio ln -s ocio-$OCIO_VERSION $INST/ocio + else + ERROR "OpenColorIO-$OCIO_VERSION failed to compile, exiting" + exit 1 fi magic_compile_set ocio-$OCIO_VERSION $ocio_magic @@ -376,6 +385,9 @@ compile_OIIO() { if [ -d $_inst ]; then rm -f $INST/oiio ln -s oiio-$OIIO_VERSION $INST/oiio + else + ERROR "OpenImageIO-$OIIO_VERSION failed to compile, exiting" + exit 1 fi magic_compile_set oiio-$OIIO_VERSION $oiio_magic @@ -450,6 +462,9 @@ compile_OSL() { if [ -d $_inst ]; then rm -f $INST/osl ln -s osl-$OSL_VERSION $INST/osl + else + ERROR "OpenShadingLanguage-$OSL_VERSION failed to compile, exiting" + exit 1 fi magic_compile_set osl-$OSL_VERSION $osl_magic @@ -539,6 +554,9 @@ compile_FFmpeg() { if [ -d $_inst ]; then rm -f $INST/ffmpeg ln -s ffmpeg-$FFMPEG_VERSION $INST/ffmpeg + else + ERROR "FFmpeg-$FFMPEG_VERSION failed to compile, exiting" + exit 1 fi magic_compile_set ffmpeg-$FFMPEG_VERSION $ffmpeg_magic From 13ea663590f088e81e7924764434320b31575c86 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 12:59:24 +0000 Subject: [PATCH 081/115] Install dependencies: workaround for SHA linking issues --- build_files/build_environment/install_deps.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 75cc41d02be..5c56182d28f 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -347,6 +347,25 @@ compile_OIIO() { INFO "Unpacking OpenImageIO-$OIIO_VERSION" tar -C $SRC --transform "s,(.*/?)OpenImageIO-oiio[^/]*(.*),\1OpenImageIO-$OIIO_VERSION\2,x" \ -xf $_src.tar.gz + + cd $_src + cat << EOF | patch -p1 +diff --git a/src/libutil/SHA1.cpp b/src/libutil/SHA1.cpp +index b9e6c8b..c761185 100644 +--- a/src/libutil/SHA1.cpp ++++ b/src/libutil/SHA1.cpp +@@ -8,9 +8,9 @@ + + // If compiling with MFC, you might want to add #include "StdAfx.h" + ++#include "SHA1.h" + #include "hash.h" + #include "dassert.h" +-#include "SHA1.h" + + #ifdef SHA1_UTILITY_FUNCTIONS + #define SHA1_MAX_FILE_BUFFER 8000 +EOF fi cd $_src From 5392ff780b0124cbe6b27d36095ee6cc1175aeb6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 13:38:39 +0000 Subject: [PATCH 082/115] Fix #33210: Diffuse Pass in scale node leads to problems Was own mistake in render layers interpolation changes. --- source/blender/blenlib/intern/math_interp.c | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c index 59a1c1f649c..5a9e8244a46 100644 --- a/source/blender/blenlib/intern/math_interp.c +++ b/source/blender/blenlib/intern/math_interp.c @@ -134,12 +134,12 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl w = wx * wy[m + 1]; if (float_output) { - const float *float_data = float_buffer + width * y1 * 4 + 4 * x1; + const float *float_data = float_buffer + width * y1 * components + components * x1; vector_from_float(float_data, data, components); } else { - const unsigned char *byte_data = byte_buffer + width * y1 * 4 + 4 * x1; + const unsigned char *byte_data = byte_buffer + width * y1 * components + components * x1; vector_from_byte(byte_data, data, components); } @@ -173,12 +173,12 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl float data[4]; if (float_output) { - const float *float_data = float_buffer + width * y1 * 4 + 4 * x1; + const float *float_data = float_buffer + width * y1 * components + components * x1; vector_from_float(float_data, data, components); } else { - const unsigned char *byte_data = byte_buffer + width * y1 * 4 + 4 * x1; + const unsigned char *byte_data = byte_buffer + width * y1 * components + components * x1; vector_from_byte(byte_data, data, components); } @@ -270,16 +270,16 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1 = empty; - else row1 = float_buffer + width * y1 * 4 + 4 * x1; + else row1 = float_buffer + width * y1 * components + components * x1; if (x1 < 0 || y2 > height - 1) row2 = empty; - else row2 = float_buffer + width * y2 * 4 + 4 * x1; + else row2 = float_buffer + width * y2 * components + components * x1; if (x2 > width - 1 || y1 < 0) row3 = empty; - else row3 = float_buffer + width * y1 * 4 + 4 * x2; + else row3 = float_buffer + width * y1 * components + components * x2; if (x2 > width - 1 || y2 > height - 1) row4 = empty; - else row4 = float_buffer + width * y2 * 4 + 4 * x2; + else row4 = float_buffer + width * y2 * components + components * x2; a = u - floorf(u); b = v - floorf(v); @@ -306,16 +306,16 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1 = empty; - else row1 = byte_buffer + width * y1 * 4 + 4 * x1; + else row1 = byte_buffer + width * y1 * components + components * x1; if (x1 < 0 || y2 > height - 1) row2 = empty; - else row2 = byte_buffer + width * y2 * 4 + 4 * x1; + else row2 = byte_buffer + width * y2 * components + components * x1; if (x2 > width - 1 || y1 < 0) row3 = empty; - else row3 = byte_buffer + width * y1 * 4 + 4 * x2; + else row3 = byte_buffer + width * y1 * components + components * x2; if (x2 > width - 1 || y2 > height - 1) row4 = empty; - else row4 = byte_buffer + width * y2 * 4 + 4 * x2; + else row4 = byte_buffer + width * y2 * components + components * x2; a = u - floorf(u); b = v - floorf(v); From 215474f51c9c7f2dd324fa1520918cb211ef1136 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 13:44:05 +0000 Subject: [PATCH 083/115] Old compositor should be compilable now --- .../blender/nodes/composite/nodes/node_composite_splitViewer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index 81f2f9b05a9..41fb0e822ed 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -77,7 +77,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock); if (ibuf==NULL) { printf("node_composit_exec_viewer error\n"); - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); return; } From 4cb3aba7624c0b07fb6540d103ca441b7b8cf81b Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 17 Nov 2012 14:35:35 +0000 Subject: [PATCH 084/115] Windows / Cmake: * Another place where "psapi" was missing, caused OIIO errors. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25e258419e7..ec2dd6c73bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -950,7 +950,7 @@ elseif(WIN32) if(MSVC) - set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid) + set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid psapi) add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB) From f55b9b6e2f401ebd763fb9e5995ae37375551c61 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 17 Nov 2012 14:41:18 +0000 Subject: [PATCH 085/115] Mono-core platform seem to not output the cores field in /proc/cpuinfo :/ Also adding gawk packages (gnu awk), looks like some distro do not have that one by default! --- build_files/build_environment/install_deps.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 5c56182d28f..fcf5fb227f9 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -11,6 +11,9 @@ CWD=$PWD BUILD_OSL=false THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"` +if [ -z "$v" ]; then + THREADS=1 +fi PYTHON_VERSION="3.3.0" PYTHON_VERSION_MIN="3.3" @@ -639,7 +642,7 @@ install_DEB() { VORBIS_DEV="libvorbis-dev" THEORA_DEV="libtheora-dev" - sudo apt-get install -y cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \ + sudo apt-get install -y gawk cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \ libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \ libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV libopenexr-dev libopenal-dev \ libglew-dev yasm $SCHRO_DEV $THEORA_DEV $VORBIS_DEV libsdl1.2-dev \ @@ -809,7 +812,7 @@ install_RPM() { sudo yum -y update - sudo yum -y install gcc gcc-c++ cmake scons libpng-devel libtiff-devel \ + sudo yum -y install gawk gcc gcc-c++ cmake scons libpng-devel libtiff-devel \ freetype-devel libX11-devel libXi-devel wget libsqlite3x-devel ncurses-devel \ readline-devel openjpeg-devel openexr-devel openal-soft-devel \ glew-devel yasm schroedinger-devel libtheora-devel libvorbis-devel SDL-devel \ From 9748a2b7dce0f17541963058d9d3015e083b6980 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 15:34:06 +0000 Subject: [PATCH 086/115] One more remained issue in legacy compositor, Hopefully last one. --- source/blender/nodes/composite/nodes/node_composite_viewer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index b186a9aeaf9..1c27cc21b06 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -62,7 +62,7 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, ibuf = BKE_image_acquire_ibuf(ima, node->storage, &lock); if (ibuf == NULL) { printf("node_composit_exec_viewer error\n"); - BKE_image_release_ibuf(ima, lock); + BKE_image_release_ibuf(ima, ibuf, lock); return; } From e2b58126a21df283c8f3ab93bc3c46b57825f69d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 17 Nov 2012 16:10:47 +0000 Subject: [PATCH 087/115] Fix render layer properties not being animatable. --- source/blender/makesrna/intern/rna_scene.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 5e4eb526b76..cd82e79ce0e 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1123,6 +1123,12 @@ static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value) } } +static char *rna_SceneRenderLayer_path(PointerRNA *ptr) +{ + SceneRenderLayer *srl = (SceneRenderLayer*)ptr->data; + return BLI_sprintfN("render.layers[\"%s\"]", srl->name); +} + static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) { return (BLI_countlist(&R_engines) > 1); @@ -2775,6 +2781,7 @@ static void rna_def_scene_render_layer(BlenderRNA *brna) srna = RNA_def_struct(brna, "SceneRenderLayer", NULL); RNA_def_struct_ui_text(srna, "Scene Render Layer", "Render layer"); RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); + RNA_def_struct_path_func(srna, "rna_SceneRenderLayer_path"); rna_def_render_layer_common(srna, 1); } From 469324b049012667a083017afa21538026008734 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 17 Nov 2012 16:11:02 +0000 Subject: [PATCH 088/115] Fix compositing normal node not properly showing vector XYZ values when opening socket menu, and make the normal animatable. --- .../compositor/nodes/COM_NormalNode.cpp | 11 +++++--- .../editors/interface/interface_layout.c | 2 +- .../editors/interface/interface_widgets.c | 8 +++++- source/blender/editors/space_node/drawnode.c | 26 +++++-------------- .../composite/nodes/node_composite_normal.c | 2 +- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/source/blender/compositor/nodes/COM_NormalNode.cpp b/source/blender/compositor/nodes/COM_NormalNode.cpp index e00e71e50e9..fbfff8386d0 100644 --- a/source/blender/compositor/nodes/COM_NormalNode.cpp +++ b/source/blender/compositor/nodes/COM_NormalNode.cpp @@ -41,9 +41,14 @@ void NormalNode::convertToOperations(ExecutionSystem *graph, CompositorContext * SetVectorOperation *operationSet = new SetVectorOperation(); bNodeSocket *insock = (bNodeSocket *)editorNode->outputs.first; bNodeSocketValueVector *dval = (bNodeSocketValueVector *)insock->default_value; - operationSet->setX(dval->value[0]); - operationSet->setY(dval->value[1]); - operationSet->setZ(dval->value[2]); + float normal[3]; + + /* animation can break normalization, this restores it */ + normalize_v3_v3(normal, dval->value); + + operationSet->setX(normal[0]); + operationSet->setY(normal[1]); + operationSet->setZ(normal[2]); operationSet->setW(0.0f); outputSocket->relinkConnections(operationSet->getOutputSocket(0)); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 9eec7c195b2..e000265bb1e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -430,7 +430,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in but->type = NUMSLI; } } - else if (subtype == PROP_DIRECTION) { + else if (subtype == PROP_DIRECTION && !expand) { uiDefButR_prop(block, BUT_NORMAL, 0, name, x, y, UI_UNIT_X * 3, UI_UNIT_Y * 3, ptr, prop, 0, 0, 0, -1, -1, NULL); } else { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c836d62021e..527f383c837 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2623,6 +2623,11 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } +static void widget_normal(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign)) +{ + ui_draw_but_NORMAL(but, wcol, rect); +} + static void widget_icon_has_anim(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign)) { if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) { @@ -3030,6 +3035,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) break; case UI_WTYPE_NORMAL: + wt.custom = widget_normal; break; case UI_WTYPE_SCROLL: @@ -3269,7 +3275,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct break; case BUT_NORMAL: - ui_draw_but_NORMAL(but, &tui->wcol_regular, rect); + wt = widget_type(UI_WTYPE_NORMAL); break; case BUT_IMAGE: diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index e842bb5f262..99bdb8d6fe9 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -398,29 +398,15 @@ static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0); } -static void node_normal_cb(bContext *C, void *ntree_v, void *node_v) -{ - Main *bmain = CTX_data_main(C); - - ED_node_generic_update(bmain, ntree_v, node_v); - WM_event_add_notifier(C, NC_NODE | NA_EDITED, ntree_v); -} - static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiBlock *block = uiLayoutAbsoluteBlock(layout); - bNodeTree *ntree = ptr->id.data; - bNode *node = ptr->data; - rctf *butr = &node->butr; + bNodeTree *ntree = (bNodeTree*)ptr->id.data; + bNode *node = (bNode*)ptr->data; bNodeSocket *sock = node->outputs.first; /* first socket stores normal */ - float *nor = ((bNodeSocketValueVector *)sock->default_value)->value; - uiBut *bt; - - bt = uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "", - (int)butr->xmin, (int)butr->xmin, - (short)BLI_rctf_size_x(butr), (short)BLI_rctf_size_x(butr), - nor, 0.0f, 1.0f, 0, 0, ""); - uiButSetFunc(bt, node_normal_cb, ntree, node); + PointerRNA sockptr; + + RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &sockptr); + uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE); } #if 0 /* not used in 2.5x yet */ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) diff --git a/source/blender/nodes/composite/nodes/node_composite_normal.c b/source/blender/nodes/composite/nodes/node_composite_normal.c index 93fd7ca1c1b..d104e8f03e6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normal.c +++ b/source/blender/nodes/composite/nodes/node_composite_normal.c @@ -40,7 +40,7 @@ static bNodeSocketTemplate cmp_node_normal_in[] = { }; static bNodeSocketTemplate cmp_node_normal_out[] = { - { SOCK_VECTOR, 0, N_("Normal")}, + { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION}, { SOCK_FLOAT, 0, N_("Dot")}, { -1, 0, "" } }; From ecb11b43fcc241cd7896561b83d255023ac2905b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 17 Nov 2012 17:58:15 +0000 Subject: [PATCH 089/115] Install dependencies: added check for minimal version of x264 Also fixed parsing of package version with epoch --- build_files/build_environment/install_deps.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index fcf5fb227f9..444bf8ea50b 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -55,6 +55,7 @@ XVID_USE=false XVID_DEV="" X264_USE=false X264_DEV="" +X264_VERSION_MIN=0.118 VPX_USE=false VPX_VERSION_MIN=0.9.7 VPX_DEV="" @@ -605,7 +606,7 @@ check_package_DEB() { } check_package_version_match_DEB() { - v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*(([0-9]+\.?)+).*/\1/'` + v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*([0-9]+:)(([0-9]+\.?)+).*/\2/'` if [ -z "$v" ]; then return 1 @@ -616,7 +617,7 @@ check_package_version_match_DEB() { } check_package_version_ge_DEB() { - v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*(([0-9]+\.?)+).*/\1/'` + v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*([0-9]+:)?(([0-9]+\.?)+).*/\2/'` if [ -z "$v" ]; then return 1 @@ -676,7 +677,7 @@ install_DEB() { fi X264_DEV="libx264-dev" - check_package_DEB $X264_DEV + check_package_version_ge_DEB $X264_DEV $X264_VERSION_MIN if [ $? -eq 0 ]; then sudo apt-get install -y $X264_DEV X264_USE=true From 0c12ea09394d5fb2fd2f571f26a368db788c06f1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 17 Nov 2012 23:00:04 +0000 Subject: [PATCH 090/115] Buildbot: show OS X target version in buildbot zip filename. --- build_files/scons/tools/btools.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 5b1c1571bed..ab963d4543c 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -180,7 +180,7 @@ def validate_arguments(args, bc): 'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS', 'C_WARN', 'CC_WARN', 'CXX_WARN', 'LLIBS', 'PLATFORM_LINKFLAGS','MACOSX_ARCHITECTURE', 'MACOSX_SDK_CHECK', 'XCODE_CUR_VER', - 'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS' + 'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET' ] @@ -502,8 +502,9 @@ def read_opts(env, cfg, args): ('LLIBS', 'Platform libs', []), ('PLATFORM_LINKFLAGS', 'Platform linkflags', []), ('MACOSX_ARCHITECTURE', 'python_arch.zip select', ''), - ('MACOSX_SDK_CHECK', 'detect available OSX sdk`s', ''), - ('XCODE_CUR_VER', 'detect XCode version', ''), + ('MACOSX_SDK_CHECK', 'Detect available OS X SDK`s', ''), + ('XCODE_CUR_VER', 'Detect XCode version', ''), + ('MACOSX_DEPLOYMENT_TARGET', 'Detect OS X target version', ''), (BoolVariable('BF_PROFILE', 'Add profiling information if true', False)), ('BF_PROFILE_CFLAGS', 'C only profiling flags', []), @@ -686,7 +687,7 @@ def buildslave(target=None, source=None, env=None): elif bitness == '32bit': platform = 'linux-' + glibc + '-i686' if platform == 'darwin': - platform = 'OSX-' + env['MACOSX_ARCHITECTURE'] + platform = 'OSX-' + env['MACOSX_DEPLOYMENT_TARGET'] + '-' + env['MACOSX_ARCHITECTURE'] branch = env['BUILDBOT_BRANCH'] From fd7a3db8eb0545ff6262ece2002cef97a1814c1c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 18 Nov 2012 00:20:23 +0000 Subject: [PATCH 091/115] Buildbot: * Use rsync upload for Mac slave, rather than uploading entire file. This could be enabled for more slaves, should make more frequent builds possible. * Split Mac into 10.6 and 10.5 builds. --- build_files/buildbot/master.cfg | 14 +++++---- build_files/buildbot/slave_rsync.py | 45 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 build_files/buildbot/slave_rsync.py diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg index e9deade6e99..90f0c805f58 100644 --- a/build_files/buildbot/master.cfg +++ b/build_files/buildbot/master.cfg @@ -77,17 +77,18 @@ def svn_step(branch=''): def lib_svn_step(dir): return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir) -def rsync_step(file_from, file_to): - return ShellCommand(name='rsync', command=['rsync', '-v', '-P', file_from, 'brecht@builder.blender.org:/data/buildbot-master/' + file_to], haltOnFailure=True, description=['rsync']) +def rsync_step(id, branch, rsync_script): + return ShellCommand(name='rsync', command=['python', rsync_script, id, branch], description='uploading', descriptionDone='uploaded', workdir='install') # generic builder def generic_builder(id, libdir='', branch='', rsync=False): - filename = 'buildbot_upload_' + id + '.zip' + filename = 'uploaded/buildbot_upload_' + id + '.zip' compile_script = '../blender/build_files/buildbot/slave_compile.py' test_script = '../blender/build_files/buildbot/slave_test.py' pack_script = '../blender/build_files/buildbot/slave_pack.py' + rsync_script = '../blender/build_files/buildbot/slave_rsync.py' unpack_script = 'master_unpack.py' f = BuildFactory() @@ -95,11 +96,11 @@ def generic_builder(id, libdir='', branch='', rsync=False): if libdir != '': f.addStep(lib_svn_step(libdir)) - f.addStep(Compile(command=['python', compile_script, id])) + f.addStep(Compile(command=['python', compile_script, id], timeout=3600)) f.addStep(Test(command=['python', test_script, id])) f.addStep(ShellCommand(name='package', command=['python', pack_script, id, branch], description='packaging', descriptionDone='packaged')) if rsync: - f.addStep(rsync_step('../install/buildbot_upload.zip', filename)) + f.addStep(rsync_step(id, branch, rsync_script)) elif id.find('cmake') != -1: f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100 * 1024 * 1024)) else: @@ -109,7 +110,8 @@ def generic_builder(id, libdir='', branch='', rsync=False): # builders -add_builder(c, 'mac_x86_64_scons', '', generic_builder) +add_builder(c, 'mac_x86_64_10_6_scons', 'darwin-9.x.universal', generic_builder, '', True) +add_builder(c, 'mac_x86_64_10_5_scons', '', generic_builder, '', True) #add_builder(c, 'salad_mac_x86_64_scons', 'darwin-9.x.universal', generic_builder, 'soc-2011-salad') add_builder(c, 'mac_i386_scons', 'darwin-9.x.universal', generic_builder) add_builder(c, 'mac_ppc_scons', 'darwin-9.x.universal', generic_builder) diff --git a/build_files/buildbot/slave_rsync.py b/build_files/buildbot/slave_rsync.py new file mode 100644 index 00000000000..aea1b65e333 --- /dev/null +++ b/build_files/buildbot/slave_rsync.py @@ -0,0 +1,45 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# 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. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +# Runs on buildbot slave, rsync zip directly to buildbot server rather +# than using upload which is much slower + +import os +import sys + +# get builder name +if len(sys.argv) < 2: + sys.stderr.write("Not enough arguments, expecting builder name\n") + sys.exit(1) + +builder = sys.argv[1] + +# rsync, this assumes ssh keys are setup so no password is needed +local_zip = "buildbot_upload.zip" +remote_folder = "builder.blender.org:/data/buildbot-master/uploaded/" +remote_zip = remote_folder + "buildbot_upload_" + builder + ".zip" +command = "rsync -avz %s %s" % (local_zip, remote_zip) + +print(command) + +ret = os.system(command) +sys.exit(ret) + + From 8b57f7502bb748a3acd01858c393cdac5675fcf0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 00:30:06 +0000 Subject: [PATCH 092/115] code cleanup: gpl header update (formatting) --- source/gameengine/Ketsji/KX_Dome.cpp | 30 ++++++------ source/gameengine/Ketsji/KX_Dome.h | 46 +++++++++--------- .../Ketsji/KX_ObstacleSimulation.cpp | 8 +++- source/gameengine/VideoTexture/BlendType.h | 46 +++++++++--------- source/gameengine/VideoTexture/Common.h | 46 +++++++++--------- source/gameengine/VideoTexture/Exception.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/Exception.h | 47 ++++++++++--------- source/gameengine/VideoTexture/FilterBase.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/FilterBase.h | 46 +++++++++--------- .../VideoTexture/FilterBlueScreen.cpp | 44 +++++++++-------- .../VideoTexture/FilterBlueScreen.h | 46 +++++++++--------- .../gameengine/VideoTexture/FilterColor.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/FilterColor.h | 46 +++++++++--------- .../gameengine/VideoTexture/FilterNormal.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/FilterNormal.h | 46 +++++++++--------- .../gameengine/VideoTexture/FilterSource.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/FilterSource.h | 46 +++++++++--------- source/gameengine/VideoTexture/ImageBase.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/ImageBase.h | 46 +++++++++--------- source/gameengine/VideoTexture/ImageBuff.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/ImageBuff.h | 46 +++++++++--------- source/gameengine/VideoTexture/ImageMix.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/ImageMix.h | 46 +++++++++--------- .../gameengine/VideoTexture/ImageRender.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/ImageRender.h | 46 +++++++++--------- .../gameengine/VideoTexture/ImageViewport.cpp | 44 +++++++++-------- .../gameengine/VideoTexture/ImageViewport.h | 46 +++++++++--------- source/gameengine/VideoTexture/PyTypeList.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/PyTypeList.h | 46 +++++++++--------- source/gameengine/VideoTexture/Texture.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/Texture.h | 46 +++++++++--------- source/gameengine/VideoTexture/VideoBase.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/VideoBase.h | 46 +++++++++--------- .../gameengine/VideoTexture/VideoFFmpeg.cpp | 44 +++++++++-------- source/gameengine/VideoTexture/VideoFFmpeg.h | 46 +++++++++--------- .../gameengine/VideoTexture/blendVideoTex.cpp | 44 +++++++++-------- 36 files changed, 855 insertions(+), 716 deletions(-) diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index fca407f6398..9f530f80e37 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -1,25 +1,27 @@ /* - * ----------------------------------------------------------------------------- + * ***** BEGIN GPL LICENSE BLOCK ***** * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser 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 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 Lesser General Public License for more details. + * 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 Lesser General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307, USA, or go to - * http://www.gnu.org/copyleft/lesser.txt. + * 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(s): Dalai Felinto * * This code is originally inspired on some of the ideas and codes from Paul Bourke. - * Developed as part of a Research and Development project for SAT - La Société des arts technologiques. - * ----------------------------------------------------------------------------- + * Developed as part of a Research and Development project for + * SAT - La Société des arts technologiques. + * + * ***** END GPL LICENSE BLOCK ***** */ /** \file gameengine/Ketsji/KX_Dome.cpp diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h index 17eec3a5fcb..3bc90bf6c35 100644 --- a/source/gameengine/Ketsji/KX_Dome.h +++ b/source/gameengine/Ketsji/KX_Dome.h @@ -1,26 +1,28 @@ /* ------------------------------------------------------------------------------ - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. - -Contributor(s): Dalai Felinto - -This source uses some of the ideas and code from Paul Bourke. -Developed as part of a Research and Development project for SAT - La Société des arts technologiques. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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(s): Dalai Felinto + * + * This source uses some of the ideas and code from Paul Bourke. + * Developed as part of a Research and Development project for + * SAT - La Société des arts technologiques. + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file KX_Dome.h * \ingroup ketsji diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index 99d9fc7f9ee..8798f42fa07 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -1,6 +1,4 @@ /* - * Simulation for obstacle avoidance behavior - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -22,6 +20,12 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file gameengine/Ketsji/KX_ObstacleSimulation.cpp + * \ingroup ketsji + * + * Simulation for obstacle avoidance behavior + */ + #include "KX_ObstacleSimulation.h" #include "KX_NavMeshObject.h" #include "KX_PythonInit.h" diff --git a/source/gameengine/VideoTexture/BlendType.h b/source/gameengine/VideoTexture/BlendType.h index e19aadc49d2..28eebe07789 100644 --- a/source/gameengine/VideoTexture/BlendType.h +++ b/source/gameengine/VideoTexture/BlendType.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2006 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2006 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file BlendType.h * \ingroup bgevideotex */ - + #ifndef __BLENDTYPE_H__ #define __BLENDTYPE_H__ diff --git a/source/gameengine/VideoTexture/Common.h b/source/gameengine/VideoTexture/Common.h index e6e0ffa1ebc..90f7e66452a 100644 --- a/source/gameengine/VideoTexture/Common.h +++ b/source/gameengine/VideoTexture/Common.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2006 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2006 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file VideoTexture/Common.h * \ingroup bgevideotex */ - + #if defined WIN32 #define WINDOWS_LEAN_AND_MEAN #endif diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index 8609cd73875..8b8918d8141 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2006 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2006 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/Exception.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/Exception.h b/source/gameengine/VideoTexture/Exception.h index bc08742de8d..e0c1fdd568d 100644 --- a/source/gameengine/VideoTexture/Exception.h +++ b/source/gameengine/VideoTexture/Exception.h @@ -1,30 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2006 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ - + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2006 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file Exception.h * \ingroup bgevideotex */ - + #ifndef __EXCEPTION_H__ #define __EXCEPTION_H__ diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp index 6ec5e237ac2..a232bcc1201 100644 --- a/source/gameengine/VideoTexture/FilterBase.cpp +++ b/source/gameengine/VideoTexture/FilterBase.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/FilterBase.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h index 98bc495375a..f8fe2c772f0 100644 --- a/source/gameengine/VideoTexture/FilterBase.h +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file FilterBase.h * \ingroup bgevideotex */ - + #ifndef __FILTERBASE_H__ #define __FILTERBASE_H__ diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp index 8559e8f87f4..551694bf8c0 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp +++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/FilterBlueScreen.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.h b/source/gameengine/VideoTexture/FilterBlueScreen.h index 28ab16d966e..5a90590a39d 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.h +++ b/source/gameengine/VideoTexture/FilterBlueScreen.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of blendTex library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of blendTex library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file FilterBlueScreen.h * \ingroup bgevideotex */ - + #ifndef __FILTERBLUESCREEN_H__ #define __FILTERBLUESCREEN_H__ diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp index 35a6414f383..75803e46516 100644 --- a/source/gameengine/VideoTexture/FilterColor.cpp +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/FilterColor.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h index cd61900bbda..350f7270874 100644 --- a/source/gameengine/VideoTexture/FilterColor.h +++ b/source/gameengine/VideoTexture/FilterColor.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of blendTex library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of blendTex library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file FilterColor.h * \ingroup bgevideotex */ - + #ifndef __FILTERCOLOR_H__ #define __FILTERCOLOR_H__ diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index 03c500a7e14..8499934d61b 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/FilterNormal.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/FilterNormal.h b/source/gameengine/VideoTexture/FilterNormal.h index 19664e8b5f2..b21afb3ec26 100644 --- a/source/gameengine/VideoTexture/FilterNormal.h +++ b/source/gameengine/VideoTexture/FilterNormal.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of blendTex library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of blendTex library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file FilterNormal.h * \ingroup bgevideotex */ - + #ifndef __FILTERNORMAL_H__ #define __FILTERNORMAL_H__ diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp index e5fe4711cff..1fac87f2b04 100644 --- a/source/gameengine/VideoTexture/FilterSource.cpp +++ b/source/gameengine/VideoTexture/FilterSource.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/FilterSource.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h index cb9e22a133d..f1d2615ee32 100644 --- a/source/gameengine/VideoTexture/FilterSource.h +++ b/source/gameengine/VideoTexture/FilterSource.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of blendTex library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of blendTex library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file FilterSource.h * \ingroup bgevideotex */ - + #ifndef __FILTERSOURCE_H__ #define __FILTERSOURCE_H__ diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index de54d8e8940..3b6dec21e52 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/ImageBase.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h index a9f25f61406..3bb9c8cb090 100644 --- a/source/gameengine/VideoTexture/ImageBase.h +++ b/source/gameengine/VideoTexture/ImageBase.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of blendTex library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of blendTex library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file ImageBase.h * \ingroup bgevideotex */ - + #ifndef __IMAGEBASE_H__ #define __IMAGEBASE_H__ diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index eec0bccbe56..1593a08bb4b 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/ImageBuff.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/ImageBuff.h b/source/gameengine/VideoTexture/ImageBuff.h index b2bdbc17dc9..19299506747 100644 --- a/source/gameengine/VideoTexture/ImageBuff.h +++ b/source/gameengine/VideoTexture/ImageBuff.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file ImageBuff.h * \ingroup bgevideotex */ - + #ifndef __IMAGEBUFF_H__ #define __IMAGEBUFF_H__ diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index f09454a517b..27c4fed6fe6 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/ImageMix.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/ImageMix.h b/source/gameengine/VideoTexture/ImageMix.h index 2746635c611..712efde7dd4 100644 --- a/source/gameengine/VideoTexture/ImageMix.h +++ b/source/gameengine/VideoTexture/ImageMix.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file ImageMix.h * \ingroup bgevideotex */ - + #ifndef __IMAGEMIX_H__ #define __IMAGEMIX_H__ diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 2cc2cfb6bfc..b8dd4ad4552 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/ImageRender.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/ImageRender.h b/source/gameengine/VideoTexture/ImageRender.h index df6337e1c24..27882a9d117 100644 --- a/source/gameengine/VideoTexture/ImageRender.h +++ b/source/gameengine/VideoTexture/ImageRender.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file ImageRender.h * \ingroup bgevideotex */ - + #ifndef __IMAGERENDER_H__ #define __IMAGERENDER_H__ diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index af44e394fce..b221cb96624 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/ImageViewport.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/ImageViewport.h b/source/gameengine/VideoTexture/ImageViewport.h index 198655c6ebf..2c2b2a26ec2 100644 --- a/source/gameengine/VideoTexture/ImageViewport.h +++ b/source/gameengine/VideoTexture/ImageViewport.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file ImageViewport.h * \ingroup bgevideotex */ - + #ifndef __IMAGEVIEWPORT_H__ #define __IMAGEVIEWPORT_H__ diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp index 9fe98544961..96ac1cc5b6b 100644 --- a/source/gameengine/VideoTexture/PyTypeList.cpp +++ b/source/gameengine/VideoTexture/PyTypeList.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of blendTex library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of blendTex library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/PyTypeList.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h index 4872b3c3d5c..b36f11ed75a 100644 --- a/source/gameengine/VideoTexture/PyTypeList.h +++ b/source/gameengine/VideoTexture/PyTypeList.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of blendTex library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of blendTex library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file PyTypeList.h * \ingroup bgevideotex */ - + #ifndef __PYTYPELIST_H__ #define __PYTYPELIST_H__ diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index f58d17f949c..98d36d19ddf 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/Texture.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index cc265725b29..157eea56c09 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2006 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2006 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file VideoTexture/Texture.h * \ingroup bgevideotex */ - + #ifndef __TEXTURE_H__ #define __TEXTURE_H__ diff --git a/source/gameengine/VideoTexture/VideoBase.cpp b/source/gameengine/VideoTexture/VideoBase.cpp index 1eb2e830d37..f723001fa5a 100644 --- a/source/gameengine/VideoTexture/VideoBase.cpp +++ b/source/gameengine/VideoTexture/VideoBase.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/VideoBase.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h index 4cf913d755d..9880165c198 100644 --- a/source/gameengine/VideoTexture/VideoBase.h +++ b/source/gameengine/VideoTexture/VideoBase.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file VideoBase.h * \ingroup bgevideotex */ - + #ifndef __VIDEOBASE_H__ #define __VIDEOBASE_H__ diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 3f42d5c4fed..937705c963e 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/VideoFFmpeg.cpp * \ingroup bgevideotex diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index d5b575851ee..92043bb1f74 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -1,29 +1,33 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2007 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2007 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file VideoFFmpeg.h * \ingroup bgevideotex */ - + #ifndef __VIDEOFFMPEG_H__ #define __VIDEOFFMPEG_H__ diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index dd9d83c043f..72415026bb9 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -1,24 +1,28 @@ /* ------------------------------------------------------------------------------ -This source file is part of VideoTexture library - -Copyright (c) 2006 The Zdeno Ash Miklas - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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. + * + * Copyright (c) 2006 The Zdeno Ash Miklas + * + * This source file is part of VideoTexture library + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file gameengine/VideoTexture/blendVideoTex.cpp * \ingroup bgevideotex From b867f9f17eb1af2051749190aa6aee708972af82 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 01:22:31 +0000 Subject: [PATCH 093/115] style cleanup: comments & spelling --- release/scripts/modules/addon_utils.py | 2 +- source/blender/blenkernel/intern/pointcache.c | 6 ++++-- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenlib/intern/BLI_kdopbvh.c | 2 +- source/blender/blenlib/intern/math_rotation.c | 2 +- source/blender/blenlib/intern/scanfill.c | 2 +- source/blender/bmesh/intern/bmesh_iterators.h | 4 ++-- source/blender/bmesh/intern/bmesh_opdefines.c | 2 +- source/blender/collada/DocumentImporter.cpp | 4 ++-- source/blender/collada/DocumentImporter.h | 4 ++-- source/blender/editors/gpencil/gpencil_paint.c | 2 +- source/blender/editors/space_node/drawnode.c | 5 +++-- .../blender/editors/space_view3d/view3d_draw.c | 4 ++-- source/blender/imbuf/intern/cineon/dpxlib.c | 2 +- source/blender/imbuf/intern/dds/BlockDXT.h | 4 ++-- .../nodes/node_composite_colorbalance.c | 16 ++++++++-------- .../blender/python/generic/bpy_internal_import.c | 13 +++++++++++++ source/blender/windowmanager/intern/wm_draw.c | 4 ++-- .../windowmanager/intern/wm_event_system.c | 10 +++++----- .../blender/windowmanager/intern/wm_operators.c | 2 +- .../blender/windowmanager/intern/wm_playanim.c | 2 -- source/blender/windowmanager/intern/wm_window.c | 2 +- source/blender/windowmanager/wm_event_types.h | 6 +++--- source/gameengine/Expressions/PyObjectPlus.h | 2 +- source/gameengine/SceneGraph/SG_IObject.h | 4 ++-- 25 files changed, 61 insertions(+), 47 deletions(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 7e604c5de4c..6bf81d73f8b 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -232,7 +232,6 @@ def enable(module_name, default_set=True, persistent=False): import os import sys - import imp def handle_error(): import traceback @@ -246,6 +245,7 @@ def enable(module_name, default_set=True, persistent=False): mtime_orig = getattr(mod, "__time__", 0) mtime_new = os.path.getmtime(mod.__file__) if mtime_orig != mtime_new: + import imp print("module changed on disk:", mod.__file__, "reloading...") try: diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index f195b3d71b0..3f2eb32f61c 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2568,10 +2568,12 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) sbFreeSimulation(pid->calldata); else if (pid->type == PTCACHE_TYPE_PARTICLES) psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH); - /*else if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) +#if 0 + else if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) smokeModifier_reset(pid->calldata); else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) - smokeModifier_reset_turbulence(pid->calldata);*/ + smokeModifier_reset_turbulence(pid->calldata); +#endif else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT) dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 4f62732f5e6..9b1425584a7 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1045,7 +1045,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen /* always update layer, so that animating layers works (joshua july 2010) */ /* XXX commented out, this has depsgraph issues anyway - and this breaks setting scenes - (on scene-set, the base-lay is copied to ob-lay (ton nov 2012) */ + * (on scene-set, the base-lay is copied to ob-lay (ton nov 2012) */ // base->lay = ob->lay; } diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 7968fcabda6..6cf167b8823 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -1410,7 +1410,7 @@ static float ray_nearest_hit(BVHRayCastData *data, const float bv[6]) * Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe * [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] * - * TODO this doens't has data->ray.radius in consideration */ + * TODO this doesn't take data->ray.radius into consideration */ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *node) { const float *bv = node->bv; diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index b0c4724e1ec..3069542107e 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -84,7 +84,7 @@ void mul_qt_qtqt(float q[4], const float q1[4], const float q2[4]) * \note: * Assumes a unit quaternion? * - * in fact not, but you may wan't to use a unit quat, read on... + * in fact not, but you may want to use a unit quat, read on... * * Shortcut for 'q v q*' when \a v is actually a quaternion. * This removes the need for converting a vector to a quaternion, diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 362a87782c6..1b7858f7f88 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -985,7 +985,7 @@ int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedu /* CURRENT STATUS: - * - eve->f :1 = availalble in edges + * - eve->f :1 = available in edges * - eve->xs :polynumber * - eve->h :amount of edges connected to vertex * - eve->tmp.v :store! original vertex number diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h index c0eefc2a3aa..7291bca6356 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.h +++ b/source/blender/bmesh/intern/bmesh_iterators.h @@ -107,14 +107,14 @@ typedef struct BMIter { BMesh *bm; void (*begin)(struct BMIter *iter); void *(*step)(struct BMIter *iter); - /* +#if 0 union { void *p; int i; long l; float f; } filter; - */ +#endif int count; /* note, only some iterators set this, don't rely on it */ char itype; } BMIter; diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 398e6bbedcf..c5941a6c637 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -117,7 +117,7 @@ static BMOpDefine bmo_smooth_vert_def = { * Vertext Smooth Laplacian * Smooths vertices by using Laplacian smoothing propose by. * Desbrun, et al. Implicit Fairing of Irregular Meshes using Diffusion and Curvature Flow -*/ + */ static BMOpDefine bmo_smooth_laplacian_vert_def = { "smooth_laplacian_vert", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 1c4f0974c6d..084f71e0afc 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -552,8 +552,8 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen } /** When this method is called, the writer must handle all nodes contained in the -* library nodes. -* \return The writer should return true, if writing succeeded, false otherwise.*/ + * library nodes. + * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryNodes) { if (mImportStage != General) diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index e878a5a5b48..d54b8db9f00 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -81,8 +81,8 @@ public: /** * This method will be called if an error in the loading process occurred and the loader cannot * continue to load. The writer should undo all operations that have been performed. - \param errorMessage A message containing informations about the error that occurred. - */ + * \param errorMessage A message containing informations about the error that occurred. + */ void cancel(const COLLADAFW::String& errorMessage); /** This is the method called. The writer hast to prepare to receive data.*/ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 77f6d2bda5c..e04bbc1f2bf 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -110,7 +110,7 @@ typedef struct tGPsdata { double ocurtime; /* Used when converting to path */ float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space - * to region space */ + * to region space */ float custom_color[4]; /* custom color - hack for enforcing a particular color for track/mask editing */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 99bdb8d6fe9..92edac356e6 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1471,9 +1471,10 @@ static void node_shader_buts_script_details(uiLayout *layout, bContext *C, Point node_shader_buts_script(layout, C, ptr); - /* not implemented yet +#if 0 /* not implemented yet */ if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL) - uiItemR(layout, ptr, "use_auto_update", 0, NULL, ICON_NONE);*/ + uiItemR(layout, ptr, "use_auto_update", 0, NULL, ICON_NONE); +#endif } /* only once called */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b3e7fa15523..7a1b97ff1d6 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1228,7 +1228,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) hmargin = 0.035f * (x2 - x1); vmargin = 0.035f * (y2 - y1); - uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1+vmargin, x2 - hmargin, y2 - vmargin, 2.0f); + uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f); } if (ca && (ca->flag & CAM_SHOWSENSOR)) { /* determine sensor fit, and get sensor x/y, for auto fit we @@ -3276,7 +3276,7 @@ static void bl_debug_draw(void) int i; cpack(0x00FF0000); glBegin(GL_LINE_LOOP); - for(i=0; i < _bl_debug_draw_quads_tot; i ++) { + for (i = 0; i < _bl_debug_draw_quads_tot; i ++) { glVertex3fv(_bl_debug_draw_quads[i][0]); glVertex3fv(_bl_debug_draw_quads[i][1]); glVertex3fv(_bl_debug_draw_quads[i][2]); diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index aedce52a7bf..4c9b5e620dd 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -457,7 +457,7 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer } /* Header should be rounded to next 8k block - 6044 = 8092 - sizeof(DpxMainHeader) */ + * 6044 = 8092 - sizeof(DpxMainHeader) */ memset(&pad, 0, 6044); if (fwrite(&pad, 6044, 1, dpx->file) == 0) { if (verbose) printf("DPX: Couldn't write image header\n"); diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h index 0291816cd03..7e5a1e504b8 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.h +++ b/source/blender/imbuf/intern/dds/BlockDXT.h @@ -147,7 +147,7 @@ struct BlockDXT3 struct AlphaBlockDXT5 { // uint64 unions do not compile on all platforms - /* +#if 0 union { struct { uint64 alpha0 : 8; // 8 @@ -171,7 +171,7 @@ struct AlphaBlockDXT5 }; uint64 u; }; - */ +#endif uint64 u; uint8 alpha0() const { return u & 0xffLL; } uint8 alpha1() const { return (u >> 8) & 0xffLL; } diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index e9d26ebebbc..df49e537788 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -49,14 +49,14 @@ static bNodeSocketTemplate cmp_node_colorbalance_out[] = { #ifdef WITH_COMPOSITOR_LEGACY /* this function implements ASC-CDL according to the spec at http://www.asctech.org/ - Slope - S = in * slope - Offset - O = S + offset - = (in * slope) + offset - Power - out = Clamp(O) ^ power - = Clamp((in * slope) + offset) ^ power + * Slope + * S = in * slope + * Offset + * O = S + offset + * = (in * slope) + offset + * Power + * out = Clamp(O) ^ power + * = Clamp((in * slope) + offset) ^ power */ DO_INLINE float colorbalance_cdl(float in, float offset, float power, float slope) { diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index ad97ceb68d4..8d146bedb48 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -59,6 +59,19 @@ static PyMethodDef bpy_reload_meth; static PyObject *imp_reload_orig = NULL; /* 'builtins' is most likely PyEval_GetBuiltins() */ + +/** + * \note to the discerning developer, yes - this is nasty + * monkey-patching our own import into Python's builtin 'imp' module. + * + * However Python's alternative is to use import hooks, + * which are implemented in a way that we can't use our own importer as a + * fall-back (instead we must try and fail - raise an exception evert time). + * Since importing from blenders text-blocks is not the common case + * I prefer to use Pythons import by default and fall-back to + * Blenders - which we can only do by intercepting import calls I'm afraid. + * - Campbell + */ void bpy_import_init(PyObject *builtins) { PyObject *item; diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 60e3f7d6164..bd6e752076d 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -711,14 +711,14 @@ static int wm_automatic_draw_method(wmWindow *win) if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) return USER_DRAW_OVERLAP; /* also Intel drivers are slow */ - /* 2.64 BCon3 period, let's try if intel now works... +#if 0 /* 2.64 BCon3 period, let's try if intel now works... */ else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_UNIX, GPU_DRIVER_ANY)) return USER_DRAW_OVERLAP; else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY)) return USER_DRAW_OVERLAP_FLIP; else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_ANY)) return USER_DRAW_OVERLAP_FLIP; - */ +#endif /* Windows software driver darkens color on each redraw */ else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE)) return USER_DRAW_OVERLAP_FLIP; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 54e61df4f6a..5cbad42134c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -340,7 +340,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve int retval; /* UI code doesn't handle return values - it just always returns break. - to make the DBL_CLICK conversion work, we just don't send this to UI */ + * to make the DBL_CLICK conversion work, we just don't send this to UI */ if (event->val == KM_DBL_CLICK) return WM_HANDLER_CONTINUE; @@ -1288,9 +1288,9 @@ static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi) /* the matching rules */ if (kmitype == KM_TEXTINPUT) - if (winevent->val == KM_PRESS) { // prevent double clicks + if (winevent->val == KM_PRESS) { /* prevent double clicks */ /* NOT using ISTEXTINPUT anymore because (at least on Windows) some key codes above 255 - could have printable ascii keys - BUG [#30479] */ + * could have printable ascii keys - BUG [#30479] */ if (ISKEYBOARD(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1; } @@ -1550,8 +1550,8 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa if (handler->op->reports->list.first) { /* FIXME, temp setting window, this is really bad! - * only have because lib linking errors need to be seen by users :( - * it can be removed without breaking anything but then no linking errors - campbell */ + * only have because lib linking errors need to be seen by users :( + * it can be removed without breaking anything but then no linking errors - campbell */ wmWindow *win_prev = CTX_wm_window(C); ScrArea *area_prev = CTX_wm_area(C); ARegion *ar_prev = CTX_wm_region(C); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 035e9d44b02..896a24f3fba 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1228,7 +1228,7 @@ static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_ } /* Same as WM_operator_props_popup but call the operator first, - * This way - the button values corraspond to the result of the operator. + * This way - the button values correspond to the result of the operator. * Without this, first access to a button will make the result jump, * see [#32452] */ int WM_operator_props_popup_call(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 0da3774d9a4..f4c2c13dcac 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -88,7 +88,6 @@ typedef struct PlayState { short pingpong; short noskip; short sstep; - short pause; short wait2; short stopped; short go; @@ -748,7 +747,6 @@ void WM_main_playanim(int argc, const char **argv) ps.pingpong = FALSE; ps.noskip = FALSE; ps.sstep = FALSE; - ps.pause = FALSE; ps.wait2 = FALSE; ps.stopped = FALSE; ps.picture = NULL; diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index fbb3466032d..09f7e1692d9 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -337,7 +337,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) int scr_w, scr_h, posy; /* force setting multisamples only once, it requires restart - and you cannot - mix it, either all windows have it, or none (tested in OSX opengl) */ + * mix it, either all windows have it, or none (tested in OSX opengl) */ if (multisamples == -1) multisamples = U.ogl_multisamples; diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index ca0e9659a22..4d3d6ef89d9 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -285,9 +285,9 @@ enum { /* for event checks */ /* only used for KM_TEXTINPUT, so assume that we want all user-inputtable ascii codes included */ - /* UNUSED - see wm_eventmatch - BUG [#30479] -#define ISTEXTINPUT(event) (event >= ' ' && event <= 255) - */ + /* UNUSED - see wm_eventmatch - BUG [#30479] */ +// #define ISTEXTINPUT(event) (event >= ' ' && event <= 255) + /* test whether the event is a key on the keyboard */ #define ISKEYBOARD(event) (event >= ' ' && event <= 320) diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 83b7c8c8771..37e26e88750 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -526,7 +526,7 @@ typedef struct KX_PYATTRIBUTE_DEF { /*------------------------------ * PyObjectPlus -------------------------------*/ + *------------------------------ */ typedef PyTypeObject *PyParentObject; /* Define the PyParent Object */ #else // WITH_PYTHON diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index 6b57db1a467..72a04064834 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -152,8 +152,8 @@ struct SG_Callbacks }; /** -base object that can be part of the scenegraph. -*/ + * base object that can be part of the scenegraph. + */ class SG_IObject : public SG_QList { private : From 973cb29d841a37f0c101cc20433329a83400d894 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 02:41:55 +0000 Subject: [PATCH 094/115] style cleanup: if's on the same line. --- intern/ghost/intern/GHOST_SystemCocoa.mm | 16 ++++++++----- source/blender/avi/intern/avi_rgb.c | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/library.c | 4 +++- source/blender/blenkernel/intern/particle.c | 24 ++++++++++++------- source/blender/blenlib/intern/noise.c | 6 +++-- source/blender/editors/curve/editcurve.c | 8 ++++--- .../editors/interface/interface_regions.c | 4 ++-- source/blender/imbuf/intern/scaling.c | 8 +++---- 9 files changed, 46 insertions(+), 28 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 475ad2bdcb3..628b0d038f9 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1591,13 +1591,17 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) if ((dx == 0) && (dy == 0)) break; /* Quadratic acceleration */ - dx = dx*(fabs(dx)+0.5); - if (dx<0.0) dx-=0.5; else dx+=0.5; - if (dx< -deltaMax) dx= -deltaMax; else if (dx>deltaMax) dx=deltaMax; + dx = dx*(fabs(dx) + 0.5); + if (dx < 0.0) dx -= 0.5; + else dx += 0.5; + if (dx < -deltaMax) dx = -deltaMax; + else if (dx > deltaMax) dx = deltaMax; - dy = dy*(fabs(dy)+0.5); - if (dy<0.0) dy-=0.5; else dy+=0.5; - if (dy< -deltaMax) dy= -deltaMax; else if (dy>deltaMax) dy=deltaMax; + dy = dy*(fabs(dy) + 0.5); + if (dy < 0.0) dy -= 0.5; + else dy += 0.5; + if (dy < -deltaMax) dy= -deltaMax; + else if (dy > deltaMax) dy= deltaMax; window->clientToScreenIntern(mousePos.x, mousePos.y, x, y); dy = -dy; diff --git a/source/blender/avi/intern/avi_rgb.c b/source/blender/avi/intern/avi_rgb.c index 11d9bdf8612..c6a78eccce2 100644 --- a/source/blender/avi/intern/avi_rgb.c +++ b/source/blender/avi/intern/avi_rgb.c @@ -98,7 +98,7 @@ void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buf buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); rowstride = movie->header->Width * 3; - if (bits != 16) if (movie->header->Width % 2) rowstride++; + if ((bits != 16) && (movie->header->Width % 2)) rowstride++; for (y = 0; y < movie->header->Height; y++) { memcpy(&buf[y * movie->header->Width * 3], &buffer[((movie->header->Height - 1) - y) * rowstride], movie->header->Width * 3); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index f2cd695d64a..754a4fbc0c8 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1116,7 +1116,7 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float * *fp = basisu[i] * bp->vec[3]; sumdiv += *fp; } - if (sumdiv != 0.0f) if (sumdiv < 0.999f || sumdiv > 1.001f) { + if ((sumdiv != 0.0f) && (sumdiv < 0.999f || sumdiv > 1.001f)) { /* is normalizing needed? */ fp = sum; for (i = istart; i <= iend; i++, fp++) { diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 9deff12f124..eb0612a75bd 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1520,7 +1520,9 @@ void test_idbutton(char *name) /* search for id */ idtest = BLI_findstring(lb, name, offsetof(ID, name) + 2); - if (idtest) if (new_id(lb, idtest, name) == 0) id_sort_by_name(lb, idtest); + if (idtest && (new_id(lb, idtest, name) == 0)) { + id_sort_by_name(lb, idtest); + } } void text_idbutton(struct ID *id, char *text) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index d645204d29c..93bf5a5c0b4 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3786,14 +3786,22 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co return 1; } -#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) \ - if ((event & mtex->mapto) & type) { pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } (void)0 +#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) \ + if ((event & mtex->mapto) & type) { \ + pvalue = texture_value_blend(def, pvalue, value, texfac, blend); \ + } (void)0 -#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) \ - if (event & type) { if (pvalue < 0.0f) pvalue = 1.0f + pvalue; CLAMP(pvalue, 0.0f, 1.0f); } (void)0 +#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) \ + if (event & type) { \ + if (pvalue < 0.0f) \ + pvalue = 1.0f + pvalue; \ + CLAMP(pvalue, 0.0f, 1.0f); \ + } (void)0 -#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) \ - if (event & type) { CLAMP(pvalue, -1.0f, 1.0f); } (void)0 +#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) \ + if (event & type) { \ + CLAMP(pvalue, -1.0f, 1.0f); \ + } (void)0 static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, const float fw[4], float *orco, ParticleTexture *ptex, int event, float cfra) { @@ -3802,8 +3810,8 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti float value, rgba[4], texvec[3]; ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = - ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink = - ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; + ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink = + ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f; ptex->length = 1.0f - part->randlength * PSYS_FRAND(child_index + 26); ptex->length *= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f; diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 6bb59e1e195..f37e1e03f39 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -398,7 +398,8 @@ static float orgBlenderNoise(float x, float y, float z) h = hashvectf + 3 * hash[b21 + b11]; n += i * (h[0] * jx + h[1] * jy + h[2] * jz); - if (n < 0.0f) n = 0.0f; else if (n > 1.0f) n = 1.0f; + if (n < 0.0f) n = 0.0f; + else if (n > 1.0f) n = 1.0f; return n; } @@ -1890,7 +1891,8 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity y *= lacunarity; z *= lacunarity; weight = signal * gain; - if (weight > 1.0f) weight = 1.0f; else if (weight < 0.0f) weight = 0.0f; + if (weight > 1.0f) weight = 1.0f; + else if (weight < 0.0f) weight = 0.0f; signal = offset - fabsf(noisefunc(x, y, z)); signal *= signal; signal *= weight; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 957dcfbd848..348b98a0380 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -3678,10 +3678,12 @@ static int is_u_selected(Nurb *nu, int u) /* what about resolu == 2? */ bp = &nu->bp[u]; for (v = 0; v < nu->pntsv - 1; v++, bp += nu->pntsu) { - if (v) if (bp->f1 & SELECT) return 1; + if ((v != 0) && (bp->f1 & SELECT)) { + return TRUE; + } } - return 0; + return FALSE; } typedef struct NurbSort { @@ -6464,7 +6466,7 @@ Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type bp->vec[0] += fac * grid; fac = (float)b - 1.5f; bp->vec[1] += fac * grid; - if (a == 1 || a == 2) if (b == 1 || b == 2) { + if ((a == 1 || a == 2) && (b == 1 || b == 2)) { bp->vec[2] += grid; } mul_m4_v3(mat, bp->vec); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 9b77072dee1..c1547593f96 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1409,8 +1409,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, dir1 &= (UI_TOP | UI_DOWN); } - if (dir2 == 0) if (dir1 == UI_LEFT || dir1 == UI_RIGHT) dir2 = UI_DOWN; - if (dir2 == 0) if (dir1 == UI_TOP || dir1 == UI_DOWN) dir2 = UI_LEFT; + if ((dir2 == 0) && (dir1 == UI_LEFT || dir1 == UI_RIGHT)) dir2 = UI_DOWN; + if ((dir2 == 0) && (dir1 == UI_TOP || dir1 == UI_DOWN)) dir2 = UI_LEFT; /* no space at all? don't change */ if (left || right) { diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index b9525ccccf1..1e701b8d615 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1467,10 +1467,10 @@ struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int return ibuf; } - if (newx < ibuf->x) if (newx) scaledownx(ibuf, newx); - if (newy < ibuf->y) if (newy) scaledowny(ibuf, newy); - if (newx > ibuf->x) if (newx) scaleupx(ibuf, newx); - if (newy > ibuf->y) if (newy) scaleupy(ibuf, newy); + if (newx && (newx < ibuf->x)) scaledownx(ibuf, newx); + if (newy && (newy < ibuf->y)) scaledowny(ibuf, newy); + if (newx && (newx > ibuf->x)) scaleupx(ibuf, newx); + if (newy && (newy > ibuf->y)) scaleupy(ibuf, newy); return(ibuf); } From 8cdc141b9a98decb993f09bce276c646d41c59ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 03:01:31 +0000 Subject: [PATCH 095/115] typo in own recent commit. --- release/scripts/startup/bl_operators/presets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 4e7003fd453..ee9769d8b43 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -558,7 +558,7 @@ class WM_MT_operator_presets(Menu): # dummy 'default' menu item layout = self.layout layout.operator("wm.operator_defaults") - layout.seperator() + layout.separator() Menu.draw_preset(self, context) From 681081306811c5a00269579c14277e2b747b77a3 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 18 Nov 2012 03:56:53 +0000 Subject: [PATCH 096/115] OSL / Windows: * Some fixes for scons, kernel/osl compiles now. * Still disabled per default, as relative path to oslc.exe does not work and linking fails. --- build_files/scons/config/win32-vc-config.py | 4 +--- build_files/scons/config/win64-vc-config.py | 4 +--- intern/cycles/kernel/osl/SConscript | 6 +++++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index 74ae186d54b..39031ef27ca 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -151,8 +151,7 @@ WITH_BF_OPENMP = True WITH_BF_CYCLES = True #OSL -''' -WITH_BF_CYCLES_OSL = True +WITH_BF_CYCLES_OSL = False WITH_BF_STATICOSL = True BF_OSL = LIBDIR + '/osl' BF_OSL_INC = '${BF_OSL}/include' @@ -161,7 +160,6 @@ BF_OSL_INC = '${BF_OSL}/include' BF_OSL_LIB = 'oslcomp oslexec oslquery' BF_OSL_LIBPATH = '${BF_OSL}/lib' BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' -''' WITH_BF_OIIO = True BF_OIIO = '${LIBDIR}/openimageio' diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index 86b9984b7e3..2434cb0c63a 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -147,8 +147,7 @@ WITH_BF_OPENMP = True WITH_BF_CYCLES = True #OSL -''' -WITH_BF_CYCLES_OSL = True +WITH_BF_CYCLES_OSL = False WITH_BF_STATICOSL = True BF_OSL = LIBDIR + '/osl' BF_OSL_INC = '${BF_OSL}/include' @@ -157,7 +156,6 @@ BF_OSL_INC = '${BF_OSL}/include' BF_OSL_LIB = 'oslcomp oslexec oslquery' BF_OSL_LIBPATH = '${BF_OSL}/lib' BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' -''' WITH_BF_OIIO = True BF_OIIO = '${LIBDIR}/openimageio' diff --git a/intern/cycles/kernel/osl/SConscript b/intern/cycles/kernel/osl/SConscript index 2060422ba13..59a6655eed6 100644 --- a/intern/cycles/kernel/osl/SConscript +++ b/intern/cycles/kernel/osl/SConscript @@ -17,6 +17,10 @@ defs.append('CCL_NAMESPACE_END=}') defs.append('WITH_OSL') cxxflags = env['CXXFLAGS'] -cxxflags = "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags = "/EHsc -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" + incs += ' ' + env['BF_PTHREADS_INC'] +else: + cxxflags = "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" env.BlenderLib ('cycles_kernel_osl', sources, Split(incs), defs, libtype=['intern'], priority=[10], cxx_compileflags=Split(cxxflags)) From d3d5c57c32c16fcff38fe31acfefa36a6aef8420 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 07:41:38 +0000 Subject: [PATCH 097/115] move source/darwin into release/darwin since these files are for osx packaging. --- build_files/scons/tools/Blender.py | 6 +++--- .../darwin/blender.app/Contents/Info.plist | 0 .../darwin/blender.app/Contents/MacOS/blender | 0 .../darwin/blender.app/Contents/PkgInfo | 0 .../Contents/Resources/blender file icon.icns | Bin .../Contents/Resources/blender icon.icns | Bin .../darwin/blenderplayer.app/Contents/Info.plist | 0 .../blenderplayer.app/Contents/MacOS/blenderplayer | 0 .../darwin/blenderplayer.app/Contents/PkgInfo | 0 .../Contents/Resources/blender file icon.icns | Bin .../Contents/Resources/blender player icon.icns | Bin .../set_simulation_threads.app/Contents/Info.plist | 0 .../Contents/MacOS/applet | Bin .../set_simulation_threads.app/Contents/PkgInfo | 0 .../Contents/Resources/Scripts/main.scpt | Bin .../Contents/Resources/applet.icns | Bin .../Contents/Resources/applet.rsrc | Bin .../Contents/Resources/description.rtfd/TXT.rtf | 0 source/blenderplayer/CMakeLists.txt | 2 +- source/creator/CMakeLists.txt | 4 ++-- 20 files changed, 6 insertions(+), 6 deletions(-) rename {source => release}/darwin/blender.app/Contents/Info.plist (100%) rename {source => release}/darwin/blender.app/Contents/MacOS/blender (100%) rename {source => release}/darwin/blender.app/Contents/PkgInfo (100%) rename {source => release}/darwin/blender.app/Contents/Resources/blender file icon.icns (100%) rename {source => release}/darwin/blender.app/Contents/Resources/blender icon.icns (100%) rename {source => release}/darwin/blenderplayer.app/Contents/Info.plist (100%) rename {source => release}/darwin/blenderplayer.app/Contents/MacOS/blenderplayer (100%) rename {source => release}/darwin/blenderplayer.app/Contents/PkgInfo (100%) rename {source => release}/darwin/blenderplayer.app/Contents/Resources/blender file icon.icns (100%) rename {source => release}/darwin/blenderplayer.app/Contents/Resources/blender player icon.icns (100%) rename {source => release}/darwin/set_simulation_threads.app/Contents/Info.plist (100%) rename {source => release}/darwin/set_simulation_threads.app/Contents/MacOS/applet (100%) rename {source => release}/darwin/set_simulation_threads.app/Contents/PkgInfo (100%) rename {source => release}/darwin/set_simulation_threads.app/Contents/Resources/Scripts/main.scpt (100%) rename {source => release}/darwin/set_simulation_threads.app/Contents/Resources/applet.icns (100%) rename {source => release}/darwin/set_simulation_threads.app/Contents/Resources/applet.rsrc (100%) rename {source => release}/darwin/set_simulation_threads.app/Contents/Resources/description.rtfd/TXT.rtf (100%) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 27e8feaea80..7aa2a293ae6 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -596,8 +596,8 @@ def AppIt(target=None, source=None, env=None): bldroot = env.Dir('.').abspath binary = env['BINARYKIND'] - sourcedir = bldroot + '/source/darwin/%s.app'%binary - sourceinfo = bldroot + "/source/darwin/%s.app/Contents/Info.plist"%binary + sourcedir = bldroot + '/release/darwin/%s.app' % binary + sourceinfo = bldroot + "/release/darwin/%s.app/Contents/Info.plist"%binary targetinfo = installdir +'/' + "%s.app/Contents/Info.plist"%binary cmd = installdir + '/' +'%s.app'%binary @@ -686,7 +686,7 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) cmd = 'rm -rf %s/set_simulation_threads.app'%(installdir) # first clear omp_num_threads applescript commands.getoutput(cmd) - cmd = 'cp -R %s/source/darwin/set_simulation_threads.app %s/'%(bldroot, installdir) # copy the omp_num_threads applescript + cmd = 'cp -R %s/release/darwin/set_simulation_threads.app %s/'%(bldroot, installdir) # copy the omp_num_threads applescript commands.getoutput(cmd) # extract copy system python, be sure to update other build systems diff --git a/source/darwin/blender.app/Contents/Info.plist b/release/darwin/blender.app/Contents/Info.plist similarity index 100% rename from source/darwin/blender.app/Contents/Info.plist rename to release/darwin/blender.app/Contents/Info.plist diff --git a/source/darwin/blender.app/Contents/MacOS/blender b/release/darwin/blender.app/Contents/MacOS/blender similarity index 100% rename from source/darwin/blender.app/Contents/MacOS/blender rename to release/darwin/blender.app/Contents/MacOS/blender diff --git a/source/darwin/blender.app/Contents/PkgInfo b/release/darwin/blender.app/Contents/PkgInfo similarity index 100% rename from source/darwin/blender.app/Contents/PkgInfo rename to release/darwin/blender.app/Contents/PkgInfo diff --git a/source/darwin/blender.app/Contents/Resources/blender file icon.icns b/release/darwin/blender.app/Contents/Resources/blender file icon.icns similarity index 100% rename from source/darwin/blender.app/Contents/Resources/blender file icon.icns rename to release/darwin/blender.app/Contents/Resources/blender file icon.icns diff --git a/source/darwin/blender.app/Contents/Resources/blender icon.icns b/release/darwin/blender.app/Contents/Resources/blender icon.icns similarity index 100% rename from source/darwin/blender.app/Contents/Resources/blender icon.icns rename to release/darwin/blender.app/Contents/Resources/blender icon.icns diff --git a/source/darwin/blenderplayer.app/Contents/Info.plist b/release/darwin/blenderplayer.app/Contents/Info.plist similarity index 100% rename from source/darwin/blenderplayer.app/Contents/Info.plist rename to release/darwin/blenderplayer.app/Contents/Info.plist diff --git a/source/darwin/blenderplayer.app/Contents/MacOS/blenderplayer b/release/darwin/blenderplayer.app/Contents/MacOS/blenderplayer similarity index 100% rename from source/darwin/blenderplayer.app/Contents/MacOS/blenderplayer rename to release/darwin/blenderplayer.app/Contents/MacOS/blenderplayer diff --git a/source/darwin/blenderplayer.app/Contents/PkgInfo b/release/darwin/blenderplayer.app/Contents/PkgInfo similarity index 100% rename from source/darwin/blenderplayer.app/Contents/PkgInfo rename to release/darwin/blenderplayer.app/Contents/PkgInfo diff --git a/source/darwin/blenderplayer.app/Contents/Resources/blender file icon.icns b/release/darwin/blenderplayer.app/Contents/Resources/blender file icon.icns similarity index 100% rename from source/darwin/blenderplayer.app/Contents/Resources/blender file icon.icns rename to release/darwin/blenderplayer.app/Contents/Resources/blender file icon.icns diff --git a/source/darwin/blenderplayer.app/Contents/Resources/blender player icon.icns b/release/darwin/blenderplayer.app/Contents/Resources/blender player icon.icns similarity index 100% rename from source/darwin/blenderplayer.app/Contents/Resources/blender player icon.icns rename to release/darwin/blenderplayer.app/Contents/Resources/blender player icon.icns diff --git a/source/darwin/set_simulation_threads.app/Contents/Info.plist b/release/darwin/set_simulation_threads.app/Contents/Info.plist similarity index 100% rename from source/darwin/set_simulation_threads.app/Contents/Info.plist rename to release/darwin/set_simulation_threads.app/Contents/Info.plist diff --git a/source/darwin/set_simulation_threads.app/Contents/MacOS/applet b/release/darwin/set_simulation_threads.app/Contents/MacOS/applet similarity index 100% rename from source/darwin/set_simulation_threads.app/Contents/MacOS/applet rename to release/darwin/set_simulation_threads.app/Contents/MacOS/applet diff --git a/source/darwin/set_simulation_threads.app/Contents/PkgInfo b/release/darwin/set_simulation_threads.app/Contents/PkgInfo similarity index 100% rename from source/darwin/set_simulation_threads.app/Contents/PkgInfo rename to release/darwin/set_simulation_threads.app/Contents/PkgInfo diff --git a/source/darwin/set_simulation_threads.app/Contents/Resources/Scripts/main.scpt b/release/darwin/set_simulation_threads.app/Contents/Resources/Scripts/main.scpt similarity index 100% rename from source/darwin/set_simulation_threads.app/Contents/Resources/Scripts/main.scpt rename to release/darwin/set_simulation_threads.app/Contents/Resources/Scripts/main.scpt diff --git a/source/darwin/set_simulation_threads.app/Contents/Resources/applet.icns b/release/darwin/set_simulation_threads.app/Contents/Resources/applet.icns similarity index 100% rename from source/darwin/set_simulation_threads.app/Contents/Resources/applet.icns rename to release/darwin/set_simulation_threads.app/Contents/Resources/applet.icns diff --git a/source/darwin/set_simulation_threads.app/Contents/Resources/applet.rsrc b/release/darwin/set_simulation_threads.app/Contents/Resources/applet.rsrc similarity index 100% rename from source/darwin/set_simulation_threads.app/Contents/Resources/applet.rsrc rename to release/darwin/set_simulation_threads.app/Contents/Resources/applet.rsrc diff --git a/source/darwin/set_simulation_threads.app/Contents/Resources/description.rtfd/TXT.rtf b/release/darwin/set_simulation_threads.app/Contents/Resources/description.rtfd/TXT.rtf similarity index 100% rename from source/darwin/set_simulation_threads.app/Contents/Resources/description.rtfd/TXT.rtf rename to release/darwin/set_simulation_threads.app/Contents/Resources/description.rtfd/TXT.rtf diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 11e790451cd..85bb07d6e83 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -60,7 +60,7 @@ elseif(APPLE) add_executable(blenderplayer ${EXETYPE} bad_level_call_stubs/stubs.c) # setup Info.plist execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) - set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app) + set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app) set(PLAYER_SOURCEINFO ${PLAYER_SOURCEDIR}/Contents/Info.plist) set_target_properties(blenderplayer PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PLAYER_SOURCEINFO} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 66c3beeebad..32b990d14c5 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -656,7 +656,7 @@ elseif(APPLE) ) endmacro() - set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) + set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blender.app) # setup Info.plist execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -715,7 +715,7 @@ elseif(APPLE) # install blenderplayer bundle - copy of blender.app above. re-using macros et al # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it if(WITH_GAMEENGINE AND WITH_PLAYER) - set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app) + set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app) set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist) set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION}) From 916039f520fd12105333df460031c5b94c324bf7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 08:16:09 +0000 Subject: [PATCH 098/115] move decimator into tools/ dir --- source/blender/bmesh/CMakeLists.txt | 8 ++++---- source/blender/bmesh/bmesh.h | 3 ++- source/blender/bmesh/{intern => tools}/bmesh_decimate.h | 0 .../bmesh/{intern => tools}/bmesh_decimate_collapse.c | 3 ++- .../bmesh/{intern => tools}/bmesh_decimate_dissolve.c | 0 .../bmesh/{intern => tools}/bmesh_decimate_unsubdivide.c | 0 6 files changed, 8 insertions(+), 6 deletions(-) rename source/blender/bmesh/{intern => tools}/bmesh_decimate.h (100%) rename source/blender/bmesh/{intern => tools}/bmesh_decimate_collapse.c (99%) rename source/blender/bmesh/{intern => tools}/bmesh_decimate_dissolve.c (100%) rename source/blender/bmesh/{intern => tools}/bmesh_decimate_unsubdivide.c (100%) diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index d7858ebbc0d..75f424010ae 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -68,10 +68,6 @@ set(SRC intern/bmesh_construct.h intern/bmesh_core.c intern/bmesh_core.h - intern/bmesh_decimate_collapse.c - intern/bmesh_decimate_dissolve.c - intern/bmesh_decimate_unsubdivide.c - intern/bmesh_decimate.h intern/bmesh_inline.h intern/bmesh_interp.c intern/bmesh_interp.h @@ -109,6 +105,10 @@ set(SRC intern/bmesh_error.h tools/BME_bevel.c + tools/bmesh_decimate_collapse.c + tools/bmesh_decimate_dissolve.c + tools/bmesh_decimate_unsubdivide.c + tools/bmesh_decimate.h bmesh.h bmesh_class.h diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index a672ec0b6a7..54f55833664 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -252,7 +252,6 @@ extern "C" { #include "intern/bmesh_construct.h" #include "intern/bmesh_core.h" -#include "intern/bmesh_decimate.h" #include "intern/bmesh_interp.h" #include "intern/bmesh_iterators.h" #include "intern/bmesh_marking.h" @@ -267,6 +266,8 @@ extern "C" { #include "intern/bmesh_inline.h" +#include "tools/bmesh_decimate.h" + #ifdef __cplusplus } #endif diff --git a/source/blender/bmesh/intern/bmesh_decimate.h b/source/blender/bmesh/tools/bmesh_decimate.h similarity index 100% rename from source/blender/bmesh/intern/bmesh_decimate.h rename to source/blender/bmesh/tools/bmesh_decimate.h diff --git a/source/blender/bmesh/intern/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c similarity index 99% rename from source/blender/bmesh/intern/bmesh_decimate_collapse.c rename to source/blender/bmesh/tools/bmesh_decimate_collapse.c index 74792d1d558..c38b9f54a33 100644 --- a/source/blender/bmesh/intern/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -39,9 +39,10 @@ #include "BKE_customdata.h" #include "bmesh.h" -#include "bmesh_structure.h" #include "bmesh_decimate.h" /* own include */ +#include "../intern/bmesh_structure.h" + /* defines for testing */ #define USE_CUSTOMDATA #define USE_TRIANGULATE diff --git a/source/blender/bmesh/intern/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c similarity index 100% rename from source/blender/bmesh/intern/bmesh_decimate_dissolve.c rename to source/blender/bmesh/tools/bmesh_decimate_dissolve.c diff --git a/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c similarity index 100% rename from source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c rename to source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c From 9a74fb5b05476eacdaf1a2d8c8f027c8aae34805 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 08:20:02 +0000 Subject: [PATCH 099/115] moving bevel to tools dir as-is to keep svn history (breaks build, will fix next). --- .../blender/bmesh/{operators/bmo_bevel.c => tools/bmesh_bevel.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename source/blender/bmesh/{operators/bmo_bevel.c => tools/bmesh_bevel.c} (100%) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c similarity index 100% rename from source/blender/bmesh/operators/bmo_bevel.c rename to source/blender/bmesh/tools/bmesh_bevel.c From 4401ac8c9e312a81bf1a750f0a7068e24174a7fd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 08:35:27 +0000 Subject: [PATCH 100/115] finish moving bevel code out of the operator dir (it works again) --- source/blender/bmesh/CMakeLists.txt | 2 + source/blender/bmesh/bmesh.h | 1 + source/blender/bmesh/operators/bmo_bevel.c | 51 +++++++++++++++++++ source/blender/bmesh/tools/bmesh_bevel.c | 27 +++++----- source/blender/bmesh/tools/bmesh_bevel.h | 32 ++++++++++++ source/blender/bmesh/tools/bmesh_decimate.h | 2 +- .../bmesh/tools/bmesh_decimate_collapse.c | 2 +- .../bmesh/tools/bmesh_decimate_dissolve.c | 2 +- .../bmesh/tools/bmesh_decimate_unsubdivide.c | 2 +- 9 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 source/blender/bmesh/operators/bmo_bevel.c create mode 100644 source/blender/bmesh/tools/bmesh_bevel.h diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 75f424010ae..2a23658f5d0 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -105,6 +105,8 @@ set(SRC intern/bmesh_error.h tools/BME_bevel.c + tools/bmesh_bevel.c + tools/bmesh_bevel.h tools/bmesh_decimate_collapse.c tools/bmesh_decimate_dissolve.c tools/bmesh_decimate_unsubdivide.c diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index 54f55833664..6257aa4bf3e 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -267,6 +267,7 @@ extern "C" { #include "intern/bmesh_inline.h" #include "tools/bmesh_decimate.h" +#include "tools/bmesh_bevel.h" #ifdef __cplusplus } diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c new file mode 100644 index 00000000000..9de15fb9c9c --- /dev/null +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -0,0 +1,51 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/bmesh/operators/bmesh_bevel.c + * \ingroup bmesh + */ + +#include "BLI_utildefines.h" + +#include "bmesh.h" + +#include "intern/bmesh_operators_private.h" /* own include */ + +void bmo_bevel_exec(BMesh *bm, BMOperator *op) +{ + BMOIter siter; + BMVert *v; + + const float offset = BMO_slot_float_get(op, "offset"); + const int seg = BMO_slot_int_get(op, "segments"); + + if (offset > 0) { + /* first flush 'geom' into flags, this makes it possible to check connected data */ + BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE, BM_ELEM_TAG, FALSE); + + BMO_ITER (v, &siter, bm, op, "geom", BM_VERT | BM_EDGE) { + BM_elem_flag_enable(v, BM_ELEM_TAG); + } + + BM_mesh_bevel(bm, offset, seg); + } +} diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 3854bca5d44..fc655d60318 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -15,12 +15,16 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor(s): Joseph Eagar, Aleksandr Mokhov, Howard Trickey + * Contributor(s): + * Joseph Eagar, + * Aleksandr Mokhov, + * Howard Trickey, + * Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/bmesh/operators/bmo_bevel.c +/** \file blender/bmesh/tools/bmesh_bevel.c * \ingroup bmesh */ @@ -34,7 +38,7 @@ #include "bmesh.h" -#include "intern/bmesh_operators_private.h" /* own include */ + /* experemental - Campbell */ // #define USE_ALTERNATE_ADJ @@ -1661,16 +1665,18 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) } } -void bmo_bevel_exec(BMesh *bm, BMOperator *op) +/** + * currently only bevels BM_ELEM_TAG'd verts and edges + */ +void BM_mesh_bevel(BMesh *bm, const float offset, const float segments) { BMIter iter; - BMOIter siter; BMVert *v; BMEdge *e; BevelParams bp = {NULL}; - bp.offset = BMO_slot_float_get(op, "offset"); - bp.seg = BMO_slot_int_get(op, "segments"); + bp.offset = offset; + bp.seg = segments; if (bp.offset > 0) { /* primary alloc */ @@ -1678,13 +1684,6 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) bp.mem_arena = BLI_memarena_new((1 << 16), __func__); BLI_memarena_use_calloc(bp.mem_arena); - /* first flush 'geom' into flags, this makes it possible to check connected data */ - BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE, BM_ELEM_TAG, FALSE); - - BMO_ITER (v, &siter, bm, op, "geom", BM_VERT | BM_EDGE) { - BM_elem_flag_enable(v, BM_ELEM_TAG); - } - /* The analysis of the input vertices and execution additional constructions */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h new file mode 100644 index 00000000000..a80e4f3a4a2 --- /dev/null +++ b/source/blender/bmesh/tools/bmesh_bevel.h @@ -0,0 +1,32 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BMESH_BEVEL_H__ +#define __BMESH_BEVEL_H__ + +/** \file blender/bmesh/tools/bmesh_bevel.h + * \ingroup bmesh + */ + +void BM_mesh_bevel(BMesh *bm, const float offset, const float segments); + +#endif /* __BMESH_BEVEL_H__ */ diff --git a/source/blender/bmesh/tools/bmesh_decimate.h b/source/blender/bmesh/tools/bmesh_decimate.h index 04dc0cfd2ea..4d382d65659 100644 --- a/source/blender/bmesh/tools/bmesh_decimate.h +++ b/source/blender/bmesh/tools/bmesh_decimate.h @@ -23,7 +23,7 @@ #ifndef __BMESH_DECIMATE_H__ #define __BMESH_DECIMATE_H__ -/** \file blender/bmesh/intern/bmesh_decimate.h +/** \file blender/bmesh/tools/bmesh_decimate.h * \ingroup bmesh */ diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index c38b9f54a33..781001508f2 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -20,7 +20,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/bmesh/intern/bmesh_decimate_collapse.c +/** \file blender/bmesh/tools/bmesh_decimate_collapse.c * \ingroup bmesh * * BMesh decimator that uses an edge collapse method. diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c index fb78050988d..d2a5c580ae6 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c +++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c @@ -20,7 +20,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/bmesh/intern/bmesh_decimate_dissolve.c +/** \file blender/bmesh/tools/bmesh_decimate_dissolve.c * \ingroup bmesh * * BMesh decimator that dissolves flat areas into polygons (ngons). diff --git a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c index 1ec13010d80..acdab2510a4 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c +++ b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c @@ -20,7 +20,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/bmesh/intern/bmesh_decimate_unsubdivide.c +/** \file blender/bmesh/tools/bmesh_decimate_unsubdivide.c * \ingroup bmesh * * BMesh decimator that uses a grid un-subdivide method. From 02049cfe6b0b7be7de48648c862b5a7c153874b5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 08:56:47 +0000 Subject: [PATCH 101/115] commented bevel modifier code now calls bevel direct rather then the bevel operator. --- source/blender/modifiers/intern/MOD_bevel.c | 35 ++++++++------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 66e188693a6..e01c555d89e 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -92,20 +92,15 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) #ifdef USE_BM_BEVEL_OP_AS_MOD -#define GEOM_MARK 1 - /* BMESH_TODO * - * this bevel calls the operator which is missing many of the options - * which the bevel modifier in trunk has. + * this bevel calls the new bevel code (added since 2.64) + * which is missing many of the options which the bevel modifier from 2.4x has. * - no vertex bevel * - no weight bevel * * These will need to be added to the bmesh operator. - * - campbell - * - * note: this code is very close to MOD_edgesplit.c. - * note: if 0'd code from trunk included below. + * - campbell */ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), DerivedMesh *dm, @@ -116,14 +111,11 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), BMIter iter; BMEdge *e; BevelModifierData *bmd = (BevelModifierData *) md; - float threshold = cos((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f); + float threshold = cosf((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f); const int segments = 16; /* XXX */ bm = DM_to_bmesh(dm); - BM_mesh_normals_update(bm, FALSE); - BMO_push(bm, NULL); - if (bmd->lim_flags & BME_BEVEL_ANGLE) { BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* check for 1 edge having 2 face users */ @@ -132,9 +124,9 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), (l2 = e->l->radial_next) != l1) { if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { - BMO_elem_flag_enable(bm, e, GEOM_MARK); - BMO_elem_flag_enable(bm, e->v1, GEOM_MARK); - BMO_elem_flag_enable(bm, e->v2, GEOM_MARK); + BM_elem_flag_enable(e, BM_ELEM_TAG); + BM_elem_flag_enable(e->v1, BM_ELEM_TAG); + BM_elem_flag_enable(e->v2, BM_ELEM_TAG); } } } @@ -142,20 +134,19 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), else { /* crummy, is there a way just to operator on all? - campbell */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - BMO_elem_flag_enable(bm, e, GEOM_MARK); - BMO_elem_flag_enable(bm, e->v1, GEOM_MARK); - BMO_elem_flag_enable(bm, e->v2, GEOM_MARK); + BM_elem_flag_enable(e, BM_ELEM_TAG); + BM_elem_flag_enable(e->v1, BM_ELEM_TAG); + BM_elem_flag_enable(e->v2, BM_ELEM_TAG); } } - BMO_op_callf(bm, BMO_FLAG_DEFAULTS, - "bevel geom=%fve offset=%f segments=%i", - GEOM_MARK, bmd->value, segments); - BMO_pop(bm); + BM_mesh_bevel(bm, bmd->value, segments); result = CDDM_from_bmesh(bm, TRUE); BM_mesh_free(bm); + CDDM_calc_normals(result); + return result; } From b72c1ac33cd03553e4529b39215ed7e168920ad5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 09:25:57 +0000 Subject: [PATCH 102/115] bmesh function was still using bmesh operator flags, use edge tags instead. --- source/blender/bmesh/tools/bmesh_bevel.c | 27 ++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index fc655d60318..8020c404d5f 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -43,9 +43,6 @@ /* experemental - Campbell */ // #define USE_ALTERNATE_ADJ -#define BEVEL_FLAG 1 -#define EDGE_SELECTED 2 - #define BEVEL_EPSILON 1e-6 /* for testing */ @@ -1392,6 +1389,11 @@ static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) } } +/* take care, this flag isn't cleared before use, it just so happens that its not set */ +#define BM_BEVEL_EDGE_TAG_ENABLE(bme) BM_elem_flag_enable( (bme)->l, BM_ELEM_TAG) +#define BM_BEVEL_EDGE_TAG_DISABLE(bme) BM_elem_flag_disable( (bme)->l, BM_ELEM_TAG) +#define BM_BEVEL_EDGE_TAG_TEST(bme) BM_elem_flag_test( (bme)->l, BM_ELEM_TAG) + /* * Construction around the vertex */ @@ -1413,9 +1415,11 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) { if (BM_elem_flag_test(bme, BM_ELEM_TAG)) { if (BM_edge_is_manifold(bme)) { - BMO_elem_flag_enable(bm, bme, EDGE_SELECTED); nsel++; } + else { + BM_elem_flag_disable(bme, BM_ELEM_TAG); + } } } @@ -1436,7 +1440,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) * a face, if possible */ i = 0; bme = v->e; - BMO_elem_flag_enable(bm, bme, BEVEL_FLAG); + BM_BEVEL_EDGE_TAG_ENABLE(bme); e = &bv->edges[0]; e->e = bme; for (i = 0; i < ntot; i++) { @@ -1445,7 +1449,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) found_shared_face = 0; unflagged_bme = NULL; BM_ITER_ELEM (bme2, &iter, v, BM_EDGES_OF_VERT) { - if (BMO_elem_flag_test(bm, bme2, BEVEL_FLAG)) + if (BM_BEVEL_EDGE_TAG_TEST(bme2)) continue; if (!unflagged_bme) unflagged_bme = bme2; @@ -1469,8 +1473,8 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } } bme = e->e; - BMO_elem_flag_enable(bm, bme, BEVEL_FLAG); - if (BMO_elem_flag_test(bm, bme, EDGE_SELECTED)) { + BM_BEVEL_EDGE_TAG_ENABLE(bme); + if (BM_elem_flag_test(bme, BM_ELEM_TAG)) { e->is_bev = TRUE; e->seg = bp->seg; } @@ -1492,9 +1496,10 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } } - /* remove BEVEL_FLAG now that we are finished with it*/ - for (i = 0; i < ntot; i++) - BMO_elem_flag_disable(bm, bv->edges[i].e, BEVEL_FLAG); + /* clear BEVEL_EDGE_TAG now that we are finished with it*/ + for (i = 0; i < ntot; i++) { + BM_BEVEL_EDGE_TAG_DISABLE(bv->edges[i].e); + } /* if edge array doesn't go CCW around vertex from average normal side, * reverse the array, being careful to reverse face pointers too */ From fd9dac77d1d6de6ae6eea3ccc19099decfae665f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 09:33:11 +0000 Subject: [PATCH 103/115] bevel now only takes manifold edges (so it doesnt need to check for them) --- source/blender/bmesh/operators/bmo_bevel.c | 15 +++++++++++---- source/blender/bmesh/tools/bmesh_bevel.c | 9 +++------ source/blender/modifiers/intern/MOD_bevel.c | 8 +++++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 9de15fb9c9c..049b923315b 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -32,20 +32,27 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) { - BMOIter siter; - BMVert *v; - const float offset = BMO_slot_float_get(op, "offset"); const int seg = BMO_slot_int_get(op, "segments"); if (offset > 0) { + BMOIter siter; + BMEdge *e; + BMVert *v; + /* first flush 'geom' into flags, this makes it possible to check connected data */ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE, BM_ELEM_TAG, FALSE); - BMO_ITER (v, &siter, bm, op, "geom", BM_VERT | BM_EDGE) { + BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { BM_elem_flag_enable(v, BM_ELEM_TAG); } + BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) { + if (BM_edge_is_manifold(e)) { + BM_elem_flag_enable(e, BM_ELEM_TAG); + } + } + BM_mesh_bevel(bm, offset, seg); } } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 8020c404d5f..12a85ce34de 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -1414,12 +1414,8 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) { if (BM_elem_flag_test(bme, BM_ELEM_TAG)) { - if (BM_edge_is_manifold(bme)) { - nsel++; - } - else { - BM_elem_flag_disable(bme, BM_ELEM_TAG); - } + BLI_assert(BM_edge_is_manifold(bme)); + nsel++; } } @@ -1672,6 +1668,7 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) /** * currently only bevels BM_ELEM_TAG'd verts and edges + * all tagged edges _must_ be manifold. */ void BM_mesh_bevel(BMesh *bm, const float offset, const float segments) { diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index e01c555d89e..7a109c041b6 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -134,9 +134,11 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), else { /* crummy, is there a way just to operator on all? - campbell */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - BM_elem_flag_enable(e, BM_ELEM_TAG); - BM_elem_flag_enable(e->v1, BM_ELEM_TAG); - BM_elem_flag_enable(e->v2, BM_ELEM_TAG); + if (BM_edge_is_manifold(e)) { + BM_elem_flag_enable(e, BM_ELEM_TAG); + BM_elem_flag_enable(e->v1, BM_ELEM_TAG); + BM_elem_flag_enable(e->v2, BM_ELEM_TAG); + } } } From 42ebc9bc8086f2c1fb1323dfe22168419ec83024 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 10:17:07 +0000 Subject: [PATCH 104/115] bmesh: move internal API flags out of BMFlagLayer, into BMHeader which was being padded up anyway, added static assert to make sure it stays <=16 bytes. --- source/blender/bmesh/bmesh_class.h | 28 ++++++++++++++----- source/blender/bmesh/intern/bmesh_construct.c | 4 ++- source/blender/bmesh/intern/bmesh_operators.c | 6 ++++ source/blender/bmesh/intern/bmesh_private.h | 7 +++-- source/blender/bmesh/tools/bmesh_bevel.c | 13 ++++----- source/blender/modifiers/intern/MOD_bevel.c | 10 +++---- 6 files changed, 43 insertions(+), 25 deletions(-) diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 32ae7824739..bec184a7ca7 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -48,6 +48,8 @@ struct Object; * hrm. it doesn't but stull works ok, remove the comment above? - campbell. */ +// #pragma GCC diagnostic error "-Wpadded" + /** * BMHeader * @@ -69,10 +71,19 @@ typedef struct BMHeader { * this is abused by various tools which set it dirty. * - For loops this is used for sorting during tessellation. */ - char htype; /* element geometric type (verts/edges/loops/faces) */ - char hflag; /* this would be a CD layer, see below */ + char htype; /* element geometric type (verts/edges/loops/faces) */ + char hflag; /* this would be a CD layer, see below */ + + /* internal use only! + * note,.we are very picky about not bloating this struct + * but in this case its padded up to 16 bytes anyway, + * so adding a flag here gives no increase in size */ + char api_flag; +// char _pad; } BMHeader; +BLI_STATIC_ASSERT((sizeof(BMHeader) <= 16), "BMHeader size has grown!"); + /* note: need some way to specify custom locations for custom data layers. so we can * make them point directly into structs. and some way to make it only happen to the * active layer, and properly update when switching active layers.*/ @@ -142,21 +153,24 @@ typedef struct BMFace { BMHeader head; struct BMFlagLayer *oflags; /* an array of flags, mostly used by the operator stack */ - int len; /*includes all boundary loops*/ #ifdef USE_BMESH_HOLES int totbounds; /*total boundaries, is one plus the number of holes in the face*/ ListBase loops; #else BMLoop *l_first; #endif - float no[3]; /*yes, we do store this here*/ + int len; /* includes all boundary loops */ + float no[3]; /* yes, we do store this here */ short mat_nr; +// short _pad[3]; } BMFace; typedef struct BMFlagLayer { - short f, pflag; /* flags */ + short f; /* flags */ } BMFlagLayer; +// #pragma GCC diagnostic ignored "-Wpadded" + typedef struct BMesh { int totvert, totedge, totloop, totface; int totvertsel, totedgesel, totfacesel; @@ -166,7 +180,7 @@ typedef struct BMesh { * valid flags are - BM_VERT | BM_EDGE | BM_FACE. * BM_LOOP isn't handled so far. */ char elem_index_dirty; - + /*element pools*/ struct BLI_mempool *vpool, *epool, *lpool, *fpool; @@ -192,7 +206,7 @@ typedef struct BMesh { int walkers, totflags; ListBase selected, error_stack; - + BMFace *act_face; ListBase errorstack; diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 81405079a56..e2cee1221c2 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -187,8 +187,10 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i * _and_ the old bmesh_mf functions, so its kindof smashed together * - joeedh */ - if (!len || !v1 || !v2 || !edges || !bm) + if (!len || !v1 || !v2 || !edges || !bm) { + BLI_assert(0); return NULL; + } /* put edges in correct order */ for (i = 0; i < len; i++) { diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 9d1054dc042..4c2b353b258 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1068,18 +1068,21 @@ static void bmo_flag_layer_alloc(BMesh *bm) ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, old_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ + BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele); } BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, old_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ + BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele); } BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, old_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ + BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele); } bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); @@ -1113,18 +1116,21 @@ static void bmo_flag_layer_free(BMesh *bm) ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, new_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ + BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele); } BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, new_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ + BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele); } BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, new_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ + BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele); } bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h index b3fe3676ab8..a5eb7e63505 100644 --- a/source/blender/bmesh/intern/bmesh_private.h +++ b/source/blender/bmesh/intern/bmesh_private.h @@ -62,9 +62,10 @@ int bmesh_disk_count(BMVert *v); #define _FLAG_MF 2 /* make face */ #define _FLAG_MV 2 /* make face, vertex */ -#define BM_ELEM_API_FLAG_ENABLE(element, f) ((element)->oflags[0].pflag |= (f)) -#define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->oflags[0].pflag &= ~(f)) -#define BM_ELEM_API_FLAG_TEST(element, f) ((element)->oflags[0].pflag & (f)) +#define BM_ELEM_API_FLAG_ENABLE(element, f) ((element)->head.api_flag |= (f)) +#define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->head.api_flag &= ~(f)) +#define BM_ELEM_API_FLAG_TEST(element, f) ((element)->head.api_flag & (f)) +#define BM_ELEM_API_FLAG_CLEAR(element) ((element)->head.api_flag = 0) void calc_poly_plane(float (*verts)[3], const int nverts); void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nverts); diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 12a85ce34de..cfc7edb2400 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -252,22 +252,19 @@ static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, int totv, BMFace *f BMFace *f; if (totv == 3) { - f = BM_face_create_quad_tri(bm, - vert_arr[0], vert_arr[1], vert_arr[2], NULL, facerep, 0); + f = BM_face_create_quad_tri_v(bm, vert_arr, 3, facerep, 0); } else if (totv == 4) { - f = BM_face_create_quad_tri(bm, - vert_arr[0], vert_arr[1], vert_arr[2], vert_arr[3], facerep, 0); + f = BM_face_create_quad_tri_v(bm, vert_arr, 4, facerep, 0); } else { int i; - BMEdge *e; BMEdge **ee = NULL; - BLI_array_staticdeclare(ee, 30); + BLI_array_staticdeclare(ee, BM_DEFAULT_NGON_STACK_SIZE); + BLI_array_grow_items(ee, totv); for (i = 0; i < totv; i++) { - e = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, TRUE); - BLI_array_append(ee, e); + ee[i] = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, TRUE); } f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, FALSE); BLI_array_free(ee); diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 7a109c041b6..cb63da659b2 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -111,7 +111,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), BMIter iter; BMEdge *e; BevelModifierData *bmd = (BevelModifierData *) md; - float threshold = cosf((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f); + const float threshold = cosf((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f); const int segments = 16; /* XXX */ bm = DM_to_bmesh(dm); @@ -119,11 +119,9 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), if (bmd->lim_flags & BME_BEVEL_ANGLE) { BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* check for 1 edge having 2 face users */ - BMLoop *l1, *l2; - if ((l1 = e->l) && - (l2 = e->l->radial_next) != l1) - { - if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { + BMLoop *l_a, *l_b; + if (BM_edge_loop_pair(e, &l_a, &l_b)) { + if (dot_v3v3(l_a->f->no, l_b->f->no) < threshold) { BM_elem_flag_enable(e, BM_ELEM_TAG); BM_elem_flag_enable(e->v1, BM_ELEM_TAG); BM_elem_flag_enable(e->v2, BM_ELEM_TAG); From 317dff520c18ef7030e64534358a1861b89c8ed0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 11:48:21 +0000 Subject: [PATCH 105/115] fix for skin modifier calling rotate_normalized_v3_v3v3fl with a non unit length axis. --- source/blender/modifiers/intern/MOD_skin.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 38ec0e8bb4c..96f97a6fa8a 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -537,6 +537,7 @@ static int connection_node_mat(float mat[3][3], int v, const MeshElemMap *emap, /* Get axis and angle to rotate frame by */ angle = angle_normalized_v3v3(ine[0], oute[0]) / 2.0f; cross_v3_v3v3(axis, ine[0], oute[0]); + normalize_v3(axis); /* Build frame matrix (don't care about X axis here) */ copy_v3_v3(mat[0], ine[0]); From a9af5635264d8a143fb0902f2d8819b2a6f9f23c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Nov 2012 12:14:22 +0000 Subject: [PATCH 106/115] bmesh: lazy initialize bmesh tool flag pool, has the advantage that modifiers that dont use bmesh operators can skip allocating it. --- source/blender/bmesh/bmesh_class.h | 5 ++- source/blender/bmesh/intern/bmesh_core.c | 32 ++++++++++++---- source/blender/bmesh/intern/bmesh_mesh.c | 38 +++++++++++++++++-- source/blender/bmesh/intern/bmesh_mesh.h | 5 +++ source/blender/bmesh/intern/bmesh_operators.c | 10 ++++- source/blender/bmesh/operators/bmo_dupe.c | 4 +- source/blender/bmesh/tools/BME_bevel.c | 5 ++- source/blender/editors/mesh/editmesh_tools.c | 2 + source/blender/modifiers/intern/MOD_array.c | 1 + source/blender/modifiers/intern/MOD_bevel.c | 2 + .../blender/modifiers/intern/MOD_decimate.c | 1 + .../blender/modifiers/intern/MOD_edgesplit.c | 5 +-- 12 files changed, 88 insertions(+), 22 deletions(-) diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index bec184a7ca7..f9dbf51a629 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -133,7 +133,10 @@ typedef struct BMLoop { /* can cast BMFace/BMEdge/BMVert, but NOT BMLoop, since these don't have a flag layer */ typedef struct BMElemF { BMHeader head; - struct BMFlagLayer *oflags; /* keep after header, an array of flags, mostly used by the operator stack */ + + /* keep directly after header, + * optional array of flags, only used by the operator stack */ + struct BMFlagLayer *oflags; } BMElemF; /* can cast anything to this, including BMLoop */ diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index c427734f58d..d4539050147 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -76,7 +76,9 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example) } /* allocate flag */ - v->oflags = BLI_mempool_calloc(bm->toolflagpool); + if (bm->toolflagpool) { + v->oflags = BLI_mempool_calloc(bm->toolflagpool); + } CustomData_bmesh_set_default(&bm->vdata, &v->head.data); @@ -125,7 +127,9 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, e->head.htype = BM_EDGE; /* allocate flag */ - e->oflags = BLI_mempool_calloc(bm->toolflagpool); + if (bm->toolflagpool) { + e->oflags = BLI_mempool_calloc(bm->toolflagpool); + } e->v1 = v1; e->v2 = v2; @@ -278,7 +282,9 @@ BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm) f->head.htype = BM_FACE; /* allocate flag */ - f->oflags = BLI_mempool_calloc(bm->toolflagpool); + if (bm->toolflagpool) { + f->oflags = BLI_mempool_calloc(bm->toolflagpool); + } CustomData_bmesh_set_default(&bm->pdata, &f->head.data); @@ -495,7 +501,9 @@ static void bm_kill_only_vert(BMesh *bm, BMVert *v) if (v->head.data) CustomData_bmesh_free_block(&bm->vdata, &v->head.data); - BLI_mempool_free(bm->toolflagpool, v->oflags); + if (bm->toolflagpool) { + BLI_mempool_free(bm->toolflagpool, v->oflags); + } BLI_mempool_free(bm->vpool, v); } @@ -513,7 +521,9 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e) if (e->head.data) CustomData_bmesh_free_block(&bm->edata, &e->head.data); - BLI_mempool_free(bm->toolflagpool, e->oflags); + if (bm->toolflagpool) { + BLI_mempool_free(bm->toolflagpool, e->oflags); + } BLI_mempool_free(bm->epool, e); } @@ -534,7 +544,9 @@ static void bm_kill_only_face(BMesh *bm, BMFace *f) if (f->head.data) CustomData_bmesh_free_block(&bm->pdata, &f->head.data); - BLI_mempool_free(bm->toolflagpool, f->oflags); + if (bm->toolflagpool) { + BLI_mempool_free(bm->toolflagpool, f->oflags); + } BLI_mempool_free(bm->fpool, f); } @@ -1773,14 +1785,18 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) bmesh_disk_edge_remove(f1loop->e, f1loop->e->v2); /* deallocate edge and its two loops as well as f2 */ - BLI_mempool_free(bm->toolflagpool, f1loop->e->oflags); + if (bm->toolflagpool) { + BLI_mempool_free(bm->toolflagpool, f1loop->e->oflags); + } BLI_mempool_free(bm->epool, f1loop->e); bm->totedge--; BLI_mempool_free(bm->lpool, f1loop); bm->totloop--; BLI_mempool_free(bm->lpool, f2loop); bm->totloop--; - BLI_mempool_free(bm->toolflagpool, f2->oflags); + if (bm->toolflagpool) { + BLI_mempool_free(bm->toolflagpool, f2->oflags); + } BLI_mempool_free(bm->fpool, f2); bm->totface--; /* account for both above */ diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index d3e3bcd3556..062c47dc686 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -59,9 +59,37 @@ static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize) #ifdef USE_BMESH_HOLES bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), 512, 512, 0); #endif +} - /* allocate one flag pool that we don't get rid of. */ - bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, 0); +void BM_mesh_elem_toolflags_ensure(BMesh *bm) +{ + if (bm->toolflagpool == NULL) { + const int totflagpool_size = max_ii(512, bm->totvert + bm->totedge + bm->totface); + BLI_mempool *toolflagpool; + + BMIter iter; + BMElemF *ele; + const char iter_types[3] = {BM_VERTS_OF_MESH, + BM_EDGES_OF_MESH, + BM_FACES_OF_MESH}; + + int i; + + BLI_assert(bm->totflags == 0); + + /* allocate one flag pool that we don't get rid of. */ + toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), totflagpool_size, 512, 0); + + + for (i = 0; i < 3; i++) { + BM_ITER_MESH (ele, &iter, bm, iter_types[i]) { + ele->oflags = BLI_mempool_calloc(toolflagpool); + } + } + + bm->toolflagpool = toolflagpool; + bm->totflags = 1; + } } /** @@ -83,7 +111,7 @@ BMesh *BM_mesh_create(BMAllocTemplate *allocsize) /* allocate one flag pool that we don't get rid of. */ bm->stackdepth = 1; - bm->totflags = 1; + bm->totflags = 0; CustomData_reset(&bm->vdata); CustomData_reset(&bm->edata); @@ -143,7 +171,9 @@ void BM_mesh_data_free(BMesh *bm) BLI_mempool_destroy(bm->fpool); /* destroy flag pool */ - BLI_mempool_destroy(bm->toolflagpool); + if (bm->toolflagpool) { + BLI_mempool_destroy(bm->toolflagpool); + } #ifdef USE_BMESH_HOLES BLI_mempool_destroy(bm->looplistpool); diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h index 8b6ef9aa3e0..0dcd3fc2f01 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.h +++ b/source/blender/bmesh/intern/bmesh_mesh.h @@ -29,6 +29,7 @@ struct BMAllocTemplate; +void BM_mesh_elem_toolflags_ensure(BMesh *bm); BMesh *BM_mesh_create(struct BMAllocTemplate *allocsize); void BM_mesh_free(BMesh *bm); @@ -58,4 +59,8 @@ typedef struct BMAllocTemplate { extern BMAllocTemplate bm_mesh_allocsize_default; extern BMAllocTemplate bm_mesh_chunksize_default; +enum { + BM_MESH_CREATE_USE_TOOLFLAGS = (1 << 0) +}; + #endif /* __BMESH_MESH_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 4c2b353b258..8f38e1c9ba2 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -101,6 +101,8 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op)) { bm->stackdepth++; + BLI_assert(bm->totflags > 0); + /* add flag layer, if appropriate */ if (bm->stackdepth > 1) bmo_flag_layer_alloc(bm); @@ -172,7 +174,9 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname) */ void BMO_op_exec(BMesh *bm, BMOperator *op) { - + /* allocate tool flags on demand */ + BM_mesh_elem_toolflags_ensure(bm); + BMO_push(bm, op); if (bm->stackdepth == 2) @@ -1056,7 +1060,9 @@ static void bmo_flag_layer_alloc(BMesh *bm) /* store memcpy size for reuse */ const size_t old_totflags_size = (bm->totflags * sizeof(BMFlagLayer)); - + + BLI_assert(oldpool != NULL); + bm->totflags++; /* allocate new flag poo */ diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 32270007a0b..aa502203b50 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -181,7 +181,7 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, * Internal Copy function. */ -static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) +static void bmo_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) { BMVert *v = NULL, *v2; @@ -326,7 +326,7 @@ void bmo_duplicate_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_flag_enable(bm, dupeop, "geom", BM_ALL, DUPE_INPUT); /* use the internal copy function */ - BKE_mesh_copy(dupeop, bm, bm2); + bmo_mesh_copy(dupeop, bm, bm2); /* Output */ /* First copy the input buffers to output buffers - original data */ diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index a632a4446ed..cdfd8372d61 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -1110,10 +1110,13 @@ BMesh *BME_bevel(BMesh *bm, float value, int res, int options, int defgrp_index, td = BME_init_transdata(BLI_MEMARENA_STD_BUFSIZE); /* recursion math courtesy of Martin Poirier (theeth) */ for (i = 0; i < res - 1; i++) { - if (i == 0) fac += 1.0 / 3.0; else fac += 1.0 / (3.0 * i * 2.0); + if (i == 0) fac += 1.0 / 3.0; + else fac += 1.0 / (3.0 * i * 2.0); } d = 1.0 / fac; + BM_mesh_elem_toolflags_ensure(bm); + for (i = 0; i < res || (res == 0 && i == 0); i++) { BMO_push(bm, NULL); BME_bevel_initialize(bm, options, defgrp_index, angle, td); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index e9fd2f142a2..57d6a9b3361 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3006,6 +3006,8 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh BMesh *bm_new; bm_new = BM_mesh_create(&bm_mesh_allocsize_default); + BM_mesh_elem_toolflags_ensure(bm_new); /* needed for 'duplicate' bmo */ + CustomData_copy(&bm_old->vdata, &bm_new->vdata, CD_MASK_BMESH, CD_CALLOC, 0); CustomData_copy(&bm_old->edata, &bm_new->edata, CD_MASK_BMESH, CD_CALLOC, 0); CustomData_copy(&bm_old->ldata, &bm_new->ldata, CD_MASK_BMESH, CD_CALLOC, 0); diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index b9dd37ac50c..8ddae9f3c57 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -408,6 +408,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, * cleaner way to do this. One possibility: a "mirror" BMOp would * certainly help by compressing it all into one top-level BMOp that * executes a lot of second-level BMOps. */ + BM_mesh_elem_toolflags_ensure(bm); BMO_push(bm, NULL); bmesh_edit_begin(bm, 0); diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index cb63da659b2..59befe4db05 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -143,6 +143,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), BM_mesh_bevel(bm, bmd->value, segments); result = CDDM_from_bmesh(bm, TRUE); + + BLI_assert(bm->toolflagpool == NULL); /* make sure we never alloc'd this */ BM_mesh_free(bm); CDDM_calc_normals(result); diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index dc29e59d549..3f8eaa438c9 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -186,6 +186,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* update for display only */ dmd->face_count = bm->totface; result = CDDM_from_bmesh(bm, FALSE); + BLI_assert(bm->toolflagpool == NULL); /* make sure we never alloc'd this */ BM_mesh_free(bm); #ifdef USE_TIMEIT diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 21717d07fef..ec81c5ce699 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -67,8 +67,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj float threshold = cosf((emd->split_angle + 0.00001f) * (float)M_PI / 180.0f); bm = DM_to_bmesh(dm); - - BMO_push(bm, NULL); + BM_mesh_elem_toolflags_ensure(bm); if (emd->flags & MOD_EDGESPLIT_FROMANGLE) { BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { @@ -103,8 +102,6 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "split_edges edges=%fe", EDGE_MARK); - - BMO_pop(bm); /* BM_mesh_validate(bm); */ /* for troubleshooting */ From 2d68893d407123a55f55d190d0ceea6db25023ec Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 18 Nov 2012 13:10:43 +0000 Subject: [PATCH 107/115] Request from Riggers/Animators at BlenderPRO: Armature modifiers added via Ctrl-P operation will no longer have "envelope" deforms enabled. This helps cut down the number of unintended deformations arising from rouge-sized envelopes or stray control bones. --- source/blender/modifiers/intern/MOD_armature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 7219038b087..7ab3a5df531 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -58,7 +58,7 @@ static void initData(ModifierData *md) { ArmatureModifierData *amd = (ArmatureModifierData *) md; - amd->deformflag = ARM_DEF_ENVELOPE | ARM_DEF_VGROUP; + amd->deformflag = ARM_DEF_VGROUP; } static void copyData(ModifierData *md, ModifierData *target) From 03f4e7fba469794d970aa3e411d9ccf01c4b72e2 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 18 Nov 2012 14:27:19 +0000 Subject: [PATCH 108/115] Fix own stupid mistake for threads count, and edits to user messages (mostly adding the ldconfig trick for dynamic boost libs). --- build_files/build_environment/install_deps.sh | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 444bf8ea50b..934a983985e 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -11,7 +11,7 @@ CWD=$PWD BUILD_OSL=false THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"` -if [ -z "$v" ]; then +if [ -z "$THREADS" ]; then THREADS=1 fi @@ -196,7 +196,7 @@ compile_Python() { cd $CWD else INFO "Own Python-$PYTHON_VERSION is up to date, nothing to do!" - INFO "If you want to force rebuild of this lib, delete the '$_src' directory." + INFO "If you want to force rebuild of this lib, delete the '$_src' and '$_inst' directories." fi } @@ -246,7 +246,7 @@ compile_Boost() { cd $CWD else INFO "Own Boost-$BOOST_VERSION is up to date, nothing to do!" - INFO "If you want to force rebuild of this lib, delete the '$_src' directory." + INFO "If you want to force rebuild of this lib, delete the '$_src' and '$_inst' directories." fi } @@ -323,7 +323,7 @@ compile_OCIO() { cd $CWD else INFO "Own OpenColorIO-$OCIO_VERSION is up to date, nothing to do!" - INFO "If you want to force rebuild of this lib, delete the '$_src' directory." + INFO "If you want to force rebuild of this lib, delete the '$_src' and '$_inst' directories." fi } @@ -353,6 +353,8 @@ compile_OIIO() { -xf $_src.tar.gz cd $_src + + # XXX Ugly patching hack! cat << EOF | patch -p1 diff --git a/src/libutil/SHA1.cpp b/src/libutil/SHA1.cpp index b9e6c8b..c761185 100644 @@ -370,6 +372,7 @@ index b9e6c8b..c761185 100644 #ifdef SHA1_UTILITY_FUNCTIONS #define SHA1_MAX_FILE_BUFFER 8000 EOF + fi cd $_src @@ -418,7 +421,7 @@ EOF cd $CWD else INFO "Own OpenImageIO-$OIIO_VERSION is up to date, nothing to do!" - INFO "If you want to force rebuild of this lib, delete the '$_src' directory." + INFO "If you want to force rebuild of this lib, delete the '$_src' and '$_inst' directories." fi } @@ -495,7 +498,7 @@ compile_OSL() { cd $CWD else INFO "Own OpenShadingLanguage-$OSL_VERSION is up to date, nothing to do!" - INFO "If you want to force rebuild of this lib, delete the '$_src' directory." + INFO "If you want to force rebuild of this lib, delete the '$_src' and '$_inst' directories." fi } @@ -587,7 +590,7 @@ compile_FFmpeg() { cd $CWD else INFO "Own ffmpeg-$FFMPEG_VERSION is up to date, nothing to do!" - INFO "If you want to force rebuild of this lib, delete the '$_src' directory." + INFO "If you want to force rebuild of this lib, delete the '$_src' and '$_inst' directories." fi } @@ -1032,27 +1035,36 @@ print_info() { INFO "If you're using SCons add this to your user-config:" if [ -d $INST/python-3.3 ]; then - INFO "BF_PYTHON='$INST/python-3.3'" - INFO "BF_PYTHON_ABI_FLAGS='m'" + INFO "BF_PYTHON = '$INST/python-3.3'" + INFO "BF_PYTHON_ABI_FLAGS = 'm'" fi if [ -d $INST/ocio ]; then - INFO "BF_OCIO='$INST/ocio'" + INFO "BF_OCIO = '$INST/ocio'" fi if [ -d $INST/oiio ]; then - INFO "BF_OIIO='$INST/oiio'" + INFO "BF_OIIO = '$INST/oiio'" fi if [ -d $INST/boost ]; then - INFO "BF_BOOST='$INST/boost'" + INFO "BF_BOOST = '$INST/boost'" fi if [ -d $INST/ffmpeg ]; then - INFO "BF_FFMPEG='$INST/ffmpeg'" + INFO "BF_FFMPEG = '$INST/ffmpeg'" _ffmpeg_list_sep=" " - INFO "BF_FFMPEG_LIB='avformat avcodec swscale avutil avdevice `print_info_ffmpeglink`'" + INFO "BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice `print_info_ffmpeglink`'" fi + + INFO "" + INFO "" + INFO "WARNING: If this script had to build boost into $INST, and you are dynamically linking " + INFO " blender against it, you will have to run those commands as root user:" + INFO "" + INFO " echo \"$INST/boost/lib\" > /etc/ld.so.conf.d/boost.conf" + INFO " ldconfig" + INFO "" } # Detect distributive type used on this machine From 70b6e2717acc945059512b2b69faee7819caa88d Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 18 Nov 2012 15:02:09 +0000 Subject: [PATCH 109/115] Windows / OSL: * Scons cleanup, to avoid redeclaration of /EHsc. Linking still fails. --- intern/cycles/kernel/osl/SConscript | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/intern/cycles/kernel/osl/SConscript b/intern/cycles/kernel/osl/SConscript index 59a6655eed6..d4b42d2becb 100644 --- a/intern/cycles/kernel/osl/SConscript +++ b/intern/cycles/kernel/osl/SConscript @@ -3,24 +3,25 @@ Import('env') defs = [] +incs = [] +cxxflags = Split(env['CXXFLAGS']) + sources = env.Glob('*.cpp') -incs = '. .. ../svm ../../render ../../util ../../device' - -incs += ' ' + env['BF_OIIO_INC'] -incs += ' ' + env['BF_BOOST_INC'] -incs += ' ' + env['BF_OSL_INC'] -incs += ' ' + env['BF_OPENEXR_INC'] +incs.extend('. .. ../svm ../../render ../../util ../../device'.split()) +incs.append(env['BF_OIIO_INC']) +incs.append(env['BF_BOOST_INC']) +incs.append(env['BF_OSL_INC']) +incs.append(env['BF_OPENEXR_INC'].split()) defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {') defs.append('CCL_NAMESPACE_END=}') defs.append('WITH_OSL') -cxxflags = env['CXXFLAGS'] if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): - cxxflags = "/EHsc -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" - incs += ' ' + env['BF_PTHREADS_INC'] + cxxflags.append('-DBOOST_NO_RTTI -DBOOST_NO_TYPEID'.split()) + incs.append(env['BF_PTHREADS_INC']) else: - cxxflags = "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" + cxxflags.append('-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID'.split()) -env.BlenderLib ('cycles_kernel_osl', sources, Split(incs), defs, libtype=['intern'], priority=[10], cxx_compileflags=Split(cxxflags)) +env.BlenderLib ('cycles_kernel_osl', sources, incs, defs, libtype=['intern'], priority=[10], cxx_compileflags=cxxflags) From a996a425262dd553fc0d6d70844028dc8a215a0a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 18 Nov 2012 17:26:23 +0000 Subject: [PATCH 110/115] CMakeList: Better handling of llvm under linux (now you can try to force usage of a specific version of llvm before using default one). Also cleared LIBDIR var from linux code, as we have no more those svn folders! --- CMakeLists.txt | 56 +++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec2dd6c73bd..fe1a6d03335 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -502,20 +502,6 @@ set(PLATFORM_LINKFLAGS_DEBUG "") #Platform specifics if(UNIX AND NOT APPLE) - - # set lib directory if it exists - if(CMAKE_SYSTEM_NAME MATCHES "Linux") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/linux64) - else() - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/linux) - endif() - - if(NOT EXISTS ${LIBDIR}) - unset(LIBDIR) - endif() - endif() - find_package(JPEG REQUIRED) find_package(PNG REQUIRED) find_package(ZLIB REQUIRED) @@ -590,15 +576,8 @@ if(UNIX AND NOT APPLE) endif() if(WITH_CODEC_FFMPEG) - # use lib dir if available and nothing else specified - if(LIBDIR AND NOT FFMPEG) - set(FFMPEG ${LIBDIR}/ffmpeg CACHE PATH "FFMPEG Directory") - # XXX, some distros might need 'theoraenc theoradec' too - set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale dirac_encoder mp3lame ogg orc-0.4 schroedinger-1.0 theora vorbis vorbisenc vpx x264 xvidcore faad asound CACHE STRING "FFMPEG Libraries") - else() - set(FFMPEG /usr CACHE PATH "FFMPEG Directory") - set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries") - endif() + set(FFMPEG /usr CACHE PATH "FFMPEG Directory") + set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries") mark_as_advanced(FFMPEG) @@ -654,9 +633,8 @@ if(UNIX AND NOT APPLE) if(WITH_BOOST) # uses in build instructions to override include and library variables if(NOT BOOST_CUSTOM) - # use lib dir if available and nothing else specified - if(LIBDIR AND NOT BOOST_ROOT) - set(BOOST_ROOT ${LIBDIR}/boost) + # XXX No more lib dir, is this multithread stuff still needed? + if(NOT BOOST_ROOT) set(Boost_USE_MULTITHREADED OFF) else() set(Boost_USE_MULTITHREADED ON) @@ -676,11 +654,6 @@ if(UNIX AND NOT APPLE) endif() if(WITH_OPENIMAGEIO) - # use lib dir if available and nothing else specified - if(LIBDIR AND NOT OPENIMAGEIO_ROOT_DIR) - set(OPENIMAGEIO_ROOT_DIR ${LIBDIR}/oiio) - endif() - find_package(OpenImageIO) set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES}) @@ -701,11 +674,6 @@ if(UNIX AND NOT APPLE) endif() if(WITH_OPENCOLORIO) - # use lib dir if available and nothing else specified - if(LIBDIR AND NOT OPENCOLORIO_ROOT_DIR) - set(OPENCOLORIO_ROOT_DIR ${LIBDIR}/ocio) - endif() - find_package(OpenColorIO) set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES}) @@ -718,14 +686,16 @@ if(UNIX AND NOT APPLE) endif() endif() + # XXX Maybe most of this section should go into an llvm module? if(WITH_LLVM) - set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") - set(LLVM_VERSION "3.0" CACHE STRING "Version of LLVM to use") + # Set llvm version if not specified + if(NOT LLVM_VERSION) + set(LLVM_VERSION "3.0") + endif() set(LLVM_STATIC YES) - if(EXISTS "${LLVM_DIRECTORY}/bin/llvm-config") - set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config") - else() - set(LLVM_CONFIG llvm-config) + FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS ${LLVM_DIRECTORY}) + if(NOT LLVM_CONFIG) + FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS ${LLVM_DIRECTORY}) endif() execute_process(COMMAND ${LLVM_CONFIG} --version OUTPUT_VARIABLE LLVM_VERSION @@ -742,6 +712,8 @@ if(UNIX AND NOT APPLE) message(STATUS "LLVM version = ${LLVM_VERSION}") message(STATUS "LLVM dir = ${LLVM_DIRECTORY}") message(STATUS "LLVM lib dir = ${LLVM_LIB_DIR}") + set(LLVM_VERSION ${LLVM_VERSION} CACHE STRING "Version of LLVM to use") + set(LLVM_DIRECTORY ${LLVM_DIRECTORY} CACHE PATH "Path to the LLVM installation") if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR) if(LLVM_STATIC) From 76c901d34297e537241b3ed409b311eeb72cc6c7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 18 Nov 2012 17:27:29 +0000 Subject: [PATCH 111/115] Better handing of llvm version (now we can be sure to use the same for osl and blender - and the latest one available!). And more cosmetic cleanups... --- build_files/build_environment/install_deps.sh | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 934a983985e..a2d68c5bd23 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -34,6 +34,7 @@ OIIO_VERSION_MIN="1.1" LLVM_VERSION="3.1" LLVM_VERSION_MIN="3.0" +LLVM_VERSION_FOUND="" # OSL needs to be compiled for now! OSL_VERSION="1.2.0" @@ -427,7 +428,7 @@ EOF compile_OSL() { # To be changed each time we make edits that would modify the compiled result! - osl_magic=4 + osl_magic=5 _src=$SRC/OpenShadingLanguage-$OSL_VERSION _inst=$INST/osl-$OSL_VERSION @@ -467,10 +468,10 @@ compile_OSL() { mkdir build cd build - cmake_d="-D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_INSTALL_PREFIX=$_inst - -D BUILDSTATIC=ON \ - -D BUILD_TESTING=OFF" + cmake_d="-D CMAKE_BUILD_TYPE=Release" + cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst" + cmake_d="$cmake_d -D BUILDSTATIC=ON" + cmake_d="$cmake_d -D BUILD_TESTING=OFF" if [ -d $INST/boost ]; then cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost" @@ -480,6 +481,10 @@ compile_OSL() { cmake_d="$cmake_d -D OPENIMAGEIOHOME=$INST/oiio" fi + if [ ! -z $LLVM_VERSION_FOUND ]; then + cmake_d="$cmake_d -D LLVM_VERSION=$LLVM_VERSION_FOUND" + fi + cmake $cmake_d ../src make -j$THREADS && make install @@ -631,10 +636,12 @@ check_package_version_ge_DEB() { } install_DEB() { + INFO "" INFO "Installing dependencies for DEB-based distribution" INFO "Source code of dependencies needed to be compiled will be downloaded and extracted into $SRC" INFO "Built libs of dependencies needed to be compiled will be installed into $INST" INFO "Please edit \$SRC and/or \$INST variables at the begining of this script if you want to use other paths!" + INFO "" sudo apt-get update # XXX Why in hell? Let's let this stuff to the user's responsability!!! @@ -744,11 +751,13 @@ install_DEB() { if [ $? -eq 0 ]; then sudo apt-get install -y llvm-$LLVM_VERSION-dev clang have_llvm=true + LLVM_VERSION_FOUND=$LLVM_VERSION else check_package_DEB llvm-$LLVM_VERSION_MIN-dev if [ $? -eq 0 ]; then sudo apt-get install -y llvm-$LLVM_VERSION_MIN-dev clang have_llvm=true + LLVM_VERSION_FOUND=$LLVM_VERSION_MIN fi fi @@ -809,10 +818,12 @@ check_package_version_ge_RPM() { } install_RPM() { + INFO "" INFO "Installing dependencies for RPM-based distribution" INFO "Source code of dependencies needed to be compiled will be downloaded and extracted into $SRC" INFO "Built libs of dependencies needed to be compiled will be installed into $INST" INFO "Please edit \$SRC and/or \$INST variables at the begining of this script if you want to use other paths!" + INFO "" sudo yum -y update @@ -907,10 +918,12 @@ check_package_version_SUSE() { } install_SUSE() { + INFO "" INFO "Installing dependencies for SuSE-based distribution" INFO "Source code of dependencies needed to be compiled will be downloaded and extracted into $SRC" INFO "Built libs of dependencies needed to be compiled will be installed into $INST" INFO "Please edit \$SRC and/or \$INST variables at the begining of this script if you want to use other paths!" + INFO "" sudo zypper --non-interactive update --auto-agree-with-licenses @@ -1023,6 +1036,7 @@ print_info() { if [ -d $INST/osl ]; then INFO " -D CYCLES_OSL=$INST/osl" INFO " -D WITH_CYCLES_OSL=ON" + INFO " -D LLVM_VERSION=$LLVM_VERSION_FOUND" fi if [ -d $INST/ffmpeg ]; then From 00c194718adafd333e474fc47f7d12ce6d5a8fd3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 18 Nov 2012 17:47:26 +0000 Subject: [PATCH 112/115] More cleanup/deduplication. Also explicitly using gawk (so system without it should print a much comprehensive error message!). Note: RPM-related edits not yet tested. --- build_files/build_environment/install_deps.sh | 138 +++++++++--------- 1 file changed, 67 insertions(+), 71 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index a2d68c5bd23..63ef350a1f5 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -827,63 +827,74 @@ install_RPM() { sudo yum -y update + # These libs should always be available in debian/ubuntu official repository... + OPENJPEG_DEV="openjpeg-devel" + SCHRO_DEV="schroedinger-devel" + VORBIS_DEV="libvorbis-devel" + THEORA_DEV="libtheora-devel" + sudo yum -y install gawk gcc gcc-c++ cmake scons libpng-devel libtiff-devel \ freetype-devel libX11-devel libXi-devel wget libsqlite3x-devel ncurses-devel \ - readline-devel openjpeg-devel openexr-devel openal-soft-devel \ - glew-devel yasm schroedinger-devel libtheora-devel libvorbis-devel SDL-devel \ + readline-devel $OPENJPEG_DEV openexr-devel openal-soft-devel \ + glew-devel yasm $SCHRO_DEV $THEORA_DEV $VORBIS_DEV SDL-devel \ fftw-devel lame-libs jack-audio-connection-kit-devel libspnav-devel \ libjpeg-devel patch python-devel OPENJPEG_USE=true SCHRO_USE=true + VORBIS_USE=true + THEORA_USE=true - check_package_RPM x264-devel + X264_DEV="x264-devel" + check_package_version_ge_RPM $X264_DEV $X264_VERSION_MIN if [ $? -eq 0 ]; then - sudo yum install -y x264-devel + sudo yum install -y $X264_DEV X264_USE=true fi - check_package_RPM xvidcore-devel + XVID_DEV="xvidcore-devel" + check_package_RPM $XVID_DEV if [ $? -eq 0 ]; then - sudo yum install -y xvidcore-devel + sudo yum install -y $XVID_DEV XVID_USE=true - XVID_DEV="xvidcore-devel" fi - check_package_version_ge_RPM libvpx-devel 0.9.7 + VPX_DEV="libvpx-devel" + check_package_version_ge_RPM $VPX_DEV $VPX_VERSION_MIN if [ $? -eq 0 ]; then - sudo yum install -y libvpx-devel + sudo yum install -y $VPX_DEV VPX_USE=true fi - check_package_RPM lame-devel + MP3LAME_DEV="lame-devel" + check_package_RPM $MP3LAME_DEV if [ $? -eq 0 ]; then - sudo yum install -y lame-devel + sudo yum install -y $MP3LAME_DEV MP3LAME_USE=true fi - check_package_version_match_RPM python3-devel 3.3 + check_package_version_match_RPM python3-devel $PYTHON_VERSION_MIN if [ $? -eq 0 ]; then - sudo yum install -y python-devel + sudo yum install -y python3-devel else compile_Python fi - check_package_RPM boost-devel + check_package_version_ge_RPM boost-devel $BOOST_VERSION_MIN if [ $? -eq 0 ]; then sudo yum install -y boost-devel else compile_Boost fi - check_package_RPM OpenColorIO-devel + check_package_version_ge_RPM OpenColorIO-devel $OCIO_VERSION_MIN if [ $? -eq 0 ]; then sudo yum install -y OpenColorIO-devel else compile_OCIO fi - check_package_RPM OpenImageIO-devel + check_package_version_ge_RPM OpenImageIO-devel $OIIO_VERSION_MIN if [ $? -eq 0 ]; then sudo yum install -y OpenImageIO-devel else @@ -949,63 +960,11 @@ install_SUSE() { } print_info_ffmpeglink_DEB() { - _packages="libtheora-dev" - - if $XVID_USE; then - _packages="$_packages $XVID_DEV" - fi - - if $VPX_USE; then - _packages="$_packages libvpx-dev" - fi - - if $MP3LAME_USE; then - _packages="$_packages libmp3lame-dev" - fi - - if $X264_USE; then - _packages="$_packages libx264-dev" - fi - - if $OPENJPEG_USE; then - _packages="$_packages libopenjpeg-dev" - fi - - if $SCHRO_USE; then - _packages="$_packages libschroedinger-dev" - fi - - dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.so" | awk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }' + dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }' } print_info_ffmpeglink_RPM() { - _packages="libtheora-devel libvorbis-devel" - - if $XVID_USE; then - _packages="$_packages $XVID_DEV" - fi - - if $VPX_USE; then - _packages="$_packages libvpx-devel" - fi - - if $MP3LAME_USE; then - _packages="$_packages lame-devel" - fi - - if $X264_USE; then - _packages="$_packages x264-devel" - fi - - if $OPENJPEG_USE; then - _packages="$_packages openjpeg-devel" - fi - - if $SCHRO_USE; then - _packages="$_packages schroedinger-devel" - fi - - rpm -ql $_packages | grep -e ".*\/lib[^\/]\+\.so" | awk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }' + rpm -ql $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }' } print_info_ffmpeglink() { @@ -1013,7 +972,44 @@ print_info_ffmpeglink() { if [ -z "$DISTRO" ]; then ERROR "Failed to detect distribution type" exit 1 - elif [ "$DISTRO" = "DEB" ]; then + fi + + # Create list of packages from which to get libs names... + _packages="" + + if $THEORA_USE; then + _packages="$_packages $THEORA_DEV" + fi + + if $VORBIS_USE; then + _packages="$_packages $VORBIS_DEV" + fi + + if $XVID_USE; then + _packages="$_packages $XVID_DEV" + fi + + if $VPX_USE; then + _packages="$_packages $VPX_DEV" + fi + + if $MP3LAME_USE; then + _packages="$_packages $MP3LAME_DEV" + fi + + if $X264_USE; then + _packages="$_packages $X264_DEV" + fi + + if $OPENJPEG_USE; then + _packages="$_packages $OPENJPEG_DEV" + fi + + if $SCHRO_USE; then + _packages="$_packages $SCHRO_DEV" + fi + + if [ "$DISTRO" = "DEB" ]; then print_info_ffmpeglink_DEB elif [ "$DISTRO" = "RPM" ]; then print_info_ffmpeglink_RPM From 0aadad0896a0fd5c490938bbfffc9fb127d7cf3e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 18 Nov 2012 20:31:58 +0000 Subject: [PATCH 113/115] Partial fix to version_ge (greater or equal), was not working correctly with eaqual versions, now will do with exact same versions at least (yet have to fix case like comparing 1.0 and 1.0.0). Also refactored a bit osl/llvm/etc. stuff for DEB (so that now all osl-deps are only installed when we do have a valid llvm and want to [try to!] build osl). And added osl/llvm/etc. code for RPM (osl does not compile under fedora currently, though :/ ). --- build_files/build_environment/install_deps.sh | 54 ++++++++++++++++--- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 63ef350a1f5..7077b66fc5e 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -81,7 +81,9 @@ INFO() { # Return 0 if $1 >= $2, else 1. # $1 and $2 should be version numbers made of numbers only. version_ge() { - if [ $(echo -e "$1\n$2" | sort --version-sort | head --lines=1) = "$1" ]; then + # XXX Not yet perfect, won't always work as expected with e.g. 1.0.0 and 1.0... :/ + if [ "$1" != "$2" ] && + [ $(echo -e "$1\n$2" | sort --version-sort | head --lines=1) = "$1" ]; then return 1 else return 0 @@ -599,8 +601,8 @@ compile_FFmpeg() { fi } -deb_version() { - dpkg-query -W -f '${Version}' $1 | sed -r 's/^([0-9]\.[0-9]+).*/\1/' +get_package_version_DEB() { + dpkg-query -W -f '${Version}' $1 | sed -r 's/.*:\s*([0-9]+:)(([0-9]+\.?)+).*/\2/' } check_package_DEB() { @@ -657,7 +659,7 @@ install_DEB() { libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \ libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV libopenexr-dev libopenal-dev \ libglew-dev yasm $SCHRO_DEV $THEORA_DEV $VORBIS_DEV libsdl1.2-dev \ - libfftw3-dev libjack-dev python-dev patch flex bison libtbb-dev git + libfftw3-dev libjack-dev python-dev patch OPENJPEG_USE=true SCHRO_USE=true @@ -716,7 +718,7 @@ install_DEB() { if [ $? -eq 0 ]; then sudo apt-get install -y libboost-dev - boost_version=`deb_version libboost-dev` + boost_version=`get_package_version_DEB libboost-dev` check_package_DEB libboost-locale$boost_version-dev if [ $? -eq 0 ]; then @@ -749,19 +751,20 @@ install_DEB() { check_package_DEB llvm-$LLVM_VERSION-dev if [ $? -eq 0 ]; then - sudo apt-get install -y llvm-$LLVM_VERSION-dev clang + sudo apt-get install -y llvm-$LLVM_VERSION-dev have_llvm=true LLVM_VERSION_FOUND=$LLVM_VERSION else check_package_DEB llvm-$LLVM_VERSION_MIN-dev if [ $? -eq 0 ]; then - sudo apt-get install -y llvm-$LLVM_VERSION_MIN-dev clang + sudo apt-get install -y llvm-$LLVM_VERSION_MIN-dev have_llvm=true LLVM_VERSION_FOUND=$LLVM_VERSION_MIN fi fi if $have_llvm; then + sudo apt-get install -y clang flex bison libtbb-dev git # No package currently! compile_OSL fi @@ -772,7 +775,7 @@ install_DEB() { # check_package_DEB ffmpeg # if [ $? -eq 0 ]; then # sudo apt-get install -y ffmpeg -# ffmpeg_version=`deb_version ffmpeg` +# ffmpeg_version=`get_package_version_DEB ffmpeg` # INFO "ffmpeg version: $ffmpeg_version" # if [ ! -z "$ffmpeg_version" ]; then # if dpkg --compare-versions $ffmpeg_version gt 0.7.2; then @@ -785,6 +788,10 @@ install_DEB() { compile_FFmpeg } +get_package_version_RPM() { + yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/' +} + check_package_RPM() { r=`yum info $1 | grep -c 'Summary'` @@ -901,6 +908,37 @@ install_RPM() { compile_OIIO fi + if $BUILD_OSL; then + have_llvm=false + + check_package_RPM llvm-$LLVM_VERSION-devel + if [ $? -eq 0 ]; then + sudo yum install -y llvm-$LLVM_VERSION-devel + have_llvm=true + LLVM_VERSION_FOUND=$LLVM_VERSION + else + check_package_RPM llvm-$LLVM_VERSION_MIN-devel + if [ $? -eq 0 ]; then + sudo yum install -y llvm-$LLVM_VERSION_MIN-devel + have_llvm=true + LLVM_VERSION_FOUND=$LLVM_VERSION_MIN + else + check_package_version_ge_RPM llvm-devel $LLVM_VERSION_MIN + if [ $? -eq 0 ]; then + sudo yum install -y llvm-devel + have_llvm=true + LLVM_VERSION_FOUND=`get_package_version_RPM llvm-devel` + fi + fi + fi + + if $have_llvm; then + sudo yum install -y flex bison clang tbb-devel git + # No package currently! + compile_OSL + fi + fi + # Always for now, not sure which packages should be installed compile_FFmpeg } From 2bed09e7a6a6b32dd485a91a444dcff917115767 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 18 Nov 2012 20:38:27 +0000 Subject: [PATCH 114/115] BGE: Changing "transform_uv" -> "transformUV" in some error messages. --- source/gameengine/Ketsji/KX_MeshProxy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 0188a7e15b8..dbbf6bd8c2a 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -292,7 +292,7 @@ PyObject *KX_MeshProxy::PyTransformUV(PyObject *args, PyObject *kwds) MT_Matrix4x4 transform; - if (!PyArg_ParseTuple(args,"iO|iii:transform_uv", &matindex, &pymat, &uvindex, &uvindex_from) || + if (!PyArg_ParseTuple(args,"iO|iii:transformUV", &matindex, &pymat, &uvindex, &uvindex_from) || !PyMatTo(pymat, transform)) { return NULL; @@ -300,12 +300,12 @@ PyObject *KX_MeshProxy::PyTransformUV(PyObject *args, PyObject *kwds) if (uvindex < -1 || uvindex > 1) { PyErr_Format(PyExc_ValueError, - "mesh.transform_uv(...): invalid uv_index %d", uvindex); + "mesh.transformUV(...): invalid uv_index %d", uvindex); return NULL; } if (uvindex_from < -1 || uvindex_from > 1 || uvindex == -1) { PyErr_Format(PyExc_ValueError, - "mesh.transform_uv(...): invalid uv_index_from %d", uvindex); + "mesh.transformUV(...): invalid uv_index_from %d", uvindex); return NULL; } if (uvindex_from == uvindex) { @@ -365,7 +365,7 @@ PyObject *KX_MeshProxy::PyTransformUV(PyObject *args, PyObject *kwds) if (ok == false) { PyErr_Format(PyExc_ValueError, - "mesh.transform_uv(...): invalid material index %d", matindex); + "mesh.transformUV(...): invalid material index %d", matindex); return NULL; } From eb1fccd8a54c33a057fa3692eb3dfa1012f4fdfc Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 18 Nov 2012 20:56:50 +0000 Subject: [PATCH 115/115] BGE: The Step Height for a character physics controller is now set to 0.01, which means that Step Height can no longer be 0, which causes issues such as those noted in issue #33221, "KX_CharacterWrapper inconsistencies and error," reported by Angus Hollands (agoose77). I've also added a do_versions() fix that will give objects with 0 Step Height sane defaults. This means old files will now work better with character physics. --- source/blender/blenloader/intern/readfile.c | 11 +++++++++++ source/blender/makesrna/intern/rna_object.c | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 03e5a1d2525..89f723cb945 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8364,6 +8364,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + { + Object *ob; + for (ob = main->object.first; ob; ob = ob->id.next) { + if (ob->step_height == 0.0) { + ob->step_height = 0.150; + ob->jump_speed = 10.0; + ob->fall_speed = 55.0; + } + } + } + /* 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! */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index d436e4719ea..a669cb2558a 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1643,21 +1643,23 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed"); + /* Character physics */ prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "step_height"); - RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_range(prop, 0.01, 1.0); RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over"); prop = RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "jump_speed"); RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping (with the Motion actuator)"); + RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping"); prop = RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fall_speed"); RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall"); + /* Collision Masks */ prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1); RNA_def_property_array(prop, OB_MAX_COL_MASKS);