From 056c49e9ec53849f75aa091f9a98638e77eb82f5 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 21 Dec 2011 02:41:27 +0000 Subject: Patch [#29654] New menu option under Object > Game with "Copy All Physics Attributes" by Daniel Macedo "This is a patch that adds an option under the menu Object > Game to copy all the physics attributes from Game Engine." --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/editors/object/object_edit.c | 48 +++++++++++++++++++++++++++ source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + 4 files changed, 51 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 5444ad327a9..57bde4eb0dd 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -993,6 +993,7 @@ class VIEW3D_MT_object_game(Menu): layout = self.layout layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks") + layout.operator("object.game_physics_copy", text="Copy Physics Properties") layout.separator() diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 07ab80f6d15..fa308624454 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2178,3 +2178,51 @@ void OBJECT_OT_logic_bricks_copy(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } + +static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob=ED_object_active_context(C); + + CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { + if(ob != ob_iter) { + ob_iter->gameflag = ob->gameflag; + ob_iter->gameflag2 = ob->gameflag2; + ob_iter->inertia = ob->inertia; + ob_iter->formfactor = ob->formfactor;; + ob_iter->damping = ob->damping; + ob_iter->rdamping = ob->rdamping; + ob_iter->min_vel = ob->min_vel; + ob_iter->max_vel = ob->max_vel; + ob_iter->obstacleRad = ob->obstacleRad; + ob_iter->mass = ob->mass; + ob_iter->anisotropicFriction[0] = ob->anisotropicFriction[0]; + ob_iter->anisotropicFriction[1] = ob->anisotropicFriction[1]; + ob_iter->anisotropicFriction[2] = ob->anisotropicFriction[2]; + ob_iter->collision_boundtype = ob->collision_boundtype; + ob_iter->margin = ob->margin; + ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft); + if(ob->restrictflag & OB_RESTRICT_RENDER) + ob_iter->restrictflag |= OB_RESTRICT_RENDER; + else + ob_iter->restrictflag &= ~OB_RESTRICT_RENDER; + } + } + CTX_DATA_END; + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Game Physics Properties to Selected"; + ot->description = "Copy game physics properties to other selected objects"; + ot->idname= "OBJECT_OT_game_physics_copy"; + + /* api callbacks */ + ot->exec= game_physics_copy_exec; + ot->poll= ED_operator_object_active_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 185d8d43765..35e802e3e11 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -92,6 +92,7 @@ void OBJECT_OT_game_property_remove(struct wmOperatorType *ot); void OBJECT_OT_game_property_copy(struct wmOperatorType *ot); void OBJECT_OT_game_property_clear(struct wmOperatorType *ot); void OBJECT_OT_logic_bricks_copy(struct wmOperatorType *ot); +void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot); /* object_select.c */ void OBJECT_OT_select_all(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 3b4a5ed976e..a899d60c2ab 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -189,6 +189,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_game_property_copy); WM_operatortype_append(OBJECT_OT_game_property_clear); WM_operatortype_append(OBJECT_OT_logic_bricks_copy); + WM_operatortype_append(OBJECT_OT_game_physics_copy); WM_operatortype_append(OBJECT_OT_shape_key_add); WM_operatortype_append(OBJECT_OT_shape_key_remove); -- cgit v1.2.3 From 8fbff6100d9dc2430b98b61f4681a3afff24acae Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 21 Dec 2011 11:01:08 +0000 Subject: Added Record run no gaps timecode for movie clips. Also get rid of hardcoded constants in readfile and use constants from ImBuf headers. --- source/blender/blenkernel/intern/movieclip.c | 5 ++++- source/blender/blenloader/CMakeLists.txt | 1 + source/blender/blenloader/SConscript | 2 +- source/blender/blenloader/intern/readfile.c | 16 +++++++++++++--- source/blender/makesrna/intern/rna_movieclip.c | 1 + 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 75d8ec584e8..736c889f66c 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -372,7 +372,10 @@ static MovieClip *movieclip_alloc(const char *name) BKE_tracking_init_settings(&clip->tracking); clip->proxy.build_size_flag= IMB_PROXY_25; - clip->proxy.build_tc_flag= IMB_TC_RECORD_RUN|IMB_TC_FREE_RUN|IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN; + clip->proxy.build_tc_flag= IMB_TC_RECORD_RUN | + IMB_TC_FREE_RUN | + IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN | + IMB_TC_RECORD_RUN_NO_GAPS; clip->proxy.quality= 90; return clip; diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 9cf721738a7..35271f7b873 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../nodes ../render/extern/include ../../../intern/guardedalloc + ../imbuf ) set(INC_SYS diff --git a/source/blender/blenloader/SConscript b/source/blender/blenloader/SConscript index d5d2df3ea35..0333eab7e1f 100644 --- a/source/blender/blenloader/SConscript +++ b/source/blender/blenloader/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('intern/*.c') incs = '. #/intern/guardedalloc ../blenlib ../blenkernel' incs += ' ../makesdna ../editors/include' -incs += ' ../render/extern/include ../makesrna ../nodes' +incs += ' ../render/extern/include ../makesrna ../nodes ../imbuf' incs += ' ' + env['BF_ZLIB_INC'] diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 593b526d38b..bf40a3e73b3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -139,6 +139,8 @@ #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "BKE_sound.h" +#include "IMB_imbuf.h" // for proxy / timecode versioning stuff + #include "NOD_socket.h" //XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes @@ -12588,10 +12590,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) clip->aspy= 1.0f; } - /* XXX: a bit hacky, probably include imbuf and use real constants are nicer */ - clip->proxy.build_tc_flag= 7; + clip->proxy.build_tc_flag= IMB_TC_RECORD_RUN | + IMB_TC_FREE_RUN | + IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN; + if(clip->proxy.build_size_flag==0) - clip->proxy.build_size_flag= 1; + clip->proxy.build_size_flag= IMB_PROXY_25; if(clip->proxy.quality==0) clip->proxy.quality= 90; @@ -12731,6 +12735,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) scene->gm.exitkey = 218; // Blender key code for ESC } } + { + MovieClip *clip; + for(clip= main->movieclip.first; clip; clip= clip->id.next) { + clip->proxy.build_tc_flag|= IMB_TC_RECORD_RUN_NO_GAPS; + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index 3b1ac8f22c3..fbc6a0155f2 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -78,6 +78,7 @@ static void rna_def_movieclip_proxy(BlenderRNA *brna) {IMB_TC_RECORD_RUN, "RECORD_RUN", 0, "Record Run", "Use images in the order they are recorded"}, {IMB_TC_FREE_RUN, "FREE_RUN", 0, "Free Run", "Use global timestamp written by recording device"}, {IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN, "FREE_RUN_REC_DATE", 0, "Free Run (rec date)", "Interpolate a global timestamp using the record date and time written by recording device"}, + {IMB_TC_RECORD_RUN_NO_GAPS, "FREE_RUN_NO_GAPS", 0, "Free Run No Gaps", "Record run, but ignore timecode, changes in framerate or dropouts"}, {0, NULL, 0, NULL, NULL}}; srna = RNA_def_struct(brna, "MovieClipProxy", NULL); -- cgit v1.2.3 From 01de7c2979dd95aa87652a6fb54bcf7fae3a9d13 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Dec 2011 11:36:28 +0000 Subject: fix for mathutils mat*vec for non sqyare matrices by Andrew Hale --- source/blender/python/mathutils/mathutils_Vector.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index bd121b6177f..4e6fce59b7e 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1576,7 +1576,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) return NULL; } - return Vector_CreatePyObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1)); + return Vector_CreatePyObject(tvec, ((MatrixObject *)v2)->num_col, Py_NEW, Py_TYPE(vec1)); } else if (QuaternionObject_Check(v2)) { /* VEC * QUAT */ @@ -2603,7 +2603,7 @@ if len(unique) != len(items): */ /* ROW VECTOR Multiplication - Vector X Matrix - * [x][y][z] * [1][4][7] + * [x][y][z] * [1][4][7] * [2][5][8] * [3][6][9] * vector/matrix multiplication IS NOT COMMUTATIVE!!!! */ @@ -2611,7 +2611,7 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v { float vec_cpy[MAX_DIMENSIONS]; double dot = 0.0f; - int x, y, z= 0, vec_size= vec->size; + int row, col, z= 0, vec_size= vec->size; if (mat->num_row != vec_size) { if (mat->num_row == 4 && vec_size != 3) { @@ -2632,9 +2632,9 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v rvec[3] = 1.0f; //muliplication - for (x = 0; x < mat->num_col; x++) { - for (y = 0; y < mat->num_row; y++) { - dot += MATRIX_ITEM(mat, y, x) * vec_cpy[y]; + for (col = 0; col < mat->num_col; col++) { + for (row = 0; row < mat->num_row; row++) { + dot += MATRIX_ITEM(mat, row, col) * vec_cpy[row]; } rvec[z++] = (float)dot; dot = 0.0f; -- cgit v1.2.3 From 04077f46802b6561cb2e4f7942903ba5c9666f2f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 21 Dec 2011 11:56:42 +0000 Subject: =?UTF-8?q?Small=20i18n=20edits:=20*=20Added=20serbian=5Flatin=20l?= =?UTF-8?q?ocale=20(sr@latin).=20*=20Changed=20serbian=20UI=20to=20=20"Ser?= =?UTF-8?q?bian=20(=D0=A1=D1=80=D0=BF=D1=81=D0=BA=D0=B8)"=20(as=20requeste?= =?UTF-8?q?d=20by=20Nikola=20Radovanovic,=20serbian=20translator).=20*=20R?= =?UTF-8?q?eordered=20languages=20in=20menu=20in=20alphabetical=20order!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/blender/blenfont/intern/blf_lang.c | 5 +-- source/blender/makesrna/intern/rna_userdef.c | 47 +++++++++++++++------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 2ba23e501b4..77f9542883c 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -86,7 +86,7 @@ static const char *locales[] = { "Chinese (Traditional)_China.1252", "zh_TW", "russian", "ru_RU", "croatian", "hr_HR", - "serbian", "sr_RS", + "serbian", "sr", "ukrainian", "uk_UA", "polish", "pl_PL", "romanian", "ro_RO", @@ -96,7 +96,8 @@ static const char *locales[] = { "korean", "ko_KR", "nepali", "ne_NP", "persian", "fa_PE", - "indonesian", "id_ID" + "indonesian", "id_ID", + "serbian (latin)", "sr@latin", }; void BLF_lang_init(void) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f9b20d3ac78..c0a644f5758 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2607,40 +2607,43 @@ static void rna_def_userdef_system(BlenderRNA *brna) /* hardcoded here, could become dynamic somehow */ /* locale according to http://www.roseindia.net/tutorials/I18N/locales-list.shtml */ /* if you edit here, please also edit the source/blender/blenfont/intern/blf_lang.c 's locales */ + /* Note: As this list is in alphabetical order, and not defined order, + * here is the highest define currently in use: 28 (serbian latin). */ static EnumPropertyItem language_items[] = { - {0, "", 0, "Nearly done", ""}, - {0, "DEFAULT", 0, "Default (Default)", ""}, - {1, "ENGLISH", 0, "English (English)", "en_US"}, - {8, "FRENCH", 0, "French (Français)", "fr_FR"}, - {4, "ITALIAN", 0, "Italian (Italiano)", "it_IT"}, + { 0, "", 0, "Nearly done", ""}, + { 0, "DEFAULT", 0, "Default (Default)", ""}, + { 1, "ENGLISH", 0, "English (English)", "en_US"}, + { 8, "FRENCH", 0, "French (Français)", "fr_FR"}, + { 4, "ITALIAN", 0, "Italian (Italiano)", "it_IT"}, {15, "RUSSIAN", 0, "Russian (Русский)", "ru_RU"}, {13, "SIMPLIFIED_CHINESE", 0, "Simplified Chinese (简体中文)", "zh_CN"}, - {9, "SPANISH", 0, "Spanish (Español)", "es"}, + { 9, "SPANISH", 0, "Spanish (Español)", "es"}, {14, "TRADITIONAL_CHINESE", 0, "Traditional Chinese (繁體中文)", "zh_TW"}, - {0, "", 0, "In progress", ""}, - {2, "JAPANESE", 0, "Japanese (日本語)", "ja_JP"}, - {3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"}, - {5, "GERMAN", 0, "German (Deutsch)", "de_DE"}, - {6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"}, - {7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"}, - {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"}, - {11, "CZECH", 0, "Czech (Český)", "cs_CZ"}, - {12, "BRAZILIAN_PORTUGUESE", 0, "Brazilian Portuguese (Português do Brasil)", "pt_BR"}, - {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"}, - {17, "SERBIAN", 0, "Serbian (Српском језику)", "sr_RS"}, - {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, - {19, "POLISH", 0, "Polish (Polski)", "pl_PL"}, - {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, + { 0, "", 0, "In progress", ""}, /* using the utf8 flipped form of Arabic (العربية) */ {21, "ARABIC", 0, "Arabic (ﺔﻴﺑﺮﻌﻟﺍ)", "ar_EG"}, + {12, "BRAZILIAN_PORTUGUESE", 0, "Brazilian Portuguese (Português do Brasil)", "pt_BR"}, {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"}, + {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"}, + {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"}, + {11, "CZECH", 0, "Czech (Český)", "cs_CZ"}, + { 3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"}, + { 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"}, + { 5, "GERMAN", 0, "German (Deutsch)", "de_DE"}, {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"}, + {27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"}, + { 2, "JAPANESE", 0, "Japanese (日本語)", "ja_JP"}, {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, {25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"}, /* using the utf8 flipped form of Persian (فارسی) */ {26, "PERSIAN", 0, "Persian (ﯽﺳﺭﺎﻓ)", "fa_PE"}, - {27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"}, - {0, NULL, 0, NULL, NULL}}; + {19, "POLISH", 0, "Polish (Polski)", "pl_PL"}, + {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, + {17, "SERBIAN", 0, "Serbian (Српски)", "sr"}, + {28, "SERBIAN_LATIN", 0, "Serbian latin (Srpski latinica)", "sr@latin"}, + { 7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"}, + {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, + { 0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "UserPreferencesSystem", NULL); RNA_def_struct_sdna(srna, "UserDef"); -- cgit v1.2.3 From 045a91a37860dd40a2604f8208325b8d11c9e3a9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 21 Dec 2011 13:31:28 +0000 Subject: Do not show "Modify" modifiers group for curve objects This commit prevents adding empty groups to Add Modifier menu making this menu small and nice for objects which don't support all modifiers from some group (like Curves don't support Modify modifiers). --- source/blender/editors/object/object_modifier.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 913e5893a77..9a592bc9324 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -643,7 +643,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op) static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *ob= ED_object_active_context(C); - EnumPropertyItem *item= NULL, *md_item; + EnumPropertyItem *item= NULL, *md_item, *group_item= NULL; ModifierTypeInfo *mti; int totitem= 0, a; @@ -663,6 +663,17 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr) (ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) continue; } + else { + group_item= md_item; + md_item= NULL; + + continue; + } + + if(group_item) { + RNA_enum_item_add(&item, &totitem, group_item); + group_item= NULL; + } RNA_enum_item_add(&item, &totitem, md_item); } -- cgit v1.2.3 From 34909c64e57149c997ebb7e3d794c6ceff0541b0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 13:48:35 +0000 Subject: Cycles: some small code refactoring related to buffer parameters. --- intern/cycles/render/buffers.h | 6 ++++++ intern/cycles/render/session.cpp | 24 ++++++++++-------------- intern/cycles/render/tile.cpp | 16 ++++++++-------- intern/cycles/render/tile.h | 6 ++---- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h index 66bd03c8893..f4a9b37c09b 100644 --- a/intern/cycles/render/buffers.h +++ b/intern/cycles/render/buffers.h @@ -56,6 +56,12 @@ public: full_height = 0; } + void get_offset_stride(int& offset, int& stride) + { + offset = -(full_x + full_y*width); + stride = width; + } + bool modified(const BufferParams& params) { return !(full_x == params.full_x diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 26c4dbfbb7a..be2e493dc7f 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -515,10 +515,8 @@ void Session::update_scene() knows nothing about progressive or cropped rendering, it just gets the image dimensions passed in */ Camera *cam = scene->camera; - float progressive_x = tile_manager.state.width/(float)tile_manager.params.width; - float progressive_y = tile_manager.state.height/(float)tile_manager.params.height; - int width = tile_manager.params.full_width*progressive_x; - int height = tile_manager.params.full_height*progressive_y; + int width = tile_manager.state.buffer.full_width; + int height = tile_manager.state.buffer.full_height; if(width != cam->width || height != cam->height) { cam->width = width; @@ -574,16 +572,15 @@ void Session::path_trace(Tile& tile) /* add path trace task */ DeviceTask task(DeviceTask::PATH_TRACE); - task.x = tile_manager.state.full_x + tile.x; - task.y = tile_manager.state.full_y + tile.y; + task.x = tile_manager.state.buffer.full_x + tile.x; + task.y = tile_manager.state.buffer.full_y + tile.y; task.w = tile.w; task.h = tile.h; task.buffer = buffers->buffer.device_pointer; task.rng_state = buffers->rng_state.device_pointer; task.sample = tile_manager.state.sample; task.resolution = tile_manager.state.resolution; - task.offset = -(tile_manager.state.full_x + tile_manager.state.full_y*tile_manager.state.width); - task.stride = tile_manager.state.width; + tile_manager.state.buffer.get_offset_stride(task.offset, task.stride); device->task_add(task); } @@ -593,16 +590,15 @@ void Session::tonemap() /* add tonemap task */ DeviceTask task(DeviceTask::TONEMAP); - task.x = tile_manager.state.full_x; - task.y = tile_manager.state.full_y; - task.w = tile_manager.state.width; - task.h = tile_manager.state.height; + task.x = tile_manager.state.buffer.full_x; + task.y = tile_manager.state.buffer.full_y; + task.w = tile_manager.state.buffer.width; + task.h = tile_manager.state.buffer.height; task.rgba = display->rgba.device_pointer; task.buffer = buffers->buffer.device_pointer; task.sample = tile_manager.state.sample; task.resolution = tile_manager.state.resolution; - task.offset = -(tile_manager.state.full_x + tile_manager.state.full_y*tile_manager.state.width); - task.stride = tile_manager.state.width; + tile_manager.state.buffer.get_offset_stride(task.offset, task.stride); if(task.w > 0 && task.h > 0) { device->task_add(task); diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp index b118a7ba478..40833e5b08b 100644 --- a/intern/cycles/render/tile.cpp +++ b/intern/cycles/render/tile.cpp @@ -55,10 +55,7 @@ void TileManager::reset(BufferParams& params_, int samples_) samples = samples_; - state.full_x = 0; - state.full_y = 0; - state.width = 0; - state.height = 0; + state.buffer = BufferParams(); state.sample = -1; state.resolution = start_resolution; state.tiles.clear(); @@ -92,10 +89,13 @@ void TileManager::set_tiles() } } - state.full_x = params.full_x/resolution; - state.full_y = params.full_y/resolution; - state.width = image_w; - state.height = image_h; + state.buffer.width = image_w; + state.buffer.height = image_h; + + state.buffer.full_x = params.full_x/resolution; + state.buffer.full_y = params.full_y/resolution; + state.buffer.full_width = max(1, params.full_width/resolution); + state.buffer.full_height = max(1, params.full_height/resolution); } bool TileManager::done() diff --git a/intern/cycles/render/tile.h b/intern/cycles/render/tile.h index 76863d23498..b6e610c8d90 100644 --- a/intern/cycles/render/tile.h +++ b/intern/cycles/render/tile.h @@ -41,11 +41,9 @@ public: class TileManager { public: BufferParams params; + struct State { - int full_x; - int full_y; - int width; - int height; + BufferParams buffer; int sample; int resolution; list tiles; -- cgit v1.2.3 From 1dd72692cd69fed019f8be0701c9d776cd45c721 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 13:48:51 +0000 Subject: Code refactoring: move MD5 out of imbuf into blenlib. --- source/blender/blenlib/BLI_md5.h | 45 ++++ source/blender/blenlib/CMakeLists.txt | 2 + source/blender/blenlib/intern/md5.c | 414 ++++++++++++++++++++++++++++++++++ source/blender/imbuf/CMakeLists.txt | 2 - source/blender/imbuf/intern/md5.c | 360 ----------------------------- source/blender/imbuf/intern/md5.h | 119 ---------- source/blender/imbuf/intern/thumbs.c | 9 +- 7 files changed, 466 insertions(+), 485 deletions(-) create mode 100644 source/blender/blenlib/BLI_md5.h create mode 100644 source/blender/blenlib/intern/md5.c delete mode 100644 source/blender/imbuf/intern/md5.c delete mode 100644 source/blender/imbuf/intern/md5.h diff --git a/source/blender/blenlib/BLI_md5.h b/source/blender/blenlib/BLI_md5.h new file mode 100644 index 00000000000..afcc3cdfa3e --- /dev/null +++ b/source/blender/blenlib/BLI_md5.h @@ -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 ***** + */ + +#ifndef BLI_MD5_H +#define BLI_MD5_H + +/** \file BLI_md5.h + * \ingroup bli + */ + +#include +#include + +/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The + result is always in little endian byte order, so that a byte-wise + output yields to the wanted ASCII representation of the message + digest. */ + +void *md5_buffer(const char *buffer, size_t len, void *resblock); + +/* Compute MD5 message digest for bytes read from STREAM. The + resulting message digest number will be written into the 16 bytes + beginning at RESBLOCK. */ + +int md5_stream(FILE *stream, void *resblock); + +#endif + diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 5d54ffbeb36..fb9b8021b8e 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -71,6 +71,7 @@ set(SRC intern/math_rotation.c intern/math_vector.c intern/math_vector_inline.c + intern/md5.c intern/noise.c intern/path_util.c intern/pbvh.c @@ -117,6 +118,7 @@ set(SRC BLI_math_matrix.h BLI_math_rotation.h BLI_math_vector.h + BLI_md5.h BLI_memarena.h BLI_mempool.h BLI_noise.h diff --git a/source/blender/blenlib/intern/md5.c b/source/blender/blenlib/intern/md5.c new file mode 100644 index 00000000000..25582a5f750 --- /dev/null +++ b/source/blender/blenlib/intern/md5.c @@ -0,0 +1,414 @@ +/** \file blender/imbuf/intern/md5.c + * \ingroup imbuf + */ +/* md5.c - Functions to compute MD5 message digest of files or memory blocks + according to the definition of MD5 in RFC 1321 from April 1992. + Copyright (C) 1995 Software Foundation, Inc. + + 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Written by Ulrich Drepper . */ + +#include +#include +#include +#include + +#if defined HAVE_LIMITS_H || defined _LIBC +# include +#endif + +/* The following contortions are an attempt to use the C preprocessor + to determine an unsigned integral type that is 32 bits wide. An + alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but + doing that would require that the configure script compile and *run* + the resulting executable. Locally running cross-compiled executables + is usually not possible. */ + +#if defined __STDC__ && __STDC__ +# define UINT_MAX_32_BITS 4294967295U +#else +# define UINT_MAX_32_BITS 0xFFFFFFFF +#endif + +/* If UINT_MAX isn't defined, assume it's a 32-bit type. + This should be valid for all systems GNU cares about because + that doesn't include 16-bit systems, and only modern systems + (that certainly have ) have 64+-bit integral types. */ + +#ifndef UINT_MAX +# define UINT_MAX UINT_MAX_32_BITS +#endif + +#if UINT_MAX == UINT_MAX_32_BITS + typedef unsigned int md5_uint32; +#else +# if USHRT_MAX == UINT_MAX_32_BITS + typedef unsigned short md5_uint32; +# else +# if ULONG_MAX == UINT_MAX_32_BITS + typedef unsigned long md5_uint32; +# else + /* The following line is intended to evoke an error. + Using #error is not portable enough. */ + "Cannot determine unsigned 32-bit data type." +# endif +# endif +#endif + +/* Structure to save state of computation between the single steps. */ +struct md5_ctx +{ + md5_uint32 A; + md5_uint32 B; + md5_uint32 C; + md5_uint32 D; +}; + +/* + * The following three functions are build up the low level used in + * the functions `md5_stream' and `md5_buffer'. + */ + +/* Initialize structure containing state of computation. + (RFC 1321, 3.3: Step 3) */ +static void md5_init_ctx(struct md5_ctx *ctx); + +/* Starting with the result of former calls of this function (or the + initialzation function update the context for the next LEN bytes + starting at BUFFER. + It is necessary that LEN is a multiple of 64!!! */ +static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx); + +/* Put result from CTX in first 16 bytes following RESBUF. The result is + always in little endian byte order, so that a byte-wise output yields + to the wanted ASCII representation of the message digest. */ +static void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf); + + +#ifdef __BIG_ENDIAN__ +# define SWAP(n) \ + (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) +#else +# define SWAP(n) (n) +#endif + + +/* This array contains the bytes used to pad the buffer to the next + 64-byte boundary. (RFC 1321, 3.1: Step 1) */ +static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; + + +/* Initialize structure containing state of computation. + (RFC 1321, 3.3: Step 3) */ +static void md5_init_ctx(struct md5_ctx *ctx) +{ + ctx->A = 0x67452301; + ctx->B = 0xefcdab89; + ctx->C = 0x98badcfe; + ctx->D = 0x10325476; +} + +/* Put result from CTX in first 16 bytes following RESBUF. The result must + be in little endian byte order. */ +static void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf) +{ + ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); + ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); + ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); + ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); + + return resbuf; +} + +/* Compute MD5 message digest for bytes read from STREAM. The + resulting message digest number will be written into the 16 bytes + beginning at RESBLOCK. */ +int md5_stream(FILE *stream, void *resblock) +{ + /* Important: BLOCKSIZE must be a multiple of 64. */ +#define BLOCKSIZE 4096 + struct md5_ctx ctx; + md5_uint32 len[2]; + char buffer[BLOCKSIZE + 72]; + size_t pad, sum; + + /* Initialize the computation context. */ + md5_init_ctx (&ctx); + + len[0] = 0; + len[1] = 0; + + /* Iterate over full file contents. */ + while (1) + { + /* We read the file in blocks of BLOCKSIZE bytes. One call of the + computation function processes the whole buffer so that with the + next round of the loop another block can be read. */ + size_t n; + sum = 0; + + /* Read block. Take care for partial reads. */ + do + { + n = fread (buffer, 1, BLOCKSIZE - sum, stream); + + sum += n; + } + while (sum < BLOCKSIZE && n != 0); + if (n == 0 && ferror (stream)) + return 1; + + /* RFC 1321 specifies the possible length of the file up to 2^64 bits. + Here we only compute the number of bytes. Do a double word + increment. */ + len[0] += sum; + if (len[0] < sum) + ++len[1]; + + /* If end of file is reached, end the loop. */ + if (n == 0) + break; + + /* Process buffer with BLOCKSIZE bytes. Note that + BLOCKSIZE % 64 == 0 + */ + md5_process_block (buffer, BLOCKSIZE, &ctx); + } + + /* We can copy 64 byte because the buffer is always big enough. FILLBUF + contains the needed bits. */ + memcpy (&buffer[sum], fillbuf, 64); + + /* Compute amount of padding bytes needed. Alignment is done to + (N + PAD) % 64 == 56 + There is always at least one byte padded. I.e. even the alignment + is correctly aligned 64 padding bytes are added. */ + pad = sum & 63; + pad = pad >= 56 ? 64 + 56 - pad : 56 - pad; + + /* Put the 64-bit file length in *bits* at the end of the buffer. */ + *(md5_uint32 *) &buffer[sum + pad] = SWAP (len[0] << 3); + *(md5_uint32 *) &buffer[sum + pad + 4] = SWAP ((len[1] << 3) + | (len[0] >> 29)); + + /* Process last bytes. */ + md5_process_block (buffer, sum + pad + 8, &ctx); + + /* Construct result in desired memory. */ + md5_read_ctx (&ctx, resblock); + return 0; +} + +/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The + result is always in little endian byte order, so that a byte-wise + output yields to the wanted ASCII representation of the message + digest. */ +void *md5_buffer(const char *buffer, size_t len, void *resblock) +{ + struct md5_ctx ctx; + char restbuf[64 + 72]; + size_t blocks = len & ~63; + size_t pad, rest; + + /* Initialize the computation context. */ + md5_init_ctx (&ctx); + + /* Process whole buffer but last len % 64 bytes. */ + md5_process_block (buffer, blocks, &ctx); + + /* REST bytes are not processed yet. */ + rest = len - blocks; + /* Copy to own buffer. */ + memcpy (restbuf, &buffer[blocks], rest); + /* Append needed fill bytes at end of buffer. We can copy 64 byte + because the buffer is always big enough. */ + memcpy (&restbuf[rest], fillbuf, 64); + + /* PAD bytes are used for padding to correct alignment. Note that + always at least one byte is padded. */ + pad = rest >= 56 ? 64 + 56 - rest : 56 - rest; + + /* Put length of buffer in *bits* in last eight bytes. */ + *(md5_uint32 *) &restbuf[rest + pad] = (md5_uint32) SWAP (len << 3); + *(md5_uint32 *) &restbuf[rest + pad + 4] = (md5_uint32) SWAP (len >> 29); + + /* Process last bytes. */ + md5_process_block (restbuf, rest + pad + 8, &ctx); + + /* Put result in desired memory area. */ + return md5_read_ctx (&ctx, resblock); +} + + +/* These are the four functions used in the four steps of the MD5 algorithm + and defined in the RFC 1321. The first function is a little bit optimized + (as found in Colin Plumbs public domain implementation). */ +/* #define FF(b, c, d) ((b & c) | (~b & d)) */ +#define FF(b, c, d) (d ^ (b & (c ^ d))) +#define FG(b, c, d) FF (d, b, c) +#define FH(b, c, d) (b ^ c ^ d) +#define FI(b, c, d) (c ^ (b | ~d)) + +/* Process LEN bytes of BUFFER, accumulating context into CTX. + It is assumed that LEN % 64 == 0. */ + +void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) +{ + md5_uint32 correct_words[16]; + const md5_uint32 *words = buffer; + size_t nwords = len / sizeof (md5_uint32); + const md5_uint32 *endp = words + nwords; + md5_uint32 A = ctx->A; + md5_uint32 B = ctx->B; + md5_uint32 C = ctx->C; + md5_uint32 D = ctx->D; + + /* Process all bytes in the buffer with 64 bytes in each round of + the loop. */ + while (words < endp) + { + md5_uint32 *cwp = correct_words; + md5_uint32 A_save = A; + md5_uint32 B_save = B; + md5_uint32 C_save = C; + md5_uint32 D_save = D; + + /* First round: using the given function, the context and a constant + the next context is computed. Because the algorithms processing + unit is a 32-bit word and it is determined to work on words in + little endian byte order we perhaps have to change the byte order + before the computation. To reduce the work for the next steps + we store the swapped words in the array CORRECT_WORDS. */ + +#define OP(a, b, c, d, s, T) \ + do \ + { \ + a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ + ++words; \ + CYCLIC (a, s); \ + a += b; \ + } \ + while (0) + + /* It is unfortunate that C does not provide an operator for + cyclic rotation. Hope the C compiler is smart enough. */ +#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) + + /* Before we start, one word to the strange constants. + They are defined in RFC 1321 as + + T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 + */ + + /* Round 1. */ + OP (A, B, C, D, 7, 0xd76aa478); + OP (D, A, B, C, 12, 0xe8c7b756); + OP (C, D, A, B, 17, 0x242070db); + OP (B, C, D, A, 22, 0xc1bdceee); + OP (A, B, C, D, 7, 0xf57c0faf); + OP (D, A, B, C, 12, 0x4787c62a); + OP (C, D, A, B, 17, 0xa8304613); + OP (B, C, D, A, 22, 0xfd469501); + OP (A, B, C, D, 7, 0x698098d8); + OP (D, A, B, C, 12, 0x8b44f7af); + OP (C, D, A, B, 17, 0xffff5bb1); + OP (B, C, D, A, 22, 0x895cd7be); + OP (A, B, C, D, 7, 0x6b901122); + OP (D, A, B, C, 12, 0xfd987193); + OP (C, D, A, B, 17, 0xa679438e); + OP (B, C, D, A, 22, 0x49b40821); + + /* For the second to fourth round we have the possibly swapped words + in CORRECT_WORDS. Redefine the macro to take an additional first + argument specifying the function to use. */ +#undef OP +#define OP(f, a, b, c, d, k, s, T) \ + do \ + { \ + a += f (b, c, d) + correct_words[k] + T; \ + CYCLIC (a, s); \ + a += b; \ + } \ + while (0) + + /* Round 2. */ + OP (FG, A, B, C, D, 1, 5, 0xf61e2562); + OP (FG, D, A, B, C, 6, 9, 0xc040b340); + OP (FG, C, D, A, B, 11, 14, 0x265e5a51); + OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); + OP (FG, A, B, C, D, 5, 5, 0xd62f105d); + OP (FG, D, A, B, C, 10, 9, 0x02441453); + OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); + OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); + OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); + OP (FG, D, A, B, C, 14, 9, 0xc33707d6); + OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); + OP (FG, B, C, D, A, 8, 20, 0x455a14ed); + OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); + OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); + OP (FG, C, D, A, B, 7, 14, 0x676f02d9); + OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); + + /* Round 3. */ + OP (FH, A, B, C, D, 5, 4, 0xfffa3942); + OP (FH, D, A, B, C, 8, 11, 0x8771f681); + OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); + OP (FH, B, C, D, A, 14, 23, 0xfde5380c); + OP (FH, A, B, C, D, 1, 4, 0xa4beea44); + OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); + OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); + OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); + OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); + OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); + OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); + OP (FH, B, C, D, A, 6, 23, 0x04881d05); + OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); + OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); + OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); + OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); + + /* Round 4. */ + OP (FI, A, B, C, D, 0, 6, 0xf4292244); + OP (FI, D, A, B, C, 7, 10, 0x432aff97); + OP (FI, C, D, A, B, 14, 15, 0xab9423a7); + OP (FI, B, C, D, A, 5, 21, 0xfc93a039); + OP (FI, A, B, C, D, 12, 6, 0x655b59c3); + OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); + OP (FI, C, D, A, B, 10, 15, 0xffeff47d); + OP (FI, B, C, D, A, 1, 21, 0x85845dd1); + OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); + OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); + OP (FI, C, D, A, B, 6, 15, 0xa3014314); + OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); + OP (FI, A, B, C, D, 4, 6, 0xf7537e82); + OP (FI, D, A, B, C, 11, 10, 0xbd3af235); + OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); + OP (FI, B, C, D, A, 9, 21, 0xeb86d391); + + /* Add the starting values of the context. */ + A += A_save; + B += B_save; + C += C_save; + D += D_save; + } + + /* Put checksum in context given as argument. */ + ctx->A = A; + ctx->B = B; + ctx->C = C; + ctx->D = D; +} + diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index a03d6ce280d..4c8a79e6372 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -53,7 +53,6 @@ set(SRC intern/indexer_dv.c intern/iris.c intern/jpeg.c - intern/md5.c intern/metadata.c intern/module.c intern/moviecache.c @@ -96,7 +95,6 @@ set(SRC intern/dds/Stream.h intern/dds/dds_api.h intern/imbuf.h - intern/md5.h intern/openexr/openexr_api.h intern/openexr/openexr_multi.h diff --git a/source/blender/imbuf/intern/md5.c b/source/blender/imbuf/intern/md5.c deleted file mode 100644 index 2192fa32f19..00000000000 --- a/source/blender/imbuf/intern/md5.c +++ /dev/null @@ -1,360 +0,0 @@ -/** \file blender/imbuf/intern/md5.c - * \ingroup imbuf - */ -/* md5.c - Functions to compute MD5 message digest of files or memory blocks - according to the definition of MD5 in RFC 1321 from April 1992. - Copyright (C) 1995 Software Foundation, Inc. - - 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Written by Ulrich Drepper . */ - -#include - -# include -# include - -#include "md5.h" - -#ifdef __BIG_ENDIAN__ -# define SWAP(n) \ - (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) -#else -# define SWAP(n) (n) -#endif - - -/* This array contains the bytes used to pad the buffer to the next - 64-byte boundary. (RFC 1321, 3.1: Step 1) */ -static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; - - -/* Initialize structure containing state of computation. - (RFC 1321, 3.3: Step 3) */ -void -md5_init_ctx (ctx) - struct md5_ctx *ctx; -{ - ctx->A = 0x67452301; - ctx->B = 0xefcdab89; - ctx->C = 0x98badcfe; - ctx->D = 0x10325476; -} - -/* Put result from CTX in first 16 bytes following RESBUF. The result must - be in little endian byte order. */ -void * -md5_read_ctx (ctx, resbuf) - const struct md5_ctx *ctx; - void *resbuf; -{ - ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); - ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); - ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); - ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); - - return resbuf; -} - -/* Compute MD5 message digest for bytes read from STREAM. The - resulting message digest number will be written into the 16 bytes - beginning at RESBLOCK. */ -int -md5_stream (stream, resblock) - FILE *stream; - void *resblock; -{ - /* Important: BLOCKSIZE must be a multiple of 64. */ -#define BLOCKSIZE 4096 - struct md5_ctx ctx; - md5_uint32 len[2]; - char buffer[BLOCKSIZE + 72]; - size_t pad, sum; - - /* Initialize the computation context. */ - md5_init_ctx (&ctx); - - len[0] = 0; - len[1] = 0; - - /* Iterate over full file contents. */ - while (1) - { - /* We read the file in blocks of BLOCKSIZE bytes. One call of the - computation function processes the whole buffer so that with the - next round of the loop another block can be read. */ - size_t n; - sum = 0; - - /* Read block. Take care for partial reads. */ - do - { - n = fread (buffer, 1, BLOCKSIZE - sum, stream); - - sum += n; - } - while (sum < BLOCKSIZE && n != 0); - if (n == 0 && ferror (stream)) - return 1; - - /* RFC 1321 specifies the possible length of the file up to 2^64 bits. - Here we only compute the number of bytes. Do a double word - increment. */ - len[0] += sum; - if (len[0] < sum) - ++len[1]; - - /* If end of file is reached, end the loop. */ - if (n == 0) - break; - - /* Process buffer with BLOCKSIZE bytes. Note that - BLOCKSIZE % 64 == 0 - */ - md5_process_block (buffer, BLOCKSIZE, &ctx); - } - - /* We can copy 64 byte because the buffer is always big enough. FILLBUF - contains the needed bits. */ - memcpy (&buffer[sum], fillbuf, 64); - - /* Compute amount of padding bytes needed. Alignment is done to - (N + PAD) % 64 == 56 - There is always at least one byte padded. I.e. even the alignment - is correctly aligned 64 padding bytes are added. */ - pad = sum & 63; - pad = pad >= 56 ? 64 + 56 - pad : 56 - pad; - - /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(md5_uint32 *) &buffer[sum + pad] = SWAP (len[0] << 3); - *(md5_uint32 *) &buffer[sum + pad + 4] = SWAP ((len[1] << 3) - | (len[0] >> 29)); - - /* Process last bytes. */ - md5_process_block (buffer, sum + pad + 8, &ctx); - - /* Construct result in desired memory. */ - md5_read_ctx (&ctx, resblock); - return 0; -} - -/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The - result is always in little endian byte order, so that a byte-wise - output yields to the wanted ASCII representation of the message - digest. */ -void * -md5_buffer (buffer, len, resblock) - const char *buffer; - size_t len; - void *resblock; -{ - struct md5_ctx ctx; - char restbuf[64 + 72]; - size_t blocks = len & ~63; - size_t pad, rest; - - /* Initialize the computation context. */ - md5_init_ctx (&ctx); - - /* Process whole buffer but last len % 64 bytes. */ - md5_process_block (buffer, blocks, &ctx); - - /* REST bytes are not processed yet. */ - rest = len - blocks; - /* Copy to own buffer. */ - memcpy (restbuf, &buffer[blocks], rest); - /* Append needed fill bytes at end of buffer. We can copy 64 byte - because the buffer is always big enough. */ - memcpy (&restbuf[rest], fillbuf, 64); - - /* PAD bytes are used for padding to correct alignment. Note that - always at least one byte is padded. */ - pad = rest >= 56 ? 64 + 56 - rest : 56 - rest; - - /* Put length of buffer in *bits* in last eight bytes. */ - *(md5_uint32 *) &restbuf[rest + pad] = (md5_uint32) SWAP (len << 3); - *(md5_uint32 *) &restbuf[rest + pad + 4] = (md5_uint32) SWAP (len >> 29); - - /* Process last bytes. */ - md5_process_block (restbuf, rest + pad + 8, &ctx); - - /* Put result in desired memory area. */ - return md5_read_ctx (&ctx, resblock); -} - - -/* These are the four functions used in the four steps of the MD5 algorithm - and defined in the RFC 1321. The first function is a little bit optimized - (as found in Colin Plumbs public domain implementation). */ -/* #define FF(b, c, d) ((b & c) | (~b & d)) */ -#define FF(b, c, d) (d ^ (b & (c ^ d))) -#define FG(b, c, d) FF (d, b, c) -#define FH(b, c, d) (b ^ c ^ d) -#define FI(b, c, d) (c ^ (b | ~d)) - -/* Process LEN bytes of BUFFER, accumulating context into CTX. - It is assumed that LEN % 64 == 0. */ - -void -md5_process_block (buffer, len, ctx) - const void *buffer; - size_t len; - struct md5_ctx *ctx; -{ - md5_uint32 correct_words[16]; - const md5_uint32 *words = buffer; - size_t nwords = len / sizeof (md5_uint32); - const md5_uint32 *endp = words + nwords; - md5_uint32 A = ctx->A; - md5_uint32 B = ctx->B; - md5_uint32 C = ctx->C; - md5_uint32 D = ctx->D; - - /* Process all bytes in the buffer with 64 bytes in each round of - the loop. */ - while (words < endp) - { - md5_uint32 *cwp = correct_words; - md5_uint32 A_save = A; - md5_uint32 B_save = B; - md5_uint32 C_save = C; - md5_uint32 D_save = D; - - /* First round: using the given function, the context and a constant - the next context is computed. Because the algorithms processing - unit is a 32-bit word and it is determined to work on words in - little endian byte order we perhaps have to change the byte order - before the computation. To reduce the work for the next steps - we store the swapped words in the array CORRECT_WORDS. */ - -#define OP(a, b, c, d, s, T) \ - do \ - { \ - a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ - ++words; \ - CYCLIC (a, s); \ - a += b; \ - } \ - while (0) - - /* It is unfortunate that C does not provide an operator for - cyclic rotation. Hope the C compiler is smart enough. */ -#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) - - /* Before we start, one word to the strange constants. - They are defined in RFC 1321 as - - T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 - */ - - /* Round 1. */ - OP (A, B, C, D, 7, 0xd76aa478); - OP (D, A, B, C, 12, 0xe8c7b756); - OP (C, D, A, B, 17, 0x242070db); - OP (B, C, D, A, 22, 0xc1bdceee); - OP (A, B, C, D, 7, 0xf57c0faf); - OP (D, A, B, C, 12, 0x4787c62a); - OP (C, D, A, B, 17, 0xa8304613); - OP (B, C, D, A, 22, 0xfd469501); - OP (A, B, C, D, 7, 0x698098d8); - OP (D, A, B, C, 12, 0x8b44f7af); - OP (C, D, A, B, 17, 0xffff5bb1); - OP (B, C, D, A, 22, 0x895cd7be); - OP (A, B, C, D, 7, 0x6b901122); - OP (D, A, B, C, 12, 0xfd987193); - OP (C, D, A, B, 17, 0xa679438e); - OP (B, C, D, A, 22, 0x49b40821); - - /* For the second to fourth round we have the possibly swapped words - in CORRECT_WORDS. Redefine the macro to take an additional first - argument specifying the function to use. */ -#undef OP -#define OP(f, a, b, c, d, k, s, T) \ - do \ - { \ - a += f (b, c, d) + correct_words[k] + T; \ - CYCLIC (a, s); \ - a += b; \ - } \ - while (0) - - /* Round 2. */ - OP (FG, A, B, C, D, 1, 5, 0xf61e2562); - OP (FG, D, A, B, C, 6, 9, 0xc040b340); - OP (FG, C, D, A, B, 11, 14, 0x265e5a51); - OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); - OP (FG, A, B, C, D, 5, 5, 0xd62f105d); - OP (FG, D, A, B, C, 10, 9, 0x02441453); - OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); - OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); - OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); - OP (FG, D, A, B, C, 14, 9, 0xc33707d6); - OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); - OP (FG, B, C, D, A, 8, 20, 0x455a14ed); - OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); - OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); - OP (FG, C, D, A, B, 7, 14, 0x676f02d9); - OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); - - /* Round 3. */ - OP (FH, A, B, C, D, 5, 4, 0xfffa3942); - OP (FH, D, A, B, C, 8, 11, 0x8771f681); - OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); - OP (FH, B, C, D, A, 14, 23, 0xfde5380c); - OP (FH, A, B, C, D, 1, 4, 0xa4beea44); - OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); - OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); - OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); - OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); - OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); - OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); - OP (FH, B, C, D, A, 6, 23, 0x04881d05); - OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); - OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); - OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); - OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); - - /* Round 4. */ - OP (FI, A, B, C, D, 0, 6, 0xf4292244); - OP (FI, D, A, B, C, 7, 10, 0x432aff97); - OP (FI, C, D, A, B, 14, 15, 0xab9423a7); - OP (FI, B, C, D, A, 5, 21, 0xfc93a039); - OP (FI, A, B, C, D, 12, 6, 0x655b59c3); - OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); - OP (FI, C, D, A, B, 10, 15, 0xffeff47d); - OP (FI, B, C, D, A, 1, 21, 0x85845dd1); - OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); - OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); - OP (FI, C, D, A, B, 6, 15, 0xa3014314); - OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); - OP (FI, A, B, C, D, 4, 6, 0xf7537e82); - OP (FI, D, A, B, C, 11, 10, 0xbd3af235); - OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); - OP (FI, B, C, D, A, 9, 21, 0xeb86d391); - - /* Add the starting values of the context. */ - A += A_save; - B += B_save; - C += C_save; - D += D_save; - } - - /* Put checksum in context given as argument. */ - ctx->A = A; - ctx->B = B; - ctx->C = C; - ctx->D = D; -} - diff --git a/source/blender/imbuf/intern/md5.h b/source/blender/imbuf/intern/md5.h deleted file mode 100644 index 79c480d8152..00000000000 --- a/source/blender/imbuf/intern/md5.h +++ /dev/null @@ -1,119 +0,0 @@ -/** \file blender/imbuf/intern/md5.h - * \ingroup imbuf - */ -/* md5.h - Declaration of functions and data types used for MD5 sum - computing library functions. - Copyright (C) 1995 Free Software Foundation, Inc. - -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, or (at your option) -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _MD5_H -#define _MD5_H - -#include - -#if defined HAVE_LIMITS_H || defined _LIBC -# include -#endif - -/* The following contortions are an attempt to use the C preprocessor - to determine an unsigned integral type that is 32 bits wide. An - alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but - doing that would require that the configure script compile and *run* - the resulting executable. Locally running cross-compiled executables - is usually not possible. */ - -#if defined __STDC__ && __STDC__ -# define UINT_MAX_32_BITS 4294967295U -#else -# define UINT_MAX_32_BITS 0xFFFFFFFF -#endif - -/* If UINT_MAX isn't defined, assume it's a 32-bit type. - This should be valid for all systems GNU cares about because - that doesn't include 16-bit systems, and only modern systems - (that certainly have ) have 64+-bit integral types. */ - -#ifndef UINT_MAX -# define UINT_MAX UINT_MAX_32_BITS -#endif - -#if UINT_MAX == UINT_MAX_32_BITS - typedef unsigned int md5_uint32; -#else -# if USHRT_MAX == UINT_MAX_32_BITS - typedef unsigned short md5_uint32; -# else -# if ULONG_MAX == UINT_MAX_32_BITS - typedef unsigned long md5_uint32; -# else - /* The following line is intended to evoke an error. - Using #error is not portable enough. */ - "Cannot determine unsigned 32-bit data type." -# endif -# endif -#endif - -#undef __P -#if defined (__STDC__) && __STDC__ -#define __P(x) x -#else -#define __P(x) () -#endif - -/* Structure to save state of computation between the single steps. */ -struct md5_ctx -{ - md5_uint32 A; - md5_uint32 B; - md5_uint32 C; - md5_uint32 D; -}; - -/* - * The following three functions are build up the low level used in - * the functions `md5_stream' and `md5_buffer'. - */ - -/* Initialize structure containing state of computation. - (RFC 1321, 3.3: Step 3) */ -void md5_init_ctx __P ((struct md5_ctx *ctx)); - -/* Starting with the result of former calls of this function (or the - initialzation function update the context for the next LEN bytes - starting at BUFFER. - It is necessary that LEN is a multiple of 64!!! */ -void md5_process_block __P ((const void *buffer, size_t len, - struct md5_ctx *ctx)); - -/* Put result from CTX in first 16 bytes following RESBUF. The result is - always in little endian byte order, so that a byte-wise output yields - to the wanted ASCII representation of the message digest. */ -void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf)); - - -/* Compute MD5 message digest for bytes read from STREAM. The - resulting message digest number will be written into the 16 bytes - beginning at RESBLOCK. */ -int md5_stream __P ((FILE *stream, void *resblock)); - -/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The - result is always in little endian byte order, so that a byte-wise - output yields to the wanted ASCII representation of the message - digest. */ -void *md5_buffer __P ((const char *buffer, size_t len, void *resblock)); - -#endif - diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 19eb917469d..808bcbed751 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -32,17 +32,18 @@ #include -#include "BKE_utildefines.h" -#include "BLI_blenlib.h" #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" +#include "BLI_md5.h" + +#include "BKE_utildefines.h" + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_thumbs.h" #include "IMB_metadata.h" -#include "md5.h" - #include #include #include -- cgit v1.2.3 From 99e6e6cc08a9e246cf00724574e99a78f3293f5c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 13:49:22 +0000 Subject: Fix #29670: color picker draw issues with RGB values out of soft range. --- source/blender/editors/interface/interface.c | 2 +- source/blender/editors/interface/interface_handlers.c | 2 +- source/blender/editors/interface/interface_widgets.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 1bad61be324..63e41082449 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1901,7 +1901,7 @@ void ui_set_but_soft_range(uiBut *but, double value) if(softmin < (double)but->hardmin) softmin= (double)but->hardmin; } - else if(value_max-1e-10 > softmax) { + if(value_max-1e-10 > softmax) { if(value_max < 0.0) softmax= -soft_range_round_down(-value_max, -softmax); else diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 6ebfddff5c1..900cbbd5cbf 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5247,7 +5247,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s highlight when not in a popup menu, we remove because data used in button below popup might have been removed by action of popup. Needs a more reliable solution... */ - if(state != BUTTON_STATE_HIGHLIGHT || but->block->handle) + if(state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP)) ui_check_but(but); } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 0da4d3895e0..d8a34262e81 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1795,7 +1795,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) { /* gouraud triangle fan */ float radstep, ang= 0.0f; - float centx, centy, radius; + float centx, centy, radius, cursor_radius; float rgb[3], hsvo[3], hsv[3], col[3], colcent[3]; int a, tot= 32; int color_profile = but->block->color_profile; @@ -1864,12 +1864,12 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) ang= 2.0f*(float)M_PI*hsvo[0] + 0.5f*(float)M_PI; if(but->flag & UI_BUT_COLOR_CUBIC) - radius= (1.0f - powf(1.0f - hsvo[1], 3.0f)) *radius; + cursor_radius = (1.0f - powf(1.0f - hsvo[1], 3.0f)); else - radius= hsvo[1] * radius; + cursor_radius = hsvo[1]; + radius= CLAMPIS(cursor_radius, 0.0f, 1.0f) * radius; ui_hsv_cursor(centx + cosf(-ang)*radius, centy + sinf(-ang)*radius); - } /* ************ custom buttons, old stuff ************** */ -- cgit v1.2.3 From 2777ba097f5404a736333239bb6d61ab4b561e13 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 14:35:48 +0000 Subject: Fix linux linking issue with md5 commit. --- source/creator/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 6851b783463..48c7dca0b4d 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -775,11 +775,11 @@ endif() bf_nodes bf_gpu bf_blenloader + bf_imbuf bf_blenlib bf_intern_ghost bf_intern_string bf_blenpluginapi - bf_imbuf bf_avi bf_imbuf_cineon bf_imbuf_openexr -- cgit v1.2.3 From fbc83625975131720aa6f81a236ac6b1eea4ccac Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 21 Dec 2011 18:18:36 +0000 Subject: A few small fixes to new UI messages... --- release/scripts/startup/bl_operators/wm.py | 2 +- source/blender/makesrna/intern/rna_material.c | 4 ++-- source/blender/makesrna/intern/rna_scene.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 58941e00914..ec58b3aecd1 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1178,7 +1178,7 @@ class WM_OT_copy_prev_settings(Operator): return {'CANCELLED'} class WM_OT_blenderplayer_start(bpy.types.Operator): - '''Launches the Blenderplayer with the current blendfile''' + '''Launch the Blenderplayer with the current blendfile''' bl_idname = "wm.blenderplayer_start" bl_label = "Start" diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 40b6d5b96e4..8794914e727 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -415,8 +415,8 @@ static void rna_def_material_mtex(BlenderRNA *brna) {MTEX_COMPAT_BUMP, "BUMP_COMPATIBLE", 0, "Compatible", ""}, {MTEX_3TAP_BUMP, "BUMP_LOW_QUALITY", 0, "Low Quality", "Use 3 tap filtering"}, {MTEX_5TAP_BUMP, "BUMP_MEDIUM_QUALITY", 0, "Medium Quality", "Use 5 tap filtering"}, - {MTEX_BICUBIC_BUMP, "BUMP_BEST_QUALITY", 0, "Best Quality", "Use bicubic filtering. Requires OpenGL 3.0+. " - "It will fall back on medium setting for other systems"}, + {MTEX_BICUBIC_BUMP, "BUMP_BEST_QUALITY", 0, "Best Quality", "Use bicubic filtering (requires OpenGL 3.0+, " + "it will fall back on medium setting for other systems)"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_bump_space_items[] = { diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 9638bba3e80..2a5e815591a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2115,7 +2115,7 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "exitkey"); RNA_def_property_enum_items(prop, event_type_items); RNA_def_property_enum_funcs(prop, NULL, "rna_GameSettings_exit_key_set", NULL); - RNA_def_property_ui_text(prop, "Exit Key", "Sets the key that exits the Game Engine"); + RNA_def_property_ui_text(prop, "Exit Key", "The key that exits the Game Engine"); RNA_def_property_update(prop, NC_SCENE, NULL); // Do we need it here ? (since we already have it in World -- cgit v1.2.3 From 2f90cfd423b49d28443bc69ad2cfe551622e0cdf Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Wed, 21 Dec 2011 20:32:29 +0000 Subject: SVN maintenance. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index ff4b9ba9c96..c6a1105124c 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -3032,4 +3032,4 @@ void BL_ConvertBlenderObjects(struct Main* maggie, SCA_IInputDevice::KX_EnumInputs ConvertKeyCode(int key_code) { return gReverseKeyTranslateTable[key_code]; -} \ No newline at end of file +} -- cgit v1.2.3 From b65061e2ae95e92dea8b1009bf0cf4e02254dac2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 20:51:43 +0000 Subject: Cycles: code refactoring, to do render layer visibility test a bit different, replacing the camera visibility flag with object layer flags. --- intern/cycles/app/cycles_test.cpp | 4 ++-- intern/cycles/app/cycles_xml.cpp | 1 - intern/cycles/blender/blender_object.cpp | 24 +++++++++++++----------- intern/cycles/blender/blender_sync.cpp | 5 ++--- intern/cycles/blender/blender_sync.h | 2 +- intern/cycles/kernel/kernel_path.h | 7 +++++-- intern/cycles/kernel/kernel_types.h | 13 ++++++++++--- intern/cycles/render/integrator.cpp | 8 +++----- intern/cycles/render/integrator.h | 2 +- 9 files changed, 37 insertions(+), 29 deletions(-) diff --git a/intern/cycles/app/cycles_test.cpp b/intern/cycles/app/cycles_test.cpp index 83816727404..d162dbf12a9 100644 --- a/intern/cycles/app/cycles_test.cpp +++ b/intern/cycles/app/cycles_test.cpp @@ -82,9 +82,9 @@ static void session_print_status() session_print(status); } -static BufferParams session_buffer_params() +static BufferParams& session_buffer_params() { - BufferParams buffer_params; + static BufferParams buffer_params; buffer_params.width = options.width; buffer_params.height = options.height; buffer_params.full_width = options.width; diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index f5cc01cd062..21b03b56b7a 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -258,7 +258,6 @@ static void xml_read_integrator(const XMLReadState& state, pugi::xml_node node) xml_read_int(&integrator->min_bounce, node, "min_bounce"); xml_read_int(&integrator->max_bounce, node, "max_bounce"); xml_read_bool(&integrator->no_caustics, node, "no_caustics"); - xml_read_float(&integrator->blur_caustics, node, "blur_caustics"); } /* Camera */ diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index ec22d3db6f7..db8ea5fbf1e 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -154,7 +154,7 @@ void BlenderSync::sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, /* Object */ -void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint visibility) +void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag) { /* light is handled separately */ if(object_is_light(b_ob)) { @@ -181,11 +181,19 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, if(object_updated || (object->mesh && object->mesh->need_update)) { object->name = b_ob.name().c_str(); object->tfm = tfm; - - object->visibility = object_ray_visibility(b_ob) & visibility; + + /* visibility flags for both parent */ + object->visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL; if(b_parent.ptr.data != b_ob.ptr.data) object->visibility &= object_ray_visibility(b_parent); + /* camera flag is not actually used, instead is tested + against render layer flags */ + if(object->visibility & PATH_RAY_CAMERA) { + object->visibility |= layer_flag << PATH_RAY_LAYER_SHIFT; + object->visibility &= ~PATH_RAY_CAMERA; + } + object->tag_update(scene); } } @@ -196,7 +204,6 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d) { /* layer data */ uint scene_layer = render_layer.scene_layer; - uint layer = render_layer.layer; /* prepare for sync */ light_map.pre_sync(); @@ -212,11 +219,6 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d) uint ob_layer = get_layer(b_ob->layers()); if(!hide && (ob_layer & scene_layer)) { - uint visibility = PATH_RAY_ALL; - - if(!(ob_layer & layer)) - visibility &= ~PATH_RAY_CAMERA; - if(b_ob->is_duplicator()) { /* dupli objects */ object_create_duplilist(*b_ob, b_scene); @@ -226,7 +228,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d) for(b_ob->dupli_list.begin(b_dup); b_dup != b_ob->dupli_list.end(); ++b_dup) { Transform tfm = get_transform(b_dup->matrix()); - sync_object(*b_ob, b_index, b_dup->object(), tfm, visibility); + sync_object(*b_ob, b_index, b_dup->object(), tfm, ob_layer); b_index++; } @@ -244,7 +246,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d) if(!hide) { /* object itself */ Transform tfm = get_transform(b_ob->matrix_world()); - sync_object(*b_ob, 0, *b_ob, tfm, visibility); + sync_object(*b_ob, 0, *b_ob, tfm, ob_layer); } } } diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 4c8fe350b88..52555fadefb 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -122,9 +122,9 @@ bool BlenderSync::sync_recalc() void BlenderSync::sync_data(BL::SpaceView3D b_v3d) { + sync_render_layer(b_v3d); sync_integrator(); sync_film(); - sync_render_layer(b_v3d); sync_shaders(); sync_objects(b_v3d); } @@ -152,9 +152,8 @@ void BlenderSync::sync_integrator() integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows"); integrator->no_caustics = get_boolean(cscene, "no_caustics"); - integrator->blur_caustics = get_float(cscene, "blur_caustics"); - integrator->seed = get_int(cscene, "seed"); + integrator->layer_flag = render_layer.layer; if(integrator->modified(previntegrator)) integrator->tag_update(scene); diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 824904cd81d..cd667205854 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -78,7 +78,7 @@ private: void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree); Mesh *sync_mesh(BL::Object b_ob, bool object_updated); - void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint visibility); + void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag); void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm); /* util */ diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 05707f31352..d27ad861c6a 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -130,13 +130,16 @@ __device_inline void path_state_next(KernelGlobals *kg, PathState *state, int la } } -__device_inline uint path_state_ray_visibility(PathState *state) +__device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state) { uint flag = state->flag; /* for visibility, diffuse/glossy are for reflection only */ if(flag & PATH_RAY_TRANSMIT) flag &= ~(PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY); + /* for camera visibility, use render layer flags */ + if(flag & PATH_RAY_CAMERA) + flag |= kernel_data.integrator.layer_flag; return flag; } @@ -249,7 +252,7 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R for(;; rng_offset += PRNG_BOUNCE_NUM) { /* intersect scene */ Intersection isect; - uint visibility = path_state_ray_visibility(&state); + uint visibility = path_state_ray_visibility(kg, &state); if(!scene_intersect(kg, &ray, visibility, &isect)) { /* eval background shader if nothing hit */ diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index ea73f87a8a5..56db4d2b78a 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -100,7 +100,10 @@ enum PathTraceDimension { /* these flag values correspond exactly to OSL defaults, so be careful not to * change this, or if you do, set the "raytypes" shading system attribute with - * your own new ray types and bitflag values */ + * your own new ray types and bitflag values. + * + * for ray visibility tests in BVH traversal, the upper 20 bits are used for + * layer visibility tests. */ enum PathRayFlag { PATH_RAY_CAMERA = 1, @@ -117,7 +120,9 @@ enum PathRayFlag { PATH_RAY_MIS_SKIP = 512, - PATH_RAY_ALL = (1|2|4|8|16|32|64|128|256|512) + PATH_RAY_ALL = (1|2|4|8|16|32|64|128|256|512), + + PATH_RAY_LAYER_SHIFT = (32-20) }; /* Closure Label */ @@ -383,10 +388,12 @@ typedef struct KernelIntegrator { /* caustics */ int no_caustics; - float blur_caustics; /* seed */ int seed; + + /* render layer */ + int layer_flag; } KernelIntegrator; typedef struct KernelBVH { diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index 9d129d8e8db..47059a0a009 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -41,9 +41,8 @@ Integrator::Integrator() transparent_shadows = false; no_caustics = false; - blur_caustics = 0.0f; - seed = 0; + layer_flag = ~0; need_update = true; } @@ -81,9 +80,8 @@ void Integrator::device_update(Device *device, DeviceScene *dscene) kintegrator->transparent_shadows = transparent_shadows; kintegrator->no_caustics = no_caustics; - kintegrator->blur_caustics = blur_caustics; - kintegrator->seed = hash_int(seed); + kintegrator->layer_flag = layer_flag << PATH_RAY_LAYER_SHIFT; /* sobol directions table */ int dimensions = PRNG_BASE_NUM + (max_bounce + transparent_max_bounce + 2)*PRNG_BOUNCE_NUM; @@ -115,7 +113,7 @@ bool Integrator::modified(const Integrator& integrator) transparent_probalistic == integrator.transparent_probalistic && transparent_shadows == integrator.transparent_shadows && no_caustics == integrator.no_caustics && - blur_caustics == integrator.blur_caustics && + layer_flag == integrator.layer_flag && seed == integrator.seed); } diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h index 52032fa1a26..e610d670142 100644 --- a/intern/cycles/render/integrator.h +++ b/intern/cycles/render/integrator.h @@ -41,9 +41,9 @@ public: bool transparent_shadows; bool no_caustics; - float blur_caustics; int seed; + int layer_flag; bool need_update; -- cgit v1.2.3 From c287a09b40cf9010c36363d4ee61f7a88c6bad7d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 20:51:55 +0000 Subject: Cycles: support for multiple render layers. It currently renders each layer entirely before moving on to the next. --- intern/cycles/blender/addon/ui.py | 16 +++---- intern/cycles/blender/blender_mesh.cpp | 6 ++- intern/cycles/blender/blender_object.cpp | 2 +- intern/cycles/blender/blender_session.cpp | 75 +++++++++++++++++++++---------- intern/cycles/blender/blender_session.h | 2 + intern/cycles/blender/blender_sync.cpp | 40 ++++++++++------- intern/cycles/blender/blender_sync.h | 11 +++-- 7 files changed, 96 insertions(+), 56 deletions(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index d631158f5eb..24f3de6e859 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -160,18 +160,17 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel): scene = context.scene rd = scene.render - # row = layout.row() - # row.template_list(rd, "layers", rd.layers, "active_index", rows=2) + row = layout.row() + row.template_list(rd, "layers", rd.layers, "active_index", rows=2) - # col = row.column(align=True) - # col.operator("scene.render_layer_add", icon='ZOOMIN', text="") - # col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="") + col = row.column(align=True) + col.operator("scene.render_layer_add", icon='ZOOMIN', text="") + col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="") row = layout.row() - # rl = rd.layers.active - rl = rd.layers[0] + rl = rd.layers.active row.prop(rl, "name") - #row.prop(rd, "use_single_layer", text="", icon_only=True) + row.prop(rd, "use_single_layer", text="", icon_only=True) split = layout.split() @@ -183,6 +182,7 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel): layout.separator() + rl = rd.layers[0] layout.prop(rl, "material_override", text="Material") diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 4b7651dba4c..72b8cfa2355 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -232,8 +232,10 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated) BL::Object::material_slots_iterator slot; for(b_ob.material_slots.begin(slot); slot != b_ob.material_slots.end(); ++slot) { - if(render_layer.material_override) - find_shader(render_layer.material_override, used_shaders, scene->default_surface); + BL::Material material_override = render_layers.front().material_override; + + if(material_override) + find_shader(material_override, used_shaders, scene->default_surface); else find_shader(slot->material(), used_shaders, scene->default_surface); } diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index db8ea5fbf1e..608c5fda5ac 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -203,7 +203,7 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, void BlenderSync::sync_objects(BL::SpaceView3D b_v3d) { /* layer data */ - uint scene_layer = render_layer.scene_layer; + uint scene_layer = render_layers.front().scene_layer; /* prepare for sync */ light_map.pre_sync(); diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 1803dd36beb..d8c65c7a607 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -40,7 +40,8 @@ CCL_NAMESPACE_BEGIN BlenderSession::BlenderSession(BL::RenderEngine b_engine_, BL::BlendData b_data_, BL::Scene b_scene_) -: b_engine(b_engine_), b_data(b_data_), b_scene(b_scene_), b_v3d(PointerRNA_NULL), b_rv3d(PointerRNA_NULL) +: b_engine(b_engine_), b_data(b_data_), b_scene(b_scene_), b_v3d(PointerRNA_NULL), b_rv3d(PointerRNA_NULL), + b_rr(PointerRNA_NULL), b_rlay(PointerRNA_NULL) { /* offline render */ BL::RenderSettings r = b_scene.render(); @@ -55,7 +56,8 @@ BlenderSession::BlenderSession(BL::RenderEngine b_engine_, BL::BlendData b_data_ BlenderSession::BlenderSession(BL::RenderEngine b_engine_, BL::BlendData b_data_, BL::Scene b_scene_, BL::SpaceView3D b_v3d_, BL::RegionView3D b_rv3d_, int width_, int height_) -: b_engine(b_engine_), b_data(b_data_), b_scene(b_scene_), b_v3d(b_v3d_), b_rv3d(b_rv3d_) +: b_engine(b_engine_), b_data(b_data_), b_scene(b_scene_), b_v3d(b_v3d_), b_rv3d(b_rv3d_), + b_rr(PointerRNA_NULL), b_rlay(PointerRNA_NULL) { /* 3d view render */ width = width_; @@ -64,6 +66,7 @@ BlenderSession::BlenderSession(BL::RenderEngine b_engine_, BL::BlendData b_data_ last_redraw_time = 0.0f; create_session(); + session->start(); } BlenderSession::~BlenderSession() @@ -99,11 +102,9 @@ void BlenderSession::create_session() session->progress.set_cancel_callback(function_bind(&BlenderSession::test_cancel, this)); session->set_pause(BlenderSync::get_session_pause(b_scene, background)); - /* start rendering */ + /* set buffer parameters */ BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); - session->reset(buffer_params, session_params.samples); - session->start(); } void BlenderSession::free_session() @@ -114,42 +115,67 @@ void BlenderSession::free_session() void BlenderSession::render() { - session->wait(); + /* get buffer parameters */ + BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); + int w = buffer_params.width, h = buffer_params.height; - if(session->progress.get_cancel()) - return; + /* create render result */ + RenderResult *rrp = RE_engine_begin_result((RenderEngine*)b_engine.ptr.data, 0, 0, w, h); + PointerRNA rrptr; + RNA_pointer_create(NULL, &RNA_RenderResult, rrp, &rrptr); + b_rr = BL::RenderResult(rrptr); + + BL::RenderSettings r = b_scene.render(); + BL::RenderResult::layers_iterator b_iter; + BL::RenderLayers b_rr_layers(r.ptr); + + int active = 0; + + /* render each layer */ + for(b_rr.layers.begin(b_iter); b_iter != b_rr.layers.end(); ++b_iter, ++active) { + /* single layer render */ + if(r.use_single_layer()) + active = b_rr_layers.active_index(); + + /* set layer */ + b_rlay = *b_iter; - /* write result */ - write_render_result(); + /* update scene */ + sync->sync_data(b_v3d, active); + + /* render */ + session->start(); + session->wait(); + + if(session->progress.get_cancel()) + break; + + /* write result */ + write_render_result(); + } + + /* delete render result */ + RE_engine_end_result((RenderEngine*)b_engine.ptr.data, (RenderResult*)b_rr.ptr.data); } void BlenderSession::write_render_result() { - /* get result */ + /* get state */ RenderBuffers *buffers = session->buffers; float exposure = scene->film->exposure; double total_time, sample_time; int sample; session->progress.get_sample(sample, total_time, sample_time); + /* get pixels */ float4 *pixels = buffers->copy_from_device(exposure, sample); if(!pixels) return; - BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); - int w = buffer_params.width, h = buffer_params.height; - - struct RenderResult *rrp = RE_engine_begin_result((RenderEngine*)b_engine.ptr.data, 0, 0, w, h); - PointerRNA rrptr; - RNA_pointer_create(NULL, &RNA_RenderResult, rrp, &rrptr); - BL::RenderResult rr(rrptr); - - BL::RenderResult::layers_iterator layer; - rr.layers.begin(layer); - rna_RenderLayer_rect_set(&layer->ptr, (float*)pixels); - - RE_engine_end_result((RenderEngine*)b_engine.ptr.data, rrp); + /* write pixels */ + rna_RenderLayer_rect_set(&b_rlay.ptr, (float*)pixels); + RE_engine_update_result((RenderEngine*)b_engine.ptr.data, (RenderResult*)b_rr.ptr.data); delete [] pixels; } @@ -164,6 +190,7 @@ void BlenderSession::synchronize() scene->params.modified(scene_params)) { free_session(); create_session(); + session->start(); return; } diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h index e30b60c3d63..26fffcf3aff 100644 --- a/intern/cycles/blender/blender_session.h +++ b/intern/cycles/blender/blender_session.h @@ -69,6 +69,8 @@ public: BL::Scene b_scene; BL::SpaceView3D b_v3d; BL::RegionView3D b_rv3d; + BL::RenderResult b_rr; + BL::RenderLayer b_rlay; string last_status; float last_progress; diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 52555fadefb..3443f76b1ce 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -48,7 +48,8 @@ BlenderSync::BlenderSync(BL::BlendData b_data_, BL::Scene b_scene_, Scene *scene light_map(&scene_->lights), world_map(NULL), world_recalc(false), - experimental(false) + experimental(false), + active_layer(0) { scene = scene_; preview = preview_; @@ -120,10 +121,10 @@ bool BlenderSync::sync_recalc() return recalc; } -void BlenderSync::sync_data(BL::SpaceView3D b_v3d) +void BlenderSync::sync_data(BL::SpaceView3D b_v3d, int layer) { - sync_render_layer(b_v3d); - sync_integrator(); + sync_render_layers(b_v3d); + sync_integrator(layer); sync_film(); sync_shaders(); sync_objects(b_v3d); @@ -131,7 +132,7 @@ void BlenderSync::sync_data(BL::SpaceView3D b_v3d) /* Integrator */ -void BlenderSync::sync_integrator() +void BlenderSync::sync_integrator(int layer) { PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); @@ -153,7 +154,7 @@ void BlenderSync::sync_integrator() integrator->no_caustics = get_boolean(cscene, "no_caustics"); integrator->seed = get_int(cscene, "seed"); - integrator->layer_flag = render_layer.layer; + integrator->layer_flag = render_layers[layer].layer; if(integrator->modified(previntegrator)) integrator->tag_update(scene); @@ -185,27 +186,32 @@ void BlenderSync::sync_film() /* Render Layer */ -void BlenderSync::sync_render_layer(BL::SpaceView3D b_v3d) +void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d) { + render_layers.clear(); + if(b_v3d) { - render_layer.scene_layer = get_layer(b_v3d.layers()); - render_layer.layer = render_layer.scene_layer; - render_layer.material_override = PointerRNA_NULL; + RenderLayerInfo rlay; + + rlay.scene_layer = get_layer(b_v3d.layers()); + rlay.layer = rlay.scene_layer; + rlay.material_override = PointerRNA_NULL; + + render_layers.push_back(rlay); } else { BL::RenderSettings r = b_scene.render(); BL::RenderSettings::layers_iterator b_rlay; - bool first = true; for(r.layers.begin(b_rlay); b_rlay != r.layers.end(); ++b_rlay) { /* single layer for now */ - if(first) { - render_layer.scene_layer = get_layer(b_scene.layers()); - render_layer.layer = get_layer(b_rlay->layers()); - render_layer.material_override = b_rlay->material_override(); + RenderLayerInfo rlay; - first = false; - } + rlay.scene_layer = get_layer(b_scene.layers()); + rlay.layer = get_layer(b_rlay->layers()); + rlay.material_override = b_rlay->material_override(); + + render_layers.push_back(rlay); } } } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index cd667205854..60fdd7c386b 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -54,7 +54,7 @@ public: /* sync */ bool sync_recalc(); - void sync_data(BL::SpaceView3D b_v3d); + void sync_data(BL::SpaceView3D b_v3d, int layer = 0); void sync_camera(int width, int height); void sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height); @@ -70,10 +70,10 @@ private: void sync_materials(); void sync_objects(BL::SpaceView3D b_v3d); void sync_film(); - void sync_integrator(); + void sync_integrator(int layer); void sync_view(); void sync_world(); - void sync_render_layer(BL::SpaceView3D b_v3d); + void sync_render_layers(BL::SpaceView3D b_v3d); void sync_shaders(); void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree); @@ -112,7 +112,10 @@ private: uint scene_layer; uint layer; BL::Material material_override; - } render_layer; + }; + + vector render_layers; + int active_layer; }; CCL_NAMESPACE_END -- cgit v1.2.3 From 3b7aa6bb122000da96b00cb1fc823085b8e1f348 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Dec 2011 20:56:49 +0000 Subject: patch [#29667] Fix for potential memory corruption in path_util.c from Andrew Wiggin (ender79) --- source/blender/blenlib/intern/path_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index e79d850caa5..9adb39f09ef 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -317,7 +317,7 @@ void BLI_uniquename(ListBase *list, void *vlink, const char defname[], char deli void BLI_cleanup_path(const char *relabase, char *dir) { - short a; + ptrdiff_t a; char *start, *eind; if (relabase) { BLI_path_abs(dir, relabase); @@ -1416,7 +1416,7 @@ int BLI_replace_extension(char *path, size_t maxlen, const char *ext) { size_t path_len= strlen(path); size_t ext_len= strlen(ext); - size_t a; + ssize_t a; for(a= path_len - 1; a >= 0; a--) { if (ELEM3(path[a], '.', '/', '\\')) { @@ -1424,7 +1424,7 @@ int BLI_replace_extension(char *path, size_t maxlen, const char *ext) } } - if (path[a] != '.') { + if ((a < 0) || (path[a] != '.')) { a= path_len; } @@ -1440,7 +1440,7 @@ int BLI_ensure_extension(char *path, size_t maxlen, const char *ext) { size_t path_len= strlen(path); size_t ext_len= strlen(ext); - size_t a; + ssize_t a; /* first check the extension is alread there */ if ( (ext_len <= path_len) && -- cgit v1.2.3 From 840dfcd56d132cf71e0d43978a28c3f19aa57826 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Dec 2011 21:21:27 +0000 Subject: cleanup and some fixes to mathutils by Andrew Hale * 1. Resize 4x4, code was ridiculously complex (cleanup only) * 2. matrix * matrix checking for compatibility wasn't working right (bug in last release) * 3. fix for result size for matrix * vector if matrix is 4x4 and vector size 3 (bug in recent patch) * 4. fix for result size vector * matrix if matrix is 4x4 and vector size 3 (bug in recent patch) --- source/blender/python/mathutils/mathutils_Matrix.c | 54 +++++++++++----------- source/blender/python/mathutils/mathutils_Vector.c | 18 ++++++-- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 59aad37f746..47b101c73dc 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -761,7 +761,8 @@ PyDoc_STRVAR(Matrix_resize_4x4_doc, ); static PyObject *Matrix_resize_4x4(MatrixObject *self) { - int x, first_row_elem, curr_pos, new_pos, blank_columns, blank_rows, index; + float mat[16]; + int col; if (self->wrapped==Py_WRAP) { PyErr_SetString(PyExc_TypeError, @@ -784,30 +785,14 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self) return NULL; } - /*move data to new spot in array + clean*/ - for (blank_rows = (4 - self->num_col); blank_rows > 0; blank_rows--) { - for (x = 0; x < 4; x++) { - index = (4 * (self->num_col + (blank_rows - 1))) + x; - if (index == 10 || index == 15) { - self->matrix[index] = 1.0f; - } - else { - self->matrix[index] = 0.0f; - } - } - } - for (x = 1; x <= self->num_col; x++) { - first_row_elem = (self->num_row * (self->num_col - x)); - curr_pos = (first_row_elem + (self->num_row -1)); - new_pos = (4 * (self->num_col - x)) + (curr_pos - first_row_elem); - for (blank_columns = (4 - self->num_row); blank_columns > 0; blank_columns--) { - self->matrix[new_pos + blank_columns] = 0.0f; - } - for ( ; curr_pos >= first_row_elem; curr_pos--) { - self->matrix[new_pos] = self->matrix[curr_pos]; - new_pos--; - } + unit_m4((float (*)[4])mat); + + for (col = 0; col < self->num_col; col++) { + memcpy(mat + (4 * col), MATRIX_COL_PTR(self, col), self->num_row * sizeof(float)); } + + copy_m4_m4((float (*)[4])self->matrix, (float (*)[4])mat); + self->num_col = 4; self->num_row = 4; @@ -1598,6 +1583,7 @@ static PyObject *matrix_mul_float(MatrixObject *mat, const float scalar) static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) { float scalar; + int vec_size; MatrixObject *mat1 = NULL, *mat2 = NULL; @@ -1621,12 +1607,19 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) double dot = 0.0f; int col, row, item; + if (mat1->num_col != mat2->num_row) { + PyErr_SetString(PyExc_ValueError, + "matrix1 * matrix2: matrix1 number of columns " + "and the matrix2 number of rows must be the same"); + return NULL; + } + for (col = 0; col < mat2->num_col; col++) { for (row = 0; row < mat1->num_row; row++) { for (item = 0; item < mat1->num_col; item++) { dot += MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col); } - mat[((col * mat1->num_row) + row)] = (float)dot; + mat[(col * mat1->num_row) + row] = (float)dot; dot = 0.0f; } } @@ -1640,7 +1633,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) } } else if (mat1) { - /*VEC * MATRIX */ + /* MATRIX * VECTOR */ if (VectorObject_Check(m2)) { VectorObject *vec2= (VectorObject *)m2; float tvec[4]; @@ -1650,7 +1643,14 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) return NULL; } - return Vector_CreatePyObject(tvec, vec2->size, Py_NEW, Py_TYPE(m2)); + if (mat1->num_col == 4 && vec2->size == 3) { + vec_size = 3; + } + else { + vec_size = mat1->num_row; + } + + return Vector_CreatePyObject(tvec, vec_size, Py_NEW, Py_TYPE(m2)); } /*FLOAT/INT * MATRIX */ else if (((scalar= PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred())==0) { diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 4e6fce59b7e..c31835cf7b5 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1540,6 +1540,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) { VectorObject *vec1 = NULL, *vec2 = NULL; float scalar; + int vec_size; if VectorObject_Check(v1) { vec1= (VectorObject *)v1; @@ -1576,7 +1577,14 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) return NULL; } - return Vector_CreatePyObject(tvec, ((MatrixObject *)v2)->num_col, Py_NEW, Py_TYPE(vec1)); + if (((MatrixObject *)v2)->num_row == 4 && vec1->size == 3) { + vec_size = 3; + } + else { + vec_size = ((MatrixObject *)v2)->num_col; + } + + return Vector_CreatePyObject(tvec, vec_size, Py_NEW, Py_TYPE(vec1)); } else if (QuaternionObject_Check(v2)) { /* VEC * QUAT */ @@ -2614,15 +2622,15 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v int row, col, z= 0, vec_size= vec->size; if (mat->num_row != vec_size) { - if (mat->num_row == 4 && vec_size != 3) { + if (mat->num_row == 4 && vec_size == 3) { + vec_cpy[3] = 1.0f; + } + else { PyErr_SetString(PyExc_ValueError, "vector * matrix: matrix column size " "and the vector size must be the same"); return -1; } - else { - vec_cpy[3] = 1.0f; - } } if (BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1) -- cgit v1.2.3 From 0772ebc02c8f0800d501ee8a7f5be01ddb01c026 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Dec 2011 21:40:21 +0000 Subject: fix for use of uninitialized value for ipo conversion. --- source/blender/blenkernel/intern/ipo.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 622ec093a3f..9890a2629fc 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -909,8 +909,10 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co if (array_index) *array_index= dummy_index; } - + + /* 'buf' _must_ be initialized in this block */ /* append preceding bits to path */ + /* note, strings are not escapted and they should be! */ if ((actname && actname[0]) && (constname && constname[0])) { /* Constraint in Pose-Channel */ sprintf(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); @@ -918,6 +920,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co else if (actname && actname[0]) { if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) { /* Actionified "Object" IPO's... no extra path stuff needed */ + buf[0]= '\0'; /* empty string */ } else if ((blocktype == ID_KE) && strcmp(actname, "Shape")==0) { /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */ @@ -936,8 +939,10 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co /* Sequence names in Scene */ sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seq->name+2); } - else + else { buf[0]= '\0'; /* empty string */ + } + BLI_dynstr_append(path, buf); /* need to add dot before property if there was anything precceding this */ -- cgit v1.2.3 From d53034d9c9c35d957fc29ebfbbf0e6979cd16f52 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Wed, 21 Dec 2011 22:23:39 +0000 Subject: == Sculpt == Reformatted all lines longer than 120 characters in sculpt.c. Should be no functional changes. Thanks to Campbell for pointing out the issue. I wouldn't normally do this, but just for reference, here is a screenshot that hopefully makes clear why I think this is worth doing: nicholasbishop.net/random/longlines00.png --- source/blender/editors/sculpt_paint/sculpt.c | 36 +++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 272475194ee..1cdc7732b21 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -592,7 +592,12 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) float pen_flip = cache->pen_flip ? -1 : 1; float invert = cache->invert ? -1 : 1; float accum = integrate_overlap(brush); - float overlap = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? 1.0f/accum : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter + /* spacing is integer percentage of radius, divide by 50 to get + normalized diameter */ + float overlap = (brush->flag & BRUSH_SPACE_ATTEN && + brush->flag & BRUSH_SPACE && + !(brush->flag & BRUSH_ANCHORED) && + (brush->spacing < 100)) ? 1.0f/accum : 1; float flip = dir * invert * pen_flip; switch(brush->sculpt_tool){ @@ -1716,7 +1721,9 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to /* this calculates flatten center and area normal together, amortizing the memory bandwidth and loop overhead to calculate both at the same time */ -static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float an[3], float fc[3]) +static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, + PBVHNode **nodes, int totnode, + float an[3], float fc[3]) { SculptSession *ss = ob->sculpt; int n; @@ -2588,7 +2595,9 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) /* Flip all the editdata across the axis/axes specified by symm. Used to calculate multiple modifications to the mesh when symmetry is enabled. */ -static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, const char axis, const float angle, const float UNUSED(feather)) +static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, + const char axis, const float angle, + const float UNUSED(feather)) { (void)sd; /* unused */ @@ -2620,7 +2629,9 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, mul_m4_v3(cache->symm_rot_mat, cache->grab_delta_symmetry); } -static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, const char symm, const int axis, const float feather) +static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, + const char symm, const int axis, + const float feather) { SculptSession *ss = ob->sculpt; int i; @@ -2954,7 +2965,10 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio cache->original = 1; } - if(ELEM8(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_TUBES, SCULPT_TOOL_ROTATE)) + if(ELEM8(brush->sculpt_tool, + SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, + SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, + SCULPT_TOOL_CLAY_TUBES, SCULPT_TOOL_ROTATE)) if(!(brush->flag & BRUSH_ACCUMULATE)) cache->original = 1; @@ -3038,7 +3052,9 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) } /* Initialize the stroke cache variants from operator properties */ -static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, struct PaintStroke *stroke, PointerRNA *ptr) +static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, + struct PaintStroke *stroke, + PointerRNA *ptr) { SculptSession *ss = ob->sculpt; StrokeCache *cache = ss->cache; @@ -3095,7 +3111,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st cache->radius_squared = cache->radius*cache->radius; - if(!(brush->flag & BRUSH_ANCHORED || ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) { + if(!(brush->flag & BRUSH_ANCHORED || + ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK, + SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) { copy_v2_v2(cache->tex_mouse, cache->mouse); if ( (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) && @@ -3137,7 +3155,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st if (!hit) copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); - cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius); + cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke), + cache->true_location, + cache->pixel_radius); cache->radius_squared = cache->radius*cache->radius; copy_v3_v3(sd->anchored_location, cache->true_location); -- cgit v1.2.3 From 96bd647c4f9eff5fe21308228808ad8cd992ba68 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Dec 2011 22:56:06 +0000 Subject: split some >120 lines, no functional changes --- source/blender/blenkernel/intern/unit.c | 10 +++-- .../editors/transform/transform_conversions.c | 24 ++++++++---- source/blender/makesrna/intern/rna_access.c | 43 ++++++++++++++++------ source/blender/python/intern/gpu.c | 16 +++++--- 4 files changed, 67 insertions(+), 26 deletions(-) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index aa914998a72..81c526e45a6 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -299,7 +299,8 @@ static bUnitDef *unit_best_fit(double value, bUnitCollection *usys, bUnitDef *un if(suppress && (unit->flag & B_UNIT_DEF_SUPPRESS)) continue; - if (value_abs >= unit->scalar*(1.0-EPS)) /* scale down scalar so 1cm doesnt convert to 10mm because of float error */ + /* scale down scalar so 1cm doesnt convert to 10mm because of float error */ + if (value_abs >= unit->scalar*(1.0-EPS)) return unit; } @@ -481,11 +482,14 @@ static int ch_is_op(char op) } } -static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, const char *replace_str) +static int unit_scale_str(char *str, int len_max, char *str_tmp, + double scale_pref, bUnitDef *unit, const char *replace_str) { char *str_found; - if((len_max>0) && (str_found= (char *)unit_find_str(str, replace_str))) { /* XXX - investigate, does not respect len_max properly */ + if((len_max>0) && (str_found= (char *)unit_find_str(str, replace_str))) { + /* XXX - investigate, does not respect len_max properly */ + int len, len_num, len_name, len_move, found_ofs; found_ofs = (int)(str_found-str); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 4b6c3a7031b..53d26f0a655 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1548,8 +1548,10 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) /* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles * but for now just dont change handle types */ - if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0) - testhandlesNurb(nu); /* sets the handles based on their selection, do this after the data is copied to the TransData */ + if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0) { + /* sets the handles based on their selection, do this after the data is copied to the TransData */ + testhandlesNurb(nu); + } } else { TransData *head, *tail; @@ -4443,7 +4445,8 @@ static int count_proportional_objects(TransInfo *t) /* mark all children */ for (base= scene->base.first; base; base= base->next) { /* all base not already selected or marked that is editable */ - if ((base->object->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && BASE_EDITABLE_BGMODE(v3d, scene, base)) + if ( (base->object->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && + (BASE_EDITABLE_BGMODE(v3d, scene, base))) { mark_children(base->object); } @@ -4454,7 +4457,8 @@ static int count_proportional_objects(TransInfo *t) Object *ob= base->object; /* if base is not selected, not a parent of selection or not a child of selection and it is editable */ - if ((ob->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && BASE_EDITABLE_BGMODE(v3d, scene, base)) + if ( (ob->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && + (BASE_EDITABLE_BGMODE(v3d, scene, base))) { /* used for flush, depgraph will change recalcs if needed :) */ @@ -4530,7 +4534,9 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, if (adt && adt->action) { for (fcu= adt->action->curves.first; fcu; fcu= fcu->next) { fcu->flag &= ~FCURVE_SELECTED; - insert_keyframe(reports, id, adt->action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, id, adt->action, + (fcu->grp ? fcu->grp->name : NULL), + fcu->rna_path, fcu->array_index, cfra, flag); } } } @@ -5048,8 +5054,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } - else if(t->scene->basact && (ob = t->scene->basact->object) && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, ob)) { - ; + else if ( (t->scene->basact) && + (ob = t->scene->basact->object) && + (ob->mode & OB_MODE_PARTICLE_EDIT) && + PE_get_current(t->scene, ob)) + { + /* do nothing */ ; } else { /* Objects */ int i, recalcObPaths=0; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 02b1fa300fb..56edfef8aa1 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -837,12 +837,17 @@ char RNA_property_array_item_char(PropertyRNA *prop, int index) PropertySubType subtype= rna_ensure_property(prop)->subtype; /* get string to use for array index */ - if ((index < 4) && ELEM(subtype, PROP_QUATERNION, PROP_AXISANGLE)) + if ((index < 4) && ELEM(subtype, PROP_QUATERNION, PROP_AXISANGLE)) { return quatitem[index]; - else if((index < 4) && ELEM8(subtype, PROP_TRANSLATION, PROP_DIRECTION, PROP_XYZ, PROP_XYZ_LENGTH, PROP_EULER, PROP_VELOCITY, PROP_ACCELERATION, PROP_COORDS)) + } + else if((index < 4) && ELEM8(subtype, PROP_TRANSLATION, PROP_DIRECTION, PROP_XYZ, PROP_XYZ_LENGTH, + PROP_EULER, PROP_VELOCITY, PROP_ACCELERATION, PROP_COORDS)) + { return vectoritem[index]; - else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) + } + else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) { return coloritem[index]; + } return '\0'; } @@ -865,7 +870,9 @@ int RNA_property_array_item_index(PropertyRNA *prop, char name) return 3; } } - else if(ELEM6(subtype, PROP_TRANSLATION, PROP_DIRECTION, PROP_XYZ, PROP_EULER, PROP_VELOCITY, PROP_ACCELERATION)) { + else if(ELEM6(subtype, PROP_TRANSLATION, PROP_DIRECTION, PROP_XYZ, + PROP_EULER, PROP_VELOCITY, PROP_ACCELERATION)) + { switch (name) { case 'x': return 0; @@ -1519,7 +1526,8 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop) /* find cache element for which key matches... */ for (uce = rna_updates_cache.first; uce; uce = uce->next) { /* just match by id only for now, since most update calls that we'll encounter only really care about this */ - // TODO: later, the cache might need to have some nesting on L1 to cope better with these problems + some tagging to indicate we need this + /* TODO: later, the cache might need to have some nesting on L1 to cope better + * with these problems + some tagging to indicate we need this */ if (uce->ptr.id.data == ptr->id.data) break; } @@ -4969,7 +4977,9 @@ static int rna_function_format_array_length(const char *format, int ofs, int fle return 0; } -static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, PropertyType type, char ftype, int len, void *dest, void *src, StructRNA *srna, const char *tid, const char *fid, const char *pid) +static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, PropertyType type, + char ftype, int len, void *dest, void *src, StructRNA *srna, + const char *tid, const char *fid, const char *pid) { /* ptr is always a function pointer, prop always a parameter */ @@ -5055,7 +5065,9 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop } if (ptype!=srna && !RNA_struct_is_a(srna, ptype)) { - fprintf(stderr, "%s.%s: wrong type for parameter %s, an object of type %s was expected, passed an object of type %s\n", tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(srna)); + fprintf(stderr, "%s.%s: wrong type for parameter %s, " + "an object of type %s was expected, passed an object of type %s\n", + tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(srna)); return -1; } @@ -5080,7 +5092,10 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop ptype= RNA_property_pointer_type(ptr, prop); if (ptype!=srna && !RNA_struct_is_a(srna, ptype)) { - fprintf(stderr, "%s.%s: wrong type for parameter %s, a collection of objects of type %s was expected, passed a collection of objects of type %s\n", tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(srna)); + fprintf(stderr, "%s.%s: wrong type for parameter %s, " + "a collection of objects of type %s was expected, " + "passed a collection of objects of type %s\n", + tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(srna)); return -1; } @@ -5159,7 +5174,10 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt if (len!=alen) { err= -1; - fprintf(stderr, "%s.%s: for parameter %s, was expecting an array of %i elements, passed %i elements instead\n", tid, fid, pid, len, alen); + fprintf(stderr, "%s.%s: for parameter %s, " + "was expecting an array of %i elements, " + "passed %i elements instead\n", + tid, fid, pid, len, alen); break; } @@ -5224,7 +5242,9 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt if (len!=alen) { err= -1; - fprintf(stderr, "%s.%s: for return parameter %s, was expecting an array of %i elements, passed %i elements instead\n", tid, fid, pid, len, alen); + fprintf(stderr, "%s.%s: for return parameter %s, " + "was expecting an array of %i elements, passed %i elements instead\n", + tid, fid, pid, len, alen); } else { switch (type) { @@ -5278,7 +5298,8 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt return err; } -int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args) +int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, + const char *identifier, const char *format, va_list args) { FunctionRNA *func; diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index a155a7ec3d9..66e8ff510ef 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -145,6 +145,14 @@ PyInit_gpu(void) PyObject_SetAttrString(d, #f, val); \ Py_DECREF(val) +PyDoc_STRVAR(GPU_export_shader_doc, +"export_shader(scene, material)\n" +"\n" +" Returns the GLSL shader that produces the visual effect of material in scene.\n" +"\n" +" :return: Dictionary defining the shader, uniforms and attributes.\n" +" :rtype: Dict" +); static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObject *kwds) { PyObject* pyscene; @@ -279,11 +287,9 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj return result; } -static PyMethodDef meth_export_shader[] = {{ "export_shader", (PyCFunction)GPU_export_shader, METH_VARARGS | METH_KEYWORDS, - "export_shader(scene,material)\n\n" - "Returns the GLSL shader that produces the visual effect of material in scene.\n\n" - ":return: Dictionary defining the shader, uniforms and attributes.\n" - ":rtype: Dict"}}; +static PyMethodDef meth_export_shader[] = { + {"export_shader", (PyCFunction)GPU_export_shader, METH_VARARGS | METH_KEYWORDS, GPU_export_shader_doc} +}; PyObject* GPU_initPython(void) { -- cgit v1.2.3 From 26f69488ca61e13d4c9146eba735351bb87496de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Dec 2011 23:12:16 +0000 Subject: Matrix.translation wrapper vector, continent accessing to matrix[3][0:3]. this is a part of patch 29534, being applied separately from patch [#29534] Change Matrix Representation and Access in Python to Conform with Standard Notation by Andrew Hale (trumanblending) --- source/blender/python/mathutils/mathutils.c | 1 + source/blender/python/mathutils/mathutils_Matrix.c | 127 +++++++++++++++++++++ source/blender/python/mathutils/mathutils_Matrix.h | 2 + 3 files changed, 130 insertions(+) diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 1dfd7c574dd..1147930ff65 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -456,6 +456,7 @@ PyMODINIT_FUNC PyInit_mathutils(void) Py_INCREF(item); mathutils_matrix_vector_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_vector_cb); + mathutils_matrix_column_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_column_cb); return submodule; } diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 47b101c73dc..19675d2a863 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -115,6 +115,87 @@ Mathutils_Callback mathutils_matrix_vector_cb = { }; /* matrix vector callbacks, this is so you can do matrix[i][j] = val */ +/* matrix row callbacks */ +int mathutils_matrix_column_cb_index= -1; + +static int mathutils_matrix_column_check(BaseMathObject *bmo) +{ + MatrixObject *self= (MatrixObject *)bmo->cb_user; + return BaseMath_ReadCallback(self); +} + +static int mathutils_matrix_column_get(BaseMathObject *bmo, int col) +{ + MatrixObject *self= (MatrixObject *)bmo->cb_user; + int num_row; + int row; + + if (BaseMath_ReadCallback(self) == -1) + return -1; + + /* for 'translation' size will always be '3' even on 4x4 vec */ + num_row = MIN2(self->num_row, ((VectorObject *)bmo)->size); + + for (row = 0; row < num_row; row++) { + bmo->data[row] = MATRIX_ITEM(self, row, col); + } + + return 0; +} + +static int mathutils_matrix_column_set(BaseMathObject *bmo, int col) +{ + MatrixObject *self= (MatrixObject *)bmo->cb_user; + int num_row; + int row; + + if (BaseMath_ReadCallback(self) == -1) + return -1; + + /* for 'translation' size will always be '3' even on 4x4 vec */ + num_row = MIN2(self->num_row, ((VectorObject *)bmo)->size); + + for (row = 0; row < num_row; row++) { + MATRIX_ITEM(self, row, col) = bmo->data[row]; + } + + (void)BaseMath_WriteCallback(self); + return 0; +} + +static int mathutils_matrix_column_get_index(BaseMathObject *bmo, int col, int row) +{ + MatrixObject *self= (MatrixObject *)bmo->cb_user; + + if (BaseMath_ReadCallback(self) == -1) + return -1; + + bmo->data[row]= MATRIX_ITEM(self, row, col); + return 0; +} + +static int mathutils_matrix_column_set_index(BaseMathObject *bmo, int col, int row) +{ + MatrixObject *self= (MatrixObject *)bmo->cb_user; + + if (BaseMath_ReadCallback(self) == -1) + return -1; + + MATRIX_ITEM(self, row, col) = bmo->data[row]; + + (void)BaseMath_WriteCallback(self); + return 0; +} + +Mathutils_Callback mathutils_matrix_column_cb = { + mathutils_matrix_column_check, + mathutils_matrix_column_get, + mathutils_matrix_column_set, + mathutils_matrix_column_get_index, + mathutils_matrix_column_set_index +}; +/* matrix column callbacks, this is so you can do matrix.translation = Vector() */ + //----------------------------------mathutils.Matrix() ----------------- //mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. //create a new matrix type @@ -1813,6 +1894,51 @@ static PyObject *Matrix_getColSize(MatrixObject *self, void *UNUSED(closure)) return PyLong_FromLong((long) self->num_row); } +static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure)) +{ + PyObject *ret; + + if (BaseMath_ReadCallback(self) == -1) + return NULL; + + /*must be 4x4 square matrix*/ + if (self->num_row != 4 || self->num_col != 4) { + PyErr_SetString(PyExc_AttributeError, + "Matrix.translation: " + "inappropriate matrix size, must be 4x4"); + return NULL; + } + + ret = (PyObject *)Vector_CreatePyObject_cb((PyObject *)self, 3, mathutils_matrix_column_cb_index, 3); + + return ret; +} + +static int Matrix_translation_set(MatrixObject *self, PyObject *value, void *UNUSED(closure)) +{ + float tvec[3]; + + if (BaseMath_ReadCallback(self) == -1) + return -1; + + /*must be 4x4 square matrix*/ + if (self->num_row != 4 || self->num_col != 4) { + PyErr_SetString(PyExc_AttributeError, + "Matrix.translation: " + "inappropriate matrix size, must be 4x4"); + return -1; + } + + if ((mathutils_array_parse(tvec, 3, 3, value, "Matrix.translation")) == -1) + return -1; + + copy_v3_v3(((float (*)[4])self->matrix)[3], tvec); + + (void)BaseMath_WriteCallback(self); + + return 0; +} + static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closure)) { float mat[3][3]; @@ -1876,6 +2002,7 @@ static PyGetSetDef Matrix_getseters[] = { {(char *)"row_size", (getter)Matrix_getRowSize, (setter)NULL, (char *)"The row size of the matrix (readonly).\n\n:type: int", NULL}, {(char *)"col_size", (getter)Matrix_getColSize, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL}, {(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL}, + {(char *)"translation", (getter)Matrix_translation_get, (setter)Matrix_translation_set, (char *)"The translation component of the matrix.\n\n:type: Vector", NULL}, {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, (char *)"True if this matrix is orthogonal, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index 91a276b648e..e7bfc06b98b 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -71,7 +71,9 @@ PyObject *Matrix_CreatePyObject(float *mat, PyObject *Matrix_CreatePyObject_cb(PyObject *user, int num_col, int num_row, int cb_type, int cb_subtype); extern int mathutils_matrix_vector_cb_index; +extern int mathutils_matrix_column_cb_index; extern struct Mathutils_Callback mathutils_matrix_vector_cb; +extern struct Mathutils_Callback mathutils_matrix_column_cb; void matrix_as_3x3(float mat[3][3], MatrixObject *self); -- cgit v1.2.3 From 5272d76faa969bc379ca1d1c28601c67fce98b24 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 21 Dec 2011 23:59:57 +0000 Subject: patch [#29676] ALPHA OVER: Fix associated alpha over situation to fix [#29675] patch by Troy Sobotka note: if alpha is negative the code will still produce non-optimal results. This is a separate issue though, the patch fix the premul assumption that alpha can be zero and rgb still be valid. --- source/blender/nodes/composite/nodes/node_composite_alphaOver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index cad85d33a66..3a783f0f32d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -47,7 +47,8 @@ static bNodeSocketTemplate cmp_node_alphaover_out[]= { static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, float *over, float *fac) { - if(over[3]<=0.0f) { + /* Zero alpha values should still permit an add of RGB data */ + if(over[3]<0.0f) { copy_v4_v4(out, src); } else if(fac[0]==1.0f && over[3]>=1.0f) { -- cgit v1.2.3 From 51016c4dea9904cbaea8b06d692d6f2dd747a6e8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 00:03:20 +0000 Subject: split >120 length lines (mostly if statements) --- intern/audaspace/intern/AUD_SoftwareDevice.cpp | 4 +++- source/blender/blenkernel/intern/idprop.c | 6 +++++- source/blender/blenloader/intern/readfile.c | 17 +++++++++++++---- source/blender/editors/interface/interface.c | 4 +++- source/blender/editors/interface/interface_templates.c | 15 +++++++++------ source/blender/editors/mesh/editmesh.c | 5 ++++- source/blender/editors/sculpt_paint/paint_image.c | 15 ++++++++++++--- source/blender/editors/space_outliner/outliner_edit.c | 13 +++++++++---- source/blender/editors/space_outliner/outliner_select.c | 6 +++++- source/blender/editors/space_view3d/view3d_header.c | 5 ++++- source/blender/editors/space_view3d/view3d_view.c | 6 +++++- .../blender/editors/transform/transform_conversions.c | 10 ++++++++-- source/blender/editors/transform/transform_snap.c | 7 ++++++- source/gameengine/Ketsji/KX_IPO_SGController.cpp | 11 ++++++++--- 14 files changed, 94 insertions(+), 30 deletions(-) diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp index b1e5d8ccd75..1d993abab73 100644 --- a/intern/audaspace/intern/AUD_SoftwareDevice.cpp +++ b/intern/audaspace/intern/AUD_SoftwareDevice.cpp @@ -121,7 +121,9 @@ void AUD_SoftwareDevice::AUD_SoftwareHandle::update() if(flags & AUD_RENDER_DISTANCE) { - if(m_device->m_distance_model == AUD_DISTANCE_MODEL_INVERSE_CLAMPED || m_device->m_distance_model == AUD_DISTANCE_MODEL_LINEAR_CLAMPED || m_device->m_distance_model == AUD_DISTANCE_MODEL_EXPONENT_CLAMPED) + if(m_device->m_distance_model == AUD_DISTANCE_MODEL_INVERSE_CLAMPED || + m_device->m_distance_model == AUD_DISTANCE_MODEL_LINEAR_CLAMPED || + m_device->m_distance_model == AUD_DISTANCE_MODEL_EXPONENT_CLAMPED) { distance = AUD_MAX(AUD_MIN(m_distance_max, distance), m_distance_reference); } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index a44957ddc01..d9fe0138784 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -692,7 +692,11 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n case IDP_ARRAY: { /*for now, we only support float and int and double arrays*/ - if (val->array.type == IDP_FLOAT || val->array.type == IDP_INT || val->array.type == IDP_DOUBLE || val->array.type == IDP_GROUP) { + if ( (val->array.type == IDP_FLOAT) || + (val->array.type == IDP_INT) || + (val->array.type == IDP_DOUBLE) || + (val->array.type == IDP_GROUP) ) + { prop = MEM_callocN(sizeof(IDProperty), "IDProperty array"); prop->subtype = val->array.type; if (val->array.len) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index bf40a3e73b3..2f3d14da4c2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -10691,8 +10691,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main) void *olddata = ob->data; ob->data = me; - if(me && me->id.lib==NULL && me->mr && me->mr->level_count > 1) /* XXX - library meshes crash on loading most yoFrankie levels, the multires pointer gets invalid - Campbell */ + /* XXX - library meshes crash on loading most yoFrankie levels, + * the multires pointer gets invalid - Campbell */ + if(me && me->id.lib==NULL && me->mr && me->mr->level_count > 1) { multires_load_old(ob, me); + } ob->data = olddata; } @@ -14271,7 +14274,8 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) expand_main(fd, mainptr); - /* dang FileData... now new libraries need to be appended to original filedata, it is not a good replacement for the old global (ton) */ + /* dang FileData... now new libraries need to be appended to original filedata, + * it is not a good replacement for the old global (ton) */ while( fd->mainlist.first ) { Main *mp= fd->mainlist.first; BLI_remlink(&fd->mainlist, mp); @@ -14293,8 +14297,13 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) ID *idn= id->next; if(id->flag & LIB_READ) { BLI_remlink(lbarray[a], id); - BKE_reportf(basefd->reports, RPT_ERROR, "LIB ERROR: %s:'%s' unread libblock missing from '%s'\n", BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath); - if(!G.background && basefd->reports)printf("LIB ERROR: %s:'%s' unread libblock missing from '%s'\n", BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath); + BKE_reportf(basefd->reports, RPT_ERROR, + "LIB ERROR: %s:'%s' unread libblock missing from '%s'\n", + BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath); + if (!G.background && basefd->reports) { + printf("LIB ERROR: %s:'%s' unread libblock missing from '%s'\n", + BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath); + } change_idid_adr(mainlist, basefd, id, NULL); MEM_freeN(id); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 63e41082449..4948073f9c6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -904,7 +904,9 @@ void uiEndBlock(const bContext *C, uiBlock *block) /* handle pending stuff */ if(block->layouts.first) uiBlockLayoutResolve(block, NULL, NULL); ui_block_do_align(block); - if((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) ui_menu_block_set_keyaccels(block); /* could use a different flag to check */ + if((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) { + ui_menu_block_set_keyaccels(block); /* could use a different flag to check */ + } if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block); /* after keymaps! */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 49e3ff10f06..a55c4f2aa0a 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -681,7 +681,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) static int modifier_can_delete(ModifierData *md) { - // fluid particle modifier can't be deleted here + /* fluid particle modifier can't be deleted here */ if(md->type == eModifierType_ParticleSystem) if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) return 0; @@ -689,14 +689,16 @@ static int modifier_can_delete(ModifierData *md) return 1; } -// Check wheter Modifier is a simulation or not, this is used for switching to the physics/particles context tab +/* Check wheter Modifier is a simulation or not, this is used for switching to the physics/particles context tab */ static int modifier_is_simulation(ModifierData *md) { - // Physic Tab - if(ELEM7(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint)) { + /* Physic Tab */ + if (ELEM7(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, + eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint)) + { return 1; } - // Particle Tab + /* Particle Tab */ else if (md->type == eModifierType_ParticleSystem) { return 2; } @@ -705,7 +707,8 @@ static int modifier_is_simulation(ModifierData *md) } } -static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex) +static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, + ModifierData *md, int index, int cageIndex, int lastCageIndex) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); PointerRNA ptr; diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 1477469ca85..f617971967c 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -922,7 +922,10 @@ void make_editMesh(Scene *scene, Object *ob) for(a=0; atotselect; a++, mselect++){ /*check if recorded selection is still valid, if so copy into editmesh*/ - if( (mselect->type == EDITVERT && me->mvert[mselect->index].flag & SELECT) || (mselect->type == EDITEDGE && me->medge[mselect->index].flag & SELECT) || (mselect->type == EDITFACE && me->mface[mselect->index].flag & ME_FACE_SEL) ){ + if ( (mselect->type == EDITVERT && me->mvert[mselect->index].flag & SELECT) || + (mselect->type == EDITEDGE && me->medge[mselect->index].flag & SELECT) || + (mselect->type == EDITFACE && me->mface[mselect->index].flag & ME_FACE_SEL) ) + { ese = MEM_callocN(sizeof(EditSelection), "Edit Selection"); ese->type = mselect->type; if(ese->type == EDITVERT) ese->data = EM_get_vert_for_index(mselect->index); else diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 3aefe5f9ea3..8a4cb8aa78b 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1816,7 +1816,9 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s return 1; */ - if((bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) || (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1]) ) { + if ( (bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) || + (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1]) ) + { return 1; } @@ -2816,7 +2818,11 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke p4[0] = bucket_bounds.xmax; p4[1] = bucket_bounds.ymin; if (mf->v4) { - if( isect_point_quad_v2(p1, v1, v2, v3, v4) || isect_point_quad_v2(p2, v1, v2, v3, v4) || isect_point_quad_v2(p3, v1, v2, v3, v4) || isect_point_quad_v2(p4, v1, v2, v3, v4) || + if ( isect_point_quad_v2(p1, v1, v2, v3, v4) || + isect_point_quad_v2(p2, v1, v2, v3, v4) || + isect_point_quad_v2(p3, v1, v2, v3, v4) || + isect_point_quad_v2(p4, v1, v2, v3, v4) || + /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */ (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3) || isect_line_line_v2(p1, p2, v3, v4)) || (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3) || isect_line_line_v2(p2, p3, v3, v4)) || @@ -2827,7 +2833,10 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke } } else { - if( isect_point_tri_v2(p1, v1, v2, v3) || isect_point_tri_v2(p2, v1, v2, v3) || isect_point_tri_v2(p3, v1, v2, v3) || isect_point_tri_v2(p4, v1, v2, v3) || + if ( isect_point_tri_v2(p1, v1, v2, v3) || + isect_point_tri_v2(p2, v1, v2, v3) || + isect_point_tri_v2(p3, v1, v2, v3) || + isect_point_tri_v2(p4, v1, v2, v3) || /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */ (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3)) || (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3)) || diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 30a7abd3c0b..9b1bd1d7b31 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -221,12 +221,17 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports) { /* can't rename rna datablocks entries */ - if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) - ; - else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + /* do nothing */; + } + else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, + TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + { BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); - else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) + } + else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); + } else if(tselem->id->lib) { // XXX error_libdata(); } diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index e728267f45f..bf570c929cc 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -823,8 +823,12 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - if(!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX) + if ( !ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && + !(soops->flag & SO_HIDE_RESTRICTCOLS) && + (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) + { return OPERATOR_CANCELLED; + } for(te= soops->tree.first; te; te= te->next) { if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 0c9ea3c6a2a..762fc51a34e 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -316,7 +316,10 @@ static char *view3d_modeselect_pup(Scene *scene) str += modeselect_addmode(str, N_("Pose Mode"), OB_MODE_POSE, ICON_POSE_HLT); } - if (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)) { + if ( ob->particlesystem.first || + modifiers_findByType(ob, eModifierType_Cloth) || + modifiers_findByType(ob, eModifierType_Softbody)) + { str += modeselect_addmode(str, N_("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE); } (void)str; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 4d98afc4c10..65ad45495db 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1727,7 +1727,11 @@ static int game_engine_exec(bContext *C, wmOperator *op) game_set_commmandline_options(&startscene->gm); - if(rv3d->persp==RV3D_CAMOB && startscene->gm.framing.type == SCE_GAMEFRAMING_BARS && startscene->gm.stereoflag != STEREO_DOME) { /* Letterbox */ + if((rv3d->persp == RV3D_CAMOB) && + (startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) && + (startscene->gm.stereoflag != STEREO_DOME)) + { + /* Letterbox */ rctf cam_framef; ED_view3d_calc_camera_border(startscene, ar, CTX_wm_view3d(C), rv3d, &cam_framef, FALSE); cam_frame.xmin = cam_framef.xmin + ar->winrct.xmin; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 53d26f0a655..0f93ff12f95 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3450,7 +3450,10 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) * then check if we're using auto-handles. * - If so, change them auto-handles to aligned handles so that handles get affected too */ - if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { + if ( ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && + ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM) && + ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) + { if (hdata && (sel1) && (sel3)) { bezt->h1= HD_ALIGN; bezt->h2= HD_ALIGN; @@ -4146,7 +4149,10 @@ static void createTransSeqData(bContext *C, TransInfo *t) int i; for(i=0; i<3; i++) { seq_user= *((&seq->seq1) + i); - if (seq_user && (seq_user->flag & SELECT) && !(seq_user->flag & SEQ_LOCK) && !(seq_user->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL))) { + if ( seq_user && (seq_user->flag & SELECT) && + !(seq_user->flag & SEQ_LOCK) && + !(seq_user->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL))) + { seq->flag |= SELECT; } } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 4635411dcdf..46792457f63 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1622,7 +1622,12 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, c } for ( base = FIRSTBASE; base != NULL; base = base->next ) { - if ( BASE_VISIBLE(v3d, base) && (base->flag & (BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA)) == 0 && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)) ) { + if ( (BASE_VISIBLE(v3d, base)) && + (base->flag & (BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA)) == 0 && + + ( (mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || + (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)) ) + { Object *ob = base->object; if (ob->transflag & OB_DUPLI) diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index 70bb2dbb5a2..728d0fb8561 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -145,7 +145,8 @@ bool KX_IpoSGController::Update(double currentTime) } //modifies position? - if (m_ipo_channels_active[OB_LOC_X] || m_ipo_channels_active[OB_LOC_Y] || m_ipo_channels_active[OB_LOC_Z] || m_ipo_channels_active[OB_DLOC_X] || m_ipo_channels_active[OB_DLOC_Y] || m_ipo_channels_active[OB_DLOC_Z]) + if (m_ipo_channels_active[OB_LOC_X] || m_ipo_channels_active[OB_LOC_Y] || m_ipo_channels_active[OB_LOC_Z] || + m_ipo_channels_active[OB_DLOC_X] || m_ipo_channels_active[OB_DLOC_Y] || m_ipo_channels_active[OB_DLOC_Z]) { if (m_ipo_as_force == true) { @@ -198,7 +199,9 @@ bool KX_IpoSGController::Update(double currentTime) } } //modifies orientation? - if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z] || m_ipo_channels_active[OB_DROT_X] || m_ipo_channels_active[OB_DROT_Y] || m_ipo_channels_active[OB_DROT_Z]) { + if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z] || + m_ipo_channels_active[OB_DROT_X] || m_ipo_channels_active[OB_DROT_Y] || m_ipo_channels_active[OB_DROT_Z]) + { if (m_ipo_as_force) { if (m_game_object && ob) { @@ -293,7 +296,9 @@ bool KX_IpoSGController::Update(double currentTime) } } //modifies scale? - if (m_ipo_channels_active[OB_SIZE_X] || m_ipo_channels_active[OB_SIZE_Y] || m_ipo_channels_active[OB_SIZE_Z] || m_ipo_channels_active[OB_DSIZE_X] || m_ipo_channels_active[OB_DSIZE_Y] || m_ipo_channels_active[OB_DSIZE_Z]) { + if (m_ipo_channels_active[OB_SIZE_X] || m_ipo_channels_active[OB_SIZE_Y] || m_ipo_channels_active[OB_SIZE_Z] || + m_ipo_channels_active[OB_DSIZE_X] || m_ipo_channels_active[OB_DSIZE_Y] || m_ipo_channels_active[OB_DSIZE_Z]) + { //default is no scale change MT_Vector3 newScale(1.0,1.0,1.0); if (!m_ipo_add) -- cgit v1.2.3 From 89db50a712358330a1794a83701881715dde6905 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 01:05:03 +0000 Subject: patch [#29534] Change Matrix Representation and Access in Python to Conform with Standard Notation from Andrew Hale Scripts which access matrix row/columns directly and scripts that create new matrices with elements defined will need updating. For more info see... * Guide for updating scripts http://wiki.blender.org/index.php/User:TrumanBlending/Matrix_Indexing * Discussion thread http://markmail.org/message/4bpqpxkcvq4wjyfu --- source/blender/python/mathutils/mathutils_Matrix.c | 98 ++++++++++++---------- source/tests/bl_pyapi_mathutils.py | 74 +++++++++++++--- 2 files changed, 119 insertions(+), 53 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 19675d2a863..de098ce8bd8 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -42,7 +42,7 @@ static PyObject *Matrix_copy(MatrixObject *self); static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value); static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObject *self); -/* matrix vector callbacks */ +/* matrix row callbacks */ int mathutils_matrix_vector_cb_index= -1; static int mathutils_matrix_vector_check(BaseMathObject *bmo) @@ -51,56 +51,56 @@ static int mathutils_matrix_vector_check(BaseMathObject *bmo) return BaseMath_ReadCallback(self); } -static int mathutils_matrix_vector_get(BaseMathObject *bmo, int col) +static int mathutils_matrix_vector_get(BaseMathObject *bmo, int row) { MatrixObject *self= (MatrixObject *)bmo->cb_user; - int row; + int col; if (BaseMath_ReadCallback(self) == -1) return -1; - for (row=0; row < self->num_row; row++) { - bmo->data[row] = MATRIX_ITEM(self, row, col); + for (col=0; col < self->num_col; col++) { + bmo->data[col] = MATRIX_ITEM(self, row, col); } return 0; } -static int mathutils_matrix_vector_set(BaseMathObject *bmo, int col) +static int mathutils_matrix_vector_set(BaseMathObject *bmo, int row) { MatrixObject *self= (MatrixObject *)bmo->cb_user; - int row; + int col; if (BaseMath_ReadCallback(self) == -1) return -1; - for (row=0; row < self->num_row; row++) { - MATRIX_ITEM(self, row, col) = bmo->data[row]; + for (col=0; col < self->num_col; col++) { + MATRIX_ITEM(self, row, col) = bmo->data[col]; } (void)BaseMath_WriteCallback(self); return 0; } -static int mathutils_matrix_vector_get_index(BaseMathObject *bmo, int col, int row) +static int mathutils_matrix_vector_get_index(BaseMathObject *bmo, int row, int col) { MatrixObject *self= (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; - bmo->data[row]= MATRIX_ITEM(self, row, col); + bmo->data[col]= MATRIX_ITEM(self, row, col); return 0; } -static int mathutils_matrix_vector_set_index(BaseMathObject *bmo, int col, int row) +static int mathutils_matrix_vector_set_index(BaseMathObject *bmo, int row, int col) { MatrixObject *self= (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; - MATRIX_ITEM(self, row, col) = bmo->data[row]; + MATRIX_ITEM(self, row, col) = bmo->data[col]; (void)BaseMath_WriteCallback(self); return 0; @@ -215,15 +215,19 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *arg= PyTuple_GET_ITEM(args, 0); + /* Input is now as a sequence of rows so length of sequence + * is the number of rows */ /* -1 is an error, size checks will accunt for this */ - const unsigned short num_col= PySequence_Size(arg); + const unsigned short num_row= PySequence_Size(arg); - if (num_col >= 2 && num_col <= 4) { + if (num_row >= 2 && num_row <= 4) { PyObject *item= PySequence_GetItem(arg, 0); - const unsigned short num_row= PySequence_Size(item); + /* Since each item is a row, number of items is the + * same as the number of columns */ + const unsigned short num_col= PySequence_Size(item); Py_XDECREF(item); - if (num_row >= 2 && num_row <= 4) { + if (num_col >= 2 && num_col <= 4) { /* sane row & col size, new matrix and assign as slice */ PyObject *matrix= Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, type); if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) { @@ -1364,13 +1368,13 @@ static PyObject *Matrix_repr(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - for (col = 0; col < self->num_col; col++) { - rows[col]= PyTuple_New(self->num_row); - for (row = 0; row < self->num_row; row++) { - PyTuple_SET_ITEM(rows[col], row, PyFloat_FromDouble(MATRIX_ITEM(self, row, col))); + for (row = 0; row < self->num_row; row++) { + rows[row]= PyTuple_New(self->num_col); + for (col = 0; col < self->num_col; col++) { + PyTuple_SET_ITEM(rows[row], col, PyFloat_FromDouble(MATRIX_ITEM(self, row, col))); } } - switch (self->num_col) { + switch (self->num_row) { case 2: return PyUnicode_FromFormat("Matrix((%R,\n" " %R))", rows[0], rows[1]); @@ -1468,44 +1472,48 @@ static PyObject* Matrix_richcmpr(PyObject *a, PyObject *b, int op) sequence length*/ static int Matrix_len(MatrixObject *self) { - return (self->num_col); + return (self->num_row); } /*----------------------------object[]--------------------------- sequence accessor (get) the wrapped vector gives direct access to the matrix data*/ -static PyObject *Matrix_item(MatrixObject *self, int i) +static PyObject *Matrix_item(MatrixObject *self, int row) { if (BaseMath_ReadCallback(self) == -1) return NULL; - if (i < 0 || i >= self->num_col) { + if (row < 0 || row >= self->num_row) { PyErr_SetString(PyExc_IndexError, "matrix[attribute]: " "array index out of range"); return NULL; } - return Vector_CreatePyObject_cb((PyObject *)self, self->num_row, mathutils_matrix_vector_cb_index, i); + return Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_vector_cb_index, row); } /*----------------------------object[]------------------------- sequence accessor (set) */ -static int Matrix_ass_item(MatrixObject *self, int i, PyObject *value) +static int Matrix_ass_item(MatrixObject *self, int row, PyObject *value) { + int col; float vec[4]; if (BaseMath_ReadCallback(self) == -1) return -1; - if (i >= self->num_col || i < 0) { + if (row >= self->num_row || row < 0) { PyErr_SetString(PyExc_IndexError, - "matrix[attribute] = x: bad column"); + "matrix[attribute] = x: bad row"); return -1; } - if (mathutils_array_parse(vec, self->num_row, self->num_row, value, "matrix[i] = value assignment") < 0) { + if (mathutils_array_parse(vec, self->num_col, self->num_col, value, "matrix[i] = value assignment") < 0) { return -1; } - memcpy(MATRIX_COL_PTR(self, i), vec, self->num_row * sizeof(float)); + /* Since we are assigning a row we cannot memcpy */ + for (col = 0; col < self->num_col; col++) { + MATRIX_ITEM(self, row, col) = vec[col]; + } (void)BaseMath_WriteCallback(self); return 0; @@ -1522,14 +1530,14 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) if (BaseMath_ReadCallback(self) == -1) return NULL; - CLAMP(begin, 0, self->num_col); - CLAMP(end, 0, self->num_col); + CLAMP(begin, 0, self->num_row); + CLAMP(end, 0, self->num_row); begin= MIN2(begin, end); tuple= PyTuple_New(end - begin); for (count= begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, - Vector_CreatePyObject_cb((PyObject *)self, self->num_row, mathutils_matrix_vector_cb_index, count)); + Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_vector_cb_index, count)); } @@ -1544,8 +1552,8 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va if (BaseMath_ReadCallback(self) == -1) return -1; - CLAMP(begin, 0, self->num_col); - CLAMP(end, 0, self->num_col); + CLAMP(begin, 0, self->num_row); + CLAMP(end, 0, self->num_row); begin = MIN2(begin, end); /* non list/tuple cases */ @@ -1555,8 +1563,9 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va } else { const int size= end - begin; - int i; + int row, col; float mat[16]; + float vec[4]; if (PySequence_Fast_GET_SIZE(value_fast) != size) { Py_DECREF(value_fast); @@ -1566,22 +1575,25 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va return -1; } + memcpy(mat, self->matrix, self->num_col * self->num_row * sizeof(float)); + /*parse sub items*/ - for (i = 0; i < size; i++) { + for (row = begin; row < end; row++) { /*parse each sub sequence*/ - PyObject *item= PySequence_Fast_GET_ITEM(value_fast, i); + PyObject *item= PySequence_Fast_GET_ITEM(value_fast, row - begin); - if (mathutils_array_parse(&mat[i * self->num_row], self->num_row, self->num_row, item, - "matrix[begin:end] = value assignment") < 0) - { + if (mathutils_array_parse(vec, self->num_col, self->num_col, item, "matrix[begin:end] = value assignment") < 0) return -1; + + for (col = 0; col < self->num_col; col++) { + mat[col * self->num_row + row] = vec[col]; } } Py_DECREF(value_fast); /*parsed well - now set in matrix*/ - memcpy(self->matrix + (begin * self->num_row), mat, sizeof(float) * (size * self->num_row)); + memcpy(self->matrix, mat, self->num_col * self->num_row * sizeof(float)); (void)BaseMath_WriteCallback(self); return 0; diff --git a/source/tests/bl_pyapi_mathutils.py b/source/tests/bl_pyapi_mathutils.py index f1d6d96c68b..b2e9f27d9ec 100644 --- a/source/tests/bl_pyapi_mathutils.py +++ b/source/tests/bl_pyapi_mathutils.py @@ -27,9 +27,9 @@ class MatrixTesting(unittest.TestCase): mat = Matrix(args) - for i in range(4): - for j in range(4): - self.assertEqual(mat[i][j], args[i][j]) + for row in range(4): + for col in range(4): + self.assertEqual(mat[row][col], args[row][col]) self.assertEqual(mat[0][2], 0) self.assertEqual(mat[3][1], 9) @@ -41,13 +41,13 @@ class MatrixTesting(unittest.TestCase): mat = Matrix() - Matrix() indices = (0, 0), (1, 3), (2, 0), (3, 2), (3, 1) checked_indices = [] - for col, row in indices: - mat[col][row] = 1 + for row, col in indices: + mat[row][col] = 1 - for col in range(4): - for row in range(4): - if mat[col][row]: - checked_indices.append((col, row)) + for row in range(4): + for col in range(4): + if mat[row][col]: + checked_indices.append((row, col)) for item in checked_indices: self.assertIn(item, indices) @@ -64,9 +64,63 @@ class MatrixTesting(unittest.TestCase): def test_matrix_to_translation(self): mat = Matrix() - mat[3] = (1, 2, 3, 4) + mat[0][3] = 1 + mat[1][3] = 2 + mat[2][3] = 3 self.assertEqual(mat.to_translation(), Vector((1, 2, 3))) + def test_matrix_translation(self): + mat = Matrix() + mat.translation = Vector((1, 2, 3)) + self.assertEqual(mat[0][3], 1) + self.assertEqual(mat[1][3], 2) + self.assertEqual(mat[2][3], 3) + + def test_non_square_mult(self): + mat1 = Matrix(((1, 2, 3), + (4, 5, 6))) + mat2 = Matrix(((1, 2), + (3, 4), + (5, 6))) + + prod_mat1 = Matrix(((22, 28), + (49, 64))) + prod_mat2 = Matrix(((9, 12, 15), + (19, 26, 33), + (29, 40, 51))) + + self.assertEqual(mat1*mat2, prod_mat1) + self.assertEqual(mat2 * mat1, prod_mat2) + + def test_mat4x4_vec3D_mult(self): + mat = Matrix(((1, 0, 2, 0), + (0, 6, 0, 0), + (0, 0, 1, 1), + (0, 0, 0, 1))) + + vec = Vector((1, 2, 3)) + + prod_mat_vec = Vector((7, 12, 4)) + prod_vec_mat = Vector((1, 12, 5)) + + self.assertEqual(mat * vec, prod_mat_vec) + self.assertEqual(vec * mat, prod_vec_mat) + + def test_mat_vec_mult(self): + mat1 = Matrix() + + vec = Vector((1, 2)) + + self.assertRaises(TypeError, mat1.__mul__, vec) + self.assertRaises(ValueError, vec.__mul__, mat1) # Why are these different?! + + mat2 = Matrix(((1, 2), + (-2, 3))) + + prod = Vector((5, 4)) + + self.assertEqual(mat2 * vec, prod) + def test_matrix_inverse(self): mat = Matrix(((1, 4, 0, -1), (2, -1, 2, -2), -- cgit v1.2.3 From e7fb276e294e35697cc8ae2c866f72c74bbb230a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 03:56:21 +0000 Subject: picky edits - use "" for non enum strings. --- release/scripts/startup/bl_operators/clip.py | 19 +++++++------ release/scripts/startup/bl_operators/sequencer.py | 8 +++--- .../startup/bl_operators/uvcalc_smart_project.py | 2 +- release/scripts/startup/bl_operators/wm.py | 33 +++++++++++----------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index 061c66dc1fa..cb21f17cff5 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -188,7 +188,7 @@ class CLIP_OT_delete_proxy(Operator): proxydir = clip.proxy.directory else: clipdir = os.path.dirname(clip.filepath) - proxydir = os.path.join(clipdir, 'BL_proxy') + proxydir = os.path.join(clipdir, "BL_proxy") clipfile = os.path.basename(clip.filepath) proxy = os.path.join(proxydir, clipfile) @@ -196,15 +196,15 @@ class CLIP_OT_delete_proxy(Operator): # proxy_[_undostorted] for x in (25, 50, 75, 100): - d = os.path.join(absproxy, 'proxy_' + str(x)) + d = os.path.join(absproxy, "proxy_%d" % x) self._rmproxy(d) - self._rmproxy(d + '_undistorted') - self._rmproxy(os.path.join(absproxy, 'proxy_' + str(x) + '.avi')) + self._rmproxy(d + "_undistorted") + self._rmproxy(os.path.join(absproxy, "proxy_%d.avi" % x)) - tc = ('free_run.blen_tc', - 'interp_free_run.blen_tc', - 'record_run.blen_tc') + tc = ("free_run.blen_tc", + "interp_free_run.blen_tc", + "record_run.blen_tc") for x in tc: self._rmproxy(os.path.join(absproxy, x)) @@ -269,7 +269,7 @@ object's movement caused by this constraint""" # TODO: several camera solvers and track followers would fail, # but can't think about eal workflow where it'll be useful for x in ob.constraints: - if x.type in ('CAMERA_SOLVER', 'FOLLOW_TRACK'): + if x.type in {'CAMERA_SOLVER', 'FOLLOW_TRACK'}: con = x if not con: @@ -340,7 +340,8 @@ object's movement caused by this constraint""" def execute(self, context): scene = context.scene - + # XXX, should probably use context.selected_editable_objects + # since selected objects can be from a lib or in hidden layer! for ob in scene.objects: if ob.select: self._bake_object(scene, ob) diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py index 67b9be59f2a..39c73f20664 100644 --- a/release/scripts/startup/bl_operators/sequencer.py +++ b/release/scripts/startup/bl_operators/sequencer.py @@ -60,14 +60,14 @@ class SequencerCrossfadeSounds(Operator): if seq1.frame_final_end > seq2.frame_final_start: tempcfra = context.scene.frame_current context.scene.frame_current = seq2.frame_final_start - seq1.keyframe_insert('volume') + seq1.keyframe_insert("volume") context.scene.frame_current = seq1.frame_final_end seq1.volume = 0 - seq1.keyframe_insert('volume') - seq2.keyframe_insert('volume') + seq1.keyframe_insert("volume") + seq2.keyframe_insert("volume") context.scene.frame_current = seq2.frame_final_start seq2.volume = 0 - seq2.keyframe_insert('volume') + seq2.keyframe_insert("volume") context.scene.frame_current = tempcfra return {'FINISHED'} else: diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 17e353ff238..b79fc0c01b3 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -756,7 +756,7 @@ def VectoQuat(vec): class thickface(object): - __slost__= 'v', 'uv', 'no', 'area', 'edge_keys' + __slost__= "v", "uv", "no", "area", "edge_keys" def __init__(self, face, uvface, mesh_verts): self.v = [mesh_verts[i] for i in face.vertices] if len(self.v)==4: diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index ec58b3aecd1..4f498e72f4b 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -766,12 +766,12 @@ class WM_OT_path_open(Operator): return {'CANCELLED'} if sys.platform[:3] == "win": - subprocess.Popen(['start', filepath], shell=True) - elif sys.platform == 'darwin': - subprocess.Popen(['open', filepath]) + subprocess.Popen(["start", filepath], shell=True) + elif sys.platform == "darwin": + subprocess.Popen(["open", filepath]) else: try: - subprocess.Popen(['xdg-open', filepath]) + subprocess.Popen(["xdg-open", filepath]) except OSError: # xdg-open *should* be supported by recent Gnome, KDE, Xfce pass @@ -847,8 +847,8 @@ class WM_OT_doc_edit(Operator): print("sending data:", data_dict) import xmlrpc.client - user = 'blenderuser' - pwd = 'blender>user' + user = "blenderuser" + pwd = "blender>user" docblog = xmlrpc.client.ServerProxy(self._url) docblog.metaWeblog.newPost(1, user, pwd, data_dict, 1) @@ -986,9 +986,8 @@ class WM_OT_properties_edit(Operator): prop_ui = rna_idprop_ui_prop_get(item, prop) if prop_type in {float, int}: - - prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.min) - prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.max) + prop_ui["soft_min"] = prop_ui["min"] = prop_type(self.min) + prop_ui["soft_max"] = prop_ui["max"] = prop_type(self.max) prop_ui['description'] = self.description @@ -1035,7 +1034,7 @@ class WM_OT_properties_add(Operator): item = eval("context.%s" % data_path) def unique_name(names): - prop = 'prop' + prop = "prop" prop_new = prop i = 1 while prop_new in names: @@ -1163,10 +1162,10 @@ class WM_OT_copy_prev_settings(Operator): # in 2.57 and earlier windows installers, system scripts were copied # into the configuration directory, don't want to copy those - system_script = os.path.join(path_dst, 'scripts/modules/bpy_types.py') + system_script = os.path.join(path_dst, "scripts/modules/bpy_types.py") if os.path.isfile(system_script): - shutil.rmtree(os.path.join(path_dst, 'scripts')) - shutil.rmtree(os.path.join(path_dst, 'plugins')) + shutil.rmtree(os.path.join(path_dst, "scripts")) + shutil.rmtree(os.path.join(path_dst, "plugins")) # don't loose users work if they open the splash later. if bpy.data.is_saved is bpy.data.is_dirty is False: @@ -1185,13 +1184,13 @@ class WM_OT_blenderplayer_start(bpy.types.Operator): blender_bin_path = bpy.app.binary_path blender_bin_dir = os.path.dirname(blender_bin_path) ext = os.path.splitext(blender_bin_path)[-1] - player_path = os.path.join(blender_bin_dir, 'blenderplayer' + ext) + player_path = os.path.join(blender_bin_dir, "blenderplayer" + ext) def execute(self, context): import sys - if sys.platform == 'darwin': - self.player_path = os.path.join(self.blender_bin_dir, '../../../blenderplayer.app/Contents/MacOS/blenderplayer') + if sys.platform == "darwin": + self.player_path = os.path.join(self.blender_bin_dir, "../../../blenderplayer.app/Contents/MacOS/blenderplayer") filepath = bpy.app.tempdir + "game.blend" bpy.ops.wm.save_as_mainfile(filepath=filepath, check_existing=False, copy=True) @@ -1451,7 +1450,7 @@ class WM_OT_operator_cheat_sheet(Operator): for op_submodule_name in dir(op_module): op = getattr(op_module, op_submodule_name) text = repr(op) - if text.split("\n")[-1].startswith('bpy.ops.'): + if text.split("\n")[-1].startswith("bpy.ops."): op_strings.append(text) tot += 1 -- cgit v1.2.3 From 4537061e55b95324a39962bc9d88a4485fb650b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 05:39:23 +0000 Subject: patch [#29673] Visualize Indices (developer aid) by Howard Trickey (howardt) --- release/scripts/startup/bl_ui/space_view3d.py | 2 ++ source/blender/editors/space_view3d/drawobject.c | 43 ++++++++++++++++++++++++ source/blender/makesdna/DNA_mesh_types.h | 3 ++ source/blender/makesrna/intern/rna_mesh.c | 5 +++ 4 files changed, 53 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 57bde4eb0dd..46a569c71d4 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2247,6 +2247,8 @@ class VIEW3D_PT_view3d_meshdisplay(Panel): col.prop(mesh, "show_extra_edge_length") col.prop(mesh, "show_extra_face_angle") col.prop(mesh, "show_extra_face_area") + if bpy.app.debug: + col.prop(mesh, "show_extra_indices") class VIEW3D_PT_view3d_curvedisplay(Panel): diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 3199c00a32a..eb6f50b932f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2793,6 +2793,44 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, } } +static void draw_em_indices(EditMesh *em) +{ + EditEdge *e; + EditFace *f; + EditVert *v; + int i; + char val[32]; + float pos[3]; + unsigned char col[4]; + + /* For now, reuse appropriate theme colors from stats text colors */ + + UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); + for (v = em->verts.first, i = 0; v; v = v->next, i++) { + if (v->f & SELECT) { + sprintf(val, "%d", i); + view3d_cached_text_draw_add(v->co, val, 0, V3D_CACHE_TEXT_ASCII, col); + } + } + + UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); + for (e = em->edges.first, i = 0; e; e = e->next, i++) { + if (e->f & SELECT) { + sprintf(val, "%d", i); + mid_v3_v3v3(pos, e->v1->co, e->v2->co); + view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col); + } + } + + UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); + for (f = em->faces.first, i = 0; f; f = f->next, i++) { + if (f->f & SELECT) { + sprintf(val, "%d", i); + view3d_cached_text_draw_add(f->cent, val, 0, V3D_CACHE_TEXT_ASCII, col); + } + } +} + static int draw_em_fancy__setFaceOpts(void *UNUSED(userData), int index, int *UNUSED(drawSmooth_r)) { EditFace *efa = EM_get_face_for_index(index); @@ -2968,6 +3006,11 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, { draw_em_measure_stats(v3d, rv3d, ob, em, &scene->unit); } + + if ((G.f & G_DEBUG) && (me->drawflag & ME_DRAWEXTRA_INDICES) && + !(v3d->flag2 & V3D_RENDER_OVERRIDE)) { + draw_em_indices(em); + } } if(dt>OB_WIRE) { diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 7d57e2c295c..f8062aeccc7 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -162,6 +162,9 @@ typedef struct TFace { #define ME_DRAWEXTRA_FACEAREA (1 << 11) #define ME_DRAWEXTRA_FACEANG (1 << 12) +/* debug only option */ +#define ME_DRAWEXTRA_INDICES (1 << 13) + /* old global flags: #define G_DRAWEDGES (1 << 18) #define G_DRAWFACES (1 << 7) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 02be3183f2c..f6e958ab1f5 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -2132,6 +2132,11 @@ static void rna_def_mesh(BlenderRNA *brna) "Display the area of selected faces, using global values when set in the transform panel"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + prop= RNA_def_property(srna, "show_extra_indices", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_INDICES); + RNA_def_property_ui_text(prop, "Indices", "Displays the index numbers of selected vertices, edges, and faces"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + /* editflag */ prop= RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_X); -- cgit v1.2.3 From f9cf67a5f35b363ea528afb607dede7a647e3540 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 05:52:31 +0000 Subject: remove commented index drawing code (now its a debug option), and remove code in editmesh stat drawing which was left over from when text drawing was immediate rather then cached. --- source/blender/editors/space_view3d/drawobject.c | 28 ++---------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index eb6f50b932f..e40fe6176a3 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2626,8 +2626,7 @@ static void draw_em_fancy_edges(Scene *scene, View3D *v3d, } } -static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, - Object *ob, EditMesh *em, UnitSettings *unit) +static void draw_em_measure_stats(View3D *v3d, Object *ob, EditMesh *em, UnitSettings *unit) { Mesh *me= ob->data; EditEdge *eed; @@ -2650,11 +2649,6 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, else if (grid < 1.0f) conv_float= "%.4g"; else if (grid < 10.0f) conv_float= "%.3g"; else conv_float= "%.2g"; - - if(v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT)==0) - glDisable(GL_DEPTH_TEST); - - if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0f); if(me->drawflag & ME_DRAWEXTRA_EDGELEN) { UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); @@ -2773,24 +2767,6 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, } } } - - /* useful for debugging index vs shape key index */ -#if 0 - { - EditVert *eve; - int j; - UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); - for(eve= em->verts.first, j= 0; eve; eve= eve->next, j++) { - sprintf(val, "%d:%d", j, eve->keyindex); - view3d_cached_text_draw_add(eve->co, val, 0, V3D_CACHE_TEXT_ASCII, col); - } - } -#endif - - if(v3d->zbuf) { - glEnable(GL_DEPTH_TEST); - bglPolygonOffset(rv3d->dist, 0.0f); - } } static void draw_em_indices(EditMesh *em) @@ -3004,7 +2980,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, if ( (me->drawflag & (ME_DRAWEXTRA_EDGELEN|ME_DRAWEXTRA_FACEAREA|ME_DRAWEXTRA_FACEANG)) && !(v3d->flag2 & V3D_RENDER_OVERRIDE)) { - draw_em_measure_stats(v3d, rv3d, ob, em, &scene->unit); + draw_em_measure_stats(v3d, ob, em, &scene->unit); } if ((G.f & G_DEBUG) && (me->drawflag & ME_DRAWEXTRA_INDICES) && -- cgit v1.2.3 From c9f1ca961aaedfce52cfd9608b4a908087b8b3ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 08:44:08 +0000 Subject: fix for matrix assignment with recent changes which broke for eg: ob.matrix_world = matrix --- source/blender/python/intern/bpy_rna_array.c | 69 ++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index 1d1cab1c66d..2a4c004d84c 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -36,6 +36,12 @@ #include "RNA_access.h" +#define USE_MATHUTILS + +#ifdef USE_MATHUTILS +# include "../mathutils/mathutils.h" /* so we can have mathutils callbacks */ +#endif + #define MAX_ARRAY_DIMENSION 10 typedef void (*ItemConvertFunc)(PyObject *, char *); @@ -259,10 +265,47 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, /* validate type first because length validation may modify property array length */ - if (validate_array_type(rvalue, lvalue_dim, totdim, dimsize, check_item_type, item_type_str, error_prefix) == -1) - return -1; - return validate_array_length(rvalue, ptr, prop, lvalue_dim, totitem, error_prefix); +#ifdef USE_MATHUTILS + if (lvalue_dim == 0) { /* only valid for first level array */ + if (MatrixObject_Check(rvalue)) { + MatrixObject *pymat= (MatrixObject *)rvalue; + + if (BaseMath_ReadCallback(pymat) == -1) + return -1; + + if (RNA_property_type(prop) != PROP_FLOAT) { + PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign to non float array", + error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop)); + return -1; + } + else if (totdim != 2) { + PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign array with %d dimensions", + error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), totdim); + return -1; + } + else if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) { + PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign dimension size mismatch, " + "is %dx%d, expected be %dx%d", + error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), + pymat->num_col, pymat->num_row, dimsize[0], dimsize[1]); + return -1; + } + else { + *totitem= dimsize[0] * dimsize[1]; + return 0; + } + } + } +#endif /* USE_MATHUTILS */ + + + { + if (validate_array_type(rvalue, lvalue_dim, totdim, dimsize, check_item_type, item_type_str, error_prefix) == -1) + return -1; + + return validate_array_length(rvalue, ptr, prop, lvalue_dim, totitem, error_prefix); + } } static char *copy_value_single(PyObject *item, PointerRNA *ptr, PropertyRNA *prop, @@ -305,6 +348,26 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, return NULL; } + +#ifdef USE_MATHUTILS + if (dim == 0) { + if (MatrixObject_Check(seq)) { + MatrixObject *pymat= (MatrixObject *)seq; + size_t allocsize= pymat->num_col * pymat->num_row * sizeof(float); + + /* read callback already done by validate */ + /* since this is the first iteration we can assume data is allocated */ + memcpy(data, pymat->matrix, allocsize); + + /* not really needed but do for completeness */ + data += allocsize; + + return data; + } + } +#endif /* USE_MATHUTILS */ + + for (i= 0; i < seq_size; i++) { PyObject *item= PySequence_GetItem(seq, i); if (item) { -- cgit v1.2.3 From 24400eab283dc9c88285c91fe3da801c562e4966 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 11:06:41 +0000 Subject: update axis conversion for recent matrix changes --- release/scripts/modules/bpy_extras/io_utils.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index 90f0d3f1c1d..38fdb8f5fec 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -121,24 +121,24 @@ _axis_convert_matrix = ( ((-1.0, 0.0, 0.0), (0.0, 0.0, 1.0), (0.0, 1.0, 0.0)), ((-1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, -1.0)), ((0.0, -1.0, 0.0), (-1.0, 0.0, 0.0), (0.0, 0.0, -1.0)), - ((0.0, -1.0, 0.0), (0.0, 0.0, -1.0), (1.0, 0.0, 0.0)), - ((0.0, -1.0, 0.0), (0.0, 0.0, 1.0), (-1.0, 0.0, 0.0)), - ((0.0, -1.0, 0.0), (1.0, 0.0, 0.0), (0.0, 0.0, 1.0)), + ((0.0, 0.0, 1.0), (-1.0, 0.0, 0.0), (0.0, -1.0, 0.0)), ((0.0, 0.0, -1.0), (-1.0, 0.0, 0.0), (0.0, 1.0, 0.0)), + ((0.0, 1.0, 0.0), (-1.0, 0.0, 0.0), (0.0, 0.0, 1.0)), + ((0.0, -1.0, 0.0), (0.0, 0.0, 1.0), (-1.0, 0.0, 0.0)), ((0.0, 0.0, -1.0), (0.0, -1.0, 0.0), (-1.0, 0.0, 0.0)), - ((0.0, 0.0, -1.0), (0.0, 1.0, 0.0), (1.0, 0.0, 0.0)), - ((0.0, 0.0, -1.0), (1.0, 0.0, 0.0), (0.0, -1.0, 0.0)), - ((0.0, 0.0, 1.0), (-1.0, 0.0, 0.0), (0.0, -1.0, 0.0)), - ((0.0, 0.0, 1.0), (0.0, -1.0, 0.0), (1.0, 0.0, 0.0)), ((0.0, 0.0, 1.0), (0.0, 1.0, 0.0), (-1.0, 0.0, 0.0)), - ((0.0, 0.0, 1.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0)), - ((0.0, 1.0, 0.0), (-1.0, 0.0, 0.0), (0.0, 0.0, 1.0)), ((0.0, 1.0, 0.0), (0.0, 0.0, -1.0), (-1.0, 0.0, 0.0)), + ((0.0, -1.0, 0.0), (0.0, 0.0, -1.0), (1.0, 0.0, 0.0)), + ((0.0, 0.0, 1.0), (0.0, -1.0, 0.0), (1.0, 0.0, 0.0)), + ((0.0, 0.0, -1.0), (0.0, 1.0, 0.0), (1.0, 0.0, 0.0)), ((0.0, 1.0, 0.0), (0.0, 0.0, 1.0), (1.0, 0.0, 0.0)), + ((0.0, -1.0, 0.0), (1.0, 0.0, 0.0), (0.0, 0.0, 1.0)), + ((0.0, 0.0, -1.0), (1.0, 0.0, 0.0), (0.0, -1.0, 0.0)), + ((0.0, 0.0, 1.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0)), ((0.0, 1.0, 0.0), (1.0, 0.0, 0.0), (0.0, 0.0, -1.0)), ((1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, -1.0)), - ((1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, 1.0, 0.0)), ((1.0, 0.0, 0.0), (0.0, 0.0, 1.0), (0.0, -1.0, 0.0)), + ((1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, 1.0, 0.0)), ) # store args as a single int -- cgit v1.2.3 From 4045b466769f1dfed21e8fb260b02959a69de659 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 22 Dec 2011 14:04:25 +0000 Subject: Some small perf tweaks to weightvg proximity: do not use indices in case all vertices are affected... --- .../modifiers/intern/MOD_weightvgproximity.c | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index f67fd907d02..8e0949f2a22 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -399,29 +399,37 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der MEM_freeN(tdw); return dm; } - indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGProximity Modifier, indices"); - memcpy(indices, tidx, sizeof(int) * numIdx); - org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, org_w"); + if(numIdx != numVerts) { + indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGProximity Modifier, indices"); + memcpy(indices, tidx, sizeof(int) * numIdx); + org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, org_w"); + memcpy(org_w, tw, sizeof(float) * numIdx); + dw = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGProximity Modifier, dw"); + memcpy(dw, tdw, sizeof(MDeformWeight*) * numIdx); + MEM_freeN(tw); + MEM_freeN(tdw); + } + else { + org_w = tw; + dw = tdw; + } new_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, new_w"); - memcpy(org_w, tw, sizeof(float) * numIdx); - dw = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGProximity Modifier, dw"); - memcpy(dw, tdw, sizeof(MDeformWeight*) * numIdx); MEM_freeN(tidx); - MEM_freeN(tw); - MEM_freeN(tdw); /* Get our vertex coordinates. */ - { + v_cos = MEM_mallocN(sizeof(float[3]) * numIdx, "WeightVGProximity Modifier, v_cos"); + if(numIdx != numVerts) { /* XXX In some situations, this code can be up to about 50 times more performant * than simply using getVertCo for each affected vertex... */ float (*tv_cos)[3] = MEM_mallocN(sizeof(float[3]) * numVerts, "WeightVGProximity Modifier, tv_cos"); - v_cos = MEM_mallocN(sizeof(float[3]) * numIdx, "WeightVGProximity Modifier, v_cos"); dm->getVertCos(dm, tv_cos); for (i = 0; i < numIdx; i++) copy_v3_v3(v_cos[i], tv_cos[indices[i]]); MEM_freeN(tv_cos); } + else + dm->getVertCos(dm, v_cos); /* Compute wanted distances. */ if (wmd->proximity_mode == MOD_WVG_PROXIMITY_OBJECT) { @@ -497,7 +505,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der MEM_freeN(org_w); MEM_freeN(new_w); MEM_freeN(dw); - MEM_freeN(indices); + if(indices) + MEM_freeN(indices); MEM_freeN(v_cos); #if DO_PROFILE -- cgit v1.2.3 From e06a0ba2bb22814392848d0cc7e9f00764e81fce Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 22 Dec 2011 16:00:34 +0000 Subject: Fix/workaround for russian ui crash on exit Crash was caused by data segment corruption near "string" in view3d_modeselect_pup(). Enlarged size of this static buffer, so it's now enough to store translated modeselect string. It's not actually fixes because in some other language this modeline might be much longer and it'll lead to corruptions again. --- source/blender/editors/space_view3d/view3d_header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 762fc51a34e..315da0423d1 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -276,7 +276,7 @@ static int modeselect_addmode(char *str, const char *title, int id, int icon) static char *view3d_modeselect_pup(Scene *scene) { Object *ob= OBACT; - static char string[256]; + static char string[512]; const char *title= IFACE_("Mode: %t"); char *str = string; -- cgit v1.2.3 From 39fd8fa4002391b24d6154ba5489cf1a5a05f5bd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 22 Dec 2011 18:25:59 +0000 Subject: Translation context for RNA properties This commit implements a way to define context of property which is used by localization stuff and which is needed to resolve translation context when some word wit the same english spelling is used in different meanings (like Manual in meaning of tutorial, and Manual in meaning of something is setting up by hand). To define property's context there's a function RNA_def_property_translation_context. If property doesn't have context, regular BLF_gettext function is used to get translation of property name, otherwise BLF_pgettext is used for this. Hence, for correct translation, messages in .po files should be marked by "msgctxt" context, otherwise property with context declared wouldn't be translated at all. Toolchain scripts from bf-translation project would be updated soon. If context for some values of enumerator property, property itself should be moved to other context and all items from this enum would be moved to this context automatically (it's impossible to move one few items to another context). P.S. Think context like "BRUSH" or "MODIFIER" are preferable than "NOUN" and "VERB" because in some cases the same english noun used in different areas better be translated differently to make translation more native. --- source/blender/blenfont/BLF_translation.h | 5 ++- source/blender/blenfont/intern/blf_lang.c | 9 ++--- source/blender/blenfont/intern/blf_translation.c | 45 +++++++++++++++++++++- source/blender/makesrna/RNA_define.h | 2 + source/blender/makesrna/intern/makesrna.c | 1 + source/blender/makesrna/intern/rna_access.c | 16 ++++++-- source/blender/makesrna/intern/rna_define.c | 5 +++ .../blender/makesrna/intern/rna_internal_types.h | 2 + source/blender/makesrna/intern/rna_rna.c | 19 +++++++++ 9 files changed, 93 insertions(+), 11 deletions(-) diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index ddbc9a6a760..ce53b76da01 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -33,6 +33,8 @@ #ifndef BLF_TRANSLATION_H #define BLF_TRANSLATION_H +#define TEXT_DOMAIN_NAME "blender" + /* blf_translation.c */ #ifdef WITH_INTERNATIONAL @@ -40,7 +42,8 @@ unsigned char *BLF_get_unifont(int *unifont_size); void BLF_free_unifont(void); #endif -const char* BLF_gettext(const char *msgid); +const char *BLF_gettext(const char *msgid); +const char *BLF_pgettext(const char *context, const char *message); /* blf_lang.c */ diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 77f9542883c..430780b19a0 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -58,7 +58,6 @@ #include "BLI_utildefines.h" #include "BLI_path_util.h" -#define DOMAIN_NAME "blender" #define SYSTEM_ENCODING_DEFAULT "UTF-8" #define FONT_SIZE_DEFAULT 12 @@ -205,15 +204,15 @@ void BLF_lang_set(const char *str) setlocale(LC_NUMERIC, "C"); - textdomain(DOMAIN_NAME); - bindtextdomain(DOMAIN_NAME, global_messagepath); - bind_textdomain_codeset(DOMAIN_NAME, global_encoding_name); + textdomain(TEXT_DOMAIN_NAME); + bindtextdomain(TEXT_DOMAIN_NAME, global_messagepath); + bind_textdomain_codeset(TEXT_DOMAIN_NAME, global_encoding_name); } void BLF_lang_encoding(const char *str) { BLI_strncpy(global_encoding_name, str, sizeof(global_encoding_name)); - /* bind_textdomain_codeset(DOMAIN_NAME, encoding_name); */ + /* bind_textdomain_codeset(TEXT_DOMAIN_NAME, encoding_name); */ } #else /* ! WITH_INTERNATIONAL */ diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index fe14f5d4d1c..1d82abcf32d 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -29,9 +29,19 @@ */ #include +#include #ifdef WITH_INTERNATIONAL #include +#include + +#define GETTEXT_CONTEXT_GLUE "\004" + +/* needed for windows version of gettext */ +#ifndef LC_MESSAGES +# define LC_MESSAGES 1729 +#endif + #endif #include "MEM_guardedalloc.h" @@ -91,6 +101,40 @@ const char* BLF_gettext(const char *msgid) #endif } +const char *BLF_pgettext(const char *context, const char *message) +{ +#ifdef WITH_INTERNATIONAL + char static_msg_ctxt_id[1024]; + char *dynamic_msg_ctxt_id = NULL; + char *msg_ctxt_id; + const char *translation; + + size_t overall_length = strlen(context) + strlen(message) + sizeof(GETTEXT_CONTEXT_GLUE) + 1; + + if (overall_length > sizeof(static_msg_ctxt_id)) { + dynamic_msg_ctxt_id = malloc(overall_length); + msg_ctxt_id = dynamic_msg_ctxt_id; + } + else { + msg_ctxt_id = static_msg_ctxt_id; + } + + sprintf(msg_ctxt_id, "%s%s%s", context, GETTEXT_CONTEXT_GLUE, message); + + translation = (char*)dcgettext(TEXT_DOMAIN_NAME, msg_ctxt_id, LC_MESSAGES); + + if (dynamic_msg_ctxt_id) + free(dynamic_msg_ctxt_id); + + if (translation == msg_ctxt_id) + translation = message; + + return translation; +#else + return message; +#endif +} + int BLF_translate_iface(void) { #ifdef WITH_INTERNATIONAL @@ -132,4 +176,3 @@ const char *BLF_translate_do_tooltip(const char *msgid) return msgid; #endif } - diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 8e8dd559fb1..4fb08227fb6 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -175,6 +175,8 @@ void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, con void RNA_def_property_srna(PropertyRNA *prop, const char *type); void RNA_def_py_data(PropertyRNA *prop, void *py_data); +void RNA_def_property_translation_context(PropertyRNA *prop, const char *context); + /* Function */ FunctionRNA *RNA_def_function(StructRNA *srna, const char *identifier, const char *call); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index fbe9ed33063..90e68058d36 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2229,6 +2229,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_print_c_string(f, prop->name); fprintf(f, ",\n\t"); rna_print_c_string(f, prop->description); fprintf(f, ",\n\t"); fprintf(f, "%d,\n", prop->icon); + rna_print_c_string(f, prop->translation_context); fprintf(f, ",\n\t"); fprintf(f, "\t%s, %s|%s, %s, %u, {%u, %u, %u}, %u,\n", RNA_property_typename(prop->type), rna_property_subtypename(prop->subtype), rna_property_subtype_unit(prop->subtype), rna_function_string(prop->getlength), prop->arraydimension, prop->arraylength[0], prop->arraylength[1], prop->arraylength[2], prop->totarraylength); fprintf(f, "\t%s%s, %d, %s, %s,\n", (prop->flag & PROP_CONTEXT_UPDATE)? "(UpdateFunc)": "", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable), rna_function_string(prop->itemeditable)); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 56edfef8aa1..c50e233c43f 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -486,8 +486,12 @@ static const char *rna_ensure_property_name(PropertyRNA *prop) name= ((IDProperty*)prop)->name; #ifdef WITH_INTERNATIONAL - if((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_IFACE)) - name= BLF_gettext(name); + if((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_IFACE)) { + if(prop->translation_context) + name = BLF_pgettext(prop->translation_context, name); + else + name = BLF_gettext(name); + } #endif return name; @@ -1194,8 +1198,12 @@ void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA } for(i=0; nitem[i].identifier; i++) { - if( nitem[i].name ) - nitem[i].name = BLF_gettext(nitem[i].name); + if( nitem[i].name ) { + if(prop->translation_context) + nitem[i].name = BLF_pgettext(prop->translation_context, nitem[i].name); + else + nitem[i].name = BLF_gettext(nitem[i].name); + } if( nitem[i].description ) nitem[i].description = BLF_gettext(nitem[i].description); } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index e55559c39dc..caf43793996 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1824,6 +1824,11 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, } } +void RNA_def_property_translation_context(PropertyRNA *prop, const char *context) +{ + prop->translation_context= context; +} + /* Functions */ void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable) diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 960d3155fd5..40157d390bc 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -147,6 +147,8 @@ struct PropertyRNA { const char *description; /* icon ID */ int icon; + /* context for translation */ + const char *translation_context; /* property type as it appears to the outside */ PropertyType type; diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 9a141dde3db..676d5f2c44f 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -465,6 +465,20 @@ static int rna_Property_description_length(PointerRNA *ptr) return prop->description ? strlen(prop->description) : 0; } +static void rna_Property_translation_context_get(PointerRNA *ptr, char *value) +{ + PropertyRNA *prop= (PropertyRNA*)ptr->data; + rna_idproperty_check(&prop, ptr); + strcpy(value, prop->translation_context ? prop->translation_context:""); +} + +static int rna_Property_translation_context_length(PointerRNA *ptr) +{ + PropertyRNA *prop= (PropertyRNA*)ptr->data; + rna_idproperty_check(&prop, ptr); + return prop->translation_context ? strlen(prop->translation_context) : 0; +} + static int rna_Property_type_get(PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; @@ -1047,6 +1061,11 @@ static void rna_def_property(BlenderRNA *brna) RNA_def_property_string_funcs(prop, "rna_Property_description_get", "rna_Property_description_length", NULL); RNA_def_property_ui_text(prop, "Description", "Description of the property for tooltips"); + prop= RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_Property_translation_context_get", "rna_Property_translation_context_length", NULL); + RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the property"); + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, property_type_items); -- cgit v1.2.3 From 3563f677f88baf7b1f68d7f435787e3bf4a20d24 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 22 Dec 2011 19:09:21 +0000 Subject: Fix #29494: Problem loading translations at Blender's startup Problem was caused by trying to set locale to short named "es" locale which failed. It's not really obvious which full locale name should be used here (there are plenty of dialects), so rather than keeping locale stuff on state when both of locale and utf-8 locale names failed, restore default settings (restore environment variables and use default locale for gettext). This will resolve cases when spanish language is native on the system, but it will fail in cases when somebody will want to have spanish interface in non-spanish system. This might be worked around by setting LANG and LANGUAGE environment variables to es_.UTF-8 and it should work fine, --- source/blender/blenfont/intern/blf_lang.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 430780b19a0..71e4fba94f6 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -189,6 +189,12 @@ void BLF_lang_set(const char *str) if (locreturn == NULL) { printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8); + + /* fallback to default settings */ + locreturn= setlocale(LC_ALL, ""); + BLI_setenv("LANG", default_locale); + BLI_setenv("LANGUAGE", default_locale); + ok= 0; } -- cgit v1.2.3 From 4d7c44717aa67671518431183d38dab5d2a7a3dd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 22 Dec 2011 20:29:44 +0000 Subject: Code cleanup: fix some clang static checker warnings. --- intern/iksolver/intern/IK_Solver.cpp | 3 ++- intern/mikktspace/mikktspace.c | 1 - intern/opennl/intern/opennl.c | 2 +- intern/opennl/superlu/get_perm_c.c | 18 +++++++++--------- intern/opennl/superlu/scolumn_bmod.c | 1 - intern/opennl/superlu/strsv.c | 13 ------------- intern/opennl/superlu/sutil.c | 4 ---- intern/opennl/superlu/util.h | 3 ++- source/blender/blenkernel/intern/depsgraph.c | 15 ++++++--------- source/blender/blenkernel/intern/fcurve.c | 5 +---- source/blender/blenkernel/intern/movieclip.c | 4 ++-- source/blender/blenkernel/intern/subsurf_ccg.c | 3 +++ source/blender/blenkernel/intern/tracking.c | 4 ++-- source/blender/editors/animation/anim_channels_edit.c | 2 +- source/blender/editors/animation/anim_filter.c | 2 +- source/blender/gpu/intern/gpu_codegen.c | 8 ++------ source/blender/gpu/intern/gpu_draw.c | 2 +- source/blender/gpu/intern/gpu_material.c | 1 - .../render/intern/raytrace/rayobject_octree.cpp | 2 +- source/blender/render/intern/source/convertblender.c | 10 +++------- source/blender/render/intern/source/pixelshading.c | 1 - source/blender/render/intern/source/rayshade.c | 2 +- source/blender/render/intern/source/renderdatabase.c | 6 ++---- source/blender/render/intern/source/shadeoutput.c | 2 -- source/blender/render/intern/source/strand.c | 1 - source/blender/render/intern/source/volumetric.c | 4 +--- 26 files changed, 41 insertions(+), 78 deletions(-) diff --git a/intern/iksolver/intern/IK_Solver.cpp b/intern/iksolver/intern/IK_Solver.cpp index af49b07d064..3876f26362c 100644 --- a/intern/iksolver/intern/IK_Solver.cpp +++ b/intern/iksolver/intern/IK_Solver.cpp @@ -225,11 +225,12 @@ void IK_SetStiffness(IK_Segment *seg, IK_SegmentAxis axis, float stiffness) void IK_GetBasisChange(IK_Segment *seg, float basis_change[][3]) { IK_QSegment *qseg = (IK_QSegment*)seg; - const MT_Matrix3x3& change = qseg->BasisChange(); if (qseg->Translational() && qseg->Composite()) qseg = qseg->Composite(); + const MT_Matrix3x3& change = qseg->BasisChange(); + // convert from moto row major to blender column major basis_change[0][0] = (float)change[0][0]; basis_change[1][0] = (float)change[0][1]; diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c index ff857e82d8f..2036e601bcb 100644 --- a/intern/mikktspace/mikktspace.c +++ b/intern/mikktspace/mikktspace.c @@ -1350,7 +1350,6 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con for(s=0; snb_rhs; j++, b+=n, x+=n) { /* Create superlu array for B */ diff --git a/intern/opennl/superlu/get_perm_c.c b/intern/opennl/superlu/get_perm_c.c index 2eb0aea678e..320fe3471f4 100644 --- a/intern/opennl/superlu/get_perm_c.c +++ b/intern/opennl/superlu/get_perm_c.c @@ -368,7 +368,7 @@ get_perm_c(int ispec, SuperMatrix *A, int *perm_c) int m, n, bnz, *b_colptr, i; int delta, maxint, nofsub, *invp; int *b_rowind, *dhead, *qsize, *llist, *marker; - double t, SuperLU_timer_(); + /* double t, SuperLU_timer_(); */ /* make gcc happy */ b_rowind=NULL; @@ -377,7 +377,7 @@ get_perm_c(int ispec, SuperMatrix *A, int *perm_c) m = A->nrow; n = A->ncol; - t = SuperLU_timer_(); + /* t = SuperLU_timer_(); */ switch ( ispec ) { case 0: /* Natural ordering */ for (i = 0; i < n; ++i) perm_c[i] = i; @@ -391,8 +391,8 @@ get_perm_c(int ispec, SuperMatrix *A, int *perm_c) #if ( PRNTlevel>=1 ) printf("Use minimum degree ordering on A'*A.\n"); #endif - t = SuperLU_timer_() - t; - /*printf("Form A'*A time = %8.3f\n", t);*/ + /*t = SuperLU_timer_() - t; + printf("Form A'*A time = %8.3f\n", t);*/ break; case 2: /* Minimum degree ordering on A'+A */ if ( m != n ) ABORT("Matrix is not square"); @@ -401,8 +401,8 @@ get_perm_c(int ispec, SuperMatrix *A, int *perm_c) #if ( PRNTlevel>=1 ) printf("Use minimum degree ordering on A'+A.\n"); #endif - t = SuperLU_timer_() - t; - /*printf("Form A'+A time = %8.3f\n", t);*/ + /*t = SuperLU_timer_() - t; + printf("Form A'+A time = %8.3f\n", t);*/ break; case 3: /* Approximate minimum degree column ordering. */ get_colamd(m, n, Astore->nnz, Astore->colptr, Astore->rowind, @@ -417,7 +417,7 @@ get_perm_c(int ispec, SuperMatrix *A, int *perm_c) } if ( bnz != 0 ) { - t = SuperLU_timer_(); + /* t = SuperLU_timer_(); */ /* Initialize and allocate storage for GENMMD. */ delta = 1; /* DELTA is a parameter to allow the choice of nodes @@ -452,8 +452,8 @@ get_perm_c(int ispec, SuperMatrix *A, int *perm_c) SUPERLU_FREE(llist); SUPERLU_FREE(marker); - t = SuperLU_timer_() - t; - /* printf("call GENMMD time = %8.3f\n", t);*/ + /* t = SuperLU_timer_() - t; + printf("call GENMMD time = %8.3f\n", t);*/ } else { /* Empty adjacency structure */ for (i = 0; i < n; ++i) perm_c[i] = i; diff --git a/intern/opennl/superlu/scolumn_bmod.c b/intern/opennl/superlu/scolumn_bmod.c index cb8d83686be..3d4f5968778 100644 --- a/intern/opennl/superlu/scolumn_bmod.c +++ b/intern/opennl/superlu/scolumn_bmod.c @@ -303,7 +303,6 @@ scolumn_bmod ( d_fsupc=0 if fsupc >= fpanelc. */ d_fsupc = fst_col - fsupc; - lptr = xlsub[fsupc] + d_fsupc; luptr = xlusup[fst_col] + d_fsupc; nsupr = xlsub[fsupc+1] - xlsub[fsupc]; /* Leading dimension */ nsupc = jcol - fst_col; /* Excluding jcol */ diff --git a/intern/opennl/superlu/strsv.c b/intern/opennl/superlu/strsv.c index a1d66ed7341..da904ba3e9d 100644 --- a/intern/opennl/superlu/strsv.c +++ b/intern/opennl/superlu/strsv.c @@ -9,9 +9,6 @@ int strsv_(char *, char *, char *, int *, float *, int *, float *, int *); { - /* System generated locals */ - int i__1, i__2; - /* Local variables */ static int info; static float temp; @@ -213,14 +210,12 @@ int strsv_(char *, char *, char *, int *, float *, int *, float *, int *); } } else { if (*incx == 1) { - i__1 = *n; for (j = 1; j <= *n; ++j) { if (X(j) != 0.f) { if (nounit) { X(j) /= A(j,j); } temp = X(j); - i__2 = *n; for (i = j + 1; i <= *n; ++i) { X(i) -= temp * A(i,j); /* L50: */ @@ -230,7 +225,6 @@ int strsv_(char *, char *, char *, int *, float *, int *, float *, int *); } } else { jx = kx; - i__1 = *n; for (j = 1; j <= *n; ++j) { if (X(jx) != 0.f) { if (nounit) { @@ -238,7 +232,6 @@ int strsv_(char *, char *, char *, int *, float *, int *, float *, int *); } temp = X(jx); ix = jx; - i__2 = *n; for (i = j + 1; i <= *n; ++i) { ix += *incx; X(ix) -= temp * A(i,j); @@ -256,10 +249,8 @@ int strsv_(char *, char *, char *, int *, float *, int *, float *, int *); if (lsame_(uplo, "U")) { if (*incx == 1) { - i__1 = *n; for (j = 1; j <= *n; ++j) { temp = X(j); - i__2 = j - 1; for (i = 1; i <= j-1; ++i) { temp -= A(i,j) * X(i); /* L90: */ @@ -272,11 +263,9 @@ int strsv_(char *, char *, char *, int *, float *, int *, float *, int *); } } else { jx = kx; - i__1 = *n; for (j = 1; j <= *n; ++j) { temp = X(jx); ix = kx; - i__2 = j - 1; for (i = 1; i <= j-1; ++i) { temp -= A(i,j) * X(ix); ix += *incx; @@ -294,7 +283,6 @@ int strsv_(char *, char *, char *, int *, float *, int *, float *, int *); if (*incx == 1) { for (j = *n; j >= 1; --j) { temp = X(j); - i__1 = j + 1; for (i = *n; i >= j+1; --i) { temp -= A(i,j) * X(i); /* L130: */ @@ -311,7 +299,6 @@ int strsv_(char *, char *, char *, int *, float *, int *, float *, int *); for (j = *n; j >= 1; --j) { temp = X(jx); ix = kx; - i__1 = j + 1; for (i = *n; i >= j+1; --i) { temp -= A(i,j) * X(ix); ix -= *incx; diff --git a/intern/opennl/superlu/sutil.c b/intern/opennl/superlu/sutil.c index 510ade8233c..a77e87b9c65 100644 --- a/intern/opennl/superlu/sutil.c +++ b/intern/opennl/superlu/sutil.c @@ -370,8 +370,6 @@ void sFillRHS(trans_t trans, int nrhs, float *x, int ldx, SuperMatrix *A, SuperMatrix *B) { - NCformat *Astore; - float *Aval; DNformat *Bstore; float *rhs; float one = 1.0; @@ -379,8 +377,6 @@ sFillRHS(trans_t trans, int nrhs, float *x, int ldx, int ldc; char transc[1]; - Astore = A->Store; - Aval = (float *) Astore->nzval; Bstore = B->Store; rhs = Bstore->nzval; ldc = Bstore->lda; diff --git a/intern/opennl/superlu/util.h b/intern/opennl/superlu/util.h index f13108b2256..c4c478cec2b 100644 --- a/intern/opennl/superlu/util.h +++ b/intern/opennl/superlu/util.h @@ -24,7 +24,8 @@ #define NUM_TEMPV(m,w,t,b) ( SUPERLU_MAX(m, (t + b)*w) ) #ifndef USER_ABORT -#define USER_ABORT(msg) superlu_abort_and_exit(msg) +#define USER_ABORT(msg) \ + { fprintf(stderr, "%s", msg); exit (-1); } #endif #define ABORT(err_msg) \ diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 4eaf49dc679..e17566b7d55 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1704,7 +1704,7 @@ static void scene_sort_groups(Main *bmain, Scene *sce) /* sort the base list on dependency order */ void DAG_scene_sort(Main *bmain, Scene *sce) { - DagNode *node; + DagNode *node, *rootnode; DagNodeQueue *nqueue; DagAdjList *itA; int time; @@ -1726,11 +1726,10 @@ void DAG_scene_sort(Main *bmain, Scene *sce) time = 1; - node = sce->theDag->DagNode.first; - - node->color = DAG_GRAY; + rootnode = sce->theDag->DagNode.first; + rootnode->color = DAG_GRAY; time++; - push_stack(nqueue,node); + push_stack(nqueue,rootnode); while(nqueue->count) { @@ -2848,10 +2847,8 @@ void DAG_pose_sort(Object *ob) for(node = dag->DagNode.first; node; node= node->next) node->color = DAG_WHITE; - node = dag->DagNode.first; - - node->color = DAG_GRAY; - push_stack(nqueue, node); + rootnode->color = DAG_GRAY; + push_stack(nqueue, rootnode); while(nqueue->count) { diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index b9947c506d1..318165af804 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1414,10 +1414,7 @@ void driver_free_variable (ChannelDriver *driver, DriverVar *dvar) DRIVER_TARGETS_LOOPER_END /* remove the variable from the driver */ - if (driver) - BLI_freelinkN(&driver->variables, dvar); - else - MEM_freeN(dvar); + BLI_freelinkN(&driver->variables, dvar); #ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 736c889f66c..7b2cfd46d33 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -988,9 +988,9 @@ void unlink_movieclip(Main *bmain, MovieClip *clip) } for(ob= bmain->object.first; ob; ob= ob->id.next) { - bConstraint *con= ob->constraints.first; + bConstraint *con; - for (con= ob->constraints.first; con; con= con->next) { + for(con= ob->constraints.first; con; con= con->next) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); if(cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) { diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 374ef3512e8..e773eb6dd35 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2292,6 +2292,9 @@ static int ccgdm_adjacent_grid(CCGSubSurf *ss, int *gridOffset, CCGFace *f, int break; } } + + if(numEdges == 0) + return -1; fIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(ss, adjf)); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 83adfa12236..04e8c3df077 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1288,8 +1288,8 @@ int BKE_tracking_next(MovieTrackingContext *context) MEM_freeN(image_new); } - coords_correct= !isnan(x2) && !isnan(y2) && finite(x2) && finite(y2); - if(coords_correct && !onbound && (tracked || !context->disable_failed)) { + coords_correct= !onbound && !isnan(x2) && !isnan(y2) && finite(x2) && finite(y2); + if(coords_correct && (tracked || !context->disable_failed)) { if(context->first_time) { #pragma omp critical { diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 8c699c840dc..a21c394a81e 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -496,7 +496,7 @@ void ANIM_flush_setting_anim_channels (bAnimContext *ac, ListBase *anim_data, bA break; /* store this level as the 'old' level now */ - prevLevel= level; // XXX: prevLevel is unused + // prevLevel= level; // XXX: prevLevel is unused } } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index fe6aed77462..45b715c406a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -2205,12 +2205,12 @@ size_t ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_m /* only filter data if there's somewhere to put it */ if (data && anim_data) { - Object *obact= (ac) ? ac->obact : NULL; /* firstly filter the data */ switch (datatype) { case ANIMCONT_ACTION: /* 'Action Editor' */ { + Object *obact= ac->obact; SpaceAction *saction = (SpaceAction *)ac->sl; bDopeSheet *ads = (saction)? &saction->ads : NULL; diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 33796b7c215..7182bbc38e2 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -538,12 +538,8 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final BLI_dynstr_appendf(ds, ", gl_TexCoord[%d].st", input->texid); } else if (input->source == GPU_SOURCE_TEX_PIXEL) { - if (input->link && input->link->output) - codegen_convert_datatype(ds, input->link->output->type, input->type, - "tmp", input->link->output->id); - else - codegen_convert_datatype(ds, input->link->output->type, input->type, - "tex", input->texid); + codegen_convert_datatype(ds, input->link->output->type, input->type, + "tmp", input->link->output->id); } else if(input->source == GPU_SOURCE_BUILTIN) BLI_dynstr_appendf(ds, "%s", GPU_builtin_name(input->builtin)); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 2dcce996065..5d36ba169f3 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1069,7 +1069,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O /* setting do_alpha_after = 1 indicates this object needs to be * drawn in a second alpha pass for improved blending */ - if(GMS.use_alpha_pass && !GMS.is_alpha_pass) + if(do_alpha_after && !GMS.is_alpha_pass) if(ELEM3(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU_BLEND_ALPHA_SORT)) *do_alpha_after= 1; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 250ea51f8c8..fb1d10b5491 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -972,7 +972,6 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "mtex_mapping_ofs", texco, GPU_uniform(ofs), &texco); talpha = 0; - rgbnor = 0; if(tex && tex->type == TEX_IMAGE && tex->ima) { GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser), &tin, &trgb); diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp index 20202319d44..14b4a7bcf9f 100644 --- a/source/blender/render/intern/raytrace/rayobject_octree.cpp +++ b/source/blender/render/intern/raytrace/rayobject_octree.cpp @@ -978,7 +978,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) } xo=ocx1; yo=ocy1; zo=ocz1; - labdao= ddalabda= MIN3(labdax,labday,labdaz); + ddalabda= MIN3(labdax,labday,labdaz); vec2[0]= ox1; vec2[1]= oy1; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 78f2fe6171b..122b47016eb 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -592,7 +592,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen { MemArena *arena= NULL; VertexTangent **vtangents= NULL; - int a, iCalcNewMethod; + int a; if(do_nmap_tangent) { arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "nmap tangent arena"); @@ -680,8 +680,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen } } - iCalcNewMethod = 1; - if(iCalcNewMethod!=0 && do_nmap_tangent!=0) + if(do_nmap_tangent!=0) { SRenderMeshToTangent mesh2tangent; SMikkTSpaceContext sContext; @@ -701,11 +700,9 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen sInterface.m_getNormal = GetNormal; sInterface.m_setTSpaceBasic = SetTSpace; - // 0 if failed - iCalcNewMethod = genTangSpaceDefault(&sContext); + genTangSpaceDefault(&sContext); } - if(arena) BLI_memarena_free(arena); if(vtangents) @@ -1068,7 +1065,6 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par mul_v3_fl(cross, width); } - else width= 1.0f; if(ma->mode & MA_TANGENT_STR) flag= R_SMOOTH|R_TANGENT; diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index b62484a6995..f261ec41746 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -176,7 +176,6 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) if(inprspotbl && lar->spotbl!=0.0f) { /* soft area */ diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index b8c4b05de50..41bfcb55068 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -2010,7 +2010,7 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) samples++; - if (qsa->type == SAMP_TYPE_HALTON) { + if (qsa && qsa->type == SAMP_TYPE_HALTON) { /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */ if (adapt_thresh > 0.0f && (samples > max_samples/2) ) { diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 25575fa965f..43761be9d71 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1026,7 +1026,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0); yn= tin*mtex->colfac; - zn= tin*mtex->alphafac; + //zn= tin*mtex->alphafac; if(mtex->mapto & MAP_COL) { zn= 1.0f-yn; @@ -1112,10 +1112,8 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater if(ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc; if(ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec; - if((ma->mode & MA_HALOTEX) && ma->mtex[0]){ + if((ma->mode & MA_HALOTEX) && ma->mtex[0]) har->tex= 1; - i=1; - } for(i=0; imtex[i] && (ma->septex & (1<flippednor) { startco = last_is->start; endco = shi->co; - intersect_type = VOL_BOUNDS_SS; } /* trace to find a backface, the other side bounds of the volume */ /* (ray intersect ignores front faces here) */ - else if (vol_get_bounds(shi, shi->co, shi->view, hitco, &is, intersect_type)) { + else if (vol_get_bounds(shi, shi->co, shi->view, hitco, &is, VOL_BOUNDS_DEPTH)) { startco = shi->co; endco = hitco; } -- cgit v1.2.3 From 3c480e85e356fd097e614088ddd12ef608991d17 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 21:44:52 +0000 Subject: update the api changelog 2.60 --> 2.61 --- doc/python_api/rst/change_log.rst | 637 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 637 insertions(+) diff --git a/doc/python_api/rst/change_log.rst b/doc/python_api/rst/change_log.rst index d332c4faff4..5de7bb49e1c 100644 --- a/doc/python_api/rst/change_log.rst +++ b/doc/python_api/rst/change_log.rst @@ -1480,3 +1480,640 @@ Added * :class:`bpy.types.SceneGameData.restrict_animation_updates` * :class:`bpy.types.SceneGameData.show_obstacle_simulation` + +2.60 to 2.61 +============ + +bpy.types.BlendDataGroups +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataGroups.is_updated` + +bpy.types.BlendDataBrushes +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataBrushes.is_updated` + +bpy.types.Theme +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Theme.clip_editor` + +bpy.types.BlendData +------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendData.movieclips` + +bpy.types.BlendDataGreasePencils +-------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataGreasePencils.is_updated` + +bpy.types.BlendDataImages +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataImages.is_updated` + +bpy.types.CompositorNodes +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodes.clear` + +bpy.types.BlendDataScenes +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataScenes.is_updated` + +bpy.types.RenderEngine +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.RenderEngine.bl_use_shading_nodes` +* :class:`bpy.types.RenderEngine.is_animation` +* :class:`bpy.types.RenderEngine.is_preview` +* :class:`bpy.types.RenderEngine.tag_redraw` +* :class:`bpy.types.RenderEngine.tag_update` +* :class:`bpy.types.RenderEngine.update` +* :class:`bpy.types.RenderEngine.update_progress` +* :class:`bpy.types.RenderEngine.view_draw` +* :class:`bpy.types.RenderEngine.view_update` + +bpy.types.BackgroundImage +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BackgroundImage.clip` +* :class:`bpy.types.BackgroundImage.clip_user` +* :class:`bpy.types.BackgroundImage.show_background_image` +* :class:`bpy.types.BackgroundImage.source` +* :class:`bpy.types.BackgroundImage.use_camera_clip` + +bpy.types.BlendDataMetaBalls +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataMetaBalls.is_updated` + +bpy.types.SpaceTimeline +----------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceTimeline.cache_dynamicpaint` + +bpy.types.BlendDataMeshes +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataMeshes.is_updated` + +bpy.types.BlendDataNodeTrees +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataNodeTrees.is_updated` + +bpy.types.RenderSettings +------------------------ + +Added +^^^^^ + +* :class:`bpy.types.RenderSettings.image_settings` +* :class:`bpy.types.RenderSettings.use_shading_nodes` + +Removed +^^^^^^^ + +* **cineon_black** +* **cineon_gamma** +* **cineon_white** +* **color_mode** +* **exr_codec** +* **exr_preview** +* **exr_zbuf** +* **file_format** +* **file_quality** +* **jpeg2k_depth** +* **jpeg2k_preset** +* **jpeg2k_ycc** +* **use_cineon_log** +* **use_exr_half** +* **use_tiff_16bit** + +bpy.types.Curve +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Curve.cycles` + +bpy.types.RegionView3D +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.RegionView3D.view_camera_offset` +* :class:`bpy.types.RegionView3D.view_camera_zoom` + +bpy.types.Scene +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Scene.active_clip` +* :class:`bpy.types.Scene.cycles` + +bpy.types.NodeLinks +------------------- + +Added +^^^^^ + +* :class:`bpy.types.NodeLinks.clear` + +bpy.types.BlendDataLattices +--------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataLattices.is_updated` + +bpy.types.BlendDataParticles +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataParticles.is_updated` + +bpy.types.BlendDataWorlds +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataWorlds.is_updated` + +bpy.types.ObjectConstraints +--------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ObjectConstraints.clear` + +bpy.types.RenderLayers +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.RenderLayers.new` +* :class:`bpy.types.RenderLayers.remove` + +bpy.types.Menu +-------------- + +Added +^^^^^ + +* :class:`bpy.types.Menu.bl_description` + +bpy.types.Lamp +-------------- + +Added +^^^^^ + +* :class:`bpy.types.Lamp.cycles` +* :class:`bpy.types.Lamp.node_tree` +* :class:`bpy.types.Lamp.use_nodes` + +bpy.types.CurveSplines +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.CurveSplines.clear` + +bpy.types.Screen +---------------- + +Added +^^^^^ + +* :class:`bpy.types.Screen.use_play_clip_editors` + +bpy.types.BlendDataActions +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataActions.is_updated` + +bpy.types.BlendDataSounds +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataSounds.is_updated` + +bpy.types.Object +---------------- + +Added +^^^^^ + +* :class:`bpy.types.Object.cycles_visibility` +* :class:`bpy.types.Object.slow_parent_offset` + +Removed +^^^^^^^ + +* **time_offset** +* **use_time_offset_add_parent** +* **use_time_offset_edit** +* **use_time_offset_parent** +* **use_time_offset_particle** + +bpy.types.ObjectModifiers +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ObjectModifiers.clear` + +bpy.types.BlendDataMaterials +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataMaterials.is_updated` + +bpy.types.MetaBallElements +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.MetaBallElements.clear` + +bpy.types.NodeSocket +-------------------- + +Added +^^^^^ + +* :class:`bpy.types.NodeSocket.group_socket` +* :class:`bpy.types.NodeSocket.show_expanded` + +bpy.types.Node +-------------- + +Added +^^^^^ + +* :class:`bpy.types.Node.show_texture` + +bpy.types.CompositorNodeOutputFile +---------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeOutputFile.image_settings` + +Removed +^^^^^^^ + +* **exr_codec** +* **image_type** +* **quality** +* **use_exr_half** + +bpy.types.BlendDataTexts +------------------------ + +Added +^^^^^ + +* :class:`bpy.types.BlendDataTexts.is_updated` + +bpy.types.ThemeView3D +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.ThemeView3D.bundle_solid` +* :class:`bpy.types.ThemeView3D.camera_path` + +bpy.types.Event +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Event.unicode` + +bpy.types.VertexGroups +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.VertexGroups.clear` + +bpy.types.TexMapping +-------------------- + +Added +^^^^^ + +* :class:`bpy.types.TexMapping.mapping` +* :class:`bpy.types.TexMapping.mapping_x` +* :class:`bpy.types.TexMapping.mapping_y` +* :class:`bpy.types.TexMapping.mapping_z` + +bpy.types.BlendDataObjects +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataObjects.is_updated` + +bpy.types.BlendDataCurves +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataCurves.is_updated` + +bpy.types.BlendDataLibraries +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataLibraries.is_updated` + +bpy.types.ThemeUserInterface +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ThemeUserInterface.icon_alpha` +* :class:`bpy.types.ThemeUserInterface.panel` + +bpy.types.SpaceNodeEditor +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceNodeEditor.shader_type` + +bpy.types.SpaceView3D +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceView3D.show_bundle_names` +* :class:`bpy.types.SpaceView3D.show_camera_path` +* :class:`bpy.types.SpaceView3D.show_reconstruction` +* :class:`bpy.types.SpaceView3D.tracks_draw_size` +* :class:`bpy.types.SpaceView3D.tracks_draw_type` + +bpy.types.BlendDataWindowManagers +--------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataWindowManagers.is_updated` + +bpy.types.BlendDataScreens +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataScreens.is_updated` + +bpy.types.BlendDataArmatures +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataArmatures.is_updated` + +bpy.types.UserPreferencesInput +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.UserPreferencesInput.tweak_threshold` + +Removed +^^^^^^^ + +* **ndof_orbit_invert_axes** + +bpy.types.Mesh +-------------- + +Added +^^^^^ + +* :class:`bpy.types.Mesh.cycles` + +bpy.types.BlendDataCameras +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataCameras.is_updated` + +bpy.types.MetaBall +------------------ + +Added +^^^^^ + +* :class:`bpy.types.MetaBall.cycles` + +bpy.types.UILayout +------------------ + +Added +^^^^^ + +* :class:`bpy.types.UILayout.template_image_settings` +* :class:`bpy.types.UILayout.template_marker` +* :class:`bpy.types.UILayout.template_movieclip` +* :class:`bpy.types.UILayout.template_node_link` +* :class:`bpy.types.UILayout.template_node_view` +* :class:`bpy.types.UILayout.template_texture_user` +* :class:`bpy.types.UILayout.template_track` + +Function Arguments +^^^^^^^^^^^^^^^^^^ + +* :class:`bpy.types.UILayout.template_list` (data, property, active_data, active_property, prop_list, rows, maxrows, type), *was (data, property, active_data, active_property, rows, maxrows, type)* + +bpy.types.ID +------------ + +Added +^^^^^ + +* :class:`bpy.types.ID.is_updated` +* :class:`bpy.types.ID.is_updated_data` + +bpy.types.World +--------------- + +Added +^^^^^ + +* :class:`bpy.types.World.cycles` +* :class:`bpy.types.World.node_tree` +* :class:`bpy.types.World.use_nodes` + +bpy.types.BlendDataTextures +--------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataTextures.is_updated` + +bpy.types.ShaderNodes +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.ShaderNodes.clear` + +bpy.types.TimelineMarkers +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.TimelineMarkers.clear` + +bpy.types.SpaceFileBrowser +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceFileBrowser.active_operator` + +bpy.types.Material +------------------ + +Added +^^^^^ + +* :class:`bpy.types.Material.cycles` + +bpy.types.BlendDataSpeakers +--------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataSpeakers.is_updated` + +bpy.types.Camera +---------------- + +Added +^^^^^ + +* :class:`bpy.types.Camera.angle_x` +* :class:`bpy.types.Camera.angle_y` +* :class:`bpy.types.Camera.cycles` +* :class:`bpy.types.Camera.sensor_fit` +* :class:`bpy.types.Camera.sensor_height` +* :class:`bpy.types.Camera.sensor_width` +* :class:`bpy.types.Camera.show_sensor` + +bpy.types.BlendDataLamps +------------------------ + +Added +^^^^^ + +* :class:`bpy.types.BlendDataLamps.is_updated` + +bpy.types.TextureNodes +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.TextureNodes.clear` + +bpy.types.BlendDataFonts +------------------------ + +Added +^^^^^ + +* :class:`bpy.types.BlendDataFonts.is_updated` -- cgit v1.2.3 From e68f0ff3c0d5f580aaf0e4ec2b278be3c0875ba5 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 22 Dec 2011 22:34:23 +0000 Subject: Another Fix after Cucumber Merge: * Cycles did not displayed the Scene panels anymore, due to addition of COMPAT_ENGINE to them. --- intern/cycles/blender/addon/ui.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 24f3de6e859..6e73795666e 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -745,6 +745,12 @@ def get_panels(): bpy.types.RENDER_PT_encoding, bpy.types.RENDER_PT_dimensions, bpy.types.RENDER_PT_stamp, + bpy.types.SCENE_PT_scene, + bpy.types.SCENE_PT_audio, + bpy.types.SCENE_PT_unit, + bpy.types.SCENE_PT_keying_sets, + bpy.types.SCENE_PT_keying_set_paths, + bpy.types.SCENE_PT_physics, bpy.types.WORLD_PT_context_world, bpy.types.DATA_PT_context_mesh, bpy.types.DATA_PT_context_camera, -- cgit v1.2.3 From cb61a71ff66d2f29a60ac0407d9936c8c99c6a33 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Dec 2011 23:18:43 +0000 Subject: DNA genfile - de-duplicate some checks and replace magic type numbers with an enum --- source/blender/makesdna/DNA_genfile.h | 16 ++- source/blender/makesdna/intern/dna_genfile.c | 140 +++++++++++++++------------ source/blender/makesdna/intern/makesdna.c | 21 ++-- 3 files changed, 106 insertions(+), 71 deletions(-) diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h index 4f8b2343a9f..1ca669836ac 100644 --- a/source/blender/makesdna/DNA_genfile.h +++ b/source/blender/makesdna/DNA_genfile.h @@ -38,6 +38,19 @@ struct SDNA; extern unsigned char DNAstr[]; /* DNA.c */ extern int DNAlen; +typedef enum eSDNA_Type { + SDNA_TYPE_CHAR = 0, + SDNA_TYPE_UCHAR = 1, + SDNA_TYPE_SHORT = 2, + SDNA_TYPE_USHORT = 3, + SDNA_TYPE_INT = 4, + SDNA_TYPE_LONG = 5, + SDNA_TYPE_ULONG = 6, + SDNA_TYPE_FLOAT = 7, + SDNA_TYPE_DOUBLE = 8 + /* ,SDNA_TYPE_VOID = 9 */ /* nothing uses yet */ +} eSDNA_Type; + struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap); void DNA_sdna_free(struct SDNA *sdna); @@ -49,6 +62,7 @@ void *DNA_struct_reconstruct(struct SDNA *newsdna, struct SDNA *oldsdna, char *c int DNA_elem_array_size(const char *astr, int len); int DNA_elem_offset(struct SDNA *sdna, const char *stype, const char *vartype, const char *name); -#endif +int DNA_elem_type_size(const eSDNA_Type elem_nr); +#endif diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 0dba78ff97e..88b6fa65370 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -655,90 +655,80 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna) return compflags; } -static void cast_elem(char *ctype, char *otype, const char *name, char *curdata, char *olddata) +static eSDNA_Type sdna_type_nr(const char *dna_type) +{ + if ((strcmp(dna_type, "char")==0) || (strcmp(dna_type, "const char")==0)) return SDNA_TYPE_CHAR; + else if((strcmp(dna_type, "uchar")==0) || (strcmp(dna_type, "unsigned char")==0)) return SDNA_TYPE_UCHAR; + else if( strcmp(dna_type, "short")==0) return SDNA_TYPE_SHORT; + else if((strcmp(dna_type, "ushort")==0)||(strcmp(dna_type, "unsigned short")==0)) return SDNA_TYPE_USHORT; + else if( strcmp(dna_type, "int")==0) return SDNA_TYPE_INT; + else if( strcmp(dna_type, "long")==0) return SDNA_TYPE_LONG; + else if((strcmp(dna_type, "ulong")==0)||(strcmp(dna_type, "unsigned long")==0)) return SDNA_TYPE_ULONG; + else if( strcmp(dna_type, "float")==0) return SDNA_TYPE_FLOAT; + else if( strcmp(dna_type, "double")==0) return SDNA_TYPE_DOUBLE; + else return -1; /* invalid! */ +} + +static void cast_elem(const char *ctype, const char *otype, const char *name, char *curdata, char *olddata) { double val = 0.0; - int arrlen, curlen=1, oldlen=1, ctypenr, otypenr; - + int arrlen, curlen=1, oldlen=1; + + eSDNA_Type ctypenr, otypenr; + arrlen= DNA_elem_array_size(name, strlen(name)); - - /* define otypenr */ - if(strcmp(otype, "char")==0 || (strcmp(otype, "const char")==0)) otypenr= 0; - else if((strcmp(otype, "uchar")==0) || (strcmp(otype, "unsigned char")==0)) otypenr= 1; - else if(strcmp(otype, "short")==0) otypenr= 2; - else if((strcmp(otype, "ushort")==0)||(strcmp(otype, "unsigned short")==0)) otypenr= 3; - else if(strcmp(otype, "int")==0) otypenr= 4; - else if(strcmp(otype, "long")==0) otypenr= 5; - else if((strcmp(otype, "ulong")==0)||(strcmp(otype, "unsigned long")==0)) otypenr= 6; - else if(strcmp(otype, "float")==0) otypenr= 7; - else if(strcmp(otype, "double")==0) otypenr= 8; - else return; - - /* define ctypenr */ - if(strcmp(ctype, "char")==0) ctypenr= 0; - else if(strcmp(ctype, "const char")==0) ctypenr= 0; - else if((strcmp(ctype, "uchar")==0)||(strcmp(ctype, "unsigned char")==0)) ctypenr= 1; - else if(strcmp(ctype, "short")==0) ctypenr= 2; - else if((strcmp(ctype, "ushort")==0)||(strcmp(ctype, "unsigned short")==0)) ctypenr= 3; - else if(strcmp(ctype, "int")==0) ctypenr= 4; - else if(strcmp(ctype, "long")==0) ctypenr= 5; - else if((strcmp(ctype, "ulong")==0)||(strcmp(ctype, "unsigned long")==0)) ctypenr= 6; - else if(strcmp(ctype, "float")==0) ctypenr= 7; - else if(strcmp(ctype, "double")==0) ctypenr= 8; - else return; + + if ( (otypenr= sdna_type_nr(otype)) == -1 || + (ctypenr= sdna_type_nr(ctype)) == -1 ) + { + return; + } /* define lengths */ - if(otypenr < 2) oldlen= 1; - else if(otypenr < 4) oldlen= 2; - else if(otypenr < 8) oldlen= 4; - else oldlen= 8; - - if(ctypenr < 2) curlen= 1; - else if(ctypenr < 4) curlen= 2; - else if(ctypenr < 8) curlen= 4; - else curlen= 8; - + oldlen= DNA_elem_type_size(otypenr); + curlen= DNA_elem_type_size(ctypenr); + while(arrlen>0) { switch(otypenr) { - case 0: + case SDNA_TYPE_CHAR: val= *olddata; break; - case 1: + case SDNA_TYPE_UCHAR: val= *( (unsigned char *)olddata); break; - case 2: + case SDNA_TYPE_SHORT: val= *( (short *)olddata); break; - case 3: + case SDNA_TYPE_USHORT: val= *( (unsigned short *)olddata); break; - case 4: + case SDNA_TYPE_INT: val= *( (int *)olddata); break; - case 5: + case SDNA_TYPE_LONG: val= *( (int *)olddata); break; - case 6: + case SDNA_TYPE_ULONG: val= *( (unsigned int *)olddata); break; - case 7: + case SDNA_TYPE_FLOAT: val= *( (float *)olddata); break; - case 8: + case SDNA_TYPE_DOUBLE: val= *( (double *)olddata); break; } switch(ctypenr) { - case 0: + case SDNA_TYPE_CHAR: *curdata= val; break; - case 1: + case SDNA_TYPE_UCHAR: *( (unsigned char *)curdata)= val; break; - case 2: + case SDNA_TYPE_SHORT: *( (short *)curdata)= val; break; - case 3: + case SDNA_TYPE_USHORT: *( (unsigned short *)curdata)= val; break; - case 4: + case SDNA_TYPE_INT: *( (int *)curdata)= val; break; - case 5: + case SDNA_TYPE_LONG: *( (int *)curdata)= val; break; - case 6: + case SDNA_TYPE_ULONG: *( (unsigned int *)curdata)= val; break; - case 7: + case SDNA_TYPE_FLOAT: if(otypenr<2) val/= 255; *( (float *)curdata)= val; break; - case 8: + case SDNA_TYPE_DOUBLE: if(otypenr<2) val/= 255; *( (double *)curdata)= val; break; } @@ -838,7 +828,8 @@ static char *find_elem(SDNA *sdna, const char *type, const char *name, short *ol return NULL; } -static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, const char *name, char *curdata, short *old, char *olddata) +static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, + char *type, const char *name, char *curdata, short *old, char *olddata) { /* rules: test for NAME: - name equal: @@ -912,7 +903,8 @@ static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, const cha } } -static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna, char *compflags, int oldSDNAnr, char *data, int curSDNAnr, char *cur) +static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna, + char *compflags, int oldSDNAnr, char *data, int curSDNAnr, char *cur) { /* Recursive! * Per element from cur_struct, read data from old_struct. @@ -1054,7 +1046,9 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) } else { - if( spc[0]==2 || spc[0]==3 ) { /* short-ushort */ + if ( spc[0]==SDNA_TYPE_SHORT || + spc[0]==SDNA_TYPE_USHORT ) + { /* exception: variable called blocktype/ipowin: derived from ID_ */ skip= 0; @@ -1076,7 +1070,11 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) } } } - else if(spc[0]>3 && spc[0]<8) { /* int-long-ulong-float */ + else if ( (spc[0]==SDNA_TYPE_INT || + spc[0]==SDNA_TYPE_LONG || + spc[0]==SDNA_TYPE_ULONG || + spc[0]==SDNA_TYPE_FLOAT)) + { mul= DNA_elem_array_size(name, strlen(name)); cpo= cur; @@ -1138,3 +1136,25 @@ int DNA_elem_offset(SDNA *sdna, const char *stype, const char *vartype, const ch return (int)((intptr_t)cp); } +int DNA_elem_type_size(const eSDNA_Type elem_nr) +{ + /* should containt all enum types */ + switch (elem_nr) { + case SDNA_TYPE_CHAR: + case SDNA_TYPE_UCHAR: + return 1; + case SDNA_TYPE_SHORT: + case SDNA_TYPE_USHORT: + return 2; + case SDNA_TYPE_INT: + case SDNA_TYPE_LONG: + case SDNA_TYPE_ULONG: + case SDNA_TYPE_FLOAT: + return 4; + case SDNA_TYPE_DOUBLE: + return 8; + } + + /* weak */ + return 8; +} diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 11ab9b1efcf..e3f62fa0f4d 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -928,16 +928,17 @@ static int make_structDNA(char *baseDirectory, FILE *file) /* insertion of all known types */ /* watch it: uint is not allowed! use in structs an unsigned int */ - add_type("char", 1); /* 0 */ - add_type("uchar", 1); /* 1 */ - add_type("short", 2); /* 2 */ - add_type("ushort", 2); /* 3 */ - add_type("int", 4); /* 4 */ - add_type("long", 4); /* 5 */ /* should it be 8 on 64 bits? */ - add_type("ulong", 4); /* 6 */ - add_type("float", 4); /* 7 */ - add_type("double", 8); /* 8 */ - add_type("void", 0); /* 9 */ + /* watch it: sizes must match DNA_elem_type_size() */ + add_type("char", 1); /* SDNA_TYPE_CHAR */ + add_type("uchar", 1); /* SDNA_TYPE_UCHAR */ + add_type("short", 2); /* SDNA_TYPE_SHORT */ + add_type("ushort", 2); /* SDNA_TYPE_USHORT */ + add_type("int", 4); /* SDNA_TYPE_INT */ + add_type("long", 4); /* SDNA_TYPE_LONG */ /* should it be 8 on 64 bits? */ + add_type("ulong", 4); /* SDNA_TYPE_ULONG */ + add_type("float", 4); /* SDNA_TYPE_FLOAT */ + add_type("double", 8); /* SDNA_TYPE_DOUBLE */ + add_type("void", 0); /* SDNA_TYPE_VOID */ // the defines above shouldn't be output in the padding file... firststruct = nr_types; -- cgit v1.2.3 From 3cce96320e9e7dcacfde7b92c110482500661f14 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Dec 2011 00:51:54 +0000 Subject: recent matrix row/col swap broke matrix assignment in the BGE, fix provided by Andrew Hale --- source/gameengine/Ketsji/KX_PyMath.h | 49 ++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index b9ff3759452..392a6633067 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -65,32 +65,59 @@ bool PyMatTo(PyObject* pymat, T& mat) { bool noerror = true; mat.setIdentity(); + + +#ifdef USE_MATHUTILS + + if (MatrixObject_Check(pymat)) + { + MatrixObject *pymatrix = (MatrixObject *)pymat; + + if (BaseMath_ReadCallback(pymatrix) == -1) + return false; + + if (pymatrix->num_col != Size(mat) || pymatrix->num_row != Size(mat)) + return false; + + for (unsigned int row = 0; row < Size(mat); row++) + { + for (unsigned int col = 0; col < Size(mat); col++) + { + mat[row][col] = *(pymatrix->matrix + col * pymatrix->num_row + row); + } + } + } + else + +#endif /* USE_MATHUTILS */ + + if (PySequence_Check(pymat)) { - unsigned int cols = PySequence_Size(pymat); - if (cols != Size(mat)) + unsigned int rows = PySequence_Size(pymat); + if (rows != Size(mat)) return false; - for (unsigned int x = 0; noerror && x < cols; x++) + for (unsigned int row = 0; noerror && row < rows; row++) { - PyObject *pycol = PySequence_GetItem(pymat, x); /* new ref */ - if (!PyErr_Occurred() && PySequence_Check(pycol)) + PyObject *pyrow = PySequence_GetItem(pymat, row); /* new ref */ + if (!PyErr_Occurred() && PySequence_Check(pyrow)) { - unsigned int rows = PySequence_Size(pycol); - if (rows != Size(mat)) + unsigned int cols = PySequence_Size(pyrow); + if (cols != Size(mat)) noerror = false; else { - for( unsigned int y = 0; y < rows; y++) + for( unsigned int col = 0; col < cols; col++) { - PyObject *item = PySequence_GetItem(pycol, y); /* new ref */ - mat[y][x] = PyFloat_AsDouble(item); + PyObject *item = PySequence_GetItem(pyrow, col); /* new ref */ + mat[row][col] = PyFloat_AsDouble(item); Py_DECREF(item); } } } else noerror = false; - Py_DECREF(pycol); + Py_DECREF(pyrow); } } else noerror = false; -- cgit v1.2.3 From 27b47892a029d8734d42cc121402155f912102d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Dec 2011 04:40:07 +0000 Subject: add DNA support for int64_t. nothing uses this currently. --- source/blender/makesdna/DNA_genfile.h | 8 ++++++-- source/blender/makesdna/intern/dna_genfile.c | 20 +++++++++++++++++++- source/blender/makesdna/intern/makesdna.c | 1 + 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h index 1ca669836ac..83292d3d8f8 100644 --- a/source/blender/makesdna/DNA_genfile.h +++ b/source/blender/makesdna/DNA_genfile.h @@ -47,10 +47,14 @@ typedef enum eSDNA_Type { SDNA_TYPE_LONG = 5, SDNA_TYPE_ULONG = 6, SDNA_TYPE_FLOAT = 7, - SDNA_TYPE_DOUBLE = 8 - /* ,SDNA_TYPE_VOID = 9 */ /* nothing uses yet */ + SDNA_TYPE_DOUBLE = 8, + SDNA_TYPE_INT64 = 9 + /* ,SDNA_TYPE_VOID = 10 */ /* nothing uses yet */ } eSDNA_Type; +/* define so switch statements don't complain */ +#define SDNA_TYPE_VOID 10 + struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap); void DNA_sdna_free(struct SDNA *sdna); diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 88b6fa65370..db0c2bc0e2d 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -491,7 +491,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap) for(nr=0; nrnr_structs; nr++) { sp= sdna->structs[nr]; if(strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0) - sp[10]= 9; + sp[10]= SDNA_TYPE_VOID; } } @@ -666,6 +666,7 @@ static eSDNA_Type sdna_type_nr(const char *dna_type) else if((strcmp(dna_type, "ulong")==0)||(strcmp(dna_type, "unsigned long")==0)) return SDNA_TYPE_ULONG; else if( strcmp(dna_type, "float")==0) return SDNA_TYPE_FLOAT; else if( strcmp(dna_type, "double")==0) return SDNA_TYPE_DOUBLE; + else if( strcmp(dna_type, "int64_t")==0) return SDNA_TYPE_INT64; else return -1; /* invalid! */ } @@ -708,6 +709,8 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch val= *( (float *)olddata); break; case SDNA_TYPE_DOUBLE: val= *( (double *)olddata); break; + case SDNA_TYPE_INT64: + val= *( (int64_t *)olddata); break; } switch(ctypenr) { @@ -731,6 +734,8 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch case SDNA_TYPE_DOUBLE: if(otypenr<2) val/= 255; *( (double *)curdata)= val; break; + case SDNA_TYPE_INT64: + *( (int64_t *)curdata)= val; break; } olddata+= oldlen; @@ -1088,6 +1093,18 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) cpo+= 4; } } + else if ( (spc[0]==SDNA_TYPE_INT64)) { + mul= DNA_elem_array_size(name, strlen(name)); + cpo= cur; + while(mul--) { + cval= cpo[0]; cpo[0]= cpo[7]; cpo[7]= cval; + cval= cpo[1]; cpo[1]= cpo[6]; cpo[6]= cval; + cval= cpo[2]; cpo[2]= cpo[5]; cpo[5]= cval; + cval= cpo[3]; cpo[3]= cpo[4]; cpo[4]= cval; + + cpo+= 8; + } + } } } cur+= elen; @@ -1152,6 +1169,7 @@ int DNA_elem_type_size(const eSDNA_Type elem_nr) case SDNA_TYPE_FLOAT: return 4; case SDNA_TYPE_DOUBLE: + case SDNA_TYPE_INT64: return 8; } diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index e3f62fa0f4d..0c417e9f884 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -938,6 +938,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) add_type("ulong", 4); /* SDNA_TYPE_ULONG */ add_type("float", 4); /* SDNA_TYPE_FLOAT */ add_type("double", 8); /* SDNA_TYPE_DOUBLE */ + add_type("int64_t", 8); /* SDNA_TYPE_INT64 */ add_type("void", 0); /* SDNA_TYPE_VOID */ // the defines above shouldn't be output in the padding file... -- cgit v1.2.3 From b59d8c6ba35e43879437e197210bd3900eb56fc9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Dec 2011 05:42:06 +0000 Subject: fix for own mistake [#29031] Importing BGL Can Crash the BGE and Blender was adding the Buffer type to the module without increffing --- source/blender/python/generic/bgl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index c2fd6036414..e32444976dd 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -1304,6 +1304,7 @@ PyObject *BPyInit_bgl(void) PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType); + Py_INCREF((PyObject *)&BGL_bufferType); #define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, item=PyLong_FromLong((int)x)); Py_DECREF(item) -- cgit v1.2.3 From ac498a6b64ea2f034aa0177894fb25d0401e327b Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Fri, 23 Dec 2011 07:10:01 +0000 Subject: Cleaning up the GPU_extensions_init/exit() code a bit to keep the Blenderplayer from crashing on exit and restart. --- source/blender/gpu/intern/gpu_codegen.c | 12 ++++++++++-- source/blender/gpu/intern/gpu_codegen.h | 3 +++ source/blender/gpu/intern/gpu_extensions.c | 17 ++++++++++++----- source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 4 ++++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 7182bbc38e2..d623697921c 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -241,7 +241,12 @@ GPUFunction *GPU_lookup_function(const char *name) return (GPUFunction*)BLI_ghash_lookup(FUNCTION_HASH, (void *)name); } -void GPU_extensions_exit(void) +void GPU_codegen_init(void) +{ + GPU_code_generate_glsl_lib(); +} + +void GPU_codegen_exit(void) { extern Material defmaterial; // render module abuse... @@ -253,8 +258,11 @@ void GPU_extensions_exit(void) FUNCTION_HASH = NULL; } - if(glsl_material_library) + if(glsl_material_library) { MEM_freeN(glsl_material_library); + glsl_material_library = NULL; + } + /*if(FUNCTION_PROTOTYPES) { MEM_freeN(FUNCTION_PROTOTYPES); FUNCTION_PROTOTYPES = NULL; diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h index f52b5bb627e..85bf65232c1 100644 --- a/source/blender/gpu/intern/gpu_codegen.h +++ b/source/blender/gpu/intern/gpu_codegen.h @@ -178,6 +178,9 @@ void GPU_pass_unbind(GPUPass *pass); void GPU_pass_free(GPUPass *pass); +void GPU_codegen_init(void); +void GPU_codegen_exit(void); + /* Material calls */ const char *GPU_builtin_name(GPUBuiltin builtin); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index eaa661a9dcf..c4ed88635b7 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -45,6 +45,7 @@ #include "GPU_draw.h" #include "GPU_extensions.h" +#include "gpu_codegen.h" #include #include @@ -85,6 +86,8 @@ int GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver) /* GPU Extensions */ +static int gpu_extensions_init = 0; + void GPU_extensions_disable(void) { GG.extdisabled = 1; @@ -96,11 +99,11 @@ void GPU_extensions_init(void) const char *vendor, *renderer; /* can't avoid calling this multiple times, see wm_window_add_ghostwindow */ - static char init= 0; - if(init) return; - init= 1; + if(gpu_extensions_init) return; + gpu_extensions_init= 1; glewInit(); + GPU_codegen_init(); /* glewIsSupported("GL_VERSION_2_0") */ @@ -112,8 +115,6 @@ void GPU_extensions_init(void) if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0; if (!GLEW_ARB_fragment_shader) GG.glslsupport = 0; - GPU_code_generate_glsl_lib(); - glGetIntegerv(GL_RED_BITS, &r); glGetIntegerv(GL_GREEN_BITS, &g); glGetIntegerv(GL_BLUE_BITS, &b); @@ -188,6 +189,12 @@ void GPU_extensions_init(void) #endif } +void GPU_extensions_exit(void) +{ + gpu_extensions_init = 0; + GPU_codegen_exit(); +} + int GPU_glsl_support(void) { return !GG.extdisabled && GG.glslsupport; diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index f9403c9725a..f249510ecc7 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -789,6 +789,10 @@ void GPG_Application::stopEngine() void GPG_Application::exitEngine() { + // We only want to kill the engine if it has been initialized + if (!m_engineInitialized) + return; + sound_exit(); if (m_ketsjiengine) { -- cgit v1.2.3