diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-04-03 16:15:56 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-04-03 16:15:56 +0300 |
commit | 5884c9f1ba45b8285930508b8ee04279a7b0b387 (patch) | |
tree | 11a71aea12aa2e4bf6121f21c041d0da7296928d /source/blender | |
parent | 3b6eaf8d96bce59756f669e0c5105ae3bb31bef8 (diff) | |
parent | cc93a66e71a9de09cb41d4433be86e0f056d2b6f (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender')
18 files changed, 104 insertions, 67 deletions
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index 62e779e7fd6..9986db89131 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -412,7 +412,7 @@ void AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupl BLI_assert(ob != dupliObParent); /* check if we have already created a transform writer for this object */ - if (getXForm(name) != NULL){ + if (getXForm(name) != NULL) { std::cerr << "xform " << name << " already exists\n"; return; } diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 49722873a91..9348f3b3285 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -304,7 +304,9 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: } } - bc_sanitize_mat(mat, 6); // XXX: Make this optional ? + if (this->export_settings->limit_precision) + bc_sanitize_mat(mat, 6); + TransformWriter::add_node_transform(node, mat, NULL); } diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp index 5444c9dfa6b..1c2642e8313 100644 --- a/source/blender/collada/ControllerExporter.cpp +++ b/source/blender/collada/ControllerExporter.cpp @@ -533,7 +533,8 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas invert_m4_m4(mat, world); converter.mat4_to_dae(inv_bind_mat, mat); - bc_sanitize_mat(inv_bind_mat, 6); // XXX: Make this optional ? + if (this->export_settings->limit_precision) + bc_sanitize_mat(inv_bind_mat, 6); source.appendValues(inv_bind_mat); } } diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index 03e380dc198..de91f68a492 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -53,6 +53,7 @@ public: BC_export_transformation_type export_transformation_type; bool open_sim; + bool limit_precision; bool keep_bind_info; char *filepath; diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index c0784ca8eb5..bfe3180909b 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -59,7 +59,7 @@ int collada_import(bContext *C, import_settings.find_chains = find_chains != 0; import_settings.fix_orientation = fix_orientation != 0; import_settings.min_chain_length = min_chain_length; - import_settings.keep_bind_info = keep_bind_info; + import_settings.keep_bind_info = keep_bind_info !=0; DocumentImporter imp(C, &import_settings); if (imp.import()) return 1; @@ -90,7 +90,7 @@ int collada_export(Scene *sce, int sort_by_name, BC_export_transformation_type export_transformation_type, int open_sim, - + int limit_precision, int keep_bind_info) { ExportSettings export_settings; @@ -116,8 +116,8 @@ int collada_export(Scene *sce, export_settings.sort_by_name = sort_by_name != 0; export_settings.export_transformation_type = export_transformation_type; export_settings.open_sim = open_sim != 0; - - export_settings.keep_bind_info = keep_bind_info; + export_settings.limit_precision = limit_precision != 0; + export_settings.keep_bind_info = keep_bind_info !=0; int includeFilter = OB_REL_NONE; if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE; diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index 09acc4a064b..8035af59c8b 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -85,6 +85,7 @@ int collada_export(struct Scene *sce, BC_export_transformation_type export_transformation_type, int open_sim, + int limit_precision, int keep_bind_info); #ifdef __cplusplus diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 407f0799014..ac4395e1430 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -32,9 +32,6 @@ #include "COLLADAFWMeshPrimitive.h" #include "COLLADAFWMeshVertexData.h" -#include "collada_utils.h" -#include "ExportSettings.h" - extern "C" { #include "DNA_modifier_types.h" #include "DNA_customdata_types.h" @@ -64,6 +61,9 @@ extern "C" { #include "bmesh_tools.h" } +#include "collada_utils.h" +#include "ExportSettings.h" + float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index) { if (index >= array.getValuesCount()) @@ -824,23 +824,11 @@ void bc_create_restpose_mat(const ExportSettings *export_settings, Bone *bone, f } /* - To get rid of those lengthy float values which make the numbers unreadable. -*/ -float bc_sanitize_float(float value, float precision) -{ - float result = floor((value * pow(10, precision) + 0.5)) / pow(10, precision); - if (abs(result) < 1 / pow(10, precision)) { - result = 0; - } - return result; -} - -/* Make 4*4 matrices better readable */ -void bc_sanitize_mat(float mat[4][4], float precision) +void bc_sanitize_mat(float mat[4][4], int precision) { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) - mat[i][j] = bc_sanitize_float(mat[i][j], precision); + mat[i][j] = double_round(mat[i][j], precision); }
\ No newline at end of file diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index b98f8bfb188..38c0bd5096a 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -97,8 +97,7 @@ extern bool bc_is_leaf_bone(Bone *bone); extern EditBone *bc_get_edit_bone(bArmature * armature, char *name); extern int bc_set_layer(int bitfield, int layer, bool enable); extern int bc_set_layer(int bitfield, int layer); -extern float bc_sanitize_float(float value, float precision); -extern void bc_sanitize_mat(float mat[4][4], float precision); +extern void bc_sanitize_mat(float mat[4][4], int precision); extern IDProperty *bc_get_IDProperty(Bone *bone, std::string key); extern void bc_set_IDProperty(EditBone *ebone, const char *key, float value); diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 76d3c8a751c..8e7f8e01a59 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -351,15 +351,24 @@ void DEG_graph_on_visible_update(Main *bmain, Scene *scene) /* Special trick to get local view to work. */ LINKLIST_FOREACH (Base *, base, &scene->base) { Object *object = base->object; - DEG::IDDepsNode *node = graph->find_id_node(&object->id); - node->layers = 0; + DEG::IDDepsNode *id_node = graph->find_id_node(&object->id); + id_node->layers = 0; } LINKLIST_FOREACH (Base *, base, &scene->base) { Object *object = base->object; - DEG::IDDepsNode *node = graph->find_id_node(&object->id); - node->layers |= base->lay; + DEG::IDDepsNode *id_node = graph->find_id_node(&object->id); + id_node->layers |= base->lay; } DEG::deg_graph_build_flush_layers(graph); + LINKLIST_FOREACH (Base *, base, &scene->base) { + Object *object = base->object; + DEG::IDDepsNode *id_node = graph->find_id_node(&object->id); + GHASH_FOREACH_BEGIN(DEG::ComponentDepsNode *, comp, id_node->components) + { + id_node->layers |= comp->layers; + } + GHASH_FOREACH_END(); + } } void DEG_on_visible_update(Main *bmain, const bool UNUSED(do_time)) diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index fa9acc36a2b..601a86b97cb 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2126,10 +2126,10 @@ static int gp_count_subdivision_cuts(bGPDstroke *gps) int totnewpoints = 0; for (i = 0, pt = gps->points; i < gps->totpoints && pt; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) { - if (i + 1 < gps->totpoints){ + if (i + 1 < gps->totpoints) { if (gps->points[i + 1].flag & GP_SPOINT_SELECT) { ++totnewpoints; - }; + } } } } @@ -2184,7 +2184,7 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) /* if next point is selected add a half way point */ if (pt->flag & GP_SPOINT_SELECT) { - if (i + 1 < oldtotpoints){ + if (i + 1 < oldtotpoints) { if (temp_points[i + 1].flag & GP_SPOINT_SELECT) { pt_final = &gps->points[i2]; /* Interpolate all values */ @@ -2196,7 +2196,7 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) pt_final->time = interpf(pt->time, next->time, 0.5f); pt_final->flag |= GP_SPOINT_SELECT; ++i2; - }; + } } } } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 7b0921941e7..9b6547cf8a1 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2174,12 +2174,13 @@ static void ui_litem_layout_row(uiLayout *litem) bool min_flag = item->flag & UI_ITEM_MIN; /* ignore min flag for rows with right or center alignment */ if (item->type != ITEM_BUTTON && - ELEM(((uiLayout *)item)->alignment, UI_LAYOUT_ALIGN_RIGHT, UI_LAYOUT_ALIGN_CENTER) && - litem->alignment == UI_LAYOUT_ALIGN_EXPAND && - ((uiItem *)litem)->flag & UI_ITEM_MIN) { + ELEM(((uiLayout *)item)->alignment, UI_LAYOUT_ALIGN_RIGHT, UI_LAYOUT_ALIGN_CENTER) && + litem->alignment == UI_LAYOUT_ALIGN_EXPAND && + ((uiItem *)litem)->flag & UI_ITEM_MIN) + { min_flag = false; } - + if ((neww < minw || min_flag) && w != 0) { /* fixed size */ item->flag |= UI_ITEM_FIXED; diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 9b12aa6d475..139c9817437 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -99,6 +99,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) int export_transformation_type; int open_sim; + int limit_precision; int keep_bind_info; int export_count; @@ -150,6 +151,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) export_transformation_type = RNA_enum_get(op->ptr, "export_transformation_type_selection"); open_sim = RNA_boolean_get(op->ptr, "open_sim"); + limit_precision = RNA_boolean_get(op->ptr, "limit_precision"); keep_bind_info = RNA_boolean_get(op->ptr, "keep_bind_info"); /* get editmode results */ @@ -178,6 +180,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) export_transformation_type, open_sim, + limit_precision, keep_bind_info ); @@ -276,9 +279,13 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) row = uiLayoutRow(box, false); uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, false); uiItemR(row, imfptr, "keep_bind_info", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, false); + uiItemR(row, imfptr, "limit_precision", 0, NULL, ICON_NONE); + } static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op) @@ -396,6 +403,9 @@ void WM_OT_collada_export(wmOperatorType *ot) RNA_def_boolean(func, "open_sim", 0, "Export to SL/OpenSim", "Compatibility mode for SL, OpenSim and other compatible online worlds"); + RNA_def_boolean(func, "limit_precision", 0, + "Limit Precision", "Reduce the precision of the exported data to 6 digits"); + RNA_def_boolean(func, "keep_bind_info", 0, "Keep Bind Info", "Store Bindpose information in custom bone properties for later use during Collada export"); @@ -437,7 +447,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) auto_connect, fix_orientation, min_chain_length, - keep_bind_info) ) + keep_bind_info) ) { return OPERATOR_FINISHED; } diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 89eb8f787bc..587a62d017d 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -1122,15 +1122,14 @@ static bool snapDerivedMesh( float dist_px_sq = dist_squared_to_projected_aabb_simple( lpmat, snapdata->win_half, ray_min_dist, snapdata->mval, ray_org_local, ray_normal_local, bb->vec[0], bb->vec[6]); - if (dist_px_sq > SQUARE(*dist_px)) - { + if (dist_px_sq > SQUARE(*dist_px)) { return retval; } } else { /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ if (!isect_ray_aabb_v3_simple( - ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], NULL, NULL)) + ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], NULL, NULL)) { return retval; } diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index f3146c9e6a8..9b202120b82 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -285,6 +285,7 @@ static void rna_Scene_collada_export( int sort_by_name, int export_transformation_type, int open_sim, + int limit_precision, int keep_bind_info) { collada_export(scene, @@ -311,6 +312,7 @@ static void rna_Scene_collada_export( export_transformation_type, open_sim, + limit_precision, keep_bind_info); } @@ -422,7 +424,12 @@ void RNA_api_scene(StructRNA *srna) RNA_def_boolean(func, "open_sim", false, "Export to SL/OpenSim", "Compatibility mode for SL, OpenSim and other compatible online worlds"); - RNA_def_boolean(func, "keep_bind_info", false, "Keep Bind Info", + RNA_def_boolean(func, "limit_precision", false, + "Limit Precision", + "Reduce the precision of the exported data to 6 digits"); + + RNA_def_boolean(func, "keep_bind_info", false, + "Keep Bind Info", "Store bind pose information in custom bone properties for later use during Collada export"); #endif diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c index 48d1688c386..e0bf34f42e4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c @@ -63,7 +63,7 @@ static void node_shader_exec_normal_map(void *data, int UNUSED(thread), bNode *n CLAMP_MIN(strength, 0.0f); - float *N = shi->vno; + float *N = shi->nmapnorm; int uv_index = 0; switch (nm->space) { case SHD_NORMAL_MAP_TANGENT: diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index b4a14f5337d..42e4d4f27f6 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1112,14 +1112,15 @@ static int multitex(Tex *tex, const short which_output, struct ImagePool *pool, const bool skip_load_image, - const bool texnode_preview) + const bool texnode_preview, + const bool use_nodes) { float tmpvec[3]; int retval = 0; /* return value, int:0, col:1, nor:2, everything:3 */ texres->talpha = false; /* is set when image texture returns alpha (considered premul) */ - if (tex->use_nodes && tex->nodetree) { + if (use_nodes && tex->use_nodes && tex->nodetree) { retval = ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, osatex, thread, tex, which_output, R.r.cfra, texnode_preview, NULL, NULL); } @@ -1239,7 +1240,8 @@ static int multitex_nodes_intern(Tex *tex, ImagePool *pool, const bool scene_color_manage, const bool skip_load_image, - const bool texnode_preview) + const bool texnode_preview, + const bool use_nodes) { if (tex==NULL) { memset(texres, 0, sizeof(TexResult)); @@ -1264,7 +1266,8 @@ static int multitex_nodes_intern(Tex *tex, which_output, pool, skip_load_image, - texnode_preview); + texnode_preview, + use_nodes); if (mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool); @@ -1311,7 +1314,8 @@ static int multitex_nodes_intern(Tex *tex, which_output, pool, skip_load_image, - texnode_preview); + texnode_preview, + use_nodes); { ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool); @@ -1341,7 +1345,8 @@ static int multitex_nodes_intern(Tex *tex, which_output, pool, skip_load_image, - texnode_preview); + texnode_preview, + use_nodes); } } @@ -1354,7 +1359,8 @@ int multitex_nodes(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int os return multitex_nodes_intern(tex, texvec, dxt, dyt, osatex, texres, thread, which_output, shi, mtex, pool, R.scene_color_manage, (R.r.scemode & R_NO_IMAGE_LOAD) != 0, - (R.r.scemode & R_TEXNODE_PREVIEW) != 0); + (R.r.scemode & R_TEXNODE_PREVIEW) != 0, + true); } /* this is called for surface shading */ @@ -1378,7 +1384,8 @@ static int multitex_mtex(ShadeInput *shi, MTex *mtex, float texvec[3], float dxt mtex->which_output, pool, skip_load_image, - (R.r.scemode & R_TEXNODE_PREVIEW) != 0); + (R.r.scemode & R_TEXNODE_PREVIEW) != 0, + true); } } @@ -1408,7 +1415,8 @@ int multitex_ext(Tex *tex, pool, scene_color_manage, skip_load_image, - false); + false, + true); } /* extern-tex doesn't support nodes (ntreeBeginExec() can't be called when rendering is going on)\ @@ -1417,13 +1425,19 @@ int multitex_ext(Tex *tex, */ int multitex_ext_safe(Tex *tex, float texvec[3], TexResult *texres, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image) { - int use_nodes= tex->use_nodes, retval; - - tex->use_nodes = false; - retval= multitex_nodes_intern(tex, texvec, NULL, NULL, 0, texres, 0, 0, NULL, NULL, pool, scene_color_manage, skip_load_image, false); - tex->use_nodes= use_nodes; - - return retval; + return multitex_nodes_intern(tex, + texvec, + NULL, NULL, + 0, + texres, + 0, + 0, + NULL, NULL, + pool, + scene_color_manage, + skip_load_image, + false, + false); } @@ -2873,7 +2887,8 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_ mtex->which_output, re->pool, skip_load_image, - texnode_preview); /* NULL = dxt/dyt, 0 = shi->osatex - not supported */ + texnode_preview, + true); /* NULL = dxt/dyt, 0 = shi->osatex - not supported */ /* texture output */ @@ -3051,7 +3066,8 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) mtex->which_output, har->pool, skip_load_image, - texnode_preview); + texnode_preview, + true); /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { @@ -3274,7 +3290,8 @@ void do_sky_tex( mtex->which_output, R.pool, skip_load_image, - texnode_preview); + texnode_preview, + true); /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { @@ -3500,7 +3517,8 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r mtex->which_output, R.pool, skip_load_image, - texnode_preview); + texnode_preview, + true); /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { @@ -3614,7 +3632,8 @@ int externtex(MTex *mtex, mtex->which_output, pool, skip_load_image, - texnode_preview); + texnode_preview, + true); if (rgb) { texr.tin = IMB_colormanagement_get_luminance(&texr.tr); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 59ba0b6182d..1095195acd5 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -809,7 +809,7 @@ int wm_homefile_read( if (userdef_template == NULL) { /* we need to have preferences load to overwrite preferences from previous template */ userdef_template = BKE_blendfile_userdef_read_from_memory( - datatoc_startup_blend, datatoc_startup_blend_size, NULL); + datatoc_startup_blend, datatoc_startup_blend_size, NULL); } if (userdef_template) { BKE_blender_userdef_set_app_template(userdef_template); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 151c21d3cdd..2027afef103 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -421,7 +421,7 @@ static void wm_window_set_dpi(wmWindow *win) /* Blender's UI drawing assumes DPI 72 as a good default following macOS * while Windows and Linux use DPI 96. GHOST assumes a default 96 so we * remap the DPI to Blender's convention. */ - int dpi = auto_dpi * U.ui_scale * (72.0/96.0f); + int dpi = auto_dpi * U.ui_scale * (72.0 / 96.0f); /* Automatically set larger pixel size for high DPI. */ int pixelsize = MAX2(1, dpi / 54); |