From 2cece7b221ebf0c1f9ae1b904d6961cb898b0eb3 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 16 Aug 2011 17:43:39 +0000 Subject: [PATCH 01/48] Bugfix for [#28258] [UV editor] missing snapping option. *Added back "snap_target" as we had in 2.4x. I removed the "snap_element" though, as only Vertex Snapping is supported in the UV Image Editor. --- release/scripts/startup/bl_ui/space_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 5d72482ce9c..2042fa1729d 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -387,7 +387,7 @@ class IMAGE_HT_header(Header): row = layout.row(align=True) row.prop(toolsettings, "use_snap", text="") - row.prop(toolsettings, "snap_element", text="", icon_only=True) + row.prop(toolsettings, "snap_target", text="") mesh = context.edit_object.data layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="") From feb52de6b500fe889f8a2b28d2b510087107ec88 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 16 Aug 2011 22:18:24 +0000 Subject: [PATCH 02/48] fix for error calling RNA_property_float_get_index on non array float rotations when displaying. --- source/blender/editors/interface/interface_regions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 8bce27e366b..a55ee01202c 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -424,7 +424,8 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) if (unit_type == PROP_UNIT_ROTATION) { if (RNA_property_type(but->rnaprop) == PROP_FLOAT) { - BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Radians: %f", RNA_property_float_get_index(&but->rnapoin, but->rnaprop, but->rnaindex)); + float value= RNA_property_array_check(but->rnaprop) ? RNA_property_float_get_index(&but->rnapoin, but->rnaprop, but->rnaindex) : RNA_property_float_get(&but->rnapoin, but->rnaprop); + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Radians: %f", value); data->color[data->totline]= 0x888888; data->totline++; } From dd8d24ff9d48d4103e414cbe18e6c40644051f19 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 16 Aug 2011 22:44:12 +0000 Subject: [PATCH 03/48] fix [#28274] Cant select aditional object in edit mode. missing feature from 2.4x --- source/blender/editors/space_view3d/view3d_select.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index c6835b0cad3..86112a42d99 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1335,9 +1335,9 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce if(oldbasact != basact) { ED_base_object_activate(C, basact); /* adds notifier */ } - - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } + + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } return retval; @@ -1841,8 +1841,8 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) int retval = 0; view3d_operator_needs_opengl(C); - - if(obedit) { + + if(obedit && center==FALSE) { if(obedit->type==OB_MESH) retval = mouse_mesh(C, event->mval, extend); else if(obedit->type==OB_ARMATURE) @@ -1889,7 +1889,7 @@ void VIEW3D_OT_select(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first."); - RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting (object mode only)."); + RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting, in editmode used to extend object selection."); RNA_def_boolean(ot->srna, "enumerate", 0, "Enumerate", "List objects under the mouse (object mode only)."); } From 0bac3e17dfb1cfc0b65adf1a29960cab2213d6a3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Aug 2011 12:09:02 +0000 Subject: [PATCH 04/48] Fix #28194, #28269: proxy object was not showing pose mode as available in 3d view header mode menu. A recent bugfix was incorrectly hiding pose and particle mode when the object data was library linked, but these modes edit object level settings so should be available. --- .../editors/space_view3d/view3d_header.c | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 5b95ae63e56..70b2a3d3628 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -281,31 +281,32 @@ static char *view3d_modeselect_pup(Scene *scene) str += sprintf(str, formatstr, "Object Mode", OB_MODE_OBJECT, ICON_OBJECT_DATA); if(ob==NULL || ob->data==NULL) return string; - if(ob->id.lib || ((ID *)ob->data)->lib) return string; + if(ob->id.lib) return string; - /* if active object is editable */ - if ( ((ob->type == OB_MESH) - || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT) - || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) { - - str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT); - } - else if (ob->type == OB_ARMATURE) { - if (ob->mode & OB_MODE_POSE) - str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT); - else + if(!((ID *)ob->data)->lib) { + /* if active object is editable */ + if ( ((ob->type == OB_MESH) + || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT) + || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) { + str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT); + } + else if (ob->type == OB_ARMATURE) { + if (ob->mode & OB_MODE_POSE) + str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT); + else + str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT); + } + + if (ob->type == OB_MESH) { + + str += sprintf(str, formatstr, "Sculpt Mode", OB_MODE_SCULPT, ICON_SCULPTMODE_HLT); + str += sprintf(str, formatstr, "Vertex Paint", OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT); + str += sprintf(str, formatstr, "Texture Paint", OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT); + str += sprintf(str, formatstr, "Weight Paint", OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT); + } } - - if (ob->type == OB_MESH) { - - str += sprintf(str, formatstr, "Sculpt Mode", OB_MODE_SCULPT, ICON_SCULPTMODE_HLT); - str += sprintf(str, formatstr, "Vertex Paint", OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT); - str += sprintf(str, formatstr, "Texture Paint", OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT); - str += sprintf(str, formatstr, "Weight Paint", OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT); - } - - + /* if active object is an armature */ if (ob->type==OB_ARMATURE) { str += sprintf(str, formatstr, "Pose Mode", OB_MODE_POSE, ICON_POSE_HLT); From b6dcf3b1c24fe43193ae4697b383cf1514a3caff Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Aug 2011 12:52:38 +0000 Subject: [PATCH 05/48] Fix #28277: changing smoke border collision type did not reset cache, making it seem like the option wasn't working. --- source/blender/makesrna/intern/rna_smoke.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 43d1aa24229..8abf774ff52 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -247,7 +247,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "border_collisions"); RNA_def_property_enum_items(prop, smoke_domain_colli_items); RNA_def_property_ui_text(prop, "Border Collisions", "Selects which domain border will be treated as collision object."); - RNA_def_property_update(prop, 0, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); prop= RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "EffectorWeights"); From 853620926019b242dbc34336addcf1c4eaaf7569 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 17 Aug 2011 13:04:28 +0000 Subject: [PATCH 06/48] 2.6 RNA: * Remove some NULL RNA property update calls, they do nothing. --- source/blender/makesrna/intern/rna_object_force.c | 1 - source/blender/makesrna/intern/rna_smoke.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index ca679239dd3..463f65fd3d5 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -770,7 +770,6 @@ static void rna_def_pointcache(BlenderRNA *brna) prop= RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, point_cache_compress_items); RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used"); - RNA_def_property_update(prop, 0, NULL); /* flags */ prop= RNA_def_property(srna, "is_baked", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 8abf774ff52..d439c2551f1 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -241,7 +241,6 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "cache_comp"); RNA_def_property_enum_items(prop, smoke_cache_comp_items); RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used"); - RNA_def_property_update(prop, 0, NULL); prop= RNA_def_property(srna, "collision_extents", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "border_collisions"); @@ -290,14 +289,12 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.001, 1); RNA_def_property_ui_range(prop, 0.001, 1.0, 1.0, 4); RNA_def_property_ui_text(prop, "Density", ""); - RNA_def_property_update(prop, 0, NULL); // NC_OBJECT|ND_MODIFIER prop= RNA_def_property(srna, "temperature", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "temp"); RNA_def_property_range(prop, -10, 10); RNA_def_property_ui_range(prop, -10, 10, 1, 1); RNA_def_property_ui_text(prop, "Temp. Diff.", "Temperature difference to ambient temperature"); - RNA_def_property_update(prop, 0, NULL); prop= RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "psys"); @@ -309,24 +306,20 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "use_outflow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "type", MOD_SMOKE_FLOW_TYPE_OUTFLOW); RNA_def_property_ui_text(prop, "Outflow", "Deletes smoke from simulation"); - RNA_def_property_update(prop, 0, NULL); prop= RNA_def_property(srna, "use_absolute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_ABSOLUTE); RNA_def_property_ui_text(prop, "Absolute Density", "Only allows given density value in emitter area."); - RNA_def_property_update(prop, 0, NULL); prop= RNA_def_property(srna, "initial_velocity", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_INITVELOCITY); RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke inherits it's velocity from the emitter particle"); - RNA_def_property_update(prop, 0, NULL); prop= RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vel_multi"); RNA_def_property_range(prop, -2.0, 2.0); RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5); RNA_def_property_ui_text(prop, "Multiplier", "Multiplier to adjust velocity passed to smoke"); - RNA_def_property_update(prop, 0, NULL); } static void rna_def_smoke_coll_settings(BlenderRNA *brna) From feb7afe671bb4932ebbbecc2a4cfbc3aa4516366 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Aug 2011 14:43:11 +0000 Subject: [PATCH 07/48] Fix #28262: uv unwrap in sync selection mode unwrapped all faces irrespective of selection. Changed the fix for bug #27198, live unwrap not working with sync selection. --- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index ae6836446fa..e8a7896abd5 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -205,11 +205,7 @@ static ParamHandle *construct_param_handle(Scene *scene, EditMesh *em, short imp float *uv[4]; int nverts; - if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { - if(efa->h) - continue; - } - else if((efa->h) || (sel && (efa->f & SELECT)==0)) + if((efa->h) || (sel && (efa->f & SELECT)==0)) continue; tf= (MTFace *)CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); @@ -586,7 +582,7 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit) return; } - liveHandle = construct_param_handle(scene, em, 0, fillholes, 1, 1); + liveHandle = construct_param_handle(scene, em, 0, fillholes, 0, 1); param_lscm_begin(liveHandle, PARAM_TRUE, abf); BKE_mesh_end_editmesh(obedit->data, em); From 37f9d916fab04a96441771d38ecca428456cd47b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Aug 2011 15:01:26 +0000 Subject: [PATCH 08/48] Fix #28265: blender 2.59 not starting on OS X with old ndof driver. Patch by Jens Verwiebe. --- intern/ghost/intern/GHOST_NDOFManagerCocoa.h | 1 + intern/ghost/intern/GHOST_NDOFManagerCocoa.mm | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h index e9897f30104..5e85808b5a6 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h @@ -43,6 +43,7 @@ public: // whether multi-axis functionality is available (via the OS or driver) // does not imply that a device is plugged in or being used bool available(); + bool oldDRV(); private: unsigned short m_clientID; diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm index 409ed953134..f665f5f6b39 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm @@ -143,7 +143,7 @@ GHOST_NDOFManagerCocoa::GHOST_NDOFManagerCocoa(GHOST_System& sys) // printf("ndof: client id = %d\n", m_clientID); - if (SetConnexionClientButtonMask != NULL) { + if (oldDRV()) { has_old_driver = false; SetConnexionClientButtonMask(m_clientID, kConnexionMaskAllButtons); } @@ -176,5 +176,14 @@ extern "C" { return InstallConnexionHandlers != NULL; // this means that the driver is installed and dynamically linked to blender } + + bool GHOST_NDOFManagerCocoa::oldDRV() + { + extern OSErr SetConnexionClientButtonMask() __attribute__((weak_import)); + // Make the linker happy for the framework check (see link below for more info) + // http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html + return SetConnexionClientButtonMask != NULL; + // this means that the driver has this symbol + } } #endif // WITH_INPUT_NDOF From 1719963a08e9cc470dfaa1dbc87174c9120b59af Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Aug 2011 15:55:42 +0000 Subject: [PATCH 09/48] Fix #28207: animating pin option for cloth didn't work, solver doesn't support it, so set the property as not animatable. --- source/blender/makesrna/intern/rna_cloth.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 1ce4108bab2..1b2396a4215 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -294,6 +294,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_GOAL); RNA_def_property_ui_text(prop, "Pin Cloth", "Enable pinning of cloth vertices to other objects/positions"); RNA_def_property_update(prop, 0, "rna_cloth_pinning_changed"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop= RNA_def_property(srna, "pin_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "goalspring"); @@ -313,6 +314,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_SCALING); RNA_def_property_ui_text(prop, "Stiffness Scaling", "If enabled, stiffness can be scaled along a weight painted vertex group"); RNA_def_property_update(prop, 0, "rna_cloth_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop= RNA_def_property(srna, "spring_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "Cdis"); From 14d2d7c75fcb9a1fd3d82d0434921117f26108e6 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 17 Aug 2011 20:17:27 +0000 Subject: [PATCH 10/48] BGE: Upping the max Axis Number for the Axis event type on joystick sensors from 2 to 4. The BGE supports up to 16 axis. For Axis events (not Single Axis), you get for directions per axis (up, down, left, right). So, the max should be JOYAXIS_MAX/directions = 16/4 = 4. --- source/blender/makesrna/intern/rna_sensor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 5cc8539f187..5c6a4e889fa 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -803,7 +803,7 @@ static void rna_def_joystick_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "axis_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "axis"); RNA_def_property_ui_text(prop, "Axis Number", "Specify which axis pair to use, 1 is usually the main direction input"); - RNA_def_property_range(prop, 1, 2); + RNA_def_property_range(prop, 1, 4); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "axis_threshold", PROP_INT, PROP_NONE); From 5c20bc02ff76a3a72992bc43f414b673e8275866 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 17 Aug 2011 20:44:15 +0000 Subject: [PATCH 11/48] BGE: Upon further investigation this should have been 8 since up/down and left/right both are just one axis each. So, in actuality, the number of directions = 2, not 4, and thus JOYAXIS_MAX/directions = 16/2 = 8. 8 was also the max used in 2.4x. --- source/blender/makesrna/intern/rna_sensor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 5c6a4e889fa..1f64603d6b4 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -803,7 +803,7 @@ static void rna_def_joystick_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "axis_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "axis"); RNA_def_property_ui_text(prop, "Axis Number", "Specify which axis pair to use, 1 is usually the main direction input"); - RNA_def_property_range(prop, 1, 4); + RNA_def_property_range(prop, 1, 8); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "axis_threshold", PROP_INT, PROP_NONE); From 591b087204b1bc9372d8c87d5bdf28a55f3ae13a Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 18 Aug 2011 02:12:23 +0000 Subject: [PATCH 12/48] Fix for [#28216] particles objects rotation still wrong with r39287 * The emitter object's inverse matrix wasn't in global coordinates during rendering, so the surface normals of the hair emission locations were transformed with the wrong matrix. --- source/blender/blenkernel/intern/anim.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 8aa816f9cb5..ebe7325d96a 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1245,6 +1245,8 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p sim.ob= par; sim.psys= psys; sim.psmd= psys_get_modifier(par, psys); + /* make sure emitter imat is in global coordinates instead of render view coordinates */ + invert_m4_m4(par->imat, par->obmat); /* first check for loops (particle system object used as dupli object) */ if(part->ren_as == PART_DRAW_OB) { From 83c090a555af97ae7f2f08595298d5b2e6266e85 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 12:09:53 +0000 Subject: [PATCH 13/48] fix for bad array access in transform operator, was assigning an array to a single float operator value. --- source/blender/editors/transform/transform.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index c1c812e8c68..03a98bf30d8 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1356,16 +1356,15 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) ToolSettings *ts = CTX_data_tool_settings(C); int constraint_axis[3] = {0, 0, 0}; int proportional = 0; + PropertyRNA *prop; - if (RNA_struct_find_property(op->ptr, "value")) - { - if (t->flag & T_AUTOVALUES) - { - RNA_float_set_array(op->ptr, "value", t->auto_values); + if ((prop= RNA_struct_find_property(op->ptr, "value"))) { + float *values= (t->flag & T_AUTOVALUES) ? t->auto_values : t->values; + if (RNA_property_array_check(prop)) { + RNA_property_float_set_array(op->ptr, prop, values); } - else - { - RNA_float_set_array(op->ptr, "value", t->values); + else { + RNA_property_float_set(op->ptr, prop, values[0]); } } From 2bd016fe3f08524711d1d45e8ebf12d483c6131c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 12:20:10 +0000 Subject: [PATCH 14/48] formatting edits, no functional changes. --- release/scripts/startup/bl_operators/wm.py | 248 +++++++++++++++------ source/blender/python/intern/bpy_rna.c | 97 ++++++-- 2 files changed, 250 insertions(+), 95 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index fe75c54e60e..b898d3fbf80 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -20,8 +20,12 @@ import bpy from bpy.types import Menu, Operator -from bpy.props import StringProperty, BoolProperty, IntProperty, \ - FloatProperty, EnumProperty +from bpy.props import (StringProperty, + BoolProperty, + IntProperty, + FloatProperty, + EnumProperty, + ) from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear @@ -39,15 +43,23 @@ class MESH_OT_delete_edgeloop(Operator): return {'CANCELLED'} -rna_path_prop = StringProperty(name="Context Attributes", - description="rna context string", maxlen=1024, default="") +rna_path_prop = StringProperty( + name="Context Attributes", + description="rna context string", + maxlen=1024, + ) -rna_reverse_prop = BoolProperty(name="Reverse", - description="Cycle backwards", default=False) +rna_reverse_prop = BoolProperty( + name="Reverse", + description="Cycle backwards", + default=False, + ) -rna_relative_prop = BoolProperty(name="Relative", +rna_relative_prop = BoolProperty( + name="Relative", description="Apply relative to the current value (delta)", - default=False) + default=False, + ) def context_path_validate(context, data_path): @@ -82,15 +94,21 @@ class BRUSH_OT_active_index_set(Operator): bl_idname = "brush.active_index_set" bl_label = "Set Brush Number" - mode = StringProperty(name="mode", - description="Paint mode to set brush for", maxlen=1024) - index = IntProperty(name="number", - description="Brush number") + mode = StringProperty( + name="mode", + description="Paint mode to set brush for", + maxlen=1024, + ) + index = IntProperty( + name="number", + description="Brush number", + ) _attr_dict = {"sculpt": "use_paint_sculpt", "vertex_paint": "use_paint_vertex", "weight_paint": "use_paint_weight", - "image_paint": "use_paint_image"} + "image_paint": "use_paint_image", + } def execute(self, context): attr = self._attr_dict.get(self.mode) @@ -112,8 +130,11 @@ class WM_OT_context_set_boolean(Operator): bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value = BoolProperty(name="Value", - description="Assignment value", default=True) + value = BoolProperty( + name="Value", + description="Assignment value", + default=True, + ) execute = execute_context_assign @@ -125,7 +146,11 @@ class WM_OT_context_set_int(Operator): # same as enum bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value = IntProperty(name="Value", description="Assign value", default=0) + value = IntProperty( + name="Value", + description="Assign value", + default=0, + ) relative = rna_relative_prop execute = execute_context_assign @@ -138,10 +163,16 @@ class WM_OT_context_scale_int(Operator): bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value = FloatProperty(name="Value", description="Assign value", default=1.0) - always_step = BoolProperty(name="Always Step", - description="Always adjust the value by a minimum of 1 when 'value' is not 1.0.", - default=True) + value = FloatProperty( + name="Value", + description="Assign value", + default=1.0, + ) + always_step = BoolProperty( + name="Always Step", + description="Always adjust the value by a minimum of 1 when 'value' is not 1.0.", + default=True, + ) def execute(self, context): if context_path_validate(context, self.data_path) is Ellipsis: @@ -160,7 +191,8 @@ class WM_OT_context_scale_int(Operator): else: add = "-1" func = "min" - exec("context.%s = %s(round(context.%s * value), context.%s + %s)" % (data_path, func, data_path, data_path, add)) + exec("context.%s = %s(round(context.%s * value), context.%s + %s)" % + (data_path, func, data_path, data_path, add)) else: exec("context.%s *= value" % self.data_path) @@ -174,8 +206,11 @@ class WM_OT_context_set_float(Operator): # same as enum bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value = FloatProperty(name="Value", - description="Assignment value", default=0.0) + value = FloatProperty( + name="Value", + description="Assignment value", + default=0.0, + ) relative = rna_relative_prop execute = execute_context_assign @@ -188,8 +223,11 @@ class WM_OT_context_set_string(Operator): # same as enum bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value = StringProperty(name="Value", - description="Assign value", maxlen=1024, default="") + value = StringProperty( + name="Value", + description="Assign value", + maxlen=1024, + ) execute = execute_context_assign @@ -201,9 +239,11 @@ class WM_OT_context_set_enum(Operator): bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value = StringProperty(name="Value", + value = StringProperty( + name="Value", description="Assignment value (as a string)", - maxlen=1024, default="") + maxlen=1024, + ) execute = execute_context_assign @@ -215,9 +255,11 @@ class WM_OT_context_set_value(Operator): bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value = StringProperty(name="Value", + value = StringProperty( + name="Value", description="Assignment value (as a string)", - maxlen=1024, default="") + maxlen=1024, + ) def execute(self, context): if context_path_validate(context, self.data_path) is Ellipsis: @@ -252,21 +294,27 @@ class WM_OT_context_toggle_enum(Operator): bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value_1 = StringProperty(name="Value", \ - description="Toggle enum", maxlen=1024, default="") - - value_2 = StringProperty(name="Value", \ - description="Toggle enum", maxlen=1024, default="") + value_1 = StringProperty( + name="Value", + description="Toggle enum", + maxlen=1024, + ) + value_2 = StringProperty( + name="Value", + description="Toggle enum", + maxlen=1024, + ) def execute(self, context): if context_path_validate(context, self.data_path) is Ellipsis: return {'PASS_THROUGH'} - exec("context.%s = ['%s', '%s'][context.%s!='%s']" % \ - (self.data_path, self.value_1,\ - self.value_2, self.data_path, - self.value_2)) + exec("context.%s = ['%s', '%s'][context.%s!='%s']" % + (self.data_path, self.value_1, + self.value_2, self.data_path, + self.value_2, + )) return {'FINISHED'} @@ -426,8 +474,11 @@ class WM_OT_context_set_id(Operator): bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop - value = StringProperty(name="Value", - description="Assign value", maxlen=1024, default="") + value = StringProperty( + name="Value", + description="Assign value", + maxlen=1024, + ) def execute(self, context): value = self.value @@ -454,11 +505,18 @@ class WM_OT_context_set_id(Operator): return {'FINISHED'} -doc_id = StringProperty(name="Doc ID", - description="", maxlen=1024, default="", options={'HIDDEN'}) +doc_id = StringProperty( + name="Doc ID", + description="", + maxlen=1024, + options={'HIDDEN'}, + ) -doc_new = StringProperty(name="Edit Description", - description="", maxlen=1024, default="") +doc_new = StringProperty( + name="Edit Description", + description="", + maxlen=1024, + ) data_path_iter = StringProperty( description="The data path relative to the context, must point to an iterable.") @@ -476,12 +534,13 @@ class WM_OT_context_collection_boolean_set(Operator): data_path_iter = data_path_iter data_path_item = data_path_item - type = EnumProperty(items=( - ('TOGGLE', "Toggle", ""), - ('ENABLE', "Enable", ""), - ('DISABLE', "Disable", ""), - ), - name="Type") + type = EnumProperty( + name="Type", + items=(('TOGGLE', "Toggle", ""), + ('ENABLE', "Enable", ""), + ('DISABLE', "Disable", ""), + ), + ) def execute(self, context): data_path_iter = self.data_path_iter @@ -530,8 +589,14 @@ class WM_OT_context_modal_mouse(Operator): data_path_iter = data_path_iter data_path_item = data_path_item - input_scale = FloatProperty(default=0.01, description="Scale the mouse movement by this value before applying the delta") - invert = BoolProperty(default=False, description="Invert the mouse input") + input_scale = FloatProperty( + description="Scale the mouse movement by this value before applying the delta", + default=0.01, + ) + invert = BoolProperty( + description="Invert the mouse input", + default=False, + ) initial_x = IntProperty(options={'HIDDEN'}) def _values_store(self, context): @@ -613,7 +678,10 @@ class WM_OT_url_open(Operator): bl_idname = "wm.url_open" bl_label = "" - url = StringProperty(name="URL", description="URL to open") + url = StringProperty( + name="URL", + description="URL to open", + ) def execute(self, context): import webbrowser @@ -627,7 +695,11 @@ class WM_OT_path_open(Operator): bl_idname = "wm.path_open" bl_label = "" - filepath = StringProperty(name="File Path", maxlen=1024, subtype='FILE_PATH') + filepath = StringProperty( + name="File Path", + maxlen=1024, + subtype='FILE_PATH', + ) def execute(self, context): import sys @@ -662,9 +734,11 @@ class WM_OT_doc_view(Operator): doc_id = doc_id if bpy.app.version_cycle == "release": - _prefix = "http://www.blender.org/documentation/blender_python_api_%s%s_release" % ("_".join(str(v) for v in bpy.app.version[:2]), bpy.app.version_char) + _prefix = ("http://www.blender.org/documentation/blender_python_api_%s%s_release" % + ("_".join(str(v) for v in bpy.app.version[:2]), bpy.app.version_char)) else: - _prefix = "http://www.blender.org/documentation/blender_python_api_%s" % "_".join(str(v) for v in bpy.app.version) + _prefix = ("http://www.blender.org/documentation/blender_python_api_%s" % + "_".join(str(v) for v in bpy.app.version)) def _nested_class_string(self, class_string): ls = [] @@ -682,8 +756,8 @@ class WM_OT_doc_view(Operator): class_name, class_prop = id_split if hasattr(bpy.types, class_name.upper() + '_OT_' + class_prop): - url = '%s/bpy.ops.%s.html#bpy.ops.%s.%s' % \ - (self._prefix, class_name, class_name, class_prop) + url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" % + (self._prefix, class_name, class_name, class_prop)) else: # detect if this is a inherited member and use that name instead @@ -696,8 +770,8 @@ class WM_OT_doc_view(Operator): # It so happens that epydoc nests these, not sphinx # class_name_full = self._nested_class_string(class_name) - url = '%s/bpy.types.%s.html#bpy.types.%s.%s' % \ - (self._prefix, class_name, class_name, class_prop) + url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" % + (self._prefix, class_name, class_name, class_prop)) else: return {'PASS_THROUGH'} @@ -780,17 +854,36 @@ class WM_OT_doc_edit(Operator): return wm.invoke_props_dialog(self, width=600) -rna_path = StringProperty(name="Property Edit", - description="Property data_path edit", maxlen=1024, default="", options={'HIDDEN'}) +rna_path = StringProperty( + name="Property Edit", + description="Property data_path edit", + maxlen=1024, + options={'HIDDEN'}, + ) -rna_value = StringProperty(name="Property Value", - description="Property value edit", maxlen=1024, default="") +rna_value = StringProperty( + name="Property Value", + description="Property value edit", + maxlen=1024, + ) -rna_property = StringProperty(name="Property Name", - description="Property name edit", maxlen=1024, default="") +rna_property = StringProperty( + name="Property Name", + description="Property name edit", + maxlen=1024, + ) -rna_min = FloatProperty(name="Min", default=0.0, precision=3) -rna_max = FloatProperty(name="Max", default=1.0, precision=3) +rna_min = FloatProperty( + name="Min", + default=0.0, + precision=3, + ) + +rna_max = FloatProperty( + name="Max", + default=1.0, + precision=3, + ) class WM_OT_properties_edit(Operator): @@ -804,7 +897,9 @@ class WM_OT_properties_edit(Operator): value = rna_value min = rna_min max = rna_max - description = StringProperty(name="Tip", default="") + description = StringProperty( + name="Tip", + ) def execute(self, context): data_path = self.data_path @@ -908,7 +1003,10 @@ class WM_OT_properties_context_change(Operator): bl_idname = "wm.properties_context_change" bl_label = "" - context = StringProperty(name="Context", maxlen=32) + context = StringProperty( + name="Context", + maxlen=32, + ) def execute(self, context): context.space_data.context = (self.context) @@ -933,7 +1031,10 @@ class WM_OT_keyconfig_activate(Operator): bl_idname = "wm.keyconfig_activate" bl_label = "Activate Keyconfig" - filepath = StringProperty(name="File Path", maxlen=1024) + filepath = StringProperty( + name="File Path", + maxlen=1024, + ) def execute(self, context): bpy.utils.keyconfig_set(self.filepath) @@ -961,7 +1062,10 @@ class WM_OT_appconfig_activate(Operator): bl_idname = "wm.appconfig_activate" bl_label = "Activate Application Configuration" - filepath = StringProperty(name="File Path", maxlen=1024) + filepath = StringProperty( + name="File Path", + maxlen=1024, + ) def execute(self, context): import os diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ba8145c2773..4d8d524d7e3 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -84,7 +84,9 @@ int pyrna_struct_validity_check(BPy_StructRNA *pysrna) { if(pysrna->ptr.type) return 0; - PyErr_Format(PyExc_ReferenceError, "StructRNA of type %.200s has been removed", Py_TYPE(pysrna)->tp_name); + PyErr_Format(PyExc_ReferenceError, + "StructRNA of type %.200s has been removed", + Py_TYPE(pysrna)->tp_name); return -1; } @@ -790,18 +792,23 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self) const char *name; if(!PYRNA_STRUCT_IS_VALID(self)) { - return PyUnicode_FromFormat("", Py_TYPE(self)->tp_name); + return PyUnicode_FromFormat("", + Py_TYPE(self)->tp_name); } /* print name if available */ name= RNA_struct_name_get_alloc(&self->ptr, NULL, FALSE); if(name) { - ret= PyUnicode_FromFormat("", RNA_struct_identifier(self->ptr.type), name); + ret= PyUnicode_FromFormat("", + RNA_struct_identifier(self->ptr.type), + name); MEM_freeN((void *)name); return ret; } - return PyUnicode_FromFormat("", RNA_struct_identifier(self->ptr.type), self->ptr.data); + return PyUnicode_FromFormat("", + RNA_struct_identifier(self->ptr.type), + self->ptr.data); } static PyObject *pyrna_struct_repr(BPy_StructRNA *self) @@ -811,18 +818,26 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self) return pyrna_struct_str(self); /* fallback */ if(RNA_struct_is_ID(self->ptr.type)) { - return PyUnicode_FromFormat("bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id->name+2); + return PyUnicode_FromFormat("bpy.data.%s[\"%s\"]", + BKE_idcode_to_name_plural(GS(id->name)), + id->name+2); } else { PyObject *ret; const char *path; path= RNA_path_from_ID_to_struct(&self->ptr); if(path) { - ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"].%s", BKE_idcode_to_name_plural(GS(id->name)), id->name+2, path); + ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"].%s", + BKE_idcode_to_name_plural(GS(id->name)), + id->name+2, + path); MEM_freeN((void *)path); } else { /* cant find, print something sane */ - ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"]...%s", BKE_idcode_to_name_plural(GS(id->name)), id->name+2, RNA_struct_identifier(self->ptr.type)); + ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"]...%s", + BKE_idcode_to_name_plural(GS(id->name)), + id->name+2, + RNA_struct_identifier(self->ptr.type)); } return ret; @@ -870,7 +885,11 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self) name= RNA_struct_name_get_alloc(&ptr, NULL, FALSE); if(name) { - ret= PyUnicode_FromFormat("", type_fmt, RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop), name); + ret= PyUnicode_FromFormat("", + type_fmt, + RNA_struct_identifier(self->ptr.type), + RNA_property_identifier(self->prop), + name); MEM_freeN((void *)name); return ret; } @@ -878,11 +897,16 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self) if(RNA_property_type(self->prop) == PROP_COLLECTION) { PointerRNA r_ptr; if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) { - return PyUnicode_FromFormat("", type_fmt, RNA_struct_identifier(r_ptr.type)); + return PyUnicode_FromFormat("", + type_fmt, + RNA_struct_identifier(r_ptr.type)); } } - return PyUnicode_FromFormat("", type_fmt, RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); + return PyUnicode_FromFormat("", + type_fmt, + RNA_struct_identifier(self->ptr.type), + RNA_property_identifier(self->prop)); } static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) @@ -902,7 +926,10 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) MEM_freeN((void *)path); } else { /* cant find, print something sane */ - ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"]...%s", BKE_idcode_to_name_plural(GS(id->name)), id->name+2, RNA_property_identifier(self->prop)); + ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"]...%s", + BKE_idcode_to_name_plural(GS(id->name)), + id->name+2, + RNA_property_identifier(self->prop)); } return ret; @@ -911,7 +938,10 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) static PyObject *pyrna_func_repr(BPy_FunctionRNA *self) { - return PyUnicode_FromFormat("<%.200s %.200s.%.200s()>", Py_TYPE(self)->tp_name, RNA_struct_identifier(self->ptr.type), RNA_function_identifier(self->func)); + return PyUnicode_FromFormat("<%.200s %.200s.%.200s()>", + Py_TYPE(self)->tp_name, + RNA_struct_identifier(self->ptr.type), + RNA_function_identifier(self->func)); } @@ -2995,7 +3025,9 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) else if (self->ptr.type == &RNA_Context) { bContext *C= self->ptr.data; if(C==NULL) { - PyErr_Format(PyExc_AttributeError, "bpy_struct: Context is 'NULL', can't get \"%.200s\" from context", name); + PyErr_Format(PyExc_AttributeError, + "bpy_struct: Context is 'NULL', can't get \"%.200s\" from context", + name); ret= NULL; } else { @@ -3054,7 +3086,9 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) } else { #if 0 - PyErr_Format(PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" not found", name); + PyErr_Format(PyExc_AttributeError, + "bpy_struct: attribute \"%.200s\" not found", + name); ret= NULL; #endif /* Include this incase this instance is a subtype of a python class @@ -3170,7 +3204,9 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb const char *attr_str= _PyUnicode_AsString(attr); int ret= RNA_def_property_free_identifier(srna, attr_str); if (ret == -1) { - PyErr_Format(PyExc_TypeError, "struct_meta_idprop.detattr(): '%s' not a dynamic property", attr_str); + PyErr_Format(PyExc_TypeError, + "struct_meta_idprop.detattr(): '%s' not a dynamic property", + attr_str); return -1; } } @@ -3208,7 +3244,9 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject /* code just raises correct error, context prop's cant be set, unless its apart of the py class */ bContext *C= self->ptr.data; if(C==NULL) { - PyErr_Format(PyExc_AttributeError, "bpy_struct: Context is 'NULL', can't set \"%.200s\" from context", name); + PyErr_Format(PyExc_AttributeError, + "bpy_struct: Context is 'NULL', can't set \"%.200s\" from context", + name); return -1; } else { @@ -3219,7 +3257,9 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject int done= CTX_data_get(C, name, &newptr, &newlb, &newtype); if(done==1) { - PyErr_Format(PyExc_AttributeError, "bpy_struct: Context property \"%.200s\" is read-only", name); + PyErr_Format(PyExc_AttributeError, + "bpy_struct: Context property \"%.200s\" is read-only", + name); BLI_freelistN(&newlb); return -1; } @@ -3363,7 +3403,9 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam } } - PyErr_Format(PyExc_AttributeError, "bpy_prop_collection: attribute \"%.200s\" not found", name); + PyErr_Format(PyExc_AttributeError, + "bpy_prop_collection: attribute \"%.200s\" not found", + name); return -1; } @@ -4048,11 +4090,14 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * } /* error, invalid type given */ - PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): type '%.200s' is not a subtype of bpy_struct", type->tp_name); + PyErr_Format(PyExc_TypeError, + "bpy_struct.__new__(type): type '%.200s' is not a subtype of bpy_struct", + type->tp_name); return NULL; } else { - PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): expected a single argument"); + PyErr_Format(PyExc_TypeError, + "bpy_struct.__new__(type): expected a single argument"); return NULL; } } @@ -4077,7 +4122,9 @@ static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UN return (PyObject *)ret; } else { - PyErr_Format(PyExc_TypeError, "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop", type->tp_name); + PyErr_Format(PyExc_TypeError, + "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop", + type->tp_name); return NULL; } } @@ -4139,7 +4186,9 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat } break; default: - PyErr_Format(PyExc_TypeError, "RNA Error: unknown array type \"%d\" (pyrna_param_to_py)", type); + PyErr_Format(PyExc_TypeError, + "RNA Error: unknown array type \"%d\" (pyrna_param_to_py)", + type); ret= NULL; break; } @@ -4237,7 +4286,9 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat break; } default: - PyErr_Format(PyExc_TypeError, "RNA Error: unknown type \"%d\" (pyrna_param_to_py)", type); + PyErr_Format(PyExc_TypeError, + "RNA Error: unknown type \"%d\" (pyrna_param_to_py)", + type); ret= NULL; break; } From aa4d5ccbed401640065316c59670d23964ab6ad4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 15:25:18 +0000 Subject: [PATCH 15/48] more minor changes to wm.py, get data_path's once at the start of each func and some minor style changes. --- release/scripts/startup/bl_operators/wm.py | 67 ++++++++++++---------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index b898d3fbf80..aee36bab688 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -63,11 +63,10 @@ rna_relative_prop = BoolProperty( def context_path_validate(context, data_path): - import sys try: value = eval("context.%s" % data_path) if data_path else Ellipsis - except AttributeError: - if "'NoneType'" in str(sys.exc_info()[1]): + except AttributeError as e: + if str(e).startswith("'NoneType'"): # One of the items in the rna path is None, just ignore this value = Ellipsis else: @@ -78,13 +77,14 @@ def context_path_validate(context, data_path): def execute_context_assign(self, context): - if context_path_validate(context, self.data_path) is Ellipsis: + data_path = self.data_path + if context_path_validate(context, data_path) is Ellipsis: return {'PASS_THROUGH'} if getattr(self, "relative", False): - exec("context.%s+=self.value" % self.data_path) + exec("context.%s += self.value" % data_path) else: - exec("context.%s=self.value" % self.data_path) + exec("context.%s = self.value" % data_path) return {'FINISHED'} @@ -175,11 +175,11 @@ class WM_OT_context_scale_int(Operator): ) def execute(self, context): - if context_path_validate(context, self.data_path) is Ellipsis: + data_path = self.data_path + if context_path_validate(context, data_path) is Ellipsis: return {'PASS_THROUGH'} value = self.value - data_path = self.data_path if value == 1.0: # nothing to do return {'CANCELLED'} @@ -194,7 +194,7 @@ class WM_OT_context_scale_int(Operator): exec("context.%s = %s(round(context.%s * value), context.%s + %s)" % (data_path, func, data_path, data_path, add)) else: - exec("context.%s *= value" % self.data_path) + exec("context.%s *= value" % data_path) return {'FINISHED'} @@ -262,9 +262,10 @@ class WM_OT_context_set_value(Operator): ) def execute(self, context): - if context_path_validate(context, self.data_path) is Ellipsis: + data_path = self.data_path + if context_path_validate(context, data_path) is Ellipsis: return {'PASS_THROUGH'} - exec("context.%s=%s" % (self.data_path, self.value)) + exec("context.%s = %s" % (data_path, self.value)) return {'FINISHED'} @@ -277,12 +278,12 @@ class WM_OT_context_toggle(Operator): data_path = rna_path_prop def execute(self, context): + data_path = self.data_path - if context_path_validate(context, self.data_path) is Ellipsis: + if context_path_validate(context, data_path) is Ellipsis: return {'PASS_THROUGH'} - exec("context.%s=not (context.%s)" % - (self.data_path, self.data_path)) + exec("context.%s = not (context.%s)" % (data_path, data_path)) return {'FINISHED'} @@ -306,13 +307,14 @@ class WM_OT_context_toggle_enum(Operator): ) def execute(self, context): + data_path = self.data_path - if context_path_validate(context, self.data_path) is Ellipsis: + if context_path_validate(context, data_path) is Ellipsis: return {'PASS_THROUGH'} - exec("context.%s = ['%s', '%s'][context.%s!='%s']" % - (self.data_path, self.value_1, - self.value_2, self.data_path, + exec("context.%s = ('%s', '%s')[context.%s != '%s']" % + (data_path, self.value_1, + self.value_2, data_path, self.value_2, )) @@ -340,7 +342,7 @@ class WM_OT_context_cycle_int(Operator): else: value += 1 - exec("context.%s=value" % data_path) + exec("context.%s = value" % data_path) if value != eval("context.%s" % data_path): # relies on rna clamping int's out of the range @@ -349,7 +351,7 @@ class WM_OT_context_cycle_int(Operator): else: value = -1 << 31 - exec("context.%s=value" % data_path) + exec("context.%s = value" % data_path) return {'FINISHED'} @@ -364,15 +366,15 @@ class WM_OT_context_cycle_enum(Operator): reverse = rna_reverse_prop def execute(self, context): - - value = context_path_validate(context, self.data_path) + data_path = self.data_path + value = context_path_validate(context, data_path) if value is Ellipsis: return {'PASS_THROUGH'} orig_value = value # Have to get rna enum values - rna_struct_str, rna_prop_str = self.data_path.rsplit('.', 1) + rna_struct_str, rna_prop_str = data_path.rsplit('.', 1) i = rna_prop_str.find('[') # just incse we get "context.foo.bar[0]" @@ -402,7 +404,7 @@ class WM_OT_context_cycle_enum(Operator): advance_enum = enums[orig_index + 1] # set the new value - exec("context.%s=advance_enum" % self.data_path) + exec("context.%s = advance_enum" % data_path) return {'FINISHED'} @@ -429,7 +431,7 @@ class WM_OT_context_cycle_array(Operator): array.append(array.pop(0)) return array - exec("context.%s=cycle(context.%s[:])" % (data_path, data_path)) + exec("context.%s = cycle(context.%s[:])" % (data_path, data_path)) return {'FINISHED'} @@ -500,7 +502,7 @@ class WM_OT_context_set_id(Operator): if id_iter: value_id = getattr(bpy.data, id_iter).get(value) - exec("context.%s=value_id" % data_path) + exec("context.%s = value_id" % data_path) return {'FINISHED'} @@ -952,14 +954,15 @@ class WM_OT_properties_edit(Operator): return {'FINISHED'} def invoke(self, context, event): + data_path = self.data_path - if not self.data_path: + if not data_path: self.report({'ERROR'}, "Data path not set") return {'CANCELLED'} self._last_prop = [self.property] - item = eval("context.%s" % self.data_path) + item = eval("context.%s" % data_path) # setup defaults prop_ui = rna_idprop_ui_prop_get(item, self.property, False) # dont create @@ -980,7 +983,8 @@ class WM_OT_properties_add(Operator): data_path = rna_path def execute(self, context): - item = eval("context.%s" % self.data_path) + data_path = self.data_path + item = eval("context.%s" % data_path) def unique_name(names): prop = 'prop' @@ -1009,7 +1013,7 @@ class WM_OT_properties_context_change(Operator): ) def execute(self, context): - context.space_data.context = (self.context) + context.space_data.context = self.context return {'FINISHED'} @@ -1022,7 +1026,8 @@ class WM_OT_properties_remove(Operator): property = rna_property def execute(self, context): - item = eval("context.%s" % self.data_path) + data_path = self.data_path + item = eval("context.%s" % data_path) del item[self.property] return {'FINISHED'} From feb83181437cd36b283ae6551f10045d1fdbedd5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 16:01:11 +0000 Subject: [PATCH 16/48] fix for undo issues with generic, multi-purpose WM_OT_context* operators, operators now check if they modify certain ID data (not screne, wm, brush or scene) and only do undo in those cass. - Zkey to switch shading was pushing undo's. - Wkey to interactively edit camera, lamp settings wasnt doing an undo push when it should. - Toggling settings (such as bone boolean options) now skips an undo push if there are no items selected. --- release/scripts/startup/bl_operators/wm.py | 79 ++++++++++++++++++---- 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index aee36bab688..885d8cf2aed 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -76,6 +76,54 @@ def context_path_validate(context, data_path): return value +def operator_value_is_undo(value): + if value in {None, Ellipsis}: + return False + + # typical properties or objects + id_data = getattr(value, "id_data", Ellipsis) + + if id_data is None: + return False + elif id_data is Ellipsis: + # handle mathutils types + id_data = getattr(getattr(value, "owner", None), "id_data", None) + + if id_data is None: + return False + + # return True if its a non window ID type + return (isinstance(id_data, bpy.types.ID) and + (not isinstance(id_data, (bpy.types.WindowManager, + bpy.types.Screen, + bpy.types.Scene, + bpy.types.Brush, + )))) + + +def operator_path_is_undo(context, data_path): + # note that if we have data paths that use strings this could fail + # luckily we dont do this! + # + # When we cant find the data owner assume no undo is needed. + data_path_head, data_path_sep, data_path_tail = data_path.rpartition(".") + + if not data_path_head: + return False + + value = context_path_validate(context, data_path_head) + + return operator_value_is_undo(value) + + +def operator_path_undo_return(context, data_path): + return {'FINISHED'} if operator_path_is_undo(context, data_path) else {'CANCELLED'} + + +def operator_value_undo_return(value): + return {'FINISHED'} if operator_value_is_undo(value) else {'CANCELLED'} + + def execute_context_assign(self, context): data_path = self.data_path if context_path_validate(context, data_path) is Ellipsis: @@ -86,7 +134,7 @@ def execute_context_assign(self, context): else: exec("context.%s = self.value" % data_path) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) class BRUSH_OT_active_index_set(Operator): @@ -196,7 +244,7 @@ class WM_OT_context_scale_int(Operator): else: exec("context.%s *= value" % data_path) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) class WM_OT_context_set_float(Operator): # same as enum @@ -266,7 +314,7 @@ class WM_OT_context_set_value(Operator): if context_path_validate(context, data_path) is Ellipsis: return {'PASS_THROUGH'} exec("context.%s = %s" % (data_path, self.value)) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) class WM_OT_context_toggle(Operator): @@ -285,7 +333,7 @@ class WM_OT_context_toggle(Operator): exec("context.%s = not (context.%s)" % (data_path, data_path)) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) class WM_OT_context_toggle_enum(Operator): @@ -318,7 +366,7 @@ class WM_OT_context_toggle_enum(Operator): self.value_2, )) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) class WM_OT_context_cycle_int(Operator): @@ -353,7 +401,7 @@ class WM_OT_context_cycle_int(Operator): exec("context.%s = value" % data_path) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) class WM_OT_context_cycle_enum(Operator): @@ -405,7 +453,7 @@ class WM_OT_context_cycle_enum(Operator): # set the new value exec("context.%s = advance_enum" % data_path) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) class WM_OT_context_cycle_array(Operator): @@ -433,7 +481,7 @@ class WM_OT_context_cycle_array(Operator): exec("context.%s = cycle(context.%s[:])" % (data_path, data_path)) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) class WM_MT_context_menu_enum(Menu): @@ -504,7 +552,7 @@ class WM_OT_context_set_id(Operator): value_id = getattr(bpy.data, id_iter).get(value) exec("context.%s = value_id" % data_path) - return {'FINISHED'} + return operator_path_undo_return(context, data_path) doc_id = StringProperty( @@ -568,6 +616,10 @@ class WM_OT_context_collection_boolean_set(Operator): items_ok.append(item) + # avoid undo push when nothing to do + if not items_ok: + return {'CANCELLED'} + if self.type == 'ENABLE': is_set = True elif self.type == 'DISABLE': @@ -579,14 +631,14 @@ class WM_OT_context_collection_boolean_set(Operator): for item in items_ok: exec(exec_str) - return {'FINISHED'} + return operator_value_undo_return(item) class WM_OT_context_modal_mouse(Operator): '''Adjust arbitrary values with mouse input''' bl_idname = "wm.context_modal_mouse" bl_label = "Context Modal Mouse" - bl_options = {'GRAB_POINTER', 'BLOCKING', 'INTERNAL'} + bl_options = {'GRAB_POINTER', 'BLOCKING', 'UNDO', 'INTERNAL'} data_path_iter = data_path_iter data_path_item = data_path_item @@ -651,12 +703,13 @@ class WM_OT_context_modal_mouse(Operator): self._values_delta(delta) elif 'LEFTMOUSE' == event_type: + item = next(iter(self._values.keys())) self._values_clear() - return {'FINISHED'} + return operator_value_undo_return(item) elif event_type in {'RIGHTMOUSE', 'ESC'}: self._values_restore() - return {'FINISHED'} + return {'CANCELLED'} return {'RUNNING_MODAL'} From 00426038d0dbf2821e091954cc6d694d786e6898 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 16:26:34 +0000 Subject: [PATCH 17/48] disable undo for screen & wm RNA buttons, changing shading mode via the UI for eg was doing an undo push. --- source/blender/editors/interface/interface.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e31e3a26b40..3bd50074d84 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2636,6 +2636,17 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s UI_DEF_BUT_RNA_DISABLE(but); } + /* avoid undo push for buttons who's ID are screen or wm level + * we could disable undo for buttons with no ID too but but may have + * unforseen conciquences, so best check for ID's we _know_ are not + * handled by undo - campbell */ + if (but->flag & UI_BUT_UNDO) { + ID *id= ptr->id.data; + if(id && ELEM(GS(id->name), ID_SCR, ID_WM)) { + but->flag &= ~UI_BUT_UNDO; + } + } + /* If this button uses units, calculate the step from this */ if(ui_is_but_unit(but)) but->a1= ui_get_but_step_unit(but, but->a1); From 39a46cd4ed049bc462359f920af469c491b687f9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 17:09:23 +0000 Subject: [PATCH 18/48] disable undo for hard coded interface buttons: - space type switcher. - header menu toggle. - properties window header buttons. - various view3d manipulator buttons. --- source/blender/editors/screen/area.c | 8 ++- .../editors/space_buttons/buttons_header.c | 52 +++++++++---------- .../editors/space_view3d/view3d_header.c | 13 +++-- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 82986dfbcc4..bc97cd9d3ff 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1406,6 +1406,7 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) "Displays current editor type. " "Click for menu of available types"); uiButSetFunc(but, spacefunc, NULL, NULL); + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ return xco + UI_UNIT_X + 14; } @@ -1414,6 +1415,7 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) { ScrArea *sa= CTX_wm_area(C); int xco= 8; + uiBut *but; if (!sa->full) xco= ED_area_header_switchbutton(C, block, yco); @@ -1421,20 +1423,22 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) uiBlockSetEmboss(block, UI_EMBOSSN); if (sa->flag & HEADER_NO_PULLDOWN) { - uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, + but= uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_RIGHT, xco,yco,UI_UNIT_X,UI_UNIT_Y-2, &(sa->flag), 0, 0, 0, 0, "Show pulldown menus"); } else { - uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, + but= uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_DOWN, xco,yco,UI_UNIT_X,UI_UNIT_Y-2, &(sa->flag), 0, 0, 0, 0, "Hide pulldown menus"); } + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ + uiBlockSetEmboss(block, UI_EMBOSS); return xco + UI_UNIT_X; diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 19c600be937..e631718b0cb 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -104,6 +104,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) { SpaceButs *sbuts= CTX_wm_space_buts(C); uiBlock *block; + uiBut *but; int xco, yco= 2; buttons_context_compute(C, sbuts); @@ -118,33 +119,32 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) xco -= UI_UNIT_X; // Default panels + uiBlockBeginAlign(block); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_RENDER, 0, 0, "Render"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Object Constraints"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifiers"); - if(sbuts->pathflag & (1<dataicon, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_BONE_CONSTRAINT, 0, 0, "Bone Constraints"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles"); - if(sbuts->pathflag & (1<mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics"); + +#define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \ + if(sbuts->pathflag & (1<<_ctx)) { \ + but= uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, _tip); \ + uiButClearFlag(but, UI_BUT_UNDO); \ + } \ + + + BUTTON_HEADER_CTX(BCONTEXT_RENDER, ICON_SCENE, "Render") + BUTTON_HEADER_CTX(BCONTEXT_SCENE, ICON_SCENE_DATA, "Scene"); + BUTTON_HEADER_CTX(BCONTEXT_WORLD, ICON_WORLD, "World"); + BUTTON_HEADER_CTX(BCONTEXT_OBJECT, ICON_OBJECT_DATA, "Object"); + BUTTON_HEADER_CTX(BCONTEXT_CONSTRAINT, ICON_CONSTRAINT, "Object Constraints"); + BUTTON_HEADER_CTX(BCONTEXT_MODIFIER, ICON_MODIFIER, "Object Modifiers"); + BUTTON_HEADER_CTX(BCONTEXT_DATA, sbuts->dataicon, "Object Data"); + BUTTON_HEADER_CTX(BCONTEXT_BONE, ICON_BONE_DATA, "Bone"); + BUTTON_HEADER_CTX(BCONTEXT_BONE_CONSTRAINT, ICON_CONSTRAINT_BONE, "Bone Constraints"); + BUTTON_HEADER_CTX(BCONTEXT_MATERIAL, ICON_MATERIAL, "Material"); + BUTTON_HEADER_CTX(BCONTEXT_TEXTURE, ICON_TEXTURE, "Textures"); + BUTTON_HEADER_CTX(BCONTEXT_PARTICLE, ICON_PARTICLES, "Particles"); + BUTTON_HEADER_CTX(BCONTEXT_PHYSICS, ICON_PHYSICS, "Physics"); + +#undef BUTTON_HEADER_CTX + xco+= BUT_UNIT_X; uiBlockEndAlign(block); diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 70b2a3d3628..78dcf6c9a5c 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -466,6 +466,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) Object *ob= OBACT; Object *obedit = CTX_data_edit_object(C); uiBlock *block; + uiBut *but; uiLayout *row; const float dpi_fac= UI_DPI_FAC; @@ -513,9 +514,12 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) block= uiLayoutGetBlock(row); if(v3d->twflag & V3D_USE_MANIPULATOR) { - uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode"); - uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode"); - uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode"); + but= uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode"); + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ + but= uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode"); + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ + but= uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode"); + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ } if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) { @@ -523,7 +527,8 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } str_menu = BIF_menustringTransformOrientation(C, "Orientation"); - uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation"); + but= uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation"); + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ MEM_freeN((void *)str_menu); } From ccdec67fec8a39b8239e93bd04e38b4d8cbd18e7 Mon Sep 17 00:00:00 2001 From: Morten Mikkelsen Date: Thu, 18 Aug 2011 17:25:54 +0000 Subject: [PATCH 19/48] bugfix: genx and geny are not the image resolution. Texture space variant needs this. --- .../render/intern/source/render_texture.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 5aad055a8f6..579afc21c1d 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2084,14 +2084,21 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if(tex->ima) { - // crazy hack solution that gives results similar to normal mapping - part 2 float vec[2]; + int dimx=512, dimy=512; + ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + if (ibuf) { + dimx = ibuf->x; + dimy = ibuf->y; + } + + // crazy hack solution that gives results similar to normal mapping - part 2 - vec[0] = tex->ima->gen_x*dxt[0]; - vec[1] = tex->ima->gen_y*dxt[1]; + vec[0] = dimx*dxt[0]; + vec[1] = dimy*dxt[1]; dHdx *= 1.0f/len_v2(vec); - vec[0] = tex->ima->gen_x*dyt[0]; - vec[1] = tex->ima->gen_y*dyt[1]; + vec[0] = dimx*dyt[0]; + vec[1] = dimy*dyt[1]; dHdy *= 1.0f/len_v2(vec); } } From 238955070b334062764e81c01c6d8381c332a54a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 18:42:42 +0000 Subject: [PATCH 20/48] minor change for operator OUTLINER_OT_item_activate Noticed clicking anywhere in the outliner was doing undo pushes, even in empty areas. - check if any selection is made before redrawing. - don't do an undo push when selecting outliner items since only screen data is touched here. --- .../editors/space_outliner/outliner_intern.h | 3 --- .../editors/space_outliner/outliner_select.c | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 85bbbd4fffb..1a6448588aa 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -143,9 +143,6 @@ void outliner_build_tree(struct Main *mainvar, struct Scene *scene, struct Space void draw_outliner(const struct bContext *C); /* outliner_select.c -------------------------------------------- */ - -void outliner_select(struct SpaceOops *soops, ListBase *lb, int *index, short *selecting); - int tree_element_type_active(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set); int tree_element_active(struct bContext *C, struct Scene *scene, SpaceOops *soops, TreeElement *te, int set); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 620a936a944..46a9bde8267 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -106,10 +106,11 @@ /* ****************************************************** */ /* Outliner Selection (grey-blue highlight for rows) */ -void outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selecting) +static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selecting) { TreeElement *te; TreeStoreElem *tselem; + int change= 0; for (te= lb->first; te && *index >= 0; te=te->next, (*index)--) { tselem= TREESTORE(te); @@ -131,6 +132,8 @@ void outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selectin tselem->flag |= TSE_SELECTED; else tselem->flag &= ~TSE_SELECTED; + + change |= 1; } } else if ((tselem->flag & TSE_CLOSED)==0) { @@ -142,10 +145,12 @@ void outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selectin * function correctly */ (*index)--; - outliner_select(soops, &te->subtree, index, selecting); + change |= outliner_select(soops, &te->subtree, index, selecting); (*index)++; } } + + return change; } /* ****************************************************** */ @@ -839,11 +844,14 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) fmval[0], fmval[1], NULL, &row); /* select relevant row */ - outliner_select(soops, &soops->tree, &row, &selecting); + if(outliner_select(soops, &soops->tree, &row, &selecting)) { - soops->storeflag |= SO_TREESTORE_REDRAW; + soops->storeflag |= SO_TREESTORE_REDRAW; - ED_undo_push(C, "Outliner selection event"); + /* no need for undo push here, only changing outliner data which is + * scene level - campbell */ + /* ED_undo_push(C, "Outliner selection event"); */ + } } ED_region_tag_redraw(ar); From 042d4d3509069a2dab9ed3a8f5629099d09548c2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 19:07:37 +0000 Subject: [PATCH 21/48] misc changes to unterface & undo - operator strings were doing undo pushes (in fileselector text for example), this is dumb since the operators themselves handle undo. - interface code checks rna props are arrays rather then checking the array length. - disable properties window pin undoing. - sequencer refresh was calling undo, disable since this is clearnign global data not handled by undo. - added commented out code for drawing mesh vertex index/key index, useful for debugging shapekey - hook issyes. --- source/blender/editors/interface/interface.c | 53 ++++++++++++------- .../editors/interface/interface_layout.c | 4 +- .../editors/space_buttons/buttons_context.c | 1 + .../editors/space_sequencer/sequencer_edit.c | 3 -- .../blender/editors/space_view3d/drawobject.c | 15 +++++- 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3bd50074d84..935a0ef6387 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -710,6 +710,27 @@ int uiButActiveOnly(const bContext *C, uiBlock *block, uiBut *but) return 1; } +/* use to check if we need to disable undo, but dont make any changes + * returns FALSE if undo needs to be disabled. */ +static int ui_but_is_rna_undo(uiBut *but) +{ + if(but->rnapoin.id.data) { + /* avoid undo push for buttons who's ID are screen or wm level + * we could disable undo for buttons with no ID too but may have + * unforseen conciquences, so best check for ID's we _know_ are not + * handled by undo - campbell */ + ID *id= but->rnapoin.id.data; + if(ELEM(GS(id->name), ID_SCR, ID_WM)) { + return FALSE; + } + else { + return TRUE; + } + } + + return TRUE; +} + /* assigns automatic keybindings to menu items for fast access * (underline key in menu) */ static void ui_menu_block_set_keyaccels(uiBlock *block) @@ -1245,12 +1266,14 @@ int ui_is_but_float(uiBut *but) int ui_is_but_unit(uiBut *but) { - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); - int unit_type= uiButGetUnitType(but); + const int unit_type= uiButGetUnitType(but); + Scene *scene; /* avoid getting the scene on non unit buttons */ if(unit_type == PROP_UNIT_NONE) return 0; + scene= CTX_data_scene((bContext *)but->block->evil_C); + #if 1 // removed so angle buttons get correct snapping if (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) return 0; @@ -1293,19 +1316,19 @@ double ui_get_but_val(uiBut *but) switch(RNA_property_type(prop)) { case PROP_BOOLEAN: - if(RNA_property_array_length(&but->rnapoin, prop)) + if(RNA_property_array_check(prop)) value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_boolean_get(&but->rnapoin, prop); break; case PROP_INT: - if(RNA_property_array_length(&but->rnapoin, prop)) + if(RNA_property_array_check(prop)) value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_int_get(&but->rnapoin, prop); break; case PROP_FLOAT: - if(RNA_property_array_length(&but->rnapoin, prop)) + if(RNA_property_array_check(prop)) value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_float_get(&but->rnapoin, prop); @@ -2506,12 +2529,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { + const PropertyType proptype= RNA_property_type(prop); uiBut *but; - PropertyType proptype; int freestr= 0, icon= 0; - proptype= RNA_property_type(prop); - /* use rna values if parameters are not specified */ if(!str) { if(type == MENU && proptype == PROP_ENUM) { @@ -2636,20 +2657,14 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s UI_DEF_BUT_RNA_DISABLE(but); } - /* avoid undo push for buttons who's ID are screen or wm level - * we could disable undo for buttons with no ID too but but may have - * unforseen conciquences, so best check for ID's we _know_ are not - * handled by undo - campbell */ - if (but->flag & UI_BUT_UNDO) { - ID *id= ptr->id.data; - if(id && ELEM(GS(id->name), ID_SCR, ID_WM)) { - but->flag &= ~UI_BUT_UNDO; - } + if (but->flag & UI_BUT_UNDO && (ui_but_is_rna_undo(but) == FALSE)) { + but->flag &= ~UI_BUT_UNDO; } /* If this button uses units, calculate the step from this */ - if(ui_is_but_unit(but)) + if((proptype == PROP_FLOAT) && ui_is_but_unit(but)) { but->a1= ui_get_but_step_unit(but, but->a1); + } if(freestr) MEM_freeN((void *)str); @@ -2693,6 +2708,7 @@ static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip); but->optype= ot; but->opcontext= opcontext; + but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */ if(!ot) { but->flag |= UI_BUT_DISABLED; @@ -2722,6 +2738,7 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); but->optype= ot; but->opcontext= opcontext; + but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */ if(!ot) { but->flag |= UI_BUT_DISABLED; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 4810b3fdf54..3575a8527fc 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1017,12 +1017,10 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only); /* enum item */ else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) { - const char *identifier= RNA_property_identifier(prop); - if(icon && name[0] && !icon_only) uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); else if(icon) - uiDefIconButR(block, ROW, 0, icon, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); else uiDefButR_prop(block, ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 8e1a4b2d16c..0d81a84deea 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -904,6 +904,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) block= uiLayoutGetBlock(row); uiBlockSetEmboss(block, UI_EMBOSSN); but= uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed"); + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ uiButSetFunc(but, pin_cb, NULL, NULL); for(a=0; alen; a++) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 5429f0ee98f..531ecebba5e 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1228,9 +1228,6 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_refresh_all_exec; ot->poll= sequencer_edit_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f5c178267aa..ddc10d78cac 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2367,7 +2367,20 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E } } } - + + /* 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); From 0de911210215fb6730977c68c0b310b840638b1d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Aug 2011 20:01:30 +0000 Subject: [PATCH 22/48] store a pointer to the units system in the uiBlock since the button code was doing context lookups for the scene quite a lot. --- source/blender/editors/interface/interface.c | 40 +++++++++---------- .../editors/interface/interface_handlers.c | 8 ++-- .../editors/interface/interface_intern.h | 4 +- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 935a0ef6387..a5ceb8bdb19 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1266,16 +1266,14 @@ int ui_is_but_float(uiBut *but) int ui_is_but_unit(uiBut *but) { + UnitSettings *unit= but->block->unit; const int unit_type= uiButGetUnitType(but); - Scene *scene; /* avoid getting the scene on non unit buttons */ if(unit_type == PROP_UNIT_NONE) return 0; - scene= CTX_data_scene((bContext *)but->block->evil_C); - #if 1 // removed so angle buttons get correct snapping - if (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) + if (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) return 0; #endif @@ -1283,7 +1281,7 @@ int ui_is_but_unit(uiBut *but) if (unit_type == PROP_UNIT_TIME) return 0; - if (scene->unit.system == USER_UNIT_NONE) { + if (unit->system == USER_UNIT_NONE) { if (unit_type != PROP_UNIT_ROTATION) { return 0; } @@ -1482,19 +1480,20 @@ int ui_get_but_string_max_length(uiBut *but) static double ui_get_but_scale_unit(uiBut *but, double value) { - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + UnitSettings *unit= but->block->unit; int unit_type= uiButGetUnitType(but); if(unit_type == PROP_UNIT_LENGTH) { - return value * (double)scene->unit.scale_length; + return value * (double)unit->scale_length; } else if(unit_type == PROP_UNIT_AREA) { - return value * pow(scene->unit.scale_length, 2); + return value * pow(unit->scale_length, 2); } else if(unit_type == PROP_UNIT_VOLUME) { - return value * pow(scene->unit.scale_length, 3); + return value * pow(unit->scale_length, 3); } else if(unit_type == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */ + Scene *scene= CTX_data_scene(but->block->evil_C); return FRA2TIME(value); } else { @@ -1506,14 +1505,14 @@ static double ui_get_but_scale_unit(uiBut *but, double value) void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen) { if(ui_is_but_unit(but)) { + UnitSettings *unit= but->block->unit; int unit_type= uiButGetUnitType(but); char *orig_str; - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); orig_str= MEM_callocN(sizeof(char)*maxlen + 1, "textedit sub str"); memcpy(orig_str, str, maxlen); - bUnit_ToUnitAltName(str, maxlen, orig_str, scene->unit.system, unit_type>>16); + bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, unit_type>>16); MEM_freeN(orig_str); } @@ -1521,27 +1520,26 @@ void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen) static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad) { - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); - int do_split= scene->unit.flag & USER_UNIT_OPT_SPLIT; + UnitSettings *unit= but->block->unit; + int do_split= unit->flag & USER_UNIT_OPT_SPLIT; int unit_type= uiButGetUnitType(but); int precision= but->a2; - if(scene->unit.scale_length<0.0001f) scene->unit.scale_length= 1.0f; // XXX do_versions + if(unit->scale_length<0.0001f) unit->scale_length= 1.0f; // XXX do_versions /* Sanity checks */ if(precision > PRECISION_FLOAT_MAX) precision= PRECISION_FLOAT_MAX; else if(precision==0) precision= 2; - bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, scene->unit.system, unit_type>>16, do_split, pad); + bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, unit->system, unit_type>>16, do_split, pad); } static float ui_get_but_step_unit(uiBut *but, float step_default) { - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); int unit_type= uiButGetUnitType(but)>>16; float step; - step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), scene->unit.system, unit_type); + step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), but->block->unit->system, unit_type); if(step > 0.0f) { /* -1 is an error value */ return (float)((double)step/ui_get_but_scale_unit(but, 1.0))*100.0f; @@ -1629,12 +1627,11 @@ static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char * { char str_unit_convert[256]; const int unit_type= uiButGetUnitType(but); - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ - bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type>>16); + bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), but->block->unit->system, unit_type>>16); return (BPY_button_exec(C, str_unit_convert, value, TRUE) != -1); } @@ -1981,7 +1978,10 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor block->active= 1; block->dt= dt; block->evil_C= (void*)C; // XXX - if (scn) block->color_profile= (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT); + if (scn) { + block->color_profile= (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT); + block->unit= &scn->unit; + } BLI_strncpy(block->name, name, sizeof(block->name)); if(region) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 6f3ca2bf003..3bd29f8de3e 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2310,13 +2310,13 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa float fac= 1.0f; if(ui_is_but_unit(but)) { - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + UnitSettings *unit= but->block->unit; int unit_type= uiButGetUnitType(but)>>16; - if(bUnit_IsValid(scene->unit.system, unit_type)) { - fac= (float)bUnit_BaseScalar(scene->unit.system, unit_type); + if(bUnit_IsValid(unit->system, unit_type)) { + fac= (float)bUnit_BaseScalar(unit->system, unit_type); if(ELEM3(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) { - fac /= scene->unit.scale_length; + fac /= unit->scale_length; } } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 242210e01bb..40b98bebcd0 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -332,7 +332,9 @@ struct uiBlock { void *evil_C; // XXX hack for dynamic operator enums float _hsv[3]; // XXX, only access via ui_block_hsv_get() - char color_profile; // color profile for correcting linear colors for display + char color_profile; // color profile for correcting linear colors for display + struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. + }; typedef struct uiSafetyRct { From 561b49e9258f46229ccf5a2426d3deae01028ae3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Aug 2011 10:35:47 +0000 Subject: [PATCH 23/48] minor style change --- source/blender/python/intern/bpy_rna.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4d8d524d7e3..accc34152b5 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4309,7 +4309,6 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject PropertyRNA *parm; PyObject *ret, *item; int i, pyargs_len, pykw_len, parms_len, ret_len, flag, err= 0, kw_tot= 0, kw_arg; - const char *parm_id; PropertyRNA *pret_single= NULL; void *retdata_single= NULL; @@ -4385,28 +4384,29 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject continue; } - parm_id= RNA_property_identifier(parm); item= NULL; if (i < pyargs_len) { item= PyTuple_GET_ITEM(args, i); - i++; - kw_arg= FALSE; } else if (kw != NULL) { - item= PyDict_GetItemString(kw, parm_id); /* borrow ref */ + item= PyDict_GetItemString(kw, RNA_property_identifier(parm)); /* borrow ref */ if(item) kw_tot++; /* make sure invalid keywords are not given */ kw_arg= TRUE; } + i++; /* current argument */ + if (item==NULL) { if(flag & PROP_REQUIRED) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): required parameter \"%.200s\" not specified", - RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parm_id); + RNA_struct_identifier(self_ptr->type), + RNA_function_identifier(self_func), + RNA_property_identifier(parm)); err= -1; break; } @@ -4433,9 +4433,18 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject PyErr_Clear(); /* re-raise */ if(kw_arg==TRUE) - snprintf(error_prefix, sizeof(error_prefix), "%s.%s(): error with keyword argument \"%s\" - ", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parm_id); + BLI_snprintf(error_prefix, sizeof(error_prefix), + "%.200s.%.200s(): error with keyword argument \"%.200s\" - ", + RNA_struct_identifier(self_ptr->type), + RNA_function_identifier(self_func), + RNA_property_identifier(parm)); else - snprintf(error_prefix, sizeof(error_prefix), "%s.%s(): error with argument %d, \"%s\" - ", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), i, parm_id); + BLI_snprintf(error_prefix, sizeof(error_prefix), + "%.200s.%.200s(): error with argument %d, \"%.200s\" - ", + RNA_struct_identifier(self_ptr->type), + RNA_function_identifier(self_func), + i, + RNA_property_identifier(parm)); pyrna_py_to_prop(&funcptr, parm, iter.data, item, error_prefix); From 2c1182664cb65e760742ed43fa840cd241d74b4a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Aug 2011 10:38:34 +0000 Subject: [PATCH 24/48] minor speedup to python/rna api keyword argument lookups. - dont use hash lookups in this case because converting the string to unicode and doing a hash lookup is slower then looping over the keys and comparing (which avoids creating and throwning away a unicode string). --- source/blender/python/intern/bpy_rna.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index accc34152b5..1b8f986e71c 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4297,6 +4297,27 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat return ret; } +/* Use to replace PyDict_GetItemString() when the overhead of converting a + * string into a python unicode is higher than a non hash lookup. + * works on small dict's such as keyword args. */ +static PyObject *small_dict_get_item_string(PyObject *dict, const char *key_lookup) +{ + PyObject *key= NULL; + Py_ssize_t pos = 0; + PyObject *value = NULL; + + /* case not, search for it in the script's global dictionary */ + while (PyDict_Next(dict, &pos, &key, &value)) { + if(PyUnicode_Check(key)) { + if(strcmp(key_lookup, _PyUnicode_AsString(key))==0) { + return value; + } + } + } + + return NULL; +} + static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject *kw) { /* Note, both BPy_StructRNA and BPy_PropertyRNA can be used here */ @@ -4391,7 +4412,11 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject kw_arg= FALSE; } else if (kw != NULL) { +#if 0 item= PyDict_GetItemString(kw, RNA_property_identifier(parm)); /* borrow ref */ +#else + item= small_dict_get_item_string(kw, RNA_property_identifier(parm)); /* borrow ref */ +#endif if(item) kw_tot++; /* make sure invalid keywords are not given */ From 3a81f23e0975ea87ade780965462ad5b15b39d95 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Aug 2011 16:21:29 +0000 Subject: [PATCH 25/48] warning cleanup for -Wdouble-promotion --- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenlib/intern/jitter.c | 74 +++++++++---------- source/blender/blenlib/intern/math_geom.c | 6 +- source/blender/blenlib/intern/math_rotation.c | 6 +- source/blender/blenlib/intern/rct.c | 8 +- source/blender/blenlib/intern/scanfill.c | 16 ++-- .../editors/interface/interface_widgets.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_bake.c | 4 +- .../editors/space_outliner/outliner_intern.h | 4 +- .../editors/space_view3d/view3d_draw.c | 8 +- .../editors/space_view3d/view3d_edit.c | 4 +- .../blender/editors/space_view3d/view3d_fly.c | 2 +- source/blender/editors/transform/transform.c | 2 +- .../blender/makesrna/intern/rna_sequencer.c | 2 +- .../render/intern/source/convertblender.c | 16 ++-- .../render/intern/source/volume_precache.c | 4 +- .../blender/render/intern/source/volumetric.c | 18 ++--- .../blender/render/intern/source/voxeldata.c | 6 +- .../windowmanager/intern/wm_operators.c | 2 +- 20 files changed, 94 insertions(+), 94 deletions(-) diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index ea055e90b45..3a86389dba7 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -923,7 +923,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d for(i = 0; i < dm->getNumVerts(dm); i++) { - maxdist = MAX2(maxdist, clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len*2.0)); + maxdist = MAX2(maxdist, clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len*2.0f)); } clmd->clothObject->bvhselftree = bvhselftree_build_from_cloth ( clmd, maxdist ); diff --git a/source/blender/blenlib/intern/jitter.c b/source/blender/blenlib/intern/jitter.c index 16f0c86c449..f0e81d6b5e9 100644 --- a/source/blender/blenlib/intern/jitter.c +++ b/source/blender/blenlib/intern/jitter.c @@ -53,10 +53,10 @@ void BLI_jitterate1(float *jit1, float *jit2, int num, float rad1) y = jit1[i+1]; for (j = 2*num-2; j>=0 ; j-=2) { if (i != j){ - vecx = jit1[j] - x - 1.0; - vecy = jit1[j+1] - y - 1.0; + vecx = jit1[j] - x - 1.0f; + vecy = jit1[j+1] - y - 1.0f; for (k = 3; k>0 ; k--){ - if( fabs(vecx)0 && len0 && len0 && len= 0 ; j-=2){ if (i != j){ - vecx = jit1[j] - x - 1.0; - vecy = jit1[j+1] - y - 1.0; + vecx = jit1[j] - x - 1.0f; + vecy = jit1[j+1] - y - 1.0f; - if( fabs(vecx) 0.0) { + else if (i > 0.0f) { const float i_sqrt= sqrt(i); /* avoid calc twice */ /* first intersection */ @@ -456,7 +456,7 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2], madd_v2_v2v2fl(r_p1, l1, ldir, mu); return 1; } - else if (i > 0.0) { + else if (i > 0.0f) { const float i_sqrt= sqrt(i); /* avoid calc twice */ /* first intersection */ @@ -2010,7 +2010,7 @@ void resolve_quad_uv(float uv[2], const float st[2], const float st0[2], const f } if(IS_ZERO(denom)==0) - uv[1]= (float) (( (1-uv[0])*(st0[i]-st[i]) + uv[0]*(st1[i]-st[i]) ) / denom); + uv[1]= (float) (( (1.0f-uv[0])*(st0[i]-st[i]) + uv[0]*(st1[i]-st[i]) ) / denom); } } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index dfd715ccbf2..e3e507d016a 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -213,7 +213,7 @@ void quat_to_mat4(float m[][4], const float q[4]) double q0, q1, q2, q3, qda,qdb,qdc,qaa,qab,qac,qbb,qbc,qcc; #ifdef DEBUG - if(!((q0=dot_qtqt(q, q))==0.0f || (fabsf(q0-1.0f) < (float)QUAT_EPSILON))) { + if(!((q0=dot_qtqt(q, q))==0.0f || (fabs(q0-1.0) < QUAT_EPSILON))) { fprintf(stderr, "Warning! quat_to_mat4() called with non-normalized: size %.8f *** report a bug ***\n", (float)q0); } #endif @@ -492,8 +492,8 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag) else angle= (float)(-0.5*atan2(-fp[0], -fp[1])); } - co= (float)cos(angle); - si= (float)(sin(angle)/len1); + co= cosf(angle); + si= sinf(angle)/len1; q2[0]= co; q2[1]= x2*si; q2[2]= y2*si; diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 17b07b49309..31ae8adc2d4 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -233,10 +233,10 @@ int BLI_isect_rcti(rcti *src1, rcti *src2, rcti *dest) void BLI_copy_rcti_rctf(rcti *tar, const rctf *src) { - tar->xmin= floor(src->xmin + 0.5); - tar->xmax= floor((src->xmax - src->xmin) + 0.5); - tar->ymin= floor(src->ymin + 0.5); - tar->ymax= floor((src->ymax - src->ymin) + 0.5); + tar->xmin= floor(src->xmin + 0.5f); + tar->xmax= floor((src->xmax - src->xmin) + 0.5f); + tar->ymin= floor(src->ymin + 0.5f); + tar->ymax= floor((src->ymax - src->ymin) + 0.5f); } void print_rctf(const char *str, rctf *rect) diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 47a07d86e66..b159106f748 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -288,7 +288,7 @@ static short testedgeside(float *v1, float *v2, float *v3) inp= (v2[cox]-v1[cox])*(v1[coy]-v3[coy]) +(v1[coy]-v2[coy])*(v1[cox]-v3[cox]); - if(inp<0.0) return 0; + if(inp < 0.0f) return 0; else if(inp==0) { if(v1[cox]==v3[cox] && v1[coy]==v3[coy]) return 0; if(v2[cox]==v3[cox] && v2[coy]==v3[coy]) return 0; @@ -312,8 +312,8 @@ static short addedgetoscanvert(ScFillVert *sc, EditEdge *eed) y= eed->v1->co[coy]; fac1= eed->v2->co[coy]-y; - if(fac1==0.0) { - fac1= 1.0e10*(eed->v2->co[cox]-x); + if(fac1==0.0f) { + fac1= 1.0e10f*(eed->v2->co[cox]-x); } else fac1= (x-eed->v2->co[cox])/fac1; @@ -324,8 +324,8 @@ static short addedgetoscanvert(ScFillVert *sc, EditEdge *eed) if(ed->v2==eed->v2) return 0; fac= ed->v2->co[coy]-y; - if(fac==0.0) { - fac= 1.0e10*(ed->v2->co[cox]-x); + if(fac==0.0f) { + fac= 1.0e10f*(ed->v2->co[cox]-x); } else fac= (x-ed->v2->co[cox])/fac; @@ -443,7 +443,7 @@ static void testvertexnearedge(void) vec2[1]= eed->v2->co[coy]; if(boundinsideEV(eed,eve)) { dist= dist_to_line_v2(vec1,vec2,vec3); - if(distv1, eve); @@ -816,7 +816,7 @@ int BLI_edgefill(short mat_nr) if(v2) { if( compare_v3v3(v2, eve->co, COMPLIMIT)==0) { len= normal_tri_v3( norm,v1, v2, eve->co); - if(len != 0.0) break; + if(len != 0.0f) break; } } else if(compare_v3v3(v1, eve->co, COMPLIMIT)==0) { @@ -825,7 +825,7 @@ int BLI_edgefill(short mat_nr) eve= eve->next; } - if(len==0.0) return 0; /* no fill possible */ + if(len==0.0f) return 0; /* no fill possible */ norm[0]= fabs(norm[0]); norm[1]= fabs(norm[1]); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index d235fd0c16a..5da875356ea 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -180,7 +180,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y glEnable(GL_BLEND); glGetFloatv(GL_CURRENT_COLOR, color); - color[3]*= 0.125; + color[3] *= 0.125f; glColor4fv(color); /* for each AA step */ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index cd42661f320..d5f10f1d37d 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -182,7 +182,7 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) } RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location for the newly added object", -FLT_MAX, FLT_MAX); - RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", "Rotation for the newly added object", -M_PI * 2.0f, M_PI * 2.0f); + RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", "Rotation for the newly added object", (float)-M_PI * 2.0f, (float)M_PI * 2.0f); prop = RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", ""); RNA_def_property_flag(prop, PROP_HIDDEN); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 679e4e58017..ee162464c70 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -636,14 +636,14 @@ static void apply_heights_data(void *bake_data) if(ibuf->rect_float) { float *rrgbf= ibuf->rect_float + i*4; - if(max-min > 1e-5) height= (heights[i]-min)/(max-min); + if(max-min > 1e-5f) height= (heights[i]-min)/(max-min); else height= 0; rrgbf[0]=rrgbf[1]=rrgbf[2]= height; } else { char *rrgb= (char*)ibuf->rect + i*4; - if(max-min > 1e-5) height= (heights[i]-min)/(max-min); + if(max-min > 1e-5f) height= (heights[i]-min)/(max-min); else height= 0; rrgb[0]=rrgb[1]=rrgb[2]= FTOCHAR(height); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 1a6448588aa..cf4ce9c06a8 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -124,8 +124,8 @@ typedef struct TreeElement { #define OL_TOGW OL_TOG_RESTRICT_VIEWX #define OL_RNA_COLX (UI_UNIT_X*15) -#define OL_RNA_COL_SIZEX (UI_UNIT_X*7.5) -#define OL_RNA_COL_SPACEX (UI_UNIT_X*2.5) +#define OL_RNA_COL_SIZEX (UI_UNIT_X*7.5f) +#define OL_RNA_COL_SPACEX (UI_UNIT_X*2.5f) /* outliner_tree.c ----------------------------------------------- */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7cf95261211..f8837594ddb 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -721,7 +721,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) { #define ROT_AXIS_DETAIL 13 const float s = 0.05f * scale; - const float step = 2.f * M_PI / ROT_AXIS_DETAIL; + const float step = 2.f * (float)(M_PI / ROT_AXIS_DETAIL); float angle; int i; @@ -1041,7 +1041,7 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons glBegin(GL_LINES); if(w > h) { if(golden) { - ofs = w * (1.0f-(1.0f/1.61803399)); + ofs = w * (1.0f-(1.0f/1.61803399f)); } else { ofs = h * (h / w); @@ -1059,7 +1059,7 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons } else { if(golden) { - ofs = h * (1.0f-(1.0f/1.61803399)); + ofs = h * (1.0f-(1.0f/1.61803399f)); } else { ofs = w * (w / h); @@ -1203,7 +1203,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (ca->dtx & CAM_DTX_GOLDEN) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399)); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399f)); } if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 3e6bbc13334..979a602b4f5 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1697,7 +1697,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot) static void view_dolly_mouseloc(ARegion *ar, float orig_ofs[3], float dvec[3], float dfac) { RegionView3D *rv3d= ar->regiondata; - madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0 - dfac)); + madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0f - dfac)); } static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_invert) @@ -1718,7 +1718,7 @@ static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_inv if (zoom_invert) SWAP(float, len1, len2); - zfac = 1.0 + ((len2 - len1) * 0.01 * vod->rv3d->dist); + zfac = 1.0f + ((len2 - len1) * 0.01f * vod->rv3d->dist); } if(zfac != 1.0f) diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 046037a092f..30d1a508888 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -867,7 +867,7 @@ static int flyApply(bContext *C, FlyInfo *fly) upvec[2]=1; mul_m3_v3(mat, upvec); /*make sure we have some z rolling*/ - if (fabs(upvec[2]) > 0.00001f) { + if (fabsf(upvec[2]) > 0.00001f) { roll= upvec[2] * -5.0f; upvec[0]= 1.0f; /*rotate the view about this axis*/ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 03a98bf30d8..b234ac4ceec 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4648,7 +4648,7 @@ static int createSlideVerts(TransInfo *t) uv_new = tf->uv[k]; if (ev->tmp.l) { - if (fabs(suv->origuv[0]-uv_new[0]) > 0.0001f || fabs(suv->origuv[1]-uv_new[1]) > 0.0001f) { + if (fabsf(suv->origuv[0]-uv_new[0]) > 0.0001f || fabs(suv->origuv[1]-uv_new[1]) > 0.0001f) { ev->tmp.l = -1; /* Tag as invalid */ BLI_linklist_free(suv->fuv_list,NULL); suv->fuv_list = NULL; diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 8c4e4d9e736..476ac325848 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1481,7 +1481,7 @@ static void rna_def_wipe(BlenderRNA *brna) #if 1 /* expose as radians */ prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_funcs(prop, "rna_WipeSequence_angle_get", "rna_WipeSequence_angle_set", NULL); - RNA_def_property_range(prop, DEG2RAD(-90.0f), DEG2RAD(90.0f)); + RNA_def_property_range(prop, DEG2RAD(-90.0), DEG2RAD(90.0)); #else prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "angle"); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index b385b507707..f749d1ba004 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -192,10 +192,10 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), /* minimal free space (starting at camera) */ starmindist= wrld->starmindist; - if (stargrid <= 0.10) return; + if (stargrid <= 0.10f) return; if (re) re->flag |= R_HALO; - else stargrid *= 1.0; /* then it draws fewer */ + else stargrid *= 1.0f; /* then it draws fewer */ if(re) invert_m4_m4(mat, re->viewmat); else unit_m4(mat); @@ -267,17 +267,17 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), if (alpha >= clipend) alpha = 0.0; else if (alpha <= starmindist) alpha = 0.0; - else if (alpha <= 2.0 * starmindist) { + else if (alpha <= 2.0f * starmindist) { alpha = (alpha - starmindist) / starmindist; } else { - alpha -= 2.0 * starmindist; - alpha /= (clipend - 2.0 * starmindist); - alpha = 1.0 - alpha; + alpha -= 2.0f * starmindist; + alpha /= (clipend - 2.0f * starmindist); + alpha = 1.0f - alpha; } } - if (alpha != 0.0) { + if (alpha != 0.0f) { fac = force * BLI_drand(); har = initstar(re, obr, vec, fac); @@ -822,7 +822,7 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d if(obr->totvert==0) return; asverts= MEM_callocN(sizeof(ASvert)*obr->totvert, "all smooth verts"); - thresh= cos( M_PI*(0.5f+(float)degr)/180.0 ); + thresh= cosf((float)M_PI*(0.5f+(float)degr)/180.0f ); /* step zero: give faces normals of original mesh, if this is provided */ diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index faa915b7f6c..2037acc943f 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -400,7 +400,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi sb[j] += vp->data_b[i]; /* Displays progress every second */ - if(time-lasttime>1.0f) { + if(time-lasttime>1.0) { char str[64]; BLI_snprintf(str, sizeof(str), "Simulating multiple scattering: %d%%", (int)(100.0f * (c / total))); re->i.infostr= str; @@ -747,7 +747,7 @@ static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *o caching=0; time= PIL_check_seconds_timer(); - if(time-lasttime>1.0f) { + if(time-lasttime>1.0) { char str[64]; BLI_snprintf(str, sizeof(str), "Precaching volume: %d%%", (int)(100.0f * ((float)counter / (float)totparts))); re->i.infostr= str; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 359002d05ae..19bbb11e143 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -422,9 +422,9 @@ static void vol_get_transmittance_seg(ShadeInput *shi, float *tr, float stepsize tau[1] += stepd * sigma_t[1]; tau[2] += stepd * sigma_t[2]; - tr[0] *= exp(-tau[0]); - tr[1] *= exp(-tau[1]); - tr[2] *= exp(-tau[2]); + tr[0] *= expf(-tau[0]); + tr[1] *= expf(-tau[1]); + tr[2] *= expf(-tau[2]); } /* Compute transmittance = e^(-attenuation) */ @@ -473,7 +473,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) return; if ((lar->lay & shi->lay)==0) return; - if (lar->energy == 0.0) return; + if (lar->energy == 0.0f) return; if ((visifac= lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return; @@ -613,7 +613,7 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float /* transmittance component (alpha) */ vol_get_transmittance_seg(shi, tr, stepsize, co, density); - if (t0 > t1 * 0.25) { + if (t0 > t1 * 0.25f) { /* only use depth cutoff after we've traced a little way into the volume */ if (luminance(tr) < shi->mat->vol.depth_cutoff) break; } @@ -623,9 +623,9 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float if (shi->obi->volume_precache) { float p2[3]; - p2[0] = p[0] + (step_vec[0] * 0.5); - p2[1] = p[1] + (step_vec[1] * 0.5); - p2[2] = p[2] + (step_vec[2] * 0.5); + p2[0] = p[0] + (step_vec[0] * 0.5f); + p2[1] = p[1] + (step_vec[1] * 0.5f); + p2[2] = p[2] + (step_vec[2] * 0.5f); vol_get_precached_scattering(&R, shi, scatter_col, p2); } else @@ -817,7 +817,7 @@ void shade_volume_inside(ShadeInput *shi, ShadeResult *shr) volume_trace(shi, shr, VOL_SHADE_INSIDE); shr->alpha = shr->alpha + prev_alpha; - CLAMP(shr->alpha, 0.0, 1.0); + CLAMP(shr->alpha, 0.0f, 1.0f); shi->mat = mat_backup; shi->obi = obi_backup; diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 232f7fdeede..2ba346ae4c5 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -413,9 +413,9 @@ int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres) } case TEX_REPEAT: { - co[0] = co[0] - floor(co[0]); - co[1] = co[1] - floor(co[1]); - co[2] = co[2] - floor(co[2]); + co[0] = co[0] - floorf(co[0]); + co[1] = co[1] - floorf(co[1]); + co[2] = co[2] - floorf(co[2]); break; } case TEX_EXTEND: diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1beb5b3dda3..fdf89cfd2be 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2926,7 +2926,7 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd case PROP_FACTOR: r1= (1 - rc->current_value) * WM_RADIAL_CONTROL_DISPLAY_SIZE; r2= tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE; - alpha = rc->current_value / 2 + 0.5; + alpha = rc->current_value / 2.0f + 0.5f; break; case PROP_ANGLE: r1= r2= tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE; From 90d19ad883b60511bfdbf9eba9fc9e46c3d69f51 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Aug 2011 19:25:20 +0000 Subject: [PATCH 26/48] py style change only - make property definitions consistent --- .../startup/bl_operators/add_mesh_torus.py | 66 +++++++---- release/scripts/startup/bl_operators/mesh.py | 10 +- .../scripts/startup/bl_operators/object.py | 8 +- .../startup/bl_operators/object_align.py | 55 ++++----- .../bl_operators/object_quick_effects.py | 111 +++++++++++------- .../object_randomize_transform.py | 9 +- .../scripts/startup/bl_operators/sequencer.py | 8 +- .../startup/bl_operators/uvcalc_lightmap.py | 1 - .../bl_operators/uvcalc_smart_project.py | 23 ++-- .../startup/bl_operators/vertexpaint_dirt.py | 34 +++++- release/scripts/startup/bl_operators/wm.py | 2 - release/scripts/startup/bl_ui/__init__.py | 5 +- .../scripts/startup/bl_ui/space_console.py | 6 +- .../scripts/startup/bl_ui/space_userpref.py | 46 ++++++-- .../startup/bl_ui/space_userpref_keymap.py | 70 +++++++++-- release/scripts/templates/addon_add_object.py | 10 +- release/scripts/templates/operator_export.py | 24 ++-- .../scripts/templates/operator_mesh_add.py | 41 ++++--- .../templates/operator_modal_view3d.py | 5 +- 19 files changed, 363 insertions(+), 171 deletions(-) diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index 1c4518c4feb..056b3478c2b 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -88,36 +88,62 @@ class AddTorus(Operator): bl_label = "Add Torus" bl_options = {'REGISTER', 'UNDO'} - major_radius = FloatProperty(name="Major Radius", + major_radius = FloatProperty( + name="Major Radius", description=("Radius from the origin to the " "center of the cross sections"), - default=1.0, min=0.01, max=100.0) - minor_radius = FloatProperty(name="Minor Radius", + min=0.01, max=100.0, + default=1.0, + ) + minor_radius = FloatProperty( + name="Minor Radius", description="Radius of the torus' cross section", - default=0.25, min=0.01, max=100.0) - major_segments = IntProperty(name="Major Segments", + min=0.01, max=100.0, + default=0.25, + ) + major_segments = IntProperty( + name="Major Segments", description="Number of segments for the main ring of the torus", - default=48, min=3, max=256) - minor_segments = IntProperty(name="Minor Segments", + min=3, max=256, + default=48, + ) + minor_segments = IntProperty( + name="Minor Segments", description="Number of segments for the minor ring of the torus", - default=12, min=3, max=256) - use_abso = BoolProperty(name="Use Int+Ext Controls", + min=3, max=256, + default=12, + ) + use_abso = BoolProperty( + name="Use Int+Ext Controls", description="Use the Int / Ext controls for torus dimensions", - default=False) - abso_major_rad = FloatProperty(name="Exterior Radius", + default=False, + ) + abso_major_rad = FloatProperty( + name="Exterior Radius", description="Total Exterior Radius of the torus", - default=1.0, min=0.01, max=100.0) - abso_minor_rad = FloatProperty(name="Inside Radius", + min=0.01, max=100.0, + default=1.0, + ) + abso_minor_rad = FloatProperty( + name="Inside Radius", description="Total Interior Radius of the torus", - default=0.5, min=0.01, max=100.0) + min=0.01, max=100.0, + default=0.5, + ) # generic transform props - view_align = BoolProperty(name="Align to View", - default=False) - location = FloatVectorProperty(name="Location", - subtype='TRANSLATION') - rotation = FloatVectorProperty(name="Rotation", - subtype='EULER') + view_align = BoolProperty( + name="Align to View", + default=False, + ) + location = FloatVectorProperty( + name="Location", + subtype='TRANSLATION', + ) + rotation = FloatVectorProperty( + name="Rotation", + subtype='EULER', + ) def execute(self, context): diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index 4114381f3dc..5f6583754e9 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -74,11 +74,11 @@ class MeshMirrorUV(Operator): bl_label = "Copy Mirrored UV coords" bl_options = {'REGISTER', 'UNDO'} - direction = EnumProperty(items=( - ('POSITIVE', "Positive", ""), - ('NEGATIVE', "Negative", "")), - name="Axis Direction", - description="") + direction = EnumProperty( + name="Axis Direction", + items=(('POSITIVE', "Positive", ""), + ('NEGATIVE', "Negative", "")), + ) @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index 79f57990f37..d26ec53e4e3 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -195,8 +195,12 @@ class SubdivisionSet(Operator): bl_label = "Subdivision Set" bl_options = {'REGISTER', 'UNDO'} - level = IntProperty(name="Level", - default=1, min=-100, max=100, soft_min=-6, soft_max=6) + level = IntProperty( + name="Level", + min=-100, max=100, + soft_min=-6, soft_max=6, + default=1, + ) relative = BoolProperty( name="Relative", diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index d4a3d826f2f..50e9bfb5b98 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -351,33 +351,34 @@ class AlignObjects(Operator): description=("Enables high quality calculation of the " "bounding box for perfect results on complex " "shape meshes with rotation/scale (Slow)"), - default=True) - - align_mode = EnumProperty(items=( - ('OPT_1', "Negative Sides", ""), - ('OPT_2', "Centers", ""), - ('OPT_3', "Positive Sides", "")), - name="Align Mode:", - description="", - default='OPT_2') - - relative_to = EnumProperty(items=( - ('OPT_1', "Scene Origin", ""), - ('OPT_2', "3D Cursor", ""), - ('OPT_3', "Selection", ""), - ('OPT_4', "Active", "")), - name="Relative To:", - description="", - default='OPT_4') - - align_axis = EnumProperty(items=( - ('X', "X", ""), - ('Y', "Y", ""), - ('Z', "Z", ""), - ), - name="Align", - description="Align to axis", - options={'ENUM_FLAG'}) + default=True, + ) + align_mode = EnumProperty( + name="Align Mode:", + items=(('OPT_1', "Negative Sides", ""), + ('OPT_2', "Centers", ""), + ('OPT_3', "Positive Sides", ""), + ), + default='OPT_2', + ) + relative_to = EnumProperty( + name="Relative To:", + items=(('OPT_1', "Scene Origin", ""), + ('OPT_2', "3D Cursor", ""), + ('OPT_3', "Selection", ""), + ('OPT_4', "Active", ""), + ), + default='OPT_4', + ) + align_axis = EnumProperty( + name="Align", + description="Align to axis", + items=(('X', "X", ""), + ('Y', "Y", ""), + ('Z', "Z", ""), + ), + options={'ENUM_FLAG'}, + ) @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index cd206da3a8e..48b547980d4 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -51,19 +51,25 @@ class QuickFur(Operator): bl_label = "Quick Fur" bl_options = {'REGISTER', 'UNDO'} - density = EnumProperty(items=( - ('LIGHT', "Light", ""), - ('MEDIUM', "Medium", ""), - ('HEAVY', "Heavy", "")), - name="Fur Density", - description="", - default='MEDIUM') - - view_percentage = IntProperty(name="View %", - default=10, min=1, max=100, soft_min=1, soft_max=100) - - length = FloatProperty(name="Length", - default=0.1, min=0.001, max=100, soft_min=0.01, soft_max=10) + density = EnumProperty( + name="Fur Density", + items=(('LIGHT', "Light", ""), + ('MEDIUM', "Medium", ""), + ('HEAVY', "Heavy", "")), + default='MEDIUM', + ) + view_percentage = IntProperty( + name="View %", + min=1, max=100, + soft_min=1, soft_max=100, + default=10, + ) + length = FloatProperty( + name="Length", + min=0.001, max=100, + soft_min=0.01, soft_max=10, + default=0.1, + ) def execute(self, context): fake_context = bpy.context.copy() @@ -110,31 +116,50 @@ class QuickExplode(Operator): bl_label = "Quick Explode" bl_options = {'REGISTER', 'UNDO'} - style = EnumProperty(items=( - ('EXPLODE', "Explode", ""), - ('BLEND', "Blend", "")), - name="Explode Style", - description="", - default='EXPLODE') + style = EnumProperty( + name="Explode Style", + items=(('EXPLODE', "Explode", ""), + ('BLEND', "Blend", "")), + default='EXPLODE', + ) + amount = IntProperty( + name="Amount of pieces", + min=2, max=10000, + soft_min=2, soft_max=10000, + default=100, + ) + frame_duration = IntProperty( + name="Duration", + min=1, max=300000, + soft_min=1, soft_max=10000, + default=50, + ) - amount = IntProperty(name="Amount of pieces", - default=100, min=2, max=10000, soft_min=2, soft_max=10000) + frame_start = IntProperty( + name="Start Frame", + min=1, max=300000, + soft_min=1, soft_max=10000, + default=1, + ) + frame_end = IntProperty( + name="End Frame", + min=1, max=300000, + soft_min=1, soft_max=10000, + default=10, + ) - frame_duration = IntProperty(name="Duration", - default=50, min=1, max=300000, soft_min=1, soft_max=10000) + velocity = FloatProperty( + name="Outwards Velocity", + min=0, max=300000, + soft_min=0, soft_max=10, + default=1, + ) - frame_start = IntProperty(name="Start Frame", - default=1, min=1, max=300000, soft_min=1, soft_max=10000) - - frame_end = IntProperty(name="End Frame", - default=10, min=1, max=300000, soft_min=1, soft_max=10000) - - velocity = FloatProperty(name="Outwards Velocity", - default=1, min=0, max=300000, soft_min=0, soft_max=10) - - fade = BoolProperty(name="Fade", - description="Fade the pieces over time.", - default=True) + fade = BoolProperty( + name="Fade", + description="Fade the pieces over time.", + default=True, + ) def execute(self, context): fake_context = bpy.context.copy() @@ -272,12 +297,11 @@ class QuickSmoke(Operator): bl_options = {'REGISTER', 'UNDO'} style = EnumProperty( + name="Smoke Style", items=(('STREAM', "Stream", ""), ('PUFF', "Puff", ""), ('FIRE', "Fire", ""), ), - name="Smoke Style", - description="", default='STREAM', ) @@ -390,19 +414,16 @@ class QuickFluid(Operator): bl_options = {'REGISTER', 'UNDO'} style = EnumProperty( + name="Fluid Style", items=(('INFLOW', "Inflow", ""), - ('BASIC', "Basic", ""), - ), - name="Fluid Style", - description="", - default='BASIC', - ) + ('BASIC', "Basic", "")), + default='BASIC', + ) initial_velocity = FloatVectorProperty( name="Initial Velocity", description="Initial velocity of the fluid", + min=-100.0, max=100.0, default=(0.0, 0.0, 0.0), - min=-100.0, - max=100.0, subtype='VELOCITY', ) show_flows = BoolProperty( diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index f65e3d27d83..7aea18487f3 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -145,9 +145,12 @@ class RandomizeLocRotSize(Operator): default=False, ) - '''scale_min = FloatProperty(name="Minimun Scale Factor", - description="Lowest scale percentage possible", - default=0.15, min=-1.0, max=1.0, precision=3)''' + '''scale_min = FloatProperty( + name="Minimun Scale Factor", + description="Lowest scale percentage possible", + min=-1.0, max=1.0, precision=3, + default=0.15, + )''' scale = FloatVectorProperty( name="Scale", diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py index d2f85c8d7c7..856e182279a 100644 --- a/release/scripts/startup/bl_operators/sequencer.py +++ b/release/scripts/startup/bl_operators/sequencer.py @@ -82,8 +82,12 @@ class SequencerCutMulticam(Operator): bl_label = "Cut multicam" bl_options = {'REGISTER', 'UNDO'} - camera = IntProperty(name="Camera", - default=1, min=1, max=32, soft_min=1, soft_max=32) + camera = IntProperty( + name="Camera", + min=1, max=32, + soft_min=1, soft_max=32, + default=1, + ) @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index 6b1c6e1be98..060fe400045 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -552,7 +552,6 @@ class LightMapPack(Operator): PREF_CONTEXT = bpy.props.EnumProperty( name="Selection", - description="", items=(("SEL_FACES", "Selected Faces", "Space all UVs evently"), ("ALL_FACES", "All Faces", "Average space UVs edge length of each loop"), ("ALL_OBJECTS", "Selected Mesh Object", "Average space UVs edge length of each loop") diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 8afd6c104e0..78b68418322 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -1110,17 +1110,24 @@ class SmartProject(Operator): bl_label = "Smart UV Project" bl_options = {'REGISTER', 'UNDO'} - angle_limit = FloatProperty(name="Angle Limit", + angle_limit = FloatProperty( + name="Angle Limit", description="lower for more projection groups, higher for less distortion", - default=66.0, min=1.0, max=89.0) - - island_margin = FloatProperty(name="Island Margin", + min=1.0, max=89.0, + default=66.0, + ) + island_margin = FloatProperty( + name="Island Margin", description="Margin to reduce bleed from adjacent islands", - default=0.0, min=0.0, max=1.0) - - user_area_weight = FloatProperty(name="Area Weight", + min=0.0, max=1.0, + default=0.0, + ) + user_area_weight = FloatProperty( + name="Area Weight", description="Weight projections vector by faces with larger areas", - default=0.0, min=0.0, max=1.0) + min=0.0, max=1.0, + default=0.0, + ) @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index facde82f812..4c78adb7161 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -151,11 +151,35 @@ class VertexPaintDirt(Operator): bl_label = "Dirty Vertex Colors" bl_options = {'REGISTER', 'UNDO'} - blur_strength = FloatProperty(name="Blur Strength", description="Blur strength per iteration", default=1.0, min=0.01, max=1.0) - blur_iterations = IntProperty(name="Blur Iterations", description="Number times to blur the colors. (higher blurs more)", default=1, min=0, max=40) - clean_angle = FloatProperty(name="Highlight Angle", description="Less then 90 limits the angle used in the tonal range", default=180.0, min=0.0, max=180.0) - dirt_angle = FloatProperty(name="Dirt Angle", description="Less then 90 limits the angle used in the tonal range", default=0.0, min=0.0, max=180.0) - dirt_only = BoolProperty(name="Dirt Only", description="Dont calculate cleans for convex areas", default=False) + blur_strength = FloatProperty( + name="Blur Strength", + description="Blur strength per iteration", + min=0.01, max=1.0, + default=1.0, + ) + blur_iterations = IntProperty( + name="Blur Iterations", + description="Number times to blur the colors. (higher blurs more)", + min=0, max=40, + default=1, + ) + clean_angle = FloatProperty( + name="Highlight Angle", + description="Less then 90 limits the angle used in the tonal range", + min=0.0, max=180.0, + default=180.0, + ) + dirt_angle = FloatProperty( + name="Dirt Angle", + description="Less then 90 limits the angle used in the tonal range", + min=0.0, max=180.0, + default=0.0, + ) + dirt_only = BoolProperty( + name="Dirt Only", + description="Dont calculate cleans for convex areas", + default=False, + ) def execute(self, context): import time diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 885d8cf2aed..74f125e0ad3 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -557,14 +557,12 @@ class WM_OT_context_set_id(Operator): doc_id = StringProperty( name="Doc ID", - description="", maxlen=1024, options={'HIDDEN'}, ) doc_new = StringProperty( name="Edit Description", - description="", maxlen=1024, ) diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index bf63c6071b9..e1a23143bc0 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -102,7 +102,10 @@ def register(): items.extend([(cat, cat, "") for cat in sorted(items_unique)]) return items - WindowManager.addon_search = StringProperty(name="Search", description="Search within the selected filter") + WindowManager.addon_search = StringProperty( + name="Search", + description="Search within the selected filter", + ) WindowManager.addon_filter = EnumProperty( items=addon_filter_items, name="Category", diff --git a/release/scripts/startup/bl_ui/space_console.py b/release/scripts/startup/bl_ui/space_console.py index d457a66def8..b517e0d86fb 100644 --- a/release/scripts/startup/bl_ui/space_console.py +++ b/release/scripts/startup/bl_ui/space_console.py @@ -141,7 +141,11 @@ class ConsoleLanguage(Operator): '''Set the current language for this console''' bl_idname = "console.language" bl_label = "Console Language" - language = StringProperty(name="Language", maxlen=32, default="") + + language = StringProperty( + name="Language", + maxlen=32, + ) def execute(self, context): sc = context.space_data diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 148338368fe..13edc3471d2 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1106,7 +1106,10 @@ class WM_OT_addon_disable(Operator): bl_idname = "wm.addon_disable" bl_label = "Disable Add-On" - module = StringProperty(name="Module", description="Module name of the addon to disable") + module = StringProperty( + name="Module", + description="Module name of the addon to disable", + ) def execute(self, context): addon_utils.disable(self.module) @@ -1118,16 +1121,35 @@ class WM_OT_addon_install(Operator): bl_idname = "wm.addon_install" bl_label = "Install Add-On..." - overwrite = BoolProperty(name="Overwrite", description="Remove existing addons with the same ID", default=True) + overwrite = BoolProperty( + name="Overwrite", + description="Remove existing addons with the same ID", + default=True, + ) target = EnumProperty( name="Target Path", items=(('DEFAULT', "Default", ""), - ('PREFS', "User Prefs", ""))) + ('PREFS', "User Prefs", "")), + ) - filepath = StringProperty(name="File Path", description="File path to write file to") - filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'}) - filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'}) - filter_glob = StringProperty(default="*.py;*.zip", options={'HIDDEN'}) + filepath = StringProperty( + name="File Path", + description="File path to write file to", + ) + filter_folder = BoolProperty( + name="Filter folders", + default=True, + options={'HIDDEN'}, + ) + filter_python = BoolProperty( + name="Filter python", + default=True, + options={'HIDDEN'}, + ) + filter_glob = StringProperty( + default="*.py;*.zip", + options={'HIDDEN'}, + ) @staticmethod def _module_remove(path_addons, module): @@ -1264,7 +1286,10 @@ class WM_OT_addon_remove(Operator): bl_idname = "wm.addon_remove" bl_label = "Remove Add-On" - module = StringProperty(name="Module", description="Module name of the addon to remove") + module = StringProperty( + name="Module", + description="Module name of the addon to remove", + ) @staticmethod def path_from_addon(module): @@ -1312,7 +1337,10 @@ class WM_OT_addon_expand(Operator): bl_idname = "wm.addon_expand" bl_label = "" - module = StringProperty(name="Module", description="Module name of the addon to expand") + module = StringProperty( + name="Module", + description="Module name of the addon to expand", + ) def execute(self, context): module_name = self.module diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index 6a81ff5830e..9ed1591cbf3 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -533,12 +533,31 @@ class WM_OT_keyconfig_import(Operator): bl_idname = "wm.keyconfig_import" bl_label = "Import Key Configuration..." - filepath = StringProperty(name="File Path", description="Filepath to write file to", default="keymap.py") - filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'}) - filter_text = BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'}) - filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'}) - - keep_original = BoolProperty(name="Keep original", description="Keep original file after copying to configuration folder", default=True) + filepath = StringProperty( + name="File Path", + description="Filepath to write file to", + default="keymap.py", + ) + filter_folder = BoolProperty( + name="Filter folders", + default=True, + options={'HIDDEN'}, + ) + filter_text = BoolProperty( + name="Filter text", + default=True, + options={'HIDDEN'}, + ) + filter_python = BoolProperty( + name="Filter python", + default=True, + options={'HIDDEN'}, + ) + keep_original = BoolProperty( + name="Keep original", + description="Keep original file after copying to configuration folder", + default=True, + ) def execute(self, context): from os.path import basename @@ -580,10 +599,26 @@ class WM_OT_keyconfig_export(Operator): bl_idname = "wm.keyconfig_export" bl_label = "Export Key Configuration..." - filepath = StringProperty(name="File Path", description="Filepath to write file to", default="keymap.py") - filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'}) - filter_text = BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'}) - filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'}) + filepath = StringProperty( + name="File Path", + description="Filepath to write file to", + default="keymap.py", + ) + filter_folder = BoolProperty( + name="Filter folders", + default=True, + options={'HIDDEN'}, + ) + filter_text = BoolProperty( + name="Filter text", + default=True, + options={'HIDDEN'}, + ) + filter_python = BoolProperty( + name="Filter python", + default=True, + options={'HIDDEN'}, + ) def execute(self, context): if not self.filepath: @@ -673,7 +708,10 @@ class WM_OT_keymap_restore(Operator): bl_idname = "wm.keymap_restore" bl_label = "Restore Key Map(s)" - all = BoolProperty(name="All Keymaps", description="Restore all keymaps to default") + all = BoolProperty( + name="All Keymaps", + description="Restore all keymaps to default", + ) def execute(self, context): wm = context.window_manager @@ -693,7 +731,10 @@ class WM_OT_keyitem_restore(Operator): bl_idname = "wm.keyitem_restore" bl_label = "Restore Key Map Item" - item_id = IntProperty(name="Item Identifier", description="Identifier of the item to remove") + item_id = IntProperty( + name="Item Identifier", + description="Identifier of the item to remove", + ) @classmethod def poll(cls, context): @@ -737,7 +778,10 @@ class WM_OT_keyitem_remove(Operator): bl_idname = "wm.keyitem_remove" bl_label = "Remove Key Map Item" - item_id = IntProperty(name="Item Identifier", description="Identifier of the item to remove") + item_id = IntProperty( + name="Item Identifier", + description="Identifier of the item to remove", + ) @classmethod def poll(cls, context): diff --git a/release/scripts/templates/addon_add_object.py b/release/scripts/templates/addon_add_object.py index 98517fd97a0..833ac600995 100644 --- a/release/scripts/templates/addon_add_object.py +++ b/release/scripts/templates/addon_add_object.py @@ -45,10 +45,12 @@ class OBJECT_OT_add_object(bpy.types.Operator, AddObjectHelper): bl_description = "Create a new Mesh Object" bl_options = {'REGISTER', 'UNDO'} - scale = FloatVectorProperty(name='scale', - default=(1.0, 1.0, 1.0), - subtype='TRANSLATION', - description='scaling') + scale = FloatVectorProperty( + name='scale', + default=(1.0, 1.0, 1.0), + subtype='TRANSLATION', + description='scaling', + ) def execute(self, context): diff --git a/release/scripts/templates/operator_export.py b/release/scripts/templates/operator_export.py index 4cf943a53b7..aeda4ce36fb 100644 --- a/release/scripts/templates/operator_export.py +++ b/release/scripts/templates/operator_export.py @@ -24,18 +24,26 @@ class ExportSomeData(bpy.types.Operator, ExportHelper): # ExportHelper mixin class uses this filename_ext = ".txt" - filter_glob = StringProperty(default="*.txt", options={'HIDDEN'}) + filter_glob = StringProperty( + default="*.txt", + options={'HIDDEN'}, + ) # List of operator properties, the attributes will be assigned # to the class instance from the operator settings before calling. - use_setting = BoolProperty(name="Example Boolean", description="Example Tooltip", default=True) + use_setting = BoolProperty( + name="Example Boolean", + description="Example Tooltip", + default=True, + ) - type = EnumProperty(items=(('OPT_A', "First Option", "Description one"), - ('OPT_B', "Second Option", "Description two."), - ), - name="Example Enum", - description="Choose between two items", - default='OPT_A') + type = EnumProperty( + name="Example Enum", + description="Choose between two items", + items=(('OPT_A', "First Option", "Description one"), + ('OPT_B', "Second Option", "Description two.")), + default='OPT_A', + ) @classmethod def poll(cls, context): diff --git a/release/scripts/templates/operator_mesh_add.py b/release/scripts/templates/operator_mesh_add.py index 10d23a6712d..d89b7e82f77 100644 --- a/release/scripts/templates/operator_mesh_add.py +++ b/release/scripts/templates/operator_mesh_add.py @@ -43,25 +43,38 @@ class AddBox(bpy.types.Operator): bl_label = "Add Box" bl_options = {'REGISTER', 'UNDO'} - width = FloatProperty(name="Width", + width = FloatProperty( + name="Width", description="Box Width", - default=1.0, min=0.01, max=100.0) - - height = FloatProperty(name="Height", + min=0.01, max=100.0, + default=1.0, + ) + height = FloatProperty( + name="Height", description="Box Height", - default=1.0, min=0.01, max=100.0) - - depth = FloatProperty(name="Depth", + min=0.01, max=100.0, + default=1.0, + ) + depth = FloatProperty( + name="Depth", description="Box Depth", - default=1.0, min=0.01, max=100.0) + min=0.01, max=100.0, + default=1.0, + ) # generic transform props - view_align = BoolProperty(name="Align to View", - default=False) - location = FloatVectorProperty(name="Location", - subtype='TRANSLATION') - rotation = FloatVectorProperty(name="Rotation", - subtype='EULER') + view_align = BoolProperty( + name="Align to View", + default=False, + ) + location = FloatVectorProperty( + name="Location", + subtype='TRANSLATION', + ) + rotation = FloatVectorProperty( + name="Rotation", + subtype='EULER', + ) def execute(self, context): diff --git a/release/scripts/templates/operator_modal_view3d.py b/release/scripts/templates/operator_modal_view3d.py index 925449835ca..263bf72f129 100644 --- a/release/scripts/templates/operator_modal_view3d.py +++ b/release/scripts/templates/operator_modal_view3d.py @@ -8,7 +8,10 @@ class ViewOperator(bpy.types.Operator): bl_idname = "view3d.modal_operator" bl_label = "Simple View Operator" - offset = FloatVectorProperty(name="Offset", size=3) + offset = FloatVectorProperty( + name="Offset", + size=3, + ) def execute(self, context): v3d = context.space_data From 5d88ba6165b3695bd99668bb5a8d1dc1364e805b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Aug 2011 20:25:25 +0000 Subject: [PATCH 27/48] remove over zealous undo's on operators that don't need it. --- source/blender/editors/render/render_shading.c | 10 +++------- source/blender/editors/space_image/image_ops.c | 4 ++-- source/blender/editors/space_info/info_ops.c | 2 +- .../blender/editors/space_sequencer/sequencer_edit.c | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index cfed2750e18..fbdcf7ba9b3 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -787,7 +787,7 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot) ot->poll= envmap_save_poll; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_REGISTER; /* no undo since this doesnt modify the env-map */ /* properties */ //RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as."); @@ -875,8 +875,6 @@ static int copy_material_exec(bContext *C, wmOperator *UNUSED(op)) copy_matcopybuf(ma); - WM_event_add_notifier(C, NC_MATERIAL, ma); - return OPERATOR_FINISHED; } @@ -891,7 +889,7 @@ void MATERIAL_OT_copy(wmOperatorType *ot) ot->exec= copy_material_exec; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_REGISTER; /* no undo needed since no changes are made to the material */ } static int paste_material_exec(bContext *C, wmOperator *UNUSED(op)) @@ -1015,8 +1013,6 @@ static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op)) copy_mtex_copybuf(id); - WM_event_add_notifier(C, NC_TEXTURE, NULL); - return OPERATOR_FINISHED; } @@ -1039,7 +1035,7 @@ void TEXTURE_OT_slot_copy(wmOperatorType *ot) ot->poll= copy_mtex_poll; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_REGISTER; /* no undo needed since no changes are made to the mtex */ } static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index ea8c7fc0cfa..6e0d1909963 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1331,7 +1331,7 @@ void IMAGE_OT_reload(wmOperatorType *ot) ot->exec= reload_exec; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_REGISTER; /* no undo, image buffer is not handled by undo */ } /********************** new image operator *********************/ @@ -1989,7 +1989,7 @@ void IMAGE_OT_sample_line(wmOperatorType *ot) ot->cancel= WM_gesture_straightline_cancel; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= 0; /* no undo/register since this operates on the space */ WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); } diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index d58fb7b11f0..e09565d38e9 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -273,7 +273,7 @@ void FILE_OT_report_missing_files(wmOperatorType *ot) ot->exec= report_missing_files_exec; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= 0; /* only reports so no need to undo/register */ } /********************* find missing files operator *********************/ diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 531ecebba5e..e876da41bd9 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1202,7 +1202,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot) ot->poll= sequencer_edit_poll; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */ } /* reload operator */ @@ -2522,7 +2522,7 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) ot->poll= sequencer_edit_poll; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_REGISTER; /* properties */ } From a0a96a84fed4669ac80d09a2fb667c601c048d23 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 20 Aug 2011 13:29:42 +0000 Subject: [PATCH 28/48] fix for crash when loading a file from a script, and executing user modules in the newly loaded file. --- source/blender/python/intern/bpy_interface.c | 25 ++++++++++++-------- source/blender/python/intern/bpy_util.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 8bd6e6c611c..e5e90380d61 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -87,6 +87,14 @@ static double bpy_timer_run; /* time for each python script run */ static double bpy_timer_run_tot; /* accumulate python runs */ #endif +/* use for updating while a python script runs - in case of file load */ +void bpy_context_update(bContext *C) +{ + BPy_SetContext(C); + bpy_import_main_set(CTX_data_main(C)); + BPY_modules_update(C); /* can give really bad results if this isnt here */ +} + void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) { py_call_level++; @@ -95,16 +103,7 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) *gilstate= PyGILState_Ensure(); if(py_call_level==1) { - - if(C) { // XXX - should always be true. - BPy_SetContext(C); - bpy_import_main_set(CTX_data_main(C)); - } - else { - fprintf(stderr, "ERROR: Python context called with a NULL Context. this should not happen!\n"); - } - - BPY_modules_update(C); /* can give really bad results if this isnt here */ + bpy_context_update(C); #ifdef TIME_PY_RUN if(bpy_timer_count==0) { @@ -570,6 +569,12 @@ void BPY_modules_load_user(bContext *C) if(bmain==NULL) return; + /* update pointers since this can run from a nested script + * on file load */ + if(py_call_level) { + bpy_context_update(C); + } + bpy_context_set(C, &gilstate); for(text=CTX_data_main(C)->text.first; text; text= text->id.next) { diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h index b16c8fe2e8c..09fbdf96ed2 100644 --- a/source/blender/python/intern/bpy_util.h +++ b/source/blender/python/intern/bpy_util.h @@ -51,6 +51,7 @@ short BPy_errors_to_report(struct ReportList *reports); struct bContext *BPy_GetContext(void); void BPy_SetContext(struct bContext *C); +extern void bpy_context_update(struct bContext *C); extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate); extern void bpy_context_clear(struct bContext *C, PyGILState_STATE *gilstate); #endif From d4dec1c3bcc8fa85e8f4cf3372efe077648a67bf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 20 Aug 2011 14:23:43 +0000 Subject: [PATCH 29/48] use ghash for DNA_struct_find_nr(), gives ~18% speedup on loading sintel lite, will also speedup undo. note: only works with CMake, wasn't able to get this working with scons, complains about same file being built in different environments. --- source/blender/makesdna/DNA_sdna_types.h | 5 ++- source/blender/makesdna/intern/CMakeLists.txt | 26 ++++++++++++ source/blender/makesdna/intern/SConscript | 1 + source/blender/makesdna/intern/dna_genfile.c | 42 +++++++++++++++---- source/blender/makesrna/intern/CMakeLists.txt | 1 + 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/source/blender/makesdna/DNA_sdna_types.h b/source/blender/makesdna/DNA_sdna_types.h index e5f924b5fa6..829d1eee03b 100644 --- a/source/blender/makesdna/DNA_sdna_types.h +++ b/source/blender/makesdna/DNA_sdna_types.h @@ -54,7 +54,10 @@ typedef struct SDNA { (sp[2], sp[3]), (sp[4], sp[5]), .. are the member type and name numbers respectively */ - + + struct GHash *structs_map; /* ghash for faster lookups, + requires WITH_DNA_GHASH to be used for now */ + /* wrong place for this really, its a simple * cache for findstruct_nr. */ diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index 429db63b526..5edebfe3903 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -27,12 +27,17 @@ # message(STATUS "Configuring makesdna") +# add_definitions(-DWITH_DNA_GHASH) + blender_include_dirs( ../../../../intern/guardedalloc ../../blenloader + ../../blenlib .. ) + +# ----------------------------------------------------------------------------- # Build makesdna executable set(SRC makesdna.c @@ -56,6 +61,8 @@ add_custom_command( DEPENDS makesdna ) + +# ----------------------------------------------------------------------------- # Build bf_dna library set(INC @@ -72,3 +79,22 @@ set(SRC ) blender_add_lib(bf_dna "${SRC}" "${INC}" "${INC_SYS}") + + +# ----------------------------------------------------------------------------- +# Build bf_dna_blenlib library +set(INC + +) + +set(INC_SYS + +) + +set(SRC + ../../blenlib/intern/BLI_mempool.c + ../../blenlib/intern/listbase.c + ../../blenlib/intern/BLI_ghash.c +) + +blender_add_lib(bf_dna_blenlib "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/makesdna/intern/SConscript b/source/blender/makesdna/intern/SConscript index e51ee53e078..8185676cbfc 100644 --- a/source/blender/makesdna/intern/SConscript +++ b/source/blender/makesdna/intern/SConscript @@ -67,5 +67,6 @@ else: else: dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna.exe $TARGET") +# TODO, get WITH_DNA_GHASH working, see CMake's 'WITH_DNA_GHASH' obj = ['intern/dna.c', 'intern/dna_genfile.c'] Return ('obj') diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 4e9b023b326..ebcfce84e37 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -42,6 +42,10 @@ #include "MEM_guardedalloc.h" // for MEM_freeN MEM_mallocN MEM_callocN +#ifdef WITH_DNA_GHASH +# include "BLI_ghash.h" +#endif + #include "DNA_genfile.h" #include "DNA_sdna_types.h" // for SDNA ;-) @@ -197,7 +201,11 @@ void DNA_sdna_free(SDNA *sdna) MEM_freeN((void *)sdna->names); MEM_freeN(sdna->types); MEM_freeN(sdna->structs); - + +#ifdef WITH_DNA_GHASH + BLI_ghash_free(sdna->structs_map, NULL, NULL); +#endif + MEM_freeN(sdna); } @@ -275,24 +283,30 @@ static short *findstruct_name(SDNA *sdna, const char *str) int DNA_struct_find_nr(SDNA *sdna, const char *str) { short *sp= NULL; - int a; if(sdna->lastfindnr_structs) { sp= sdna->structs[sdna->lastfind]; if(strcmp( sdna->types[ sp[0] ], str )==0) return sdna->lastfind; } - for(a=0; anr_structs; a++) { +#ifdef WITH_DNA_GHASH + return (intptr_t)BLI_ghash_lookup(sdna->structs_map, str) - 1; +#else + { + int a; - sp= sdna->structs[a]; - - if(strcmp( sdna->types[ sp[0] ], str )==0) { - sdna->lastfind= a; - return a; + for(a=0; anr_structs; a++) { + + sp= sdna->structs[a]; + + if(strcmp( sdna->types[ sp[0] ], str )==0) { + sdna->lastfind= a; + return a; + } } } - return -1; +#endif } /* ************************* END DIV ********************** */ @@ -481,6 +495,16 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap) sp[10]= 9; } } + +#ifdef WITH_DNA_GHASH + /* create a ghash lookup to speed up */ + sdna->structs_map= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "init_structDNA gh"); + + for(nr = 0; nr < sdna->nr_structs; nr++) { + sp= sdna->structs[nr]; + BLI_ghash_insert(sdna->structs_map, (void *)sdna->types[sp[0]], (void *)(nr + 1)); + } +#endif } } diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index cb593e7deab..cc7bcf04716 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -243,6 +243,7 @@ blender_include_dirs_sys( add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC}) target_link_libraries(makesrna bf_dna) +target_link_libraries(makesrna bf_dna_blenlib) # Output rna_*_gen.c # note (linux only): with crashes try add this after COMMAND: valgrind --leak-check=full --track-origins=yes From f8ec017900cba5702742bf31d99e8c6df6a1fcad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 20 Aug 2011 17:39:13 +0000 Subject: [PATCH 30/48] floats were being promoted to doubles in quite a few cases (using gcc's -Wdouble-promotion), went over render module and use float constants, gives small but consistent speedup - approx 3%. --- source/blender/blenloader/intern/readfile.c | 4 +- source/blender/python/generic/noise_py_api.c | 20 +- .../render/intern/source/convertblender.c | 50 +-- source/blender/render/intern/source/envmap.c | 24 +- .../intern/source/gammaCorrectionTables.c | 2 +- .../blender/render/intern/source/initrender.c | 50 +-- .../blender/render/intern/source/occlusion.c | 2 +- .../render/intern/source/pixelblending.c | 24 +- .../render/intern/source/pixelshading.c | 72 ++-- .../blender/render/intern/source/rayshade.c | 118 +++--- .../render/intern/source/render_texture.c | 352 +++++++++--------- .../blender/render/intern/source/rendercore.c | 36 +- .../render/intern/source/renderdatabase.c | 70 ++-- source/blender/render/intern/source/shadbuf.c | 49 ++- source/blender/render/intern/source/sss.c | 52 +-- source/blender/render/intern/source/strand.c | 8 +- source/blender/render/intern/source/sunsky.c | 112 +++--- source/blender/render/intern/source/zbuf.c | 78 ++-- 18 files changed, 558 insertions(+), 565 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index bd12677485c..0e99b357054 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11670,8 +11670,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Tex *tex; for(tex= main->tex.first; tex; tex= tex->id.next) { if(tex->pd) { - if (tex->pd->falloff_speed_scale == 0.0) - tex->pd->falloff_speed_scale = 100.0; + if (tex->pd->falloff_speed_scale == 0.0f) + tex->pd->falloff_speed_scale = 100.0f; if (!tex->pd->falloff_curve) { tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); diff --git a/source/blender/python/generic/noise_py_api.c b/source/blender/python/generic/noise_py_api.c index f5761f713a6..7be0998c0a1 100644 --- a/source/blender/python/generic/noise_py_api.c +++ b/source/blender/python/generic/noise_py_api.c @@ -210,8 +210,8 @@ static void randuvec(float v[3]) if((r = 1.f - v[2] * v[2]) > 0.f) { float a = (float)(6.283185307f * frand()); r = (float)sqrt(r); - v[0] = (float)(r * cos(a)); - v[1] = (float)(r * sin(a)); + v[0] = (float)(r * cosf(a)); + v[1] = (float)(r * sinf(a)); } else { v[2] = 1.f; @@ -254,7 +254,7 @@ static PyObject *Noise_noise(PyObject *UNUSED(self), PyObject *args) if(!PyArg_ParseTuple(args, "(fff)|i:noise", &x, &y, &z, &nb)) return NULL; - return PyFloat_FromDouble((2.0 * BLI_gNoise(1.0, x, y, z, 0, nb) - 1.0)); + return PyFloat_FromDouble((2.0f * BLI_gNoise(1.0f, x, y, z, 0, nb) - 1.0f)); } /*-------------------------------------------------------------------------*/ @@ -264,11 +264,11 @@ static PyObject *Noise_noise(PyObject *UNUSED(self), PyObject *args) static void noise_vector(float x, float y, float z, int nb, float v[3]) { /* Simply evaluate noise at 3 different positions */ - v[0] = (float)(2.0 * BLI_gNoise(1.f, x + 9.321f, y - 1.531f, z - 7.951f, 0, - nb) - 1.0); - v[1] = (float)(2.0 * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0); - v[2] = (float)(2.0 * BLI_gNoise(1.f, x + 6.327f, y + 0.1671f, z - 2.672f, 0, - nb) - 1.0); + v[0]= (float)(2.0f * BLI_gNoise(1.f, x + 9.321f, y - 1.531f, z - 7.951f, 0, + nb) - 1.0f); + v[1]= (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f); + v[2]= (float)(2.0f * BLI_gNoise(1.f, x + 6.327f, y + 0.1671f, z - 2.672f, 0, + nb) - 1.0f); } static PyObject *Noise_vector(PyObject *UNUSED(self), PyObject *args) @@ -291,7 +291,7 @@ static float turb(float x, float y, float z, int oct, int hard, int nb, float amp, out, t; int i; amp = 1.f; - out = (float)(2.0 * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0); + out = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f); if(hard) out = (float)fabs(out); for(i = 1; i < oct; i++) { @@ -299,7 +299,7 @@ static float turb(float x, float y, float z, int oct, int hard, int nb, x *= freqscale; y *= freqscale; z *= freqscale; - t = (float)(amp * (2.0 * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0)); + t = (float)(amp * (2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f)); if(hard) t = (float)fabs(t); out += t; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index f749d1ba004..7033ec27fc0 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1046,9 +1046,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par float fac; if(ma->strand_ease!=0.0f) { if(ma->strand_ease<0.0f) - fac= pow(sd->time, 1.0+ma->strand_ease); + fac= pow(sd->time, 1.0f+ma->strand_ease); else - fac= pow(sd->time, 1.0/(1.0f-ma->strand_ease)); + fac= pow(sd->time, 1.0f/(1.0f-ma->strand_ease)); } else fac= sd->time; @@ -1063,7 +1063,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par width= w; /*cross is the radius of the strand so we want it to be half of full width */ - mul_v3_fl(cross,0.5/crosslen); + mul_v3_fl(cross,0.5f/crosslen); } else width/=w; @@ -1984,8 +1984,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem else { /* render normal particles */ if(part->trail_count > 1) { - float length = part->path_end * (1.0 - part->randlength * r_length); - int trail_count = part->trail_count * (1.0 - part->randlength * r_length); + float length = part->path_end * (1.0f - part->randlength * r_length); + int trail_count = part->trail_count * (1.0f - part->randlength * r_length); float ct = (part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time; float dt = length / (trail_count ? (float)trail_count : 1.0f); @@ -2159,7 +2159,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int normalize_v3(view); zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2]; - if(zn>=0.0) hasize= 0.0; + if(zn>=0.0f) hasize= 0.0f; else hasize*= zn*zn*zn*zn; } @@ -3599,7 +3599,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4]) /* bias is percentage, made 2x larger because of correction for angle of incidence */ /* when a ray is closer to parallel of a face, bias value is increased during render */ - shb->bias= (0.02*lar->bias)*0x7FFFFFFF; + shb->bias= (0.02f*lar->bias)*0x7FFFFFFF; /* halfway method (average of first and 2nd z) reduces bias issues */ if(ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) @@ -3610,7 +3610,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4]) static void area_lamp_vectors(LampRen *lar) { - float xsize= 0.5*lar->area_size, ysize= 0.5*lar->area_sizey, multifac; + float xsize= 0.5f*lar->area_size, ysize= 0.5f*lar->area_sizey, multifac; /* make it smaller, so area light can be multisampled */ multifac= 1.0f/sqrt((float)lar->ray_totsamp); @@ -3637,7 +3637,7 @@ static void area_lamp_vectors(LampRen *lar) lar->area[3][1]= lar->co[1] + xsize*lar->mat[0][1] - ysize*lar->mat[1][1]; lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2]; /* only for correction button size, matrix size works on energy */ - lar->areasize= lar->dist*lar->dist/(4.0*xsize*ysize); + lar->areasize= lar->dist*lar->dist/(4.0f*xsize*ysize); } /* If lar takes more lamp data, the decoupling will be better. */ @@ -3791,10 +3791,10 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->spotsi= la->spotsize; if(lar->mode & LA_HALO) { - if(lar->spotsi>170.0) lar->spotsi= 170.0; + if(lar->spotsi>170.0f) lar->spotsi= 170.0f; } - lar->spotsi= cos( M_PI*lar->spotsi/360.0 ); - lar->spotbl= (1.0-lar->spotsi)*la->spotblend; + lar->spotsi= cos( M_PI*lar->spotsi/360.0f ); + lar->spotbl= (1.0f-lar->spotsi)*la->spotblend; memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *)); @@ -3813,7 +3813,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) xn= saacos(lar->spotsi); xn= sin(xn)/cos(xn); - lar->spottexfac= 1.0/(xn); + lar->spottexfac= 1.0f/(xn); if(lar->mode & LA_ONLYSHADOW) { if((lar->mode & (LA_SHAD_BUF|LA_SHAD_RAY))==0) lar->mode -= LA_ONLYSHADOW; @@ -3823,7 +3823,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) /* set flag for spothalo en initvars */ if(la->type==LA_SPOT && (la->mode & LA_HALO) && (la->buftype != LA_SHADBUF_DEEP)) { - if(la->haint>0.0) { + if(la->haint>0.0f) { re->flag |= R_LAMPHALO; /* camera position (0,0,0) rotate around lamp */ @@ -3990,9 +3990,9 @@ void init_render_world(Render *re) cp= (char *)&re->wrld.fastcol; - cp[0]= 255.0*re->wrld.horr; - cp[1]= 255.0*re->wrld.horg; - cp[2]= 255.0*re->wrld.horb; + cp[0]= 255.0f*re->wrld.horr; + cp[1]= 255.0f*re->wrld.horg; + cp[2]= 255.0f*re->wrld.horb; cp[3]= 1; VECCOPY(re->grvec, re->viewmat[2]); @@ -4047,25 +4047,25 @@ static void set_phong_threshold(ObjectRen *obr) if(vlr->flag & R_SMOOTH) { dot= INPR(vlr->n, vlr->v1->n); dot= ABS(dot); - if(dot>0.9) { + if(dot>0.9f) { thresh+= dot; tot++; } dot= INPR(vlr->n, vlr->v2->n); dot= ABS(dot); - if(dot>0.9) { + if(dot>0.9f) { thresh+= dot; tot++; } dot= INPR(vlr->n, vlr->v3->n); dot= ABS(dot); - if(dot>0.9) { + if(dot>0.9f) { thresh+= dot; tot++; } if(vlr->v4) { dot= INPR(vlr->n, vlr->v4->n); dot= ABS(dot); - if(dot>0.9) { + if(dot>0.9f) { thresh+= dot; tot++; } } @@ -4105,7 +4105,7 @@ static void set_fullsample_trace_flag(Render *re, ObjectRen *obr) else if((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) { /* for blurry reflect/refract, better to take more samples * inside the raytrace than as OSA samples */ - if ((vlr->mat->gloss_mir == 1.0) && (vlr->mat->gloss_tra == 1.0)) + if ((vlr->mat->gloss_mir == 1.0f) && (vlr->mat->gloss_tra == 1.0f)) vlr->flag |= R_FULL_OSA; } } @@ -4221,11 +4221,11 @@ static void check_non_flat_quads(ObjectRen *obr) /* render normals are inverted in render! we calculate normal of single tria here */ flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co); - if(flen==0.0) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co); + if(flen==0.0f) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co); xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2]; - if(ABS(xn) < 0.999995 ) { // checked on noisy fractal grid + if(ABS(xn) < 0.999995f ) { // checked on noisy fractal grid float d1, d2; @@ -5461,7 +5461,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * for(j=0;j<3;j++) fsvec[j] = velarray[a].vel[j]; /* (bad) HACK insert average velocity if none is there (see previous comment) */ - if((fsvec[0] == 0.0) && (fsvec[1] == 0.0) && (fsvec[2] == 0.0)) + if((fsvec[0] == 0.0f) && (fsvec[1] == 0.0f) && (fsvec[2] == 0.0f)) { fsvec[0] = avgvel[0]; fsvec[1] = avgvel[1]; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index e2ab21ef877..66a73b47790 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -595,7 +595,7 @@ static int envcube_isect(EnvMap *env, float *vec, float *answ) if(env->type==ENV_PLANE) { face= 1; - labda= 1.0/vec[2]; + labda= 1.0f/vec[2]; answ[0]= env->viewscale*labda*vec[0]; answ[1]= -env->viewscale*labda*vec[1]; } @@ -603,44 +603,44 @@ static int envcube_isect(EnvMap *env, float *vec, float *answ) /* which face */ if( vec[2]<=-fabs(vec[0]) && vec[2]<=-fabs(vec[1]) ) { face= 0; - labda= -1.0/vec[2]; + labda= -1.0f/vec[2]; answ[0]= labda*vec[0]; answ[1]= labda*vec[1]; } else if( vec[2]>=fabs(vec[0]) && vec[2]>=fabs(vec[1]) ) { face= 1; - labda= 1.0/vec[2]; + labda= 1.0f/vec[2]; answ[0]= labda*vec[0]; answ[1]= -labda*vec[1]; } else if( vec[1]>=fabs(vec[0]) ) { face= 2; - labda= 1.0/vec[1]; + labda= 1.0f/vec[1]; answ[0]= labda*vec[0]; answ[1]= labda*vec[2]; } else if( vec[0]<=-fabs(vec[1]) ) { face= 3; - labda= -1.0/vec[0]; + labda= -1.0f/vec[0]; answ[0]= labda*vec[1]; answ[1]= labda*vec[2]; } else if( vec[1]<=-fabs(vec[0]) ) { face= 4; - labda= -1.0/vec[1]; + labda= -1.0f/vec[1]; answ[0]= -labda*vec[0]; answ[1]= labda*vec[2]; } else { face= 5; - labda= 1.0/vec[0]; + labda= 1.0f/vec[0]; answ[0]= -labda*vec[1]; answ[1]= labda*vec[2]; } } - answ[0]= 0.5+0.5*answ[0]; - answ[1]= 0.5+0.5*answ[1]; + answ[0]= 0.5f+0.5f*answ[0]; + answ[1]= 0.5f+0.5f*answ[1]; return face; } @@ -725,7 +725,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe /* edges? */ - if(texres->ta<1.0) { + if(texres->ta<1.0f) { TexResult texr1, texr2; texr1.nor= texr2.nor= NULL; @@ -756,8 +756,8 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe else texr2.tr= texr2.tg= texr2.tb= texr2.ta= 0.0; fac= (texres->ta+texr1.ta+texr2.ta); - if(fac!=0.0) { - fac= 1.0/fac; + if(fac!=0.0f) { + fac= 1.0f/fac; texres->tr= fac*(texres->ta*texres->tr + texr1.ta*texr1.tr + texr2.ta*texr2.tr ); texres->tg= fac*(texres->ta*texres->tg + texr1.ta*texr1.tg + texr2.ta*texr2.tg ); diff --git a/source/blender/render/intern/source/gammaCorrectionTables.c b/source/blender/render/intern/source/gammaCorrectionTables.c index 4a16341093c..f88a5d240c3 100644 --- a/source/blender/render/intern/source/gammaCorrectionTables.c +++ b/source/blender/render/intern/source/gammaCorrectionTables.c @@ -107,7 +107,7 @@ void makeGammaTables(float gamma) int i; valid_gamma = gamma; - valid_inv_gamma = 1.0 / gamma; + valid_inv_gamma = 1.0f / gamma; color_step = 1.0 / RE_GAMMA_TABLE_SIZE; inv_color_step = (float) RE_GAMMA_TABLE_SIZE; diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 2f09742f130..bea86264af1 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -126,8 +126,8 @@ static float filt_cubic(float x) if (x < 0.0f) x = -x; - if (x < 1.0f) return 0.5*x*x2 - x2 + 2.0f/3.0f; - if (x < 2.0f) return (2.0-x)*(2.0-x)*(2.0-x)/6.0f; + if (x < 1.0f) return 0.5f*x*x2 - x2 + 2.0f/3.0f; + if (x < 2.0f) return (2.0f-x)*(2.0f-x)*(2.0f-x)/6.0f; return 0.0f; } @@ -138,27 +138,27 @@ static float filt_catrom(float x) if (x < 0.0f) x = -x; if (x < 1.0f) return 1.5f*x2*x - 2.5f*x2 + 1.0f; - if (x < 2.0f) return -0.5f*x2*x + 2.5*x2 - 4.0f*x + 2.0f; + if (x < 2.0f) return -0.5f*x2*x + 2.5f*x2 - 4.0f*x + 2.0f; return 0.0f; } static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */ { float b = 1.0f/3.0f, c = 1.0f/3.0f; - float p0 = ( 6.0 - 2.0*b ) / 6.0; - float p2 = (-18.0 + 12.0*b + 6.0*c) / 6.0; - float p3 = ( 12.0 - 9.0*b - 6.0*c) / 6.0; - float q0 = ( 8.0*b + 24.0*c) / 6.0; - float q1 = ( - 12.0*b - 48.0*c) / 6.0; - float q2 = ( 6.0*b + 30.0*c) / 6.0; - float q3 = ( - b - 6.0*c) / 6.0; + float p0 = ( 6.0f - 2.0f*b ) / 6.0f; + float p2 = (-18.0f + 12.0f*b + 6.0f*c) / 6.0f; + float p3 = ( 12.0f - 9.0f*b - 6.0f*c) / 6.0f; + float q0 = ( 8.0f*b + 24.0f*c) / 6.0f; + float q1 = ( - 12.0f *b - 48.0f*c) / 6.0f; + float q2 = ( 6.0f *b + 30.0f*c) / 6.0f; + float q3 = ( - b - 6.0f*c) / 6.0f; - if (x<-2.0) return 0.0; - if (x<-1.0) return (q0-x*(q1-x*(q2-x*q3))); - if (x< 0.0) return (p0+x*x*(p2-x*p3)); - if (x< 1.0) return (p0+x*x*(p2+x*p3)); - if (x< 2.0) return (q0+x*(q1+x*(q2+x*q3))); - return 0.0; + if (x<-2.0f) return 0.0f; + if (x<-1.0f) return (q0-x*(q1-x*(q2-x*q3))); + if (x< 0.0f) return (p0+x*x*(p2-x*p3)); + if (x< 1.0f) return (p0+x*x*(p2+x*p3)); + if (x< 2.0f) return (q0+x*(q1+x*(q2+x*q3))); + return 0.0f; } /* x ranges from -1 to 1 */ @@ -170,16 +170,16 @@ float RE_filter_value(int type, float x) switch(type) { case R_FILTER_BOX: - if(x>1.0) return 0.0f; - return 1.0; + if(x>1.0f) return 0.0f; + return 1.0f; case R_FILTER_TENT: - if(x>1.0) return 0.0f; + if(x>1.0f) return 0.0f; return 1.0f-x; case R_FILTER_GAUSS: x*= gaussfac; - return (1.0/exp(x*x) - 1.0/exp(gaussfac*gaussfac*2.25)); + return (1.0f/expf(x*x) - 1.0f/expf(gaussfac*gaussfac*2.25f)); case R_FILTER_MITCH: return filt_mitchell(x*gaussfac); @@ -221,7 +221,7 @@ static float calc_weight(Render *re, float *weight, int i, int j) case R_FILTER_GAUSS: x = dist*re->r.gauss; - weight[a]= (1.0/exp(x*x) - 1.0/exp(re->r.gauss*re->r.gauss*2.25)); + weight[a]= (1.0f/expf(x*x) - 1.0f/expf(re->r.gauss*re->r.gauss*2.25f)); break; case R_FILTER_MITCH: @@ -309,7 +309,7 @@ void make_sample_tables(Render *re) st->centmask= MEM_mallocN((1<osa), "Initfilt3"); for(a=0; a<16; a++) { - st->centLut[a]= -0.45+((float)a)/16.0; + st->centLut[a]= -0.45f+((float)a)/16.0f; } /* calculate totw */ @@ -327,7 +327,7 @@ void make_sample_tables(Render *re) memset(weight, 0, sizeof(weight)); calc_weight(re, weight, i, j); - for(a=0; a<16; a++) flweight[a]= weight[a]*(1.0/totw); + for(a=0; a<16; a++) flweight[a]= weight[a]*(1.0f/totw); m3= st->fmask1[ 3*(j+1)+i+1 ]; m4= st->fmask2[ 3*(j+1)+i+1 ]; @@ -430,9 +430,9 @@ void make_sample_tables(Render *re) for(a= (1<osa)-1; a>0; a--) { val= st->cmask[a & 255] + st->cmask[a>>8]; - i= 8+(15.9*(fpy1[a & 255]+fpy2[a>>8])/val); + i= 8+(15.9f*(fpy1[a & 255]+fpy2[a>>8])/val); CLAMP(i, 0, 15); - j= 8+(15.9*(fpx1[a & 255]+fpx2[a>>8])/val); + j= 8+(15.9f*(fpx1[a & 255]+fpx2[a>>8])/val); CLAMP(j, 0, 15); i= j + (i<<4); st->centmask[a]= i; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 0aa65479a4f..54137c62d22 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -1414,7 +1414,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f if(env) { /* sky shading using bent normal */ if(ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { - fac= 0.5*(1.0f+bn[0]*re->grvec[0]+ bn[1]*re->grvec[1]+ bn[2]*re->grvec[2]); + fac= 0.5f*(1.0f+bn[0]*re->grvec[0]+ bn[1]*re->grvec[1]+ bn[2]*re->grvec[2]); env[0]= (1.0f-fac)*re->wrld.horr + fac*re->wrld.zenr; env[1]= (1.0f-fac)*re->wrld.horg + fac*re->wrld.zeng; env[2]= (1.0f-fac)*re->wrld.horb + fac*re->wrld.zenb; diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c index c2e34e2a70d..d945436be6b 100644 --- a/source/blender/render/intern/source/pixelblending.c +++ b/source/blender/render/intern/source/pixelblending.c @@ -68,11 +68,11 @@ extern struct Render R; /* Threshold for a 'full' pixel: pixels with alpha above this level are */ /* considered opaque This is the decimal value for 0xFFF0 / 0xFFFF */ -#define RE_FULL_COLOR_FLOAT 0.9998 +#define RE_FULL_COLOR_FLOAT 0.9998f /* Threshold for an 'empty' pixel: pixels with alpha above this level are */ /* considered completely transparent. This is the decimal value */ /* for 0x000F / 0xFFFF */ -#define RE_EMPTY_COLOR_FLOAT 0.0002 +#define RE_EMPTY_COLOR_FLOAT 0.0002f /* ------------------------------------------------------------------------- */ @@ -82,7 +82,7 @@ void addAlphaOverFloat(float *dest, float *source) /* d = s + (1-alpha_s)d*/ float mul; - mul= 1.0 - source[3]; + mul= 1.0f - source[3]; dest[0]= (mul*dest[0]) + source[0]; dest[1]= (mul*dest[1]) + source[1]; @@ -98,7 +98,7 @@ void addAlphaUnderFloat(float *dest, float *source) { float mul; - mul= 1.0 - dest[3]; + mul= 1.0f - dest[3]; dest[0]+= (mul*source[0]); dest[1]+= (mul*source[1]); @@ -115,7 +115,7 @@ void addalphaAddfacFloat(float *dest, float *source, char addfac) /* Addfac is a number between 0 and 1: rescale */ /* final target is to diminish the influence of dest when addfac rises */ - m = 1.0 - ( source[3] * ((255.0 - addfac) / 255.0)); + m = 1.0f - ( source[3] * ((255 - addfac) / 255.0f)); /* blend colors*/ c= (m * dest[0]) + source[0]; @@ -178,7 +178,7 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w) a= j; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0) { + if(val!=0.0f) { rb1[0]+= val*r; rb1[1]+= val*g; rb1[2]+= val*b; @@ -187,7 +187,7 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w) a+=3; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0) { + if(val!=0.0f) { rb2[0]+= val*r; rb2[1]+= val*g; rb2[2]+= val*b; @@ -196,7 +196,7 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w) a+=3; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0) { + if(val!=0.0f) { rb3[0]+= val*r; rb3[1]+= val*g; rb3[2]+= val*b; @@ -345,21 +345,21 @@ void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row a= j; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0) { + if(val!=0.0f) { for(i= 0; ico); - dco[0]=dco[1]=dco[2]= 1.0/har->rad; + dco[0]=dco[1]=dco[2]= 1.0f/har->rad; vn= har->no; @@ -114,9 +114,9 @@ static void render_lighting_halo(HaloRen *har, float *colf) if(lar->mode & LA_QUAD) { t= 1.0; - if(lar->ld1>0.0) + if(lar->ld1>0.0f) t= lar->dist/(lar->dist+lar->ld1*ld); - if(lar->ld2>0.0) + if(lar->ld2>0.0f) t*= lar->distkw/(lar->distkw+lar->ld2*ld*ld); lampdist= t; @@ -127,7 +127,7 @@ static void render_lighting_halo(HaloRen *har, float *colf) if(lar->mode & LA_SPHERE) { t= lar->dist - ld; - if(t<0.0) continue; + if(t<0.0f) continue; t/= lar->dist; lampdist*= (t); @@ -155,7 +155,7 @@ static void render_lighting_halo(HaloRen *har, float *colf) if(lar->type==LA_SPOT) { if(lar->mode & LA_SQUARE) { - if(lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2]>0.0) { + if(lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2]>0.0f) { float x, lvrot[3]; /* rotate view to lampspace */ @@ -165,7 +165,7 @@ static void render_lighting_halo(HaloRen *har, float *colf) x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2])); /* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ - inpr= 1.0/(sqrt(1.0+x*x)); + inpr= 1.0/(sqrt(1.0f+x*x)); } else inpr= 0.0; } @@ -179,21 +179,21 @@ static void render_lighting_halo(HaloRen *har, float *colf) t= inpr-t; i= 1.0; soft= 1.0; - if(tspotbl && lar->spotbl!=0.0) { + if(tspotbl && lar->spotbl!=0.0f) { /* soft area */ i= t/lar->spotbl; t= i*i; - soft= (3.0*t-2.0*t*i); + soft= (3.0f*t-2.0f*t*i); inpr*= soft; } if(lar->mode & LA_ONLYSHADOW) { /* if(ma->mode & MA_SHADOW) { */ /* dot product positive: front side face! */ inp= vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2]; - if(inp>0.0) { + if(inp>0.0f) { /* testshadowbuf==0.0 : 100% shadow */ shadfac = testshadowbuf(&R, lar->shb, rco, dco, dco, inp, 0.0f); - if( shadfac>0.0 ) { + if( shadfac>0.0f ) { shadfac*= inp*soft*lar->energy; ir -= shadfac; ig -= shadfac; @@ -219,32 +219,32 @@ static void render_lighting_halo(HaloRen *har, float *colf) i= inp; if(lar->type==LA_HEMI) { - i= 0.5*i+0.5; + i= 0.5f*i+0.5f; } - if(i>0.0) { + if(i>0.0f) { i*= lampdist; } /* shadow */ - if(i> -0.41) { /* heuristic valua! */ + if(i> -0.41f) { /* heuristic valua! */ shadfac= 1.0; if(lar->shb) { shadfac = testshadowbuf(&R, lar->shb, rco, dco, dco, inp, 0.0f); - if(shadfac==0.0) continue; + if(shadfac==0.0f) continue; i*= shadfac; } } - if(i>0.0) { + if(i>0.0f) { ir+= i*lacol[0]; ig+= i*lacol[1]; ib+= i*lacol[2]; } } - if(ir<0.0) ir= 0.0; - if(ig<0.0) ig= 0.0; - if(ib<0.0) ib= 0.0; + if(ir<0.0f) ir= 0.0f; + if(ig<0.0f) ig= 0.0f; + if(ib<0.0f) ib= 0.0f; colf[0]*= ir; colf[1]*= ig; @@ -301,7 +301,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, } else alpha= har->alfa; - if(alpha==0.0) + if(alpha==0.0f) return 0; /* soften the halo if it intersects geometry */ @@ -355,15 +355,15 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, fac= fabs( rc[1]*(har->rad*fabs(rc[0]) - radist) ); - if(fac< 1.0) { - ringf+= (1.0-fac); + if(fac< 1.0f) { + ringf+= (1.0f-fac); } } } if(har->type & HA_VECT) { dist= fabs( har->cos*(yn) - har->sin*(xn) )/har->rad; - if(dist>1.0) dist= 1.0; + if(dist>1.0f) dist= 1.0f; if(har->tex) { zn= har->sin*xn - har->cos*yn; yn= har->cos*xn + har->sin*yn; @@ -374,7 +374,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, if(har->type & HA_FLARECIRC) { - dist= 0.5+fabs(dist-0.5); + dist= 0.5+fabs(dist-0.5f); } @@ -418,7 +418,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, float ster, angle; /* rotation */ angle= atan2(yn, xn); - angle*= (1.0+0.25*har->starpoints); + angle*= (1.0f+0.25f*har->starpoints); co= cos(angle); si= sin(angle); @@ -426,15 +426,15 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, angle= (co*xn+si*yn)*(co*yn-si*xn); ster= fabs(angle); - if(ster>1.0) { + if(ster>1.0f) { ster= (har->rad)/(ster); - if(ster<1.0) dist*= sqrt(ster); + if(ster<1.0f) dist*= sqrt(ster); } } /* disputable optimize... (ton) */ - if(dist<=0.00001) + if(dist<=0.00001f) return 0; dist*= alpha; @@ -471,7 +471,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, } /* Next, we do the line and ring factor modifications. */ - if(linef!=0.0) { + if(linef!=0.0f) { Material *ma= har->mat; col[0]+= linef * ma->specr; @@ -481,7 +481,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, if(har->type & HA_XALPHA) col[3]+= linef*linef; else col[3]+= linef; } - if(ringf!=0.0) { + if(ringf!=0.0f) { Material *ma= har->mat; col[0]+= ringf * ma->mirr; @@ -516,16 +516,16 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short th blend= view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]; - if(blend<0.0) skyflag= 0; + if(blend<0.0f) skyflag= 0; blend= fabs(blend); } else if(R.wrld.skytype & WO_SKYPAPER) { - blend= 0.5+ 0.5*view[1]; + blend= 0.5f + 0.5f * view[1]; } else { /* the fraction of how far we are above the bottom of the screen */ - blend= fabs(0.5+ view[1]); + blend= fabs(0.5f + view[1]); } VECCOPY(hor, &R.wrld.horr); @@ -545,8 +545,8 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short th do_sky_tex(rco, lo, dxyview, hor, zen, &blend, skyflag, thread); } - if(blend>1.0) blend= 1.0; - blendm= 1.0-blend; + if(blend>1.0f) blend= 1.0f; + blendm= 1.0f-blend; /* No clipping, no conversion! */ if(R.wrld.skytype & WO_SKYBLEND) { @@ -580,8 +580,8 @@ void shadeSunView(float *colf, float *view) VECCOPY(sview, view); normalize_v3(sview); mul_m3_v3(R.imat, sview); - if (sview[2] < 0.0) - sview[2] = 0.0; + if (sview[2] < 0.0f) + sview[2] = 0.0f; normalize_v3(sview); do_init= 0; } diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index d62f411a7c5..e82e969d502 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -611,12 +611,12 @@ static int refraction(float *refract, float *n, float *view, float index) index = 1.0f/index; fac= 1.0f - (1.0f - dot*dot)*index*index; if(fac<= 0.0f) return 0; - fac= -dot*index + sqrt(fac); + fac= -dot*index + sqrtf(fac); } else { fac= 1.0f - (1.0f - dot*dot)*index*index; if(fac<= 0.0f) return 0; - fac= -dot*index - sqrt(fac); + fac= -dot*index - sqrtf(fac); } refract[0]= index*view[0] + fac*n[0]; @@ -693,7 +693,7 @@ static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr) if(p < 0.0f) p= 0.0f; else if (p > 10.0f) p= 10.0f; - shr->alpha *= pow(d, p); + shr->alpha *= powf(d, p); if (shr->alpha > 1.0f) shr->alpha= 1.0f; } @@ -720,11 +720,11 @@ static void ray_fadeout(Isect *is, ShadeInput *shi, float *col, float *blendcol, /* if fading out, linear blend against fade color */ float blendfac; - blendfac = 1.0 - len_v3v3(shi->co, is->start)/dist_mir; + blendfac = 1.0f - len_v3v3(shi->co, is->start)/dist_mir; - col[0] = col[0]*blendfac + (1.0 - blendfac)*blendcol[0]; - col[1] = col[1]*blendfac + (1.0 - blendfac)*blendcol[1]; - col[2] = col[2]*blendfac + (1.0 - blendfac)*blendcol[2]; + col[0] = col[0]*blendfac + (1.0f - blendfac)*blendcol[0]; + col[1] = col[1]*blendfac + (1.0f - blendfac)*blendcol[1]; + col[2] = col[2]*blendfac + (1.0f - blendfac)*blendcol[2]; } /* the main recursive tracer itself @@ -870,7 +870,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo col[2]= shr.diff[2] + shr.spec[2]; } - if (dist_mir > 0.0) { + if (dist_mir > 0.0f) { float blendcol[3]; /* max ray distance set, but found an intersection, so fade this color @@ -922,11 +922,11 @@ static void DP_energy(float *table, float *vec, int tot, float xsize, float ysiz } } } - vec[0] += 0.1*min*result[0]/(float)tot; - vec[1] += 0.1*min*result[1]/(float)tot; + vec[0] += 0.1f*min*result[0]/(float)tot; + vec[1] += 0.1f*min*result[1]/(float)tot; // cyclic clamping - vec[0]= vec[0] - xsize*floor(vec[0]/xsize + 0.5); - vec[1]= vec[1] - ysize*floor(vec[1]/ysize + 0.5); + vec[0]= vec[0] - xsize*floorf(vec[0]/xsize + 0.5f); + vec[1]= vec[1] - ysize*floorf(vec[1]/ysize + 0.5f); } // random offset of 1 in 2 @@ -934,7 +934,7 @@ static void jitter_plane_offset(float *jitter1, float *jitter2, int tot, float s { float dsizex= sizex*ofsx; float dsizey= sizey*ofsy; - float hsizex= 0.5*sizex, hsizey= 0.5*sizey; + float hsizex= 0.5f*sizex, hsizey= 0.5f*sizey; int x; for(x=tot; x>0; x--, jitter1+=2, jitter2+=2) { @@ -968,8 +968,8 @@ void init_jitter_plane(LampRen *lar) /* fill table with random locations, area_size large */ for(x=0; xarea_size; - fp[1]= (BLI_frand()-0.5)*lar->area_sizey; + fp[0]= (BLI_frand()-0.5f)*lar->area_size; + fp[1]= (BLI_frand()-0.5f)*lar->area_sizey; } while(iter--) { @@ -1081,8 +1081,8 @@ static void QMC_initPixel(QMCSampler *qsa, int thread) { /* hammersley sequence is fixed, already created in QMCSampler init. * per pixel, gets a random offset. We create separate offsets per thread, for write-safety */ - qsa->offs[thread][0] = 0.5 * BLI_thread_frand(thread); - qsa->offs[thread][1] = 0.5 * BLI_thread_frand(thread); + qsa->offs[thread][0] = 0.5f * BLI_thread_frand(thread); + qsa->offs[thread][1] = 0.5f * BLI_thread_frand(thread); } else { /* SAMP_TYPE_HALTON */ @@ -1136,8 +1136,8 @@ static void QMC_samplePhong(float *vec, QMCSampler *qsa, int thread, int num, fl pz = pow(s[1], blur); sqr = sqrt(1.0f-pz*pz); - vec[0] = cos(phi)*sqr; - vec[1] = sin(phi)*sqr; + vec[0] = (float)(cosf(phi)*sqr); + vec[1] = (float)(sinf(phi)*sqr); vec[2] = 0.0f; } @@ -1148,8 +1148,8 @@ static void QMC_sampleRect(float *vec, QMCSampler *qsa, int thread, int num, flo QMC_getSample(s, qsa, thread, num); - vec[0] = (s[0] - 0.5) * sizex; - vec[1] = (s[1] - 0.5) * sizey; + vec[0] = (float)(s[0] - 0.5) * sizex; + vec[1] = (float)(s[1] - 0.5) * sizey; vec[2] = 0.0f; } @@ -1164,8 +1164,8 @@ static void QMC_sampleDisc(float *vec, QMCSampler *qsa, int thread, int num, flo phi = s[0]*2*M_PI; sqr = sqrt(s[1]); - vec[0] = cos(phi)*sqr* radius/2.0; - vec[1] = sin(phi)*sqr* radius/2.0; + vec[0] = cosf(phi)*sqr* radius/2.0f; + vec[1] = sinf(phi)*sqr* radius/2.0f; vec[2] = 0.0f; } @@ -1177,12 +1177,12 @@ static void QMC_sampleHemi(float *vec, QMCSampler *qsa, int thread, int num) QMC_getSample(s, qsa, thread, num); - phi = s[0]*2.f*M_PI; + phi = s[0]*2.0*M_PI; sqr = sqrt(s[1]); - vec[0] = cos(phi)*sqr; - vec[1] = sin(phi)*sqr; - vec[2] = 1.f - s[1]*s[1]; + vec[0] = cosf(phi)*sqr; + vec[1] = sinf(phi)*sqr; + vec[2] = (float)(1.0 - s[1]*s[1]); } #if 0 /* currently not used */ @@ -1272,7 +1272,7 @@ static int adaptive_sample_variance(int samples, float *col, float *colsq, float var[1] = (colsq[1] / (float)samples) - (mean[1]*mean[1]); var[2] = (colsq[2] / (float)samples) - (mean[2]*mean[2]); - if ((var[0] * 0.4 < thresh) && (var[1] * 0.3 < thresh) && (var[2] * 0.6 < thresh)) + if ((var[0] * 0.4f < thresh) && (var[1] * 0.3f < thresh) && (var[2] * 0.6f < thresh)) return 1; else return 0; @@ -1283,7 +1283,7 @@ static int adaptive_sample_contrast_val(int samples, float prev, float val, floa /* if the last sample's contribution to the total value was below a small threshold * (i.e. the samples taken are very similar), then taking more samples that are probably * going to be the same is wasting effort */ - if (fabs( prev/(float)(samples-1) - val/(float)samples ) < thresh) { + if (fabsf( prev/(float)(samples-1) - val/(float)samples ) < thresh) { return 1; } else return 0; @@ -1293,10 +1293,10 @@ static float get_avg_speed(ShadeInput *shi) { float pre_x, pre_y, post_x, post_y, speedavg; - pre_x = (shi->winspeed[0] == PASS_VECTOR_MAX)?0.0:shi->winspeed[0]; - pre_y = (shi->winspeed[1] == PASS_VECTOR_MAX)?0.0:shi->winspeed[1]; - post_x = (shi->winspeed[2] == PASS_VECTOR_MAX)?0.0:shi->winspeed[2]; - post_y = (shi->winspeed[3] == PASS_VECTOR_MAX)?0.0:shi->winspeed[3]; + pre_x = (shi->winspeed[0] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[0]; + pre_y = (shi->winspeed[1] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[1]; + post_x = (shi->winspeed[2] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[2]; + post_y = (shi->winspeed[3] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[3]; speedavg = (sqrt(pre_x*pre_x + pre_y*pre_y) + sqrt(post_x*post_x + post_y*post_y)) / 2.0; @@ -1316,7 +1316,7 @@ static void trace_refract(float *col, ShadeInput *shi, ShadeResult *shr) float v_refract[3], v_refract_new[3]; float sampcol[4], colsq[4]; - float blur = pow(1.0 - shi->mat->gloss_tra, 3); + float blur = powf(1.0f - shi->mat->gloss_tra, 3); short max_samples = shi->mat->samp_gloss_tra; float adapt_thresh = shi->mat->adapt_thresh_tra; @@ -1325,9 +1325,9 @@ static void trace_refract(float *col, ShadeInput *shi, ShadeResult *shr) colsq[0] = colsq[1] = colsq[2] = 0.0; col[0] = col[1] = col[2] = 0.0; col[3]= shr->alpha; - - if (blur > 0.0) { - if (adapt_thresh != 0.0) samp_type = SAMP_TYPE_HALTON; + + if (blur > 0.0f) { + if (adapt_thresh != 0.0f) samp_type = SAMP_TYPE_HALTON; else samp_type = SAMP_TYPE_HAMMERSLEY; /* all samples are generated per pixel */ @@ -1386,13 +1386,13 @@ static void trace_refract(float *col, ShadeInput *shi, ShadeResult *shr) samples++; /* adaptive sampling */ - if (adapt_thresh < 1.0 && samples > max_samples/2) + if (adapt_thresh < 1.0f && samples > max_samples/2) { if (adaptive_sample_variance(samples, col, colsq, adapt_thresh)) break; /* if the pixel so far is very dark, we can get away with less samples */ - if ( (col[0] + col[1] + col[2])/3.0/(float)samples < 0.01 ) + if ( (col[0] + col[1] + col[2])/3.0f/(float)samples < 0.01f ) max_samples--; } } @@ -1415,18 +1415,18 @@ static void trace_reflect(float *col, ShadeInput *shi, ShadeResult *shr, float f float v_nor_new[3], v_reflect[3]; float sampcol[4], colsq[4]; - float blur = pow(1.0 - shi->mat->gloss_mir, 3); + float blur = powf(1.0f - shi->mat->gloss_mir, 3); short max_samples = shi->mat->samp_gloss_mir; float adapt_thresh = shi->mat->adapt_thresh_mir; - float aniso = 1.0 - shi->mat->aniso_gloss_mir; + float aniso = 1.0f - shi->mat->aniso_gloss_mir; int samples=0; col[0] = col[1] = col[2] = 0.0; colsq[0] = colsq[1] = colsq[2] = 0.0; - if (blur > 0.0) { - if (adapt_thresh != 0.0) samp_type = SAMP_TYPE_HALTON; + if (blur > 0.0f) { + if (adapt_thresh != 0.0f) samp_type = SAMP_TYPE_HALTON; else samp_type = SAMP_TYPE_HAMMERSLEY; /* all samples are generated per pixel */ @@ -1485,22 +1485,22 @@ static void trace_reflect(float *col, ShadeInput *shi, ShadeResult *shr, float f samples++; /* adaptive sampling */ - if (adapt_thresh > 0.0 && samples > max_samples/3) + if (adapt_thresh > 0.0f && samples > max_samples/3) { if (adaptive_sample_variance(samples, col, colsq, adapt_thresh)) break; /* if the pixel so far is very dark, we can get away with less samples */ - if ( (col[0] + col[1] + col[2])/3.0/(float)samples < 0.01 ) + if ( (col[0] + col[1] + col[2])/3.0f/(float)samples < 0.01f ) max_samples--; /* reduce samples when reflection is dim due to low ray mirror blend value or fresnel factor * and when reflection is blurry */ - if (fresnelfac < 0.1 * (blur+1)) { + if (fresnelfac < 0.1f * (blur+1)) { max_samples--; /* even more for very dim */ - if (fresnelfac < 0.05 * (blur+1)) + if (fresnelfac < 0.05f * (blur+1)) max_samples--; } } @@ -1659,7 +1659,7 @@ static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int col[1] = a*col[1] + shr.alpha*shr.combined[1]; col[2] = a*col[2] + shr.alpha*shr.combined[2]; - col[3] = (1.0 - shr.alpha)*a; + col[3] = (1.0f - shr.alpha)*a; } if(depth>0 && col[3]>0.0f) { @@ -1758,8 +1758,8 @@ static void RandomSpherical(float *v) if ((r = 1.f - v[2]*v[2])>0.f) { float a = 6.283185307f*BLI_frand(); r = sqrt(r); - v[0] = r * cos(a); - v[1] = r * sin(a); + v[0] = r * cosf(a); + v[1] = r * sinf(a); } else v[2] = 1.f; } @@ -1956,7 +1956,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env) float speedfac; speedfac = get_avg_speed(shi) * adapt_speed_fac; - CLAMP(speedfac, 1.0, 1000.0); + CLAMP(speedfac, 1.0f, 1000.0f); max_samples /= speedfac; if (max_samples < 5) max_samples = 5; @@ -1985,7 +1985,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env) prev = fac; if(RE_rayobject_raycast(R.raytree, &isec)) { - if (R.wrld.aomode & WO_AODIST) fac+= exp(-isec.dist*R.wrld.aodistfac); + if (R.wrld.aomode & WO_AODIST) fac+= expf(-isec.dist*R.wrld.aodistfac); else fac+= 1.0f; } else if(envcolor!=WO_AOPLAIN) { @@ -1998,7 +1998,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env) normalize_v3(view); if(envcolor==WO_AOSKYCOL) { - skyfac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); + skyfac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); env[0]+= (1.0f-skyfac)*R.wrld.horr + skyfac*R.wrld.zenr; env[1]+= (1.0f-skyfac)*R.wrld.horg + skyfac*R.wrld.zeng; env[2]+= (1.0f-skyfac)*R.wrld.horb + skyfac*R.wrld.zenb; @@ -2017,7 +2017,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env) if (qsa->type == SAMP_TYPE_HALTON) { /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */ - if (adapt_thresh > 0.0 && (samples > max_samples/2) ) { + if (adapt_thresh > 0.0f && (samples > max_samples/2) ) { if (adaptive_sample_contrast_val(samples, prev, fac, adapt_thresh)) { break; @@ -2123,7 +2123,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *ao, float *env) /* do the trace */ if(RE_rayobject_raycast(R.raytree, &isec)) { - if (R.wrld.aomode & WO_AODIST) sh+= exp(-isec.dist*R.wrld.aodistfac); + if (R.wrld.aomode & WO_AODIST) sh+= expf(-isec.dist*R.wrld.aodistfac); else sh+= 1.0f; } else if(envcolor!=WO_AOPLAIN) { @@ -2136,7 +2136,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *ao, float *env) normalize_v3(view); if(envcolor==WO_AOSKYCOL) { - fac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); + fac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); env[0]+= (1.0f-fac)*R.wrld.horr + fac*R.wrld.zenr; env[1]+= (1.0f-fac)*R.wrld.horg + fac*R.wrld.zeng; env[2]+= (1.0f-fac)*R.wrld.horb + fac*R.wrld.zenb; @@ -2367,14 +2367,14 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * if (lar->ray_samp_method == LA_SAMP_HALTON) { /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */ - if ((max_samples > min_adapt_samples) && (adapt_thresh > 0.0) && (samples > max_samples / 3)) { + if ((max_samples > min_adapt_samples) && (adapt_thresh > 0.0f) && (samples > max_samples / 3)) { if (isec->mode==RE_RAY_SHADOW_TRA) { - if ((shadfac[3] / samples > (1.0-adapt_thresh)) || (shadfac[3] / samples < adapt_thresh)) + if ((shadfac[3] / samples > (1.0f-adapt_thresh)) || (shadfac[3] / samples < adapt_thresh)) break; else if (adaptive_sample_variance(samples, shadfac, colsq, adapt_thresh)) break; } else { - if ((fac / samples > (1.0-adapt_thresh)) || (fac / samples < adapt_thresh)) + if ((fac / samples > (1.0f-adapt_thresh)) || (fac / samples < adapt_thresh)) break; } } diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 579afc21c1d..ef1b1cd159c 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -175,9 +175,9 @@ static void tex_normal_derivate(Tex *tex, TexResult *texres) do_colorband(tex->coba, texres->nor[2], col); fac3= (col[0]+col[1]+col[2]); - texres->nor[0]= 0.3333*(fac0 - fac1); - texres->nor[1]= 0.3333*(fac0 - fac2); - texres->nor[2]= 0.3333*(fac0 - fac3); + texres->nor[0]= 0.3333f*(fac0 - fac1); + texres->nor[1]= 0.3333f*(fac0 - fac2); + texres->nor[2]= 0.3333f*(fac0 - fac3); return; } @@ -203,31 +203,31 @@ static int blend(Tex *tex, float *texvec, TexResult *texres) } if(tex->stype==TEX_LIN) { /* lin */ - texres->tin= (1.0+x)/2.0; + texres->tin= (1.0f+x)/2.0f; } else if(tex->stype==TEX_QUAD) { /* quad */ - texres->tin= (1.0+x)/2.0; - if(texres->tin<0.0) texres->tin= 0.0; + texres->tin= (1.0f+x)/2.0f; + if(texres->tin<0.0f) texres->tin= 0.0f; else texres->tin*= texres->tin; } else if(tex->stype==TEX_EASE) { /* ease */ - texres->tin= (1.0+x)/2.0; - if(texres->tin<=.0) texres->tin= 0.0; - else if(texres->tin>=1.0) texres->tin= 1.0; + texres->tin= (1.0f+x)/2.0f; + if(texres->tin<=0.0f) texres->tin= 0.0f; + else if(texres->tin>=1.0f) texres->tin= 1.0f; else { t= texres->tin*texres->tin; - texres->tin= (3.0*t-2.0*t*texres->tin); + texres->tin= (3.0f*t-2.0f*t*texres->tin); } } else if(tex->stype==TEX_DIAG) { /* diag */ - texres->tin= (2.0+x+y)/4.0; + texres->tin= (2.0f+x+y)/4.0f; } else if(tex->stype==TEX_RAD) { /* radial */ texres->tin= (atan2(y,x) / (2*M_PI) + 0.5); } else { /* sphere TEX_SPHERE */ texres->tin= 1.0-sqrt(x*x+ y*y+texvec[2]*texvec[2]); - if(texres->tin<0.0) texres->tin= 0.0; + if(texres->tin<0.0f) texres->tin= 0.0f; if(tex->stype==TEX_HALO) texres->tin*= texres->tin; /* halo */ } @@ -299,7 +299,7 @@ static float tex_tri(float a) const float b = 2*M_PI; const float rmax = 1.0; - a = rmax - 2.0*fabs(floor((a*(1.0/b))+0.5) - (a*(1.0/b))); + a = rmax - 2.0f*fabsf(floorf((a*(1.0f/b))+0.5f) - (a*(1.0f/b))); return a; } @@ -319,18 +319,18 @@ static float wood_int(Tex *tex, float x, float y, float z) if ((wf>TEX_TRI) || (wfturbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); - wi = waveform[wf]((x + y + z)*10.0 + wi); + wi = waveform[wf]((x + y + z)*10.0f + wi); } else if (wt==TEX_RINGNOISE) { wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); - wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0 + wi); + wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0f + wi); } return wi; @@ -370,7 +370,7 @@ static float marble_int(Tex *tex, float x, float y, float z) if ((wf>TEX_TRI) || (wfturbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -417,11 +417,11 @@ static int magic(Tex *tex, float *texvec, TexResult *texres) int n; n= tex->noisedepth; - turb= tex->turbul/5.0; + turb= tex->turbul/5.0f; - x= sin( ( texvec[0]+texvec[1]+texvec[2])*5.0 ); - y= cos( (-texvec[0]+texvec[1]-texvec[2])*5.0 ); - z= -cos( (-texvec[0]-texvec[1]+texvec[2])*5.0 ); + x= sin( ( texvec[0]+texvec[1]+texvec[2])*5.0f ); + y= cos( (-texvec[0]+texvec[1]-texvec[2])*5.0f ); + z= -cos( (-texvec[0]-texvec[1]+texvec[2])*5.0f ); if(n>0) { x*= turb; y*= turb; @@ -466,17 +466,17 @@ static int magic(Tex *tex, float *texvec, TexResult *texres) } } - if(turb!=0.0) { - turb*= 2.0; + if(turb!=0.0f) { + turb*= 2.0f; x/= turb; y/= turb; z/= turb; } - texres->tr= 0.5-x; - texres->tg= 0.5-y; - texres->tb= 0.5-z; + texres->tr= 0.5f-x; + texres->tg= 0.5f-y; + texres->tb= 0.5f-z; - texres->tin= 0.3333*(texres->tr+texres->tg+texres->tb); + texres->tin= 0.3333f*(texres->tr+texres->tg+texres->tb); BRICONTRGB; texres->ta= 1.0; @@ -494,7 +494,7 @@ static int stucci(Tex *tex, float *texvec, TexResult *texres) b2= BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); - ofs= tex->turbul/200.0; + ofs= tex->turbul/200.0f; if(tex->stype) ofs*=(b2*b2); nor[0] = BLI_gNoise(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -732,7 +732,7 @@ static int texnoise(Tex *tex, TexResult *texres) while(loop--) { ran= (ran>>2); val*= (ran & 3); - div*= 3.0; + div*= 3.0f; } texres->tin= ((float)val)/div; @@ -829,18 +829,18 @@ static int cubemap_glob(float *n, float x, float y, float z, float *adr1, float z1= fabs(nor[2]); if(z1>=x1 && z1>=y1) { - *adr1 = (x + 1.0) / 2.0; - *adr2 = (y + 1.0) / 2.0; + *adr1 = (x + 1.0f) / 2.0f; + *adr2 = (y + 1.0f) / 2.0f; ret= 0; } else if(y1>=x1 && y1>=z1) { - *adr1 = (x + 1.0) / 2.0; - *adr2 = (z + 1.0) / 2.0; + *adr1 = (x + 1.0f) / 2.0f; + *adr2 = (z + 1.0f) / 2.0f; ret= 1; } else { - *adr1 = (y + 1.0) / 2.0; - *adr2 = (z + 1.0) / 2.0; + *adr1 = (y + 1.0f) / 2.0f; + *adr2 = (z + 1.0f) / 2.0f; ret= 2; } return ret; @@ -884,17 +884,17 @@ static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z } if(vlr->puno & proj[1]) { - *adr1 = (x + 1.0) / 2.0; - *adr2 = (y + 1.0) / 2.0; + *adr1 = (x + 1.0f) / 2.0f; + *adr2 = (y + 1.0f) / 2.0f; } else if(vlr->puno & proj[2]) { - *adr1 = (x + 1.0) / 2.0; - *adr2 = (z + 1.0) / 2.0; + *adr1 = (x + 1.0f) / 2.0f; + *adr2 = (z + 1.0f) / 2.0f; ret= 1; } else { - *adr1 = (y + 1.0) / 2.0; - *adr2 = (z + 1.0) / 2.0; + *adr1 = (y + 1.0f) / 2.0f; + *adr2 = (z + 1.0f) / 2.0f; ret= 2; } } @@ -922,18 +922,18 @@ static int cubemap_ob(Object *ob, float *n, float x, float y, float z, float *ad z1= fabs(nor[2]); if(z1>=x1 && z1>=y1) { - *adr1 = (x + 1.0) / 2.0; - *adr2 = (y + 1.0) / 2.0; + *adr1 = (x + 1.0f) / 2.0f; + *adr2 = (y + 1.0f) / 2.0f; ret= 0; } else if(y1>=x1 && y1>=z1) { - *adr1 = (x + 1.0) / 2.0; - *adr2 = (z + 1.0) / 2.0; + *adr1 = (x + 1.0f) / 2.0f; + *adr2 = (z + 1.0f) / 2.0f; ret= 1; } else { - *adr1 = (y + 1.0) / 2.0; - *adr2 = (z + 1.0) / 2.0; + *adr1 = (y + 1.0f) / 2.0f; + *adr2 = (z + 1.0f) / 2.0f; ret= 2; } return ret; @@ -957,8 +957,8 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d if(R.osa==0) { if(wrap==MTEX_FLAT) { - fx = (t[0] + 1.0) / 2.0; - fy = (t[1] + 1.0) / 2.0; + fx = (t[0] + 1.0f) / 2.0f; + fy = (t[1] + 1.0f) / 2.0f; } else if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); else if(wrap==MTEX_SPHERE) map_to_sphere( &fx, &fy,t[0], t[1], t[2]); @@ -973,34 +973,34 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d if(tex->xrepeat>1) { float origf= fx *= tex->xrepeat; - if(fx>1.0) fx -= (int)(fx); - else if(fx<0.0) fx+= 1-(int)(fx); + if(fx>1.0f) fx -= (int)(fx); + else if(fx<0.0f) fx+= 1-(int)(fx); if(tex->flag & TEX_REPEAT_XMIR) { int orig= (int)floor(origf); if(orig & 1) - fx= 1.0-fx; + fx= 1.0f-fx; } } if(tex->yrepeat>1) { float origf= fy *= tex->yrepeat; - if(fy>1.0) fy -= (int)(fy); - else if(fy<0.0) fy+= 1-(int)(fy); + if(fy>1.0f) fy -= (int)(fy); + else if(fy<0.0f) fy+= 1-(int)(fy); if(tex->flag & TEX_REPEAT_YMIR) { int orig= (int)floor(origf); if(orig & 1) - fy= 1.0-fy; + fy= 1.0f-fy; } } } /* crop */ - if(tex->cropxmin!=0.0 || tex->cropxmax!=1.0) { + if(tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) { fac1= tex->cropxmax - tex->cropxmin; fx= tex->cropxmin+ fx*fac1; } - if(tex->cropymin!=0.0 || tex->cropymax!=1.0) { + if(tex->cropymin!=0.0f || tex->cropymax!=1.0f) { fac1= tex->cropymax - tex->cropymin; fy= tex->cropymin+ fy*fac1; } @@ -1011,23 +1011,23 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d else { if(wrap==MTEX_FLAT) { - fx= (t[0] + 1.0) / 2.0; - fy= (t[1] + 1.0) / 2.0; - dxt[0]/= 2.0; - dxt[1]/= 2.0; - dxt[2]/= 2.0; - dyt[0]/= 2.0; - dyt[1]/= 2.0; - dyt[2]/= 2.0; + fx= (t[0] + 1.0f) / 2.0f; + fy= (t[1] + 1.0f) / 2.0f; + dxt[0]/= 2.0f; + dxt[1]/= 2.0f; + dxt[2]/= 2.0f; + dyt[0]/= 2.0f; + dyt[1]/= 2.0f; + dyt[2]/= 2.0f; } else if ELEM(wrap, MTEX_TUBE, MTEX_SPHERE) { /* exception: the seam behind (y<0.0) */ ok= 1; - if(t[1]<=0.0) { + if(t[1]<=0.0f) { fx= t[0]+dxt[0]; fy= t[0]+dyt[0]; - if(fx>=0.0 && fy>=0.0 && t[0]>=0.0); - else if(fx<=0.0 && fy<=0.0 && t[0]<=0.0); + if(fx>=0.0f && fy>=0.0f && t[0]>=0.0f); + else if(fx<=0.0f && fy<=0.0f && t[0]<=0.0f); else ok= 0; } if(ok) { @@ -1046,10 +1046,10 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d else { if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); else map_to_sphere( &fx, &fy,t[0], t[1], t[2]); - dxt[0]/= 2.0; - dxt[1]/= 2.0; - dyt[0]/= 2.0; - dyt[1]/= 2.0; + dxt[0]/= 2.0f; + dxt[1]/= 2.0f; + dyt[0]/= 2.0f; + dyt[1]/= 2.0f; } } else { @@ -1143,13 +1143,13 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d } /* crop */ - if(tex->cropxmin!=0.0 || tex->cropxmax!=1.0) { + if(tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) { fac1= tex->cropxmax - tex->cropxmin; fx= tex->cropxmin+ fx*fac1; dxt[0]*= fac1; dyt[0]*= fac1; } - if(tex->cropymin!=0.0 || tex->cropymax!=1.0) { + if(tex->cropymin!=0.0f || tex->cropymax!=1.0f) { fac1= tex->cropymax - tex->cropymin; fy= tex->cropymin+ fy*fac1; dxt[1]*= fac1; @@ -1220,7 +1220,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - mul_v3_fl(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0f/tex->noisesize); switch(tex->stype) { case TEX_MFRACTAL: @@ -1242,7 +1242,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - mul_v3_fl(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0f/tex->noisesize); retval= voronoiTex(tex, tmpvec, texres); break; @@ -1251,7 +1251,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - mul_v3_fl(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0f/tex->noisesize); retval= mg_distNoiseTex(tex, tmpvec, texres); break; @@ -1381,7 +1381,7 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg switch(blendtype) { case MTEX_BLEND: fact*= facg; - facm= 1.0-fact; + facm= 1.0f-fact; in[0]= (fact*tex[0] + facm*out[0]); in[1]= (fact*tex[1] + facm*out[1]); @@ -1390,7 +1390,7 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg case MTEX_MUL: fact*= facg; - facm= 1.0-facg; + facm= 1.0f-facg; in[0]= (facm+fact*tex[0])*out[0]; in[1]= (facm+fact*tex[1])*out[1]; in[2]= (facm+fact*tex[2])*out[2]; @@ -1398,28 +1398,28 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg case MTEX_SCREEN: fact*= facg; - facm= 1.0-facg; - in[0]= 1.0 - (facm+fact*(1.0-tex[0])) * (1.0-out[0]); - in[1]= 1.0 - (facm+fact*(1.0-tex[1])) * (1.0-out[1]); - in[2]= 1.0 - (facm+fact*(1.0-tex[2])) * (1.0-out[2]); + facm= 1.0f-facg; + in[0]= 1.0f - (facm+fact*(1.0f-tex[0])) * (1.0f-out[0]); + in[1]= 1.0f - (facm+fact*(1.0f-tex[1])) * (1.0f-out[1]); + in[2]= 1.0f - (facm+fact*(1.0f-tex[2])) * (1.0f-out[2]); break; case MTEX_OVERLAY: fact*= facg; - facm= 1.0-facg; + facm= 1.0f-facg; if(out[0] < 0.5f) in[0] = out[0] * (facm + 2.0f*fact*tex[0]); else - in[0] = 1.0f - (facm + 2.0f*fact*(1.0 - tex[0])) * (1.0 - out[0]); + in[0] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[0])) * (1.0f - out[0]); if(out[1] < 0.5f) in[1] = out[1] * (facm + 2.0f*fact*tex[1]); else - in[1] = 1.0f - (facm + 2.0f*fact*(1.0 - tex[1])) * (1.0 - out[1]); + in[1] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[1])) * (1.0f - out[1]); if(out[2] < 0.5f) in[2] = out[2] * (facm + 2.0f*fact*tex[2]); else - in[2] = 1.0f - (facm + 2.0f*fact*(1.0 - tex[2])) * (1.0 - out[2]); + in[2] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[2])) * (1.0f - out[2]); break; case MTEX_SUB: @@ -1433,20 +1433,20 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg case MTEX_DIV: fact*= facg; - facm= 1.0-fact; + facm= 1.0f-fact; - if(tex[0]!=0.0) + if(tex[0]!=0.0f) in[0]= facm*out[0] + fact*out[0]/tex[0]; - if(tex[1]!=0.0) + if(tex[1]!=0.0f) in[1]= facm*out[1] + fact*out[1]/tex[1]; - if(tex[2]!=0.0) + if(tex[2]!=0.0f) in[2]= facm*out[2] + fact*out[2]/tex[2]; break; case MTEX_DIFF: fact*= facg; - facm= 1.0-fact; + facm= 1.0f-fact; in[0]= facm*out[0] + fact*fabs(tex[0]-out[0]); in[1]= facm*out[1] + fact*fabs(tex[1]-out[1]); in[2]= facm*out[2] + fact*fabs(tex[2]-out[2]); @@ -1454,7 +1454,7 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg case MTEX_DARK: fact*= facg; - facm= 1.0-fact; + facm= 1.0f-fact; col= tex[0]+((1-tex[0])*facm); if(col < out[0]) in[0]= col; else in[0]= out[0]; @@ -1516,7 +1516,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen facg= fabsf(facg); fact*= facg; - facm= 1.0-fact; + facm= 1.0f-fact; if(flip) SWAP(float, fact, facm); switch(blendtype) { @@ -1525,21 +1525,21 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen break; case MTEX_MUL: - facm= 1.0-facg; + facm= 1.0f-facg; in= (facm+fact*tex)*out; break; case MTEX_SCREEN: - facm= 1.0-facg; - in= 1.0-(facm+fact*(1.0-tex))*(1.0-out); + facm= 1.0f-facg; + in= 1.0f-(facm+fact*(1.0f-tex))*(1.0f-out); break; case MTEX_OVERLAY: - facm= 1.0-facg; + facm= 1.0f-facg; if(out < 0.5f) in = out * (facm + 2.0f*fact*tex); else - in = 1.0f - (facm + 2.0f*fact*(1.0 - tex)) * (1.0 - out); + in = 1.0f - (facm + 2.0f*fact*(1.0f - tex)) * (1.0f - out); break; case MTEX_SUB: @@ -1549,7 +1549,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen break; case MTEX_DIV: - if(tex!=0.0) + if(tex!=0.0f) in= facm*out + fact*out/tex; break; @@ -1568,15 +1568,15 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen break; case MTEX_SOFT_LIGHT: - scf=1.0 - (1.0 - tex) * (1.0 - out); - in= facm*out + fact * ((1.0 - out) * tex * out) + (out * scf); + scf=1.0f - (1.0f - tex) * (1.0f - out); + in= facm*out + fact * ((1.0f - out) * tex * out) + (out * scf); break; case MTEX_LIN_LIGHT: - if (tex > 0.5) - in = out + fact*(2*(tex - 0.5)); + if (tex > 0.5f) + in = out + fact*(2.0f*(tex - 0.5f)); else - in = out + fact*(2*tex - 1); + in = out + fact*(2.0f*tex - 1.0f); break; } @@ -2296,16 +2296,16 @@ void do_material_tex(ShadeInput *shi) /* texture output */ if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgbnor-= TEX_RGB; } if(mtex->texflag & MTEX_NEGATIVE) { if(rgbnor & TEX_RGB) { - texres.tr= 1.0-texres.tr; - texres.tg= 1.0-texres.tg; - texres.tb= 1.0-texres.tb; + texres.tr= 1.0f-texres.tr; + texres.tg= 1.0f-texres.tg; + texres.tb= 1.0f-texres.tb; } - texres.tin= 1.0-texres.tin; + texres.tin= 1.0f-texres.tin; } if(mtex->texflag & MTEX_STENCIL) { if(rgbnor & TEX_RGB) { @@ -2332,8 +2332,8 @@ void do_material_tex(ShadeInput *shi) texres.nor[2]= texres.tb; } else { - float co_nor= 0.5*cos(texres.tin-0.5); - float si= 0.5*sin(texres.tin-0.5); + float co_nor= 0.5*cos(texres.tin-0.5f); + float si= 0.5*sin(texres.tin-0.5f); float f1, f2; f1= shi->vn[0]; @@ -2419,7 +2419,7 @@ void do_material_tex(ShadeInput *shi) // exception for envmap only if(tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) { fact= texres.tin*mirrfac; - facm= 1.0- fact; + facm= 1.0f- fact; shi->refcol[0]= fact + facm*shi->refcol[0]; shi->refcol[1]= fact*tcol[0] + facm*shi->refcol[1]; shi->refcol[2]= fact*tcol[1] + facm*shi->refcol[2]; @@ -2564,65 +2564,65 @@ void do_material_tex(ShadeInput *shi) if(rgbnor & TEX_RGB) { if(texres.talpha) texres.tin= texres.ta; - else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); } if(mtex->mapto & MAP_REF) { float difffac= mtex->difffac*stencilTin; shi->refl= texture_value_blend(mtex->def_var, shi->refl, texres.tin, difffac, mtex->blendtype); - if(shi->refl<0.0) shi->refl= 0.0; + if(shi->refl<0.0f) shi->refl= 0.0f; } if(mtex->mapto & MAP_SPEC) { float specfac= mtex->specfac*stencilTin; shi->spec= texture_value_blend(mtex->def_var, shi->spec, texres.tin, specfac, mtex->blendtype); - if(shi->spec<0.0) shi->spec= 0.0; + if(shi->spec<0.0f) shi->spec= 0.0f; } if(mtex->mapto & MAP_EMIT) { float emitfac= mtex->emitfac*stencilTin; shi->emit= texture_value_blend(mtex->def_var, shi->emit, texres.tin, emitfac, mtex->blendtype); - if(shi->emit<0.0) shi->emit= 0.0; + if(shi->emit<0.0f) shi->emit= 0.0f; } if(mtex->mapto & MAP_ALPHA) { float alphafac= mtex->alphafac*stencilTin; shi->alpha= texture_value_blend(mtex->def_var, shi->alpha, texres.tin, alphafac, mtex->blendtype); - if(shi->alpha<0.0) shi->alpha= 0.0; - else if(shi->alpha>1.0) shi->alpha= 1.0; + if(shi->alpha<0.0f) shi->alpha= 0.0f; + else if(shi->alpha>1.0f) shi->alpha= 1.0f; } if(mtex->mapto & MAP_HAR) { float har; // have to map to 0-1 float hardfac= mtex->hardfac*stencilTin; - har= ((float)shi->har)/128.0; - har= 128.0*texture_value_blend(mtex->def_var, har, texres.tin, hardfac, mtex->blendtype); + har= ((float)shi->har)/128.0f; + har= 128.0f*texture_value_blend(mtex->def_var, har, texres.tin, hardfac, mtex->blendtype); - if(har<1.0) shi->har= 1; - else if(har>511.0) shi->har= 511; + if(har<1.0f) shi->har= 1; + else if(har>511) shi->har= 511; else shi->har= (int)har; } if(mtex->mapto & MAP_RAYMIRR) { float raymirrfac= mtex->raymirrfac*stencilTin; shi->ray_mirror= texture_value_blend(mtex->def_var, shi->ray_mirror, texres.tin, raymirrfac, mtex->blendtype); - if(shi->ray_mirror<0.0) shi->ray_mirror= 0.0; - else if(shi->ray_mirror>1.0) shi->ray_mirror= 1.0; + if(shi->ray_mirror<0.0f) shi->ray_mirror= 0.0f; + else if(shi->ray_mirror>1.0f) shi->ray_mirror= 1.0f; } if(mtex->mapto & MAP_TRANSLU) { float translfac= mtex->translfac*stencilTin; shi->translucency= texture_value_blend(mtex->def_var, shi->translucency, texres.tin, translfac, mtex->blendtype); - if(shi->translucency<0.0) shi->translucency= 0.0; - else if(shi->translucency>1.0) shi->translucency= 1.0; + if(shi->translucency<0.0f) shi->translucency= 0.0f; + else if(shi->translucency>1.0f) shi->translucency= 1.0f; } if(mtex->mapto & MAP_AMB) { float ambfac= mtex->ambfac*stencilTin; shi->amb= texture_value_blend(mtex->def_var, shi->amb, texres.tin, ambfac, mtex->blendtype); - if(shi->amb<0.0) shi->amb= 0.0; - else if(shi->amb>1.0) shi->amb= 1.0; + if(shi->amb<0.0f) shi->amb= 0.0f; + else if(shi->amb>1.0f) shi->amb= 1.0f; shi->ambr= shi->amb*R.wrld.ambr; shi->ambg= shi->amb*R.wrld.ambg; @@ -2718,16 +2718,16 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa /* texture output */ if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgbnor-= TEX_RGB; } if(mtex->texflag & MTEX_NEGATIVE) { if(rgbnor & TEX_RGB) { - texres.tr= 1.0-texres.tr; - texres.tg= 1.0-texres.tg; - texres.tb= 1.0-texres.tb; + texres.tr= 1.0f-texres.tr; + texres.tg= 1.0f-texres.tg; + texres.tb= 1.0f-texres.tb; } - texres.tin= 1.0-texres.tin; + texres.tin= 1.0f-texres.tin; } if(mtex->texflag & MTEX_STENCIL) { if(rgbnor & TEX_RGB) { @@ -2784,7 +2784,7 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa if (!(rgbnor & TEX_INT)) { if (rgbnor & TEX_RGB) { if(texres.talpha) texres.tin= texres.ta; - else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); } } @@ -2792,25 +2792,25 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa float emitfac= mtex->emitfac*stencilTin; *val = texture_value_blend(mtex->def_var, *val, texres.tin, emitfac, mtex->blendtype); - if(*val<0.0) *val= 0.0; + if(*val<0.0f) *val= 0.0f; } if((mapto_flag & MAP_DENSITY) && (mtex->mapto & MAP_DENSITY)) { float densfac= mtex->densfac*stencilTin; *val = texture_value_blend(mtex->def_var, *val, texres.tin, densfac, mtex->blendtype); - CLAMP(*val, 0.0, 1.0); + CLAMP(*val, 0.0f, 1.0f); } if((mapto_flag & MAP_SCATTERING) && (mtex->mapto & MAP_SCATTERING)) { float scatterfac= mtex->scatterfac*stencilTin; *val = texture_value_blend(mtex->def_var, *val, texres.tin, scatterfac, mtex->blendtype); - CLAMP(*val, 0.0, 1.0); + CLAMP(*val, 0.0f, 1.0f); } if((mapto_flag & MAP_REFLECTION) && (mtex->mapto & MAP_REFLECTION)) { float reflfac= mtex->reflfac*stencilTin; *val = texture_value_blend(mtex->def_var, *val, texres.tin, reflfac, mtex->blendtype); - CLAMP(*val, 0.0, 1.0); + CLAMP(*val, 0.0f, 1.0f); } } } @@ -2854,7 +2854,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf) if(osatex) { - dx= 1.0/har->rad; + dx= 1.0f/har->rad; if(mtex->projx) { dxt[0]= mtex->size[0]*dx; @@ -2882,16 +2882,16 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf) /* texture output */ if(rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgb= 0; } if(mtex->texflag & MTEX_NEGATIVE) { if(rgb) { - texres.tr= 1.0-texres.tr; - texres.tg= 1.0-texres.tg; - texres.tb= 1.0-texres.tb; + texres.tr= 1.0f-texres.tr; + texres.tg= 1.0f-texres.tg; + texres.tb= 1.0f-texres.tb; } - else texres.tin= 1.0-texres.tin; + else texres.tin= 1.0f-texres.tin; } /* mapping */ @@ -2918,10 +2918,10 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf) } fact= texres.tin*mtex->colfac; - facm= 1.0-fact; + facm= 1.0f-fact; if(mtex->blendtype==MTEX_MUL) { - facm= 1.0-mtex->colfac; + facm= 1.0f-mtex->colfac; } if(mtex->blendtype==MTEX_SUB) fact= -fact; @@ -2941,15 +2941,15 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf) colf[1]= (fact*texres.tg + har->g); colf[2]= (fact*texres.tb + har->b); - CLAMP(colf[0], 0.0, 1.0); - CLAMP(colf[1], 0.0, 1.0); - CLAMP(colf[2], 0.0, 1.0); + CLAMP(colf[0], 0.0f, 1.0f); + CLAMP(colf[1], 0.0f, 1.0f); + CLAMP(colf[2], 0.0f, 1.0f); } } if(mtex->mapto & MAP_ALPHA) { if(rgb) { if(texres.talpha) texres.tin= texres.ta; - else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); } colf[3]*= texres.tin; @@ -2999,7 +2999,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f /* only works with texture being "real" */ /* use saacos(), fixes bug [#22398], float precision caused lo[2] to be slightly less then -1.0 */ if(lo[0] || lo[1]) { /* check for zero case [#24807] */ - fact= (1.0/M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1])); + fact= (1.0f/(float)M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1])); tempvec[0]= lo[0]*fact; tempvec[1]= lo[1]*fact; tempvec[2]= 0.0; @@ -3020,13 +3020,13 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f if(mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1,lo[0], lo[2], lo[1]); else map_to_sphere( tempvec, tempvec+1,lo[0], lo[2], lo[1]); /* tube/spheremap maps for outside view, not inside */ - tempvec[0]= 1.0-tempvec[0]; + tempvec[0]= 1.0f-tempvec[0]; /* only top half */ - tempvec[1]= 2.0*tempvec[1]-1.0; + tempvec[1]= 2.0f*tempvec[1]-1.0f; tempvec[2]= 0.0; /* and correction for do_2d_mapping */ - tempvec[0]= 2.0*tempvec[0]-1.0; - tempvec[1]= 2.0*tempvec[1]-1.0; + tempvec[0]= 2.0f*tempvec[0]-1.0f; + tempvec[1]= 2.0f*tempvec[1]-1.0f; co= tempvec; } else { @@ -3075,16 +3075,16 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f /* texture output */ if(rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgb= 0; } if(mtex->texflag & MTEX_NEGATIVE) { if(rgb) { - texres.tr= 1.0-texres.tr; - texres.tg= 1.0-texres.tg; - texres.tb= 1.0-texres.tb; + texres.tr= 1.0f-texres.tr; + texres.tg= 1.0f-texres.tg; + texres.tb= 1.0f-texres.tb; } - else texres.tin= 1.0-texres.tin; + else texres.tin= 1.0f-texres.tin; } if(mtex->texflag & MTEX_STENCIL) { if(rgb) { @@ -3145,7 +3145,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f } } if(mtex->mapto & WOMAP_BLEND) { - if(rgb) texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + if(rgb) texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); *blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->blendfac, mtex->blendtype); } @@ -3281,16 +3281,16 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef /* texture output */ if(rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb); + texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgb= 0; } if(mtex->texflag & MTEX_NEGATIVE) { if(rgb) { - texres.tr= 1.0-texres.tr; - texres.tg= 1.0-texres.tg; - texres.tb= 1.0-texres.tb; + texres.tr= 1.0f-texres.tr; + texres.tg= 1.0f-texres.tg; + texres.tb= 1.0f-texres.tb; } - else texres.tin= 1.0-texres.tin; + else texres.tin= 1.0f-texres.tin; } if(mtex->texflag & MTEX_STENCIL) { if(rgb) { @@ -3375,7 +3375,7 @@ int externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *t rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output); if(rgb) { - texr.tin= (0.35*texr.tr+0.45*texr.tg+0.2*texr.tb); + texr.tin= (0.35f*texr.tr+0.45f*texr.tg+0.2f*texr.tb); } else { texr.tr= mtex->r; @@ -3424,14 +3424,14 @@ void render_realtime_texture(ShadeInput *shi, Image *ima) tex= &imatex[shi->thread]; tex->iuser.ok= ima->ok; - texvec[0]= 0.5+0.5*suv->uv[0]; - texvec[1]= 0.5+0.5*suv->uv[1]; - texvec[2] = 0; // initalize it because imagewrap looks at it. + texvec[0]= 0.5f+0.5f*suv->uv[0]; + texvec[1]= 0.5f+0.5f*suv->uv[1]; + texvec[2] = 0.0f; // initalize it because imagewrap looks at it. if(shi->osatex) { - dx[0]= 0.5*suv->dxuv[0]; - dx[1]= 0.5*suv->dxuv[1]; - dy[0]= 0.5*suv->dyuv[0]; - dy[1]= 0.5*suv->dyuv[1]; + dx[0]= 0.5f*suv->dxuv[0]; + dx[1]= 0.5f*suv->dxuv[1]; + dy[0]= 0.5f*suv->dyuv[0]; + dy[1]= 0.5f*suv->dyuv[1]; } texr.nor= NULL; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index c08d6c0f456..b66740c87ba 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -758,7 +758,7 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl) if(lar->type==LA_SUN && lar->sunsky) { /* if it's sky continue and don't apply atmosphere effect on it */ - if(*zrect >= 9.9e10 || rgbrect[3]==0.0f) { + if(*zrect >= 9.9e10f || rgbrect[3]==0.0f) { continue; } @@ -1098,7 +1098,7 @@ static unsigned short *make_solid_mask(RenderPart *pa) static void addAlphaOverFloatMask(float *dest, float *source, unsigned short dmask, unsigned short smask) { unsigned short shared= dmask & smask; - float mul= 1.0 - source[3]; + float mul= 1.0f - source[3]; if(shared) { /* overlapping masks */ @@ -1892,13 +1892,13 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har) fla.r= fabs(rc[0]); fla.g= fabs(rc[1]); fla.b= fabs(rc[2]); - fla.alfa= ma->flareboost*fabs(alfa*visifac*rc[3]); - fla.hard= 20.0f + fabs(70*rc[7]); + fla.alfa= ma->flareboost*fabsf(alfa*visifac*rc[3]); + fla.hard= 20.0f + fabsf(70.0f*rc[7]); fla.tex= 0; - type= (int)(fabs(3.9*rc[6])); + type= (int)(fabs(3.9f*rc[6])); - fla.rad= ma->subsize*sqrt(fabs(2.0f*har->rad*rc[4])); + fla.rad= ma->subsize*sqrtf(fabs(2.0f*har->rad*rc[4])); if(type==3) { fla.rad*= 3.0f; @@ -1907,22 +1907,22 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har) fla.radsq= fla.rad*fla.rad; - vec[0]= 1.4*rc[5]*(har->xs-R.winx/2); - vec[1]= 1.4*rc[5]*(har->ys-R.winy/2); - vec[2]= 32.0f*sqrt(vec[0]*vec[0] + vec[1]*vec[1] + 1.0f); + vec[0]= 1.4f*rc[5]*(har->xs-R.winx/2); + vec[1]= 1.4f*rc[5]*(har->ys-R.winy/2); + vec[2]= 32.0f*sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + 1.0f); - fla.xs= R.winx/2 + vec[0] + (1.2+rc[8])*R.rectx*vec[0]/vec[2]; - fla.ys= R.winy/2 + vec[1] + (1.2+rc[8])*R.rectx*vec[1]/vec[2]; + fla.xs= R.winx/2 + vec[0] + (1.2f+rc[8])*R.rectx*vec[0]/vec[2]; + fla.ys= R.winy/2 + vec[1] + (1.2f+rc[8])*R.rectx*vec[1]/vec[2]; if(R.flag & R_SEC_FIELD) { - if(R.r.mode & R_ODDFIELD) fla.ys += 0.5; - else fla.ys -= 0.5; + if(R.r.mode & R_ODDFIELD) fla.ys += 0.5f; + else fla.ys -= 0.5f; } if(type & 1) fla.type= HA_FLARECIRC; else fla.type= 0; renderhalo_post(rr, rectf, &fla); - fla.alfa*= 0.5; + fla.alfa*= 0.5f; if(type & 2) fla.type= HA_FLARECIRC; else fla.type= 0; renderhalo_post(rr, rectf, &fla); @@ -2205,7 +2205,7 @@ static void bake_displacement(void *handle, ShadeInput *UNUSED(shi), float dist, if(R.r.bake_flag & R_BAKE_NORMALIZE && R.r.bake_maxdist) { disp = (dist+R.r.bake_maxdist) / (R.r.bake_maxdist*2); /* alter the range from [-bake_maxdist, bake_maxdist] to [0, 1]*/ } else { - disp = 0.5 + dist; /* alter the range from [-0.5,0.5] to [0,1]*/ + disp = 0.5f + dist; /* alter the range from [-0.5,0.5] to [0,1]*/ } if(bs->rect_float) { @@ -2277,7 +2277,7 @@ static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3 * then taking u and v partial derivatives to get dxco and dyco */ A= (uv2[0] - uv1[0])*(uv3[1] - uv1[1]) - (uv3[0] - uv1[0])*(uv2[1] - uv1[1]); - if(fabs(A) > FLT_EPSILON) { + if(fabsf(A) > FLT_EPSILON) { A= 0.5f/A; d1= uv2[1] - uv3[1]; @@ -2532,8 +2532,8 @@ static void shade_tface(BakeShade *bs) * where a pixel gets in between 2 faces or the middle of a quad, * camera aligned quads also have this problem but they are less common. * Add a small offset to the UVs, fixes bug #18685 - Campbell */ - vec[a][0]= tface->uv[a][0]*(float)bs->rectx - (0.5f + 0.001); - vec[a][1]= tface->uv[a][1]*(float)bs->recty - (0.5f + 0.002); + vec[a][0]= tface->uv[a][0]*(float)bs->rectx - (0.5f + 0.001f); + vec[a][1]= tface->uv[a][1]*(float)bs->recty - (0.5f + 0.002f); } /* UV indices have to be corrected for possible quad->tria splits */ diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 456162d2d30..0c5ad0475ab 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -943,13 +943,13 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f float tin, tr, tg, tb, ta; float xn, yn, zn, texvec[3], hoco[4], hoco1[4]; - if(hasize==0.0) return NULL; + if(hasize==0.0f) return NULL; projectverto(vec, re->winmat, hoco); - if(hoco[3]==0.0) return NULL; + if(hoco[3]==0.0f) return NULL; if(vec1) { projectverto(vec1, re->winmat, hoco1); - if(hoco1[3]==0.0) return NULL; + if(hoco1[3]==0.0f) return NULL; } har= RE_findOrAddHalo(obr, obr->tothalo++); @@ -959,8 +959,8 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f /* actual projectvert is done in function project_renderdata() because of parts/border/pano */ /* we do it here for sorting of halos */ zn= hoco[3]; - har->xs= 0.5*re->winx*(hoco[0]/zn); - har->ys= 0.5*re->winy*(hoco[1]/zn); + har->xs= 0.5f*re->winx*(hoco[0]/zn); + har->ys= 0.5f*re->winy*(hoco[1]/zn); har->zs= 0x7FFFFF*(hoco[2]/zn); har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn); @@ -970,16 +970,16 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f har->type |= HA_VECT; - xn= har->xs - 0.5*re->winx*(hoco1[0]/hoco1[3]); - yn= har->ys - 0.5*re->winy*(hoco1[1]/hoco1[3]); - if(xn==0.0 || (xn==0.0 && yn==0.0)) zn= 0.0; + xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]); + yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]); + if(xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0f; else zn= atan2(yn, xn); har->sin= sin(zn); har->cos= cos(zn); zn= len_v3v3(vec1, vec); - har->hasize= vectsize*zn + (1.0-vectsize)*hasize; + har->hasize= vectsize*zn + (1.0f-vectsize)*hasize; sub_v3_v3v3(har->no, vec, vec1); normalize_v3(har->no); @@ -991,7 +991,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f har->r= ma->r; har->g= ma->g; har->b= ma->b; - har->add= (255.0*ma->add); + har->add= (255.0f*ma->add); har->mat= ma; har->hard= ma->har; har->seed= seed % 256; @@ -1032,7 +1032,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f zn= tin*mtex->alphafac; if(mtex->mapto & MAP_COL) { - zn= 1.0-yn; + zn= 1.0f-yn; har->r= (yn*tr+ zn*ma->r); har->g= (yn*tg+ zn*ma->g); har->b= (yn*tb+ zn*ma->b); @@ -1057,13 +1057,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater float xn, yn, zn, texvec[3], hoco[4], hoco1[4], in[3],tex[3],out[3]; int i, hasrgb; - if(hasize==0.0) return NULL; + if(hasize==0.0f) return NULL; projectverto(vec, re->winmat, hoco); - if(hoco[3]==0.0) return NULL; + if(hoco[3]==0.0f) return NULL; if(vec1) { projectverto(vec1, re->winmat, hoco1); - if(hoco1[3]==0.0) return NULL; + if(hoco1[3]==0.0f) return NULL; } har= RE_findOrAddHalo(obr, obr->tothalo++); @@ -1073,8 +1073,8 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater /* actual projectvert is done in function project_renderdata() because of parts/border/pano */ /* we do it here for sorting of halos */ zn= hoco[3]; - har->xs= 0.5*re->winx*(hoco[0]/zn); - har->ys= 0.5*re->winy*(hoco[1]/zn); + har->xs= 0.5f*re->winx*(hoco[0]/zn); + har->ys= 0.5f*re->winy*(hoco[1]/zn); har->zs= 0x7FFFFF*(hoco[2]/zn); har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn); @@ -1084,16 +1084,16 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater har->type |= HA_VECT; - xn= har->xs - 0.5*re->winx*(hoco1[0]/hoco1[3]); - yn= har->ys - 0.5*re->winy*(hoco1[1]/hoco1[3]); - if(xn==0.0 || (xn==0.0 && yn==0.0)) zn= 0.0; + xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]); + yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]); + if(xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0; else zn= atan2(yn, xn); har->sin= sin(zn); har->cos= cos(zn); - zn= len_v3v3(vec1, vec)*0.5; + zn= len_v3v3(vec1, vec)*0.5f; - har->hasize= vectsize*zn + (1.0-vectsize)*hasize; + har->hasize= vectsize*zn + (1.0f-vectsize)*hasize; sub_v3_v3v3(har->no, vec, vec1); normalize_v3(har->no); @@ -1105,7 +1105,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater har->r= ma->r; har->g= ma->g; har->b= ma->b; - har->add= (255.0*ma->add); + har->add= (255.0f*ma->add); har->mat= ma; har->hard= ma->har; har->seed= seed % 256; @@ -1185,13 +1185,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater if(mtex->mapto & MAP_ALPHA) har->alfa = texture_value_blend(mtex->def_var,har->alfa,tin,mtex->alphafac,mtex->blendtype); if(mtex->mapto & MAP_HAR) - har->hard = 1.0+126.0*texture_value_blend(mtex->def_var,((float)har->hard)/127.0,tin,mtex->hardfac,mtex->blendtype); + har->hard = 1.0f+126.0f*texture_value_blend(mtex->def_var,((float)har->hard)/127.0f,tin,mtex->hardfac,mtex->blendtype); if(mtex->mapto & MAP_RAYMIRR) - har->hasize = 100.0*texture_value_blend(mtex->def_var,har->hasize/100.0,tin,mtex->raymirrfac,mtex->blendtype); + har->hasize = 100.0f*texture_value_blend(mtex->def_var,har->hasize/100.0f,tin,mtex->raymirrfac,mtex->blendtype); if(mtex->mapto & MAP_TRANSLU) { - float add = texture_value_blend(mtex->def_var,(float)har->add/255.0,tin,mtex->translfac,mtex->blendtype); + float add = texture_value_blend(mtex->def_var,(float)har->add/255.0f,tin,mtex->translfac,mtex->blendtype); CLAMP(add, 0.f, 1.f); - har->add = 255.0*add; + har->add = 255.0f*add; } /* now what on earth is this good for?? */ //if(mtex->texco & 16) { @@ -1270,24 +1270,24 @@ void project_renderdata(Render *re, void (*projectfunc)(float *, float mat[][4], projectfunc(vec, re->winmat, hoco); /* we clip halos less critical, but not for the Z */ - hoco[0]*= 0.5; - hoco[1]*= 0.5; + hoco[0]*= 0.5f; + hoco[1]*= 0.5f; if( panotestclip(re, do_pano, hoco) ) { har->miny= har->maxy= -10000; /* that way render clips it */ } - else if(hoco[3]<0.0) { + else if(hoco[3]<0.0f) { har->miny= har->maxy= -10000; /* render clips it */ } else /* do the projection...*/ { /* bring back hocos */ - hoco[0]*= 2.0; - hoco[1]*= 2.0; + hoco[0]*= 2.0f; + hoco[1]*= 2.0f; zn= hoco[3]; - har->xs= 0.5*re->winx*(1.0+hoco[0]/zn); /* the 0.5 negates the previous 2...*/ - har->ys= 0.5*re->winy*(1.0+hoco[1]/zn); + har->xs= 0.5f*re->winx*(1.0f+hoco[0]/zn); /* the 0.5 negates the previous 2...*/ + har->ys= 0.5f*re->winy*(1.0f+hoco[1]/zn); /* this should be the zbuffer coordinate */ har->zs= 0x7FFFFF*(hoco[2]/zn); @@ -1298,11 +1298,11 @@ void project_renderdata(Render *re, void (*projectfunc)(float *, float mat[][4], projectfunc(vec, re->winmat, hoco); vec[0]-= har->hasize; zn= hoco[3]; - har->rad= fabs(har->xs- 0.5*re->winx*(1.0+hoco[0]/zn)); + har->rad= fabsf(har->xs- 0.5f*re->winx*(1.0f+hoco[0]/zn)); /* this clip is not really OK, to prevent stars to become too large */ if(har->type & HA_ONLYSKY) { - if(har->rad>3.0) har->rad= 3.0; + if(har->rad>3.0f) har->rad= 3.0f; } har->radsq= har->rad*har->rad; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index dcb9a3063e1..5860c395b07 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -260,7 +260,7 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon) } else { /* compute visibility at center between slopes at z */ - slope= (slopemin+slopemax)*0.5; + slope= (slopemin+slopemax)*0.5f; v= newds->v + slope*((z - newds->z)/(double)0x7FFFFFFF); } @@ -774,7 +774,7 @@ void makeshadowbuf(Render *re, LampRen *lar) angle= saacos(lar->spotsi); temp= 0.5f*shb->size*cos(angle)/sin(angle); shb->pixsize= (shb->d)/temp; - wsize= shb->pixsize*(shb->size/2.0); + wsize= shb->pixsize*(shb->size/2.0f); perspective_m4( shb->winmat,-wsize, wsize, -wsize, wsize, shb->d, shb->clipend); mul_m4_m4m4(shb->persmat, shb->viewmat, shb->winmat); @@ -1094,7 +1094,7 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int else { /* soft area */ temp= ( (float)(zs- zsamp) )/(float)bias; - return 1.0 - temp*temp; + return 1.0f - temp*temp; } } @@ -1287,7 +1287,7 @@ static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, i /* soft area */ temp= ( (float)(zs- zsamp) )/(float)bias; - return 1.0 - temp*temp; + return 1.0f - temp*temp; } @@ -1303,15 +1303,15 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) int x, y, z, xs1, ys1; int dx = 0, dy = 0; - siz= 0.5*(float)shb->size; + siz= 0.5f*(float)shb->size; co[0]= p1[0]; co[1]= p1[1]; co[2]= p1[2]/lar->sh_zfac; co[3]= 1.0; mul_m4_v4(shb->winmat, co); /* rational hom co */ - xf1= siz*(1.0+co[0]/co[3]); - yf1= siz*(1.0+co[1]/co[3]); + xf1= siz*(1.0f+co[0]/co[3]); + yf1= siz*(1.0f+co[1]/co[3]); zf1= (co[2]/co[3]); @@ -1320,8 +1320,8 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) co[2]= p2[2]/lar->sh_zfac; co[3]= 1.0; mul_m4_v4(shb->winmat, co); /* rational hom co */ - xf2= siz*(1.0+co[0]/co[3]); - yf2= siz*(1.0+co[1]/co[3]); + xf2= siz*(1.0f+co[0]/co[3]); + yf2= siz*(1.0f+co[1]/co[3]); zf2= (co[2]/co[3]); /* the 2dda (a pixel line formula) */ @@ -1330,8 +1330,8 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) ys1= (int)yf1; if(xf1 != xf2) { - if(xf2-xf1 > 0.0) { - labdax= (xf1-xs1-1.0)/(xf1-xf2); + if(xf2-xf1 > 0.0f) { + labdax= (xf1-xs1-1.0f)/(xf1-xf2); ldx= -shb->shadhalostep/(xf1-xf2); dx= shb->shadhalostep; } @@ -1347,8 +1347,8 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) } if(yf1 != yf2) { - if(yf2-yf1 > 0.0) { - labday= (yf1-ys1-1.0)/(yf1-yf2); + if(yf2-yf1 > 0.0f) { + labday= (yf1-ys1-1.0f)/(yf1-yf2); ldy= -shb->shadhalostep/(yf1-yf2); dy= shb->shadhalostep; } @@ -1389,16 +1389,16 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) } labda= MIN2(labdax, labday); - if(labda==labdao || labda>=1.0) break; + if(labda==labdao || labda>=1.0f) break; zf= zf1 + labda*(zf2-zf1); count+= (float)shb->totbuf; - if(zf<= -1.0) lightcount += 1.0; /* close to the spot */ + if(zf<= -1.0f) lightcount += 1.0f; /* close to the spot */ else { /* make sure, behind the clipend we extend halolines. */ - if(zf>=1.0) z= 0x7FFFF000; + if(zf>=1.0f) z= 0x7FFFF000; else z= (int)(0x7FFFF000*zf); for(shsample= shb->buffers.first; shsample; shsample= shsample->next) @@ -1407,8 +1407,8 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) } } - if(count!=0.0) return (lightcount/count); - return 0.0; + if(count!=0.0f) return (lightcount/count); + return 0.0f; } @@ -2081,11 +2081,11 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ if(R.r.mode & R_ORTHO) { /* x and y 3d coordinate can be derived from pixel coord and winmat */ - float fx= 2.0/(R.winx*R.winmat[0][0]); - float fy= 2.0/(R.winy*R.winmat[1][1]); + float fx= 2.0f/(R.winx*R.winmat[0][0]); + float fy= 2.0f/(R.winy*R.winmat[1][1]); - hoco[0]= (x - 0.5*R.winx)*fx - R.winmat[3][0]/R.winmat[0][0]; - hoco[1]= (y - 0.5*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1]; + hoco[0]= (x - 0.5f*R.winx)*fx - R.winmat[3][0]/R.winmat[0][0]; + hoco[1]= (y - 0.5f*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1]; /* using a*x + b*y + c*z = d equation, (a b c) is normal */ if(nor[2]!=0.0f) @@ -2141,9 +2141,9 @@ static void isb_add_shadfac(ISBShadfacA **isbsapp, MemArena *mem, int obi, int f /* in osa case, the samples were filled in with factor 1.0/R.osa. if fewer samples we have to correct */ if(R.osa) - shadfacf= ((float)shadfac*R.osa)/(4096.0*samples); + shadfacf= ((float)shadfac*R.osa)/(4096.0f*samples); else - shadfacf= ((float)shadfac)/(4096.0); + shadfacf= ((float)shadfac)/(4096.0f); new= BLI_memarena_alloc(mem, sizeof(ISBShadfacA)); new->obi= obi; @@ -2640,4 +2640,3 @@ void ISB_free(RenderPart *pa) } } } - diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index f7d1b43d4f7..0ba13b31c4b 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -172,7 +172,7 @@ static float f_Rd(float alpha_, float A, float ro) float sq; sq= sqrt(3.0f*(1.0f - alpha_)); - return (alpha_/2.0f)*(1.0f + exp((-4.0f/3.0f)*A*sq))*exp(-sq) - ro; + return (alpha_/2.0f)*(1.0f + expf((-4.0f/3.0f)*A*sq))*expf(-sq) - ro; } static float compute_reduced_albedo(ScatterSettings *ss) @@ -189,10 +189,10 @@ static float compute_reduced_albedo(ScatterSettings *ss) for(i= 0; i < max_iteration_count; i++) { fsub= (fxn - fxn_1); - if(fabs(fsub) < tolerance) + if(fabsf(fsub) < tolerance) break; d= ((xn - xn_1)/fsub)*fxn; - if(fabs(d) < tolerance) + if(fabsf(d) < tolerance) break; xn_1= xn; @@ -221,10 +221,10 @@ static float Rd_rsquare(ScatterSettings *ss, float rr) sr= sqrt(rr + ss->zr*ss->zr); sv= sqrt(rr + ss->zv*ss->zv); - Rdr= ss->zr*(1.0f + ss->sigma*sr)*exp(-ss->sigma*sr)/(sr*sr*sr); - Rdv= ss->zv*(1.0f + ss->sigma*sv)*exp(-ss->sigma*sv)/(sv*sv*sv); + Rdr= ss->zr*(1.0f + ss->sigma*sr)*expf(-ss->sigma*sr)/(sr*sr*sr); + Rdv= ss->zv*(1.0f + ss->sigma*sv)*expf(-ss->sigma*sv)/(sv*sv*sv); - return /*ss->alpha_*/(1.0f/(4.0f*M_PI))*(Rdr + Rdv); + return /*ss->alpha_*/(1.0f/(4.0f*(float)M_PI))*(Rdr + Rdv); } static float Rd(ScatterSettings *ss, float r) @@ -316,7 +316,7 @@ ScatterSettings *scatter_settings_new(float refl, float radius, float ior, float ss->alpha_= compute_reduced_albedo(ss); ss->sigma= 1.0f/ss->ld; - ss->sigma_t_= ss->sigma/sqrt(3.0f*(1.0f - ss->alpha_)); + ss->sigma_t_= ss->sigma/sqrtf(3.0f*(1.0f - ss->alpha_)); ss->sigma_s_= ss->alpha_*ss->sigma_t_; ss->sigma_a= ss->sigma_t_ - ss->sigma_s_; @@ -489,7 +489,7 @@ static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) for(i=0; itotpoint; i++) { p= &node->points[i]; - rad= p->area*fabs(p->rad[0] + p->rad[1] + p->rad[2]); + rad= p->area*fabsf(p->rad[0] + p->rad[1] + p->rad[2]); totrad += rad; node->co[0] += rad*p->co[0]; @@ -513,20 +513,20 @@ static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) } if(node->area > 1e-16f) { - inv= 1.0/node->area; + inv= 1.0f/node->area; node->rad[0] *= inv; node->rad[1] *= inv; node->rad[2] *= inv; } if(node->backarea > 1e-16f) { - inv= 1.0/node->backarea; + inv= 1.0f/node->backarea; node->backrad[0] *= inv; node->backrad[1] *= inv; node->backrad[2] *= inv; } if(totrad > 1e-16f) { - inv= 1.0/totrad; + inv= 1.0f/totrad; node->co[0] *= inv; node->co[1] *= inv; node->co[2] *= inv; @@ -566,8 +566,8 @@ static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) subnode= node->child[i]; - rad= subnode->area*fabs(subnode->rad[0] + subnode->rad[1] + subnode->rad[2]); - rad += subnode->backarea*fabs(subnode->backrad[0] + subnode->backrad[1] + subnode->backrad[2]); + rad= subnode->area*fabsf(subnode->rad[0] + subnode->rad[1] + subnode->rad[2]); + rad += subnode->backarea*fabsf(subnode->backrad[0] + subnode->backrad[1] + subnode->backrad[2]); totrad += rad; node->co[0] += rad*subnode->co[0]; @@ -587,20 +587,20 @@ static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) } if(node->area > 1e-16f) { - inv= 1.0/node->area; + inv= 1.0f/node->area; node->rad[0] *= inv; node->rad[1] *= inv; node->rad[2] *= inv; } if(node->backarea > 1e-16f) { - inv= 1.0/node->backarea; + inv= 1.0f/node->backarea; node->backrad[0] *= inv; node->backrad[1] *= inv; node->backrad[2] *= inv; } if(totrad > 1e-16f) { - inv= 1.0/totrad; + inv= 1.0f/totrad; node->co[0] *= inv; node->co[1] *= inv; node->co[2] *= inv; @@ -668,9 +668,9 @@ static void create_octree_node(ScatterTree *tree, ScatterNode *node, float *mid, return; } - subsize[0]= size[0]*0.5; - subsize[1]= size[1]*0.5; - subsize[2]= size[2]*0.5; + subsize[0]= size[0]*0.5f; + subsize[1]= size[1]*0.5f; + subsize[2]= size[2]*0.5f; node->split[0]= mid[0]; node->split[1]= mid[1]; @@ -764,7 +764,7 @@ ScatterTree *scatter_tree_new(ScatterSettings *ss[3], float scale, float error, for(i=0; iscale*tree->scale); + points[i].area= fabsf(area[i])/(tree->scale*tree->scale); points[i].back= (area[i] < 0.0f); mul_v3_fl(points[i].co, 1.0f/tree->scale); @@ -794,13 +794,13 @@ void scatter_tree_build(ScatterTree *tree) tree->root->points= newpoints; tree->root->totpoint= totpoint; - mid[0]= (tree->min[0]+tree->max[0])*0.5; - mid[1]= (tree->min[1]+tree->max[1])*0.5; - mid[2]= (tree->min[2]+tree->max[2])*0.5; + mid[0]= (tree->min[0]+tree->max[0])*0.5f; + mid[1]= (tree->min[1]+tree->max[1])*0.5f; + mid[2]= (tree->min[2]+tree->max[2])*0.5f; - size[0]= (tree->max[0]-tree->min[0])*0.5; - size[1]= (tree->max[1]-tree->min[1])*0.5; - size[2]= (tree->max[2]-tree->min[2])*0.5; + size[0]= (tree->max[0]-tree->min[0])*0.5f; + size[1]= (tree->max[1]-tree->min[1])*0.5f; + size[2]= (tree->max[2]-tree->min[2])*0.5f; create_octree_node(tree, tree->root, mid, size, tree->refpoints, 0); diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 72cb35e7827..840e5444ff0 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -78,9 +78,9 @@ static float strand_eval_width(Material *ma, float strandco) if(ma->strand_ease!=0.0f) { if(ma->strand_ease<0.0f) - fac= pow(strandco, 1.0+ma->strand_ease); + fac= pow(strandco, 1.0f+ma->strand_ease); else - fac= pow(strandco, 1.0/(1.0f-ma->strand_ease)); + fac= pow(strandco, 1.0f/(1.0f-ma->strand_ease)); } else fac= strandco; @@ -816,8 +816,8 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa zbuf_alloc_span(&zspan, pa->rectx, pa->recty, clipcrop); /* needed for transform from hoco to zbuffer co */ - zspan.zmulx= ((float)winx)/2.0; - zspan.zmuly= ((float)winy)/2.0; + zspan.zmulx= ((float)winx)/2.0f; + zspan.zmuly= ((float)winy)/2.0f; zspan.zofsx= -pa->disprect.xmin; zspan.zofsy= -pa->disprect.ymin; diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index 5877fa42292..e824b81096b 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -68,12 +68,12 @@ * */ void ClipColor(float c[3]) { - if (c[0] > 1.0) c[0] = 1.0; - if (c[0] < 0.0) c[0] = 0.0; - if (c[1] > 1.0) c[1] = 1.0; - if (c[1] < 0.0) c[1] = 0.0; - if (c[2] > 1.0) c[2] = 1.0; - if (c[2] < 0.0) c[2] = 0.0; + if (c[0] > 1.0f) c[0] = 1.0f; + if (c[0] < 0.0f) c[0] = 0.0f; + if (c[1] > 1.0f) c[1] = 1.0f; + if (c[1] < 0.0f) c[1] = 0.0f; + if (c[2] > 1.0f) c[2] = 1.0f; + if (c[2] < 0.0f) c[2] = 0.0f; } /** @@ -85,9 +85,9 @@ static float AngleBetween(float thetav, float phiv, float theta, float phi) { float cospsi = sin(thetav) * sin(theta) * cos(phi - phiv) + cos(thetav) * cos(theta); - if (cospsi > 1.0) + if (cospsi > 1.0f) return 0; - if (cospsi < -1.0) + if (cospsi < -1.0f) return M_PI; return acos(cospsi); @@ -117,11 +117,11 @@ static float PerezFunction(struct SunSky *sunsky, const float *lam, float theta, { float den, num; - den = ((1 + lam[0] * exp(lam[1])) * - (1 + lam[2] * exp(lam[3] * sunsky->theta) + lam[4] * cos(sunsky->theta) * cos(sunsky->theta))); + den = ((1 + lam[0] * expf(lam[1])) * + (1 + lam[2] * expf(lam[3] * sunsky->theta) + lam[4] * cosf(sunsky->theta) * cosf(sunsky->theta))); - num = ((1 + lam[0] * exp(lam[1] / cos(theta))) * - (1 + lam[2] * exp(lam[3] * gamma) + lam[4] * cos(gamma) * cos(gamma))); + num = ((1 + lam[0] * expf(lam[1] / cosf(theta))) * + (1 + lam[2] * expf(lam[3] * gamma) + lam[4] * cosf(gamma) * cosf(gamma))); return(lvz * num / den);} @@ -173,41 +173,41 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b T = turb; T2 = turb*turb; - chi = (4.0 / 9.0 - T / 120.0) * (M_PI - 2 * sunsky->theta); - sunsky->zenith_Y = (4.0453 * T - 4.9710) * tan(chi) - .2155 * T + 2.4192; + chi = (4.0f / 9.0f - T / 120.0f) * ((float)M_PI - 2.0f * sunsky->theta); + sunsky->zenith_Y = (4.0453f * T - 4.9710f) * tanf(chi) - 0.2155f * T + 2.4192f; sunsky->zenith_Y *= 1000; // conversion from kcd/m^2 to cd/m^2 if (sunsky->zenith_Y<=0) sunsky->zenith_Y = 1e-6; sunsky->zenith_x = - ( + 0.00165 * theta3 - 0.00374 * theta2 + 0.00208 * sunsky->theta + 0) * T2 + - ( -0.02902 * theta3 + 0.06377 * theta2 - 0.03202 * sunsky->theta + 0.00394) * T + - ( + 0.11693 * theta3 - 0.21196 * theta2 + 0.06052 * sunsky->theta + 0.25885); + ( + 0.00165f * theta3 - 0.00374f * theta2 + 0.00208f * sunsky->theta + 0.0f) * T2 + + ( -0.02902f * theta3 + 0.06377f * theta2 - 0.03202f * sunsky->theta + 0.00394f) * T + + ( + 0.11693f * theta3 - 0.21196f * theta2 + 0.06052f * sunsky->theta + 0.25885f); sunsky->zenith_y = - ( + 0.00275 * theta3 - 0.00610 * theta2 + 0.00316 * sunsky->theta + 0) * T2 + - ( -0.04214 * theta3 + 0.08970 * theta2 - 0.04153 * sunsky->theta + 0.00515) * T + - ( + 0.15346 * theta3 - 0.26756 * theta2 + 0.06669 * sunsky->theta + 0.26688); + ( + 0.00275f * theta3 - 0.00610f * theta2 + 0.00316f * sunsky->theta + 0.0f) * T2 + + ( -0.04214f * theta3 + 0.08970f * theta2 - 0.04153f * sunsky->theta + 0.00515f) * T + + ( + 0.15346f * theta3 - 0.26756f * theta2 + 0.06669f * sunsky->theta + 0.26688f); - sunsky->perez_Y[0] = 0.17872 * T - 1.46303; - sunsky->perez_Y[1] = -0.35540 * T + 0.42749; - sunsky->perez_Y[2] = -0.02266 * T + 5.32505; - sunsky->perez_Y[3] = 0.12064 * T - 2.57705; - sunsky->perez_Y[4] = -0.06696 * T + 0.37027; + sunsky->perez_Y[0] = 0.17872f * T - 1.46303f; + sunsky->perez_Y[1] = -0.35540f * T + 0.42749f; + sunsky->perez_Y[2] = -0.02266f * T + 5.32505f; + sunsky->perez_Y[3] = 0.12064f * T - 2.57705f; + sunsky->perez_Y[4] = -0.06696f * T + 0.37027f; - sunsky->perez_x[0] = -0.01925 * T - 0.25922; - sunsky->perez_x[1] = -0.06651 * T + 0.00081; - sunsky->perez_x[2] = -0.00041 * T + 0.21247; - sunsky->perez_x[3] = -0.06409 * T - 0.89887; - sunsky->perez_x[4] = -0.00325 * T + 0.04517; + sunsky->perez_x[0] = -0.01925f * T - 0.25922f; + sunsky->perez_x[1] = -0.06651f * T + 0.00081f; + sunsky->perez_x[2] = -0.00041f * T + 0.21247f; + sunsky->perez_x[3] = -0.06409f * T - 0.89887f; + sunsky->perez_x[4] = -0.00325f * T + 0.04517f; - sunsky->perez_y[0] = -0.01669 * T - 0.26078; - sunsky->perez_y[1] = -0.09495 * T + 0.00921; - sunsky->perez_y[2] = -0.00792 * T + 0.21023; - sunsky->perez_y[3] = -0.04405 * T - 1.65369; - sunsky->perez_y[4] = -0.01092 * T + 0.05291; + sunsky->perez_y[0] = -0.01669f * T - 0.26078f; + sunsky->perez_y[1] = -0.09495f * T + 0.00921f; + sunsky->perez_y[2] = -0.00792f * T + 0.21023f; + sunsky->perez_y[3] = -0.04405f * T - 1.65369f; + sunsky->perez_y[4] = -0.01092f * T + 0.05291f; /* suggested by glome in * http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/ @@ -248,17 +248,17 @@ void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float colo float hfade=1, nfade=1; - if (theta>(0.5*M_PI)) { - hfade = 1.0-(theta*M_1_PI-0.5)*2.0; - hfade = hfade*hfade*(3.0-2.0*hfade); + if (theta>(0.5f*(float)M_PI)) { + hfade = 1.0f-(theta*(float)M_1_PI-0.5f)*2.0f; + hfade = hfade*hfade*(3.0f-2.0f*hfade); theta = 0.5*M_PI; } - if (sunsky->theta>(0.5*M_PI)) { - if (theta<=0.5*M_PI) { - nfade = 1.0-(0.5-theta*M_1_PI)*2.0; - nfade *= 1.0-(sunsky->theta*M_1_PI-0.5)*2.0; - nfade = nfade*nfade*(3.0-2.0*nfade); + if (sunsky->theta>(0.5f*(float)M_PI)) { + if (theta<=0.5f*(float)M_PI) { + nfade = 1.0f-(0.5f-theta*(float)M_1_PI)*2.0f; + nfade *= 1.0f-(sunsky->theta*(float)M_1_PI-0.5f)*2.0f; + nfade = nfade*nfade*(3.0f-2.0f*nfade); } } @@ -267,7 +267,7 @@ void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float colo // Compute xyY values x = PerezFunction(sunsky, sunsky->perez_x, theta, gamma, sunsky->zenith_x); y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y); - Y = 6.666666667e-5 * nfade * hfade * PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y); + Y = 6.666666667e-5f * nfade * hfade * PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y); if(sunsky->sky_exposure!=0.0f) Y = 1.0 - exp(Y*sunsky->sky_exposure); @@ -296,8 +296,8 @@ void GetSkyXYZRadiancef(struct SunSky* sunsky, const float varg[3], float color_ copy_v3_v3(v, (float*)varg); normalize_v3(v); - if (v[2] < 0.001){ - v[2] = 0.001; + if (v[2] < 0.001f) { + v[2] = 0.001f; normalize_v3(v); } @@ -329,15 +329,15 @@ static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3]) fAlpha = 1.3f; fBeta = 0.04608365822050f * turbidity - 0.04586025928522f; - m = 1.0/(cos(theta) + 0.15f*pow(93.885f-theta/M_PI*180.0f,-1.253f)); + m = 1.0f/(cosf(theta) + 0.15f*powf(93.885f-theta/(float)M_PI*180.0f,-1.253f)); for(i = 0; i < 3; i++) { // Rayleigh Scattering - fTauR = exp( -m * 0.008735f * pow(fLambda[i], (float)(-4.08f))); + fTauR = expf( -m * 0.008735f * powf(fLambda[i], (float)(-4.08f))); // Aerosal (water + dust) attenuation - fTauA = exp(-m * fBeta * pow(fLambda[i], -fAlpha)); + fTauA = exp(-m * fBeta * powf(fLambda[i], -fAlpha)); fTau[i] = fTauR * fTauA; } @@ -364,8 +364,8 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r const float pn = 0.035f; const float T = 2.0f; float fTemp, fTemp2, fTemp3, fBeta, fBetaDash; - float c = (6.544*T - 6.51)*1e-17; - float K[3] = {0.685f, 0.679f, 0.670f}; + float c = (6.544f*T - 6.51f)*1e-17f; + float K[3] = {0.685f, 0.679f, 0.670f}; float vBetaMieTemp[3]; float fLambda[3],fLambda2[3], fLambda4[3]; @@ -410,7 +410,7 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r // Mie scattering constants. - fTemp2 = 0.434*c*(2*pi)*(2*pi)*0.5f; + fTemp2 = 0.434f*c*(2*pi)*(2*pi)*0.5f; vec3opf(sunSky->atm_BetaDashMie, vLambda2, *, fTemp2); fTemp3 = 0.434f*c*pi*(2*pi)*(2*pi); @@ -460,7 +460,7 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float vec3opv(sunSky->atm_BetaRM, sunSky->atm_BetaRay, +, sunSky->atm_BetaMie); //e^(-(beta_1 + beta_2) * s) = E1 - vec3opf(E1, sunSky->atm_BetaRM, *, -s/M_LN2); + vec3opf(E1, sunSky->atm_BetaRM, *, -s/(float)M_LN2); E1[0] = exp(E1[0]); E1[1] = exp(E1[1]); E1[2] = exp(E1[2]); @@ -469,17 +469,17 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float //Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta; - fTemp = fTemp * sqrt(fTemp); + fTemp = fTemp * sqrtf(fTemp); Phase_2 = (1 - sunSky->atm_HGg * sunSky->atm_HGg)/fTemp; vec3opf(vTemp1, sunSky->atm_BetaDashRay, *, Phase_1); vec3opf(vTemp2, sunSky->atm_BetaDashMie, *, Phase_2); vec3opv(vTemp1, vTemp1, +, vTemp2); - fopvec3(vTemp2, 1.0, -, E1); + fopvec3(vTemp2, 1.0f, -, E1); vec3opv(vTemp1, vTemp1, *, vTemp2); - fopvec3(vTemp2, 1.0, / , sunSky->atm_BetaRM); + fopvec3(vTemp2, 1.0f, / , sunSky->atm_BetaRM); vec3opv(I, vTemp1, *, vTemp2); diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 13d9ead79e8..04e4ce2c647 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -217,24 +217,24 @@ static short cliptestf(float p, float q, float *u1, float *u2) { float r; - if(p<0.0) { + if(p<0.0f) { if(q*u2) return 0; else if(r>*u1) *u1=r; } } else { - if(p>0.0) { - if(q<0.0) return 0; + if(p>0.0f) { + if(q<0.0f) return 0; else if(q0.0) { + if(u1>0.0f) { v1[0]= v1[0]+u1*dx; v1[1]= v1[1]+u1*dy; v1[2]= v1[2]+u1*dz; @@ -898,8 +898,8 @@ void hoco_to_zco(ZSpan *zspan, float *zco, float *hoco) float div; div= 1.0f/hoco[3]; - zco[0]= zspan->zmulx*(1.0+hoco[0]*div) + zspan->zofsx; - zco[1]= zspan->zmuly*(1.0+hoco[1]*div) + zspan->zofsy; + zco[0]= zspan->zmulx*(1.0f+hoco[0]*div) + zspan->zofsx; + zco[1]= zspan->zmuly*(1.0f+hoco[1]*div) + zspan->zofsy; zco[2]= 0x7FFFFFFF *(hoco[2]*div); } @@ -1083,7 +1083,7 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0) return; + if(z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -1203,7 +1203,7 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0) return; + if(z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -1330,7 +1330,7 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), f y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0) return; + if(z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -1627,12 +1627,12 @@ static void clippyra(float *labda, float *v1, float *v2, int *b2, int *b3, int a if(cliptestf(-da-dw, v13+v1[a], &u1,&u2)) { if(cliptestf(da-dw, v13-v1[a], &u1,&u2)) { *b3=1; - if(u2<1.0) { + if(u2<1.0f) { labda[1]= u2; *b2=1; } else labda[1]=1.0; /* u2 */ - if(u1>0.0) { + if(u1>0.0f) { labda[0]= u1; *b2=1; } else labda[0]=0.0; @@ -1662,8 +1662,8 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo l1= labda[0]; l2= labda[1]; - if(l1!= -1.0) { - if(l1!= 0.0) { + if(l1!= -1.0f) { + if(l1!= 0.0f) { adr= vez+4*(*clve); trias[*b1]=adr; (*clve)++; @@ -1676,8 +1676,8 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo (*b1)++; } - if(l2!= -1.0) { - if(l2!= 1.0) { + if(l2!= -1.0f) { + if(l2!= 1.0f) { adr= vez+4*(*clve); trias[*b1]=adr; (*clve)++; @@ -2066,8 +2066,8 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, zbuf_alloc_span(zspan, pa->rectx, pa->recty, R.clipcrop); /* needed for transform from hoco to zbuffer co */ - zspan->zmulx= ((float)R.winx)/2.0; - zspan->zmuly= ((float)R.winy)/2.0; + zspan->zmulx= ((float)R.winx)/2.0f; + zspan->zmuly= ((float)R.winy)/2.0f; if(R.osa) { zspan->zofsx= -pa->disprect.xmin - R.jit[pa->sample+zsample][0]; @@ -2290,8 +2290,8 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int /* 1.0f for clipping in clippyra()... bad stuff actually */ zbuf_alloc_span(&zspan, size, size, 1.0f); - zspan.zmulx= ((float)size)/2.0; - zspan.zmuly= ((float)size)/2.0; + zspan.zmulx= ((float)size)/2.0f; + zspan.zmuly= ((float)size)/2.0f; /* -0.5f to center the sample position */ zspan.zofsx= jitx - 0.5f; zspan.zofsy= jity - 0.5f; @@ -2527,8 +2527,8 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo zspan.sss_func= func; /* needed for transform from hoco to zbuffer co */ - zspan.zmulx= ((float)R.winx)/2.0; - zspan.zmuly= ((float)R.winy)/2.0; + zspan.zmulx= ((float)R.winx)/2.0f; + zspan.zmuly= ((float)R.winy)/2.0f; /* -0.5f to center the sample position */ zspan.zofsx= -pa->disprect.xmin - 0.5f; @@ -2671,7 +2671,7 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0) return; + if(z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -2840,8 +2840,8 @@ static void quad_bezier_2d(float *result, float *v1, float *v2, float *ipodata) p1[1]= v1[1]; /* official formula 2*p2 - .5*p1 - .5*p3 */ - p2[0]= -0.5*p1[0] - 0.5*p3[0]; - p2[1]= -0.5*p1[1] - 0.5*p3[1]; + p2[0]= -0.5f*p1[0] - 0.5f*p3[0]; + p2[1]= -0.5f*p1[1] - 0.5f*p3[1]; result[0]= ipodata[0]*p1[0] + ipodata[1]*p2[0] + ipodata[2]*p3[0]; result[1]= ipodata[0]*p1[1] + ipodata[1]*p2[1] + ipodata[2]*p3[1]; @@ -2871,8 +2871,8 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * char *rectmove, *dm; zbuf_alloc_span(&zspan, xsize, ysize, 1.0f); - zspan.zmulx= ((float)xsize)/2.0; - zspan.zmuly= ((float)ysize)/2.0; + zspan.zmulx= ((float)xsize)/2.0f; + zspan.zmuly= ((float)ysize)/2.0f; zspan.zofsx= 0.0f; zspan.zofsy= 0.0f; @@ -3258,8 +3258,8 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * zbuf_alloc_span(zspan, pa->rectx, pa->recty, re->clipcrop); /* needed for transform from hoco to zbuffer co */ - zspan->zmulx= ((float)winx)/2.0; - zspan->zmuly= ((float)winy)/2.0; + zspan->zmulx= ((float)winx)/2.0f; + zspan->zmuly= ((float)winy)/2.0f; /* the buffers */ zspan->arectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "Arectz"); @@ -3344,15 +3344,15 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * if(partclip==0) { /* a little advantage for transp rendering (a z offset) */ - if(!shadow && ma->zoffs != 0.0) { + if(!shadow && ma->zoffs != 0.0f) { mul= 0x7FFFFFFF; - zval= mul*(1.0+ho1[2]/ho1[3]); + zval= mul*(1.0f+ho1[2]/ho1[3]); VECCOPY(vec, v1->co); /* z is negative, otherwise its being clipped */ vec[2]-= ma->zoffs; projectverto(vec, obwinmat, hoco); - fval= mul*(1.0+hoco[2]/hoco[3]); + fval= mul*(1.0f+hoco[2]/hoco[3]); polygon_offset= (int) fabs(zval - fval ); } @@ -4240,7 +4240,3 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas /* end of zbuf.c */ - - - - From 8fcc8dd776d20d51d0e76a5cb0028c052b9dbfc3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Aug 2011 10:14:21 +0000 Subject: [PATCH 31/48] fix for out of bounds array access for shaded drawing in the UI, remove alpha blending for uiDrawBoxShade and uiDrawBoxVerticalShade. --- .../editors/interface/interface_draw.c | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 97299a6a766..dd7d2ca765f 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -140,26 +140,25 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r glEnd(); } -static void round_box_shade_col(float *col1, float *col2, float fac) +static void round_box_shade_col(const float col1[3], float const col2[3], const float fac) { - float col[4]; + float col[3]; col[0]= (fac*col1[0] + (1.0f-fac)*col2[0]); col[1]= (fac*col1[1] + (1.0f-fac)*col2[1]); col[2]= (fac*col1[2] + (1.0f-fac)*col2[2]); - col[3]= (fac*col1[3] + (1.0f-fac)*col2[3]); - glColor4fv(col); + glColor3fv(col); } - /* linear horizontal shade within button or in outline */ /* view2d scrollers use it */ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown) { float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; - float div= maxy-miny; - float coltop[4], coldown[4], color[4]; + const float div= maxy - miny; + const float idiv= 1.0f / div; + float coltop[3], coldown[3], color[4]; int a; /* mult */ @@ -173,11 +172,9 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl coltop[0]= color[0]+shadetop; if(coltop[0]>1.0f) coltop[0]= 1.0f; coltop[1]= color[1]+shadetop; if(coltop[1]>1.0f) coltop[1]= 1.0f; coltop[2]= color[2]+shadetop; if(coltop[2]>1.0f) coltop[2]= 1.0f; - coltop[3]= color[3]; coldown[0]= color[0]+shadedown; if(coldown[0]<0.0f) coldown[0]= 0.0f; coldown[1]= color[1]+shadedown; if(coldown[1]<0.0f) coldown[1]= 0.0f; coldown[2]= color[2]+shadedown; if(coldown[2]<0.0f) coldown[2]= 0.0f; - coldown[3]= color[3]; glShadeModel(GL_SMOOTH); glBegin(mode); @@ -189,11 +186,11 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl glVertex2f(maxx-rad, miny); for(a=0; a<7; a++) { - round_box_shade_col(coltop, coldown, vec[a][1]/div); + round_box_shade_col(coltop, coldown, vec[a][1]*idiv); glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]); } - round_box_shade_col(coltop, coldown, rad/div); + round_box_shade_col(coltop, coldown, rad*idiv); glVertex2f(maxx, miny+rad); } else { @@ -204,11 +201,11 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl /* corner right-top */ if(roundboxtype & 2) { - round_box_shade_col(coltop, coldown, (div-rad)/div); + round_box_shade_col(coltop, coldown, (div-rad)*idiv); glVertex2f(maxx, maxy-rad); for(a=0; a<7; a++) { - round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])/div); + round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])*idiv); glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]); } round_box_shade_col(coltop, coldown, 1.0); @@ -226,11 +223,11 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl glVertex2f(minx+rad, maxy); for(a=0; a<7; a++) { - round_box_shade_col(coltop, coldown, (div-vec[a][1])/div); + round_box_shade_col(coltop, coldown, (div-vec[a][1])*idiv); glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]); } - round_box_shade_col(coltop, coldown, (div-rad)/div); + round_box_shade_col(coltop, coldown, (div-rad)*idiv); glVertex2f(minx, maxy-rad); } else { @@ -241,11 +238,11 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl /* corner left-bottom */ if(roundboxtype & 8) { - round_box_shade_col(coltop, coldown, rad/div); + round_box_shade_col(coltop, coldown, rad*idiv); glVertex2f(minx, miny+rad); for(a=0; a<7; a++) { - round_box_shade_col(coltop, coldown, (rad-vec[a][1])/div); + round_box_shade_col(coltop, coldown, (rad-vec[a][1])*idiv); glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]); } @@ -267,7 +264,8 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float { float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; - float div= maxx-minx; + const float div= maxx - minx; + const float idiv= 1.0f / div; float colLeft[3], colRight[3], color[4]; int a; @@ -295,11 +293,11 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float glVertex2f(maxx-rad, miny); for(a=0; a<7; a++) { - round_box_shade_col(colLeft, colRight, vec[a][0]/div); + round_box_shade_col(colLeft, colRight, vec[a][0]*idiv); glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]); } - round_box_shade_col(colLeft, colRight, rad/div); + round_box_shade_col(colLeft, colRight, rad*idiv); glVertex2f(maxx, miny+rad); } else { @@ -314,10 +312,10 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float for(a=0; a<7; a++) { - round_box_shade_col(colLeft, colRight, (div-rad-vec[a][0])/div); + round_box_shade_col(colLeft, colRight, (div-rad-vec[a][0])*idiv); glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]); } - round_box_shade_col(colLeft, colRight, (div-rad)/div); + round_box_shade_col(colLeft, colRight, (div-rad)*idiv); glVertex2f(maxx-rad, maxy); } else { @@ -327,11 +325,11 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float /* corner left-top */ if(roundboxtype & 1) { - round_box_shade_col(colLeft, colRight, (div-rad)/div); + round_box_shade_col(colLeft, colRight, (div-rad)*idiv); glVertex2f(minx+rad, maxy); for(a=0; a<7; a++) { - round_box_shade_col(colLeft, colRight, (div-rad+vec[a][0])/div); + round_box_shade_col(colLeft, colRight, (div-rad+vec[a][0])*idiv); glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]); } @@ -349,7 +347,7 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float glVertex2f(minx, miny+rad); for(a=0; a<7; a++) { - round_box_shade_col(colLeft, colRight, (vec[a][0])/div); + round_box_shade_col(colLeft, colRight, (vec[a][0])*idiv); glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]); } From bebee3fb60987a4132fe488c5a179b3509ee64c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Aug 2011 11:06:49 +0000 Subject: [PATCH 32/48] new cmake doesn't consider CLang == GNUCC, set flags for clang explicitly. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf083b87bc7..0cdf1fb9da9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,6 +499,9 @@ if(UNIX AND NOT APPLE) # GNU Compiler if(CMAKE_COMPILER_IS_GNUCC) set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") + # CLang is the same as GCC for now. + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") # Intel C++ Compiler elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") # think these next two are broken From 4427c146832a3398178ad4851e9c9606fad17489 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 21 Aug 2011 13:25:19 +0000 Subject: [PATCH 33/48] Small fix, report in IRC by Olivier: Click in Compositor on output node invoked a re-composite. Only has to be done for inactive outputs. --- source/blender/editors/space_node/node_edit.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 9cafc46ca53..011f9a31c93 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -550,14 +550,16 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) } } else if(node->type==CMP_NODE_COMPOSITE) { - bNode *tnode; - - for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if( tnode->type==CMP_NODE_COMPOSITE) - tnode->flag &= ~NODE_DO_OUTPUT; - - node->flag |= NODE_DO_OUTPUT; - ED_node_generic_update(bmain, ntree, node); + if (was_output==0) { + bNode *tnode; + + for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) + if( tnode->type==CMP_NODE_COMPOSITE) + tnode->flag &= ~NODE_DO_OUTPUT; + + node->flag |= NODE_DO_OUTPUT; + ED_node_generic_update(bmain, ntree, node); + } } } else if(ntree->type==NTREE_TEXTURE) { From 36f20f162caf83929e6eb07be6b73eb59740ead4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 21 Aug 2011 13:31:46 +0000 Subject: [PATCH 34/48] Fix #28154: linux3-config.py doesn't exist Change OURPLATFORM from "linux" to simple "linux". Since new policy for linux kernel versions that major version in platform doesn't make much sense for building rules so the same rules could be used for both of linux2 and linux3 now/ Tested on both of linux2 and linux3 systems. --- SConstruct | 11 +++++++++-- .../config/{linux2-config.py => linux-config.py} | 6 +++--- build_files/scons/tools/Blender.py | 6 +++--- build_files/scons/tools/btools.py | 2 +- doc/build_systems/scons-dev.txt | 2 +- doc/build_systems/scons.txt | 2 +- extern/bullet2/src/SConscript | 4 ++-- intern/ghost/SConscript | 4 ++-- source/blender/blenpluginapi/SConscript | 2 +- source/blender/editors/armature/SConscript | 2 +- source/blender/editors/mesh/SConscript | 2 +- source/blender/editors/object/SConscript | 2 +- source/blender/editors/physics/SConscript | 2 +- source/blender/editors/render/SConscript | 2 +- source/blender/editors/screen/SConscript | 2 +- source/blender/editors/sculpt_paint/SConscript | 2 +- source/blender/editors/space_file/SConscript | 2 +- source/blender/editors/space_node/SConscript | 2 +- source/blender/makesrna/SConscript | 2 +- source/blender/makesrna/intern/SConscript | 4 ++-- source/blender/nodes/SConscript | 2 +- source/blender/render/SConscript | 2 +- source/blender/windowmanager/SConscript | 2 +- 23 files changed, 38 insertions(+), 31 deletions(-) rename build_files/scons/config/{linux2-config.py => linux-config.py} (98%) diff --git a/SConstruct b/SConstruct index 81c12c7c318..e2b83f2811f 100644 --- a/SConstruct +++ b/SConstruct @@ -166,6 +166,13 @@ if sys.platform=='win32': env.SConscriptChdir(0) +# Remove major kernel version from linux platform. +# After Linus switched kernel to new version model this major version +# shouldn't take much sense for building rules. + +if re.match('linux[0-9]+', platform): + platform = 'linux' + crossbuild = B.arguments.get('BF_CROSS', None) if crossbuild and platform not in ('win32-vc', 'win64-vc'): platform = 'linuxcross' @@ -551,7 +558,7 @@ if env['OURPLATFORM']!='darwin': scriptinstall.append(env.Install(dir=dir,source=source)) #-- icons -if env['OURPLATFORM']=='linux2': +if env['OURPLATFORM']=='linux': iconlist = [] icontargetlist = [] @@ -630,7 +637,7 @@ textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist) if env['OURPLATFORM']=='darwin': allinstall = [blenderinstall, plugininstall, textinstall] -elif env['OURPLATFORM']=='linux2': +elif env['OURPLATFORM']=='linux': allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall, iconinstall] else: allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall] diff --git a/build_files/scons/config/linux2-config.py b/build_files/scons/config/linux-config.py similarity index 98% rename from build_files/scons/config/linux2-config.py rename to build_files/scons/config/linux-config.py index d8e227cfb21..c6613ec0ac1 100644 --- a/build_files/scons/config/linux2-config.py +++ b/build_files/scons/config/linux-config.py @@ -1,4 +1,4 @@ -LCGDIR = '../lib/linux2' +LCGDIR = '../lib/linux' LIBDIR = "${LCGDIR}" BF_PYTHON_ABI_FLAGS = 'm' # Most common for linux distros @@ -241,8 +241,8 @@ BF_PROFILE_LINKFLAGS = ['-pg'] BF_DEBUG = False BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG'] -BF_BUILDDIR = '../build/linux2' -BF_INSTALLDIR='../install/linux2' +BF_BUILDDIR = '../build/linux' +BF_INSTALLDIR='../install/linux' #Link against pthread PLATFORM_LINKFLAGS = ['-pthread'] diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 6fae2785192..0b1f3fcd8a8 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -206,7 +206,7 @@ def setup_staticlibs(lenv): if lenv['WITH_BF_STATICJEMALLOC']: statlibs += Split(lenv['BF_JEMALLOC_LIB_STATIC']) - if lenv['OURPLATFORM']=='linux2': + if lenv['OURPLATFORM']=='linux': if lenv['WITH_BF_3DMOUSE']: libincs += Split(lenv['BF_3DMOUSE_LIBPATH']) if lenv['WITH_BF_STATIC3DMOUSE']: @@ -277,7 +277,7 @@ def setup_syslibs(lenv): if not lenv['WITH_BF_STATICJEMALLOC']: syslibs += Split(lenv['BF_JEMALLOC_LIB']) - if lenv['OURPLATFORM']=='linux2': + if lenv['OURPLATFORM']=='linux': if lenv['WITH_BF_3DMOUSE']: if not lenv['WITH_BF_STATIC3DMOUSE']: syslibs += Split(lenv['BF_3DMOUSE_LIB']) @@ -775,7 +775,7 @@ class BlenderEnvironment(SConsEnvironment): if lenv['OURPLATFORM'] in ('win32-vc', 'cygwin', 'win64-vc'): if lenv['BF_DEBUG']: lenv.Prepend(LINKFLAGS = ['/DEBUG','/PDB:'+progname+'.pdb','/NODEFAULTLIB:libcmt']) - if lenv['OURPLATFORM']=='linux2': + if lenv['OURPLATFORM']=='linux': if lenv['WITH_BF_PYTHON']: lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS']) if lenv['OURPLATFORM']=='sunos5': diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 25e0582c536..d222c0bcc18 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -568,7 +568,7 @@ def buildslave(target=None, source=None, env=None): extension = '.tar.bz2' platform = env['OURPLATFORM'].split('-')[0] - if platform == 'linux2': + if platform == 'linux': import platform bitness = platform.architecture()[0] diff --git a/doc/build_systems/scons-dev.txt b/doc/build_systems/scons-dev.txt index d13ea7c036f..ca1b3924804 100644 --- a/doc/build_systems/scons-dev.txt +++ b/doc/build_systems/scons-dev.txt @@ -27,7 +27,7 @@ $Id$ filenames have the form (platform)-config.py, where platform one of: * darwin - * linux2 + * linux * win32-mingw * win32-vc diff --git a/doc/build_systems/scons.txt b/doc/build_systems/scons.txt index b4d9a905885..9d018bcc790 100644 --- a/doc/build_systems/scons.txt +++ b/doc/build_systems/scons.txt @@ -76,7 +76,7 @@ $Id$ $BLENDERHOME/config. Your platform specific defaults are in (platform)-config.py, where platform is one of: - - linux2, for machines running Linux + - linux, for machines running Linux - win32-vc, for Windows machines, compiling with a Microsoft compiler - win32-mingw, for Windows machines, compiling with the MingW compiler - darwin, for OS X machines diff --git a/extern/bullet2/src/SConscript b/extern/bullet2/src/SConscript index 5cb9185d6a1..fa00ad7bc2e 100644 --- a/extern/bullet2/src/SConscript +++ b/extern/bullet2/src/SConscript @@ -11,10 +11,10 @@ if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): defs += ' WIN32 NDEBUG _WINDOWS' #cflags += ['/MT', '/W3', '/GX', '/O2', '/Op'] cflags += ['/MT', '/W3', '/GX', '/Og', '/Ot', '/Ob1', '/Op', '/G6', '/O3', '/EHcs'] -elif env['OURPLATFORM']=='win32-mingw': +elif env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'): defs += ' NDEBUG' cflags += ['-O2'] -elif sys.platform=='linux2' or sys.platform=='linux-i386' or sys.platform=='freebsd4' or sys.platform=='freebsd5': +elif env['OURPLATFORM'] in ('linux', 'freebsd4', 'freebsd5'): defs += ' NDEBUG' cflags += ['-O2'] elif sys.platform=='darwin': diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index 234fc0a172e..82f65c1c8ae 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -26,7 +26,7 @@ if env['WITH_GHOST_SDL']: pass incs += ' ' + env['BF_SDL_INC'] defs += ['WITH_GHOST_SDL'] -elif window_system in ('linux2', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'freebsd9', 'irix6', 'aix4', 'aix5'): +elif window_system in ('linux', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'freebsd9', 'irix6', 'aix4', 'aix5'): for f in pf: try: sources.remove('intern' + os.sep + f + 'Win32.cpp') @@ -81,7 +81,7 @@ else: if env['WITH_BF_3DMOUSE']: defs.append('WITH_INPUT_NDOF') - if env['OURPLATFORM']=='linux2': + if env['OURPLATFORM']=='linux': incs += ' ' + env['BF_3DMOUSE_INC'] else: sources.remove('intern' + os.sep + 'GHOST_NDOFManager.cpp') diff --git a/source/blender/blenpluginapi/SConscript b/source/blender/blenpluginapi/SConscript index 32e69069bb0..7c7c1318a6e 100644 --- a/source/blender/blenpluginapi/SConscript +++ b/source/blender/blenpluginapi/SConscript @@ -11,7 +11,7 @@ if env['WITH_BF_QUICKTIME']: defs.append('WITH_QUICKTIME') incs += ' ' + env['BF_QUICKTIME_INC'] -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/armature/SConscript b/source/blender/editors/armature/SConscript index beabd912a20..b7f9a263bc1 100644 --- a/source/blender/editors/armature/SConscript +++ b/source/blender/editors/armature/SConscript @@ -7,7 +7,7 @@ incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf ../ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../gpu ../../makesrna #/intern/opennl/extern' -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/mesh/SConscript b/source/blender/editors/mesh/SConscript index 34936c025bc..b992ae5f04c 100644 --- a/source/blender/editors/mesh/SConscript +++ b/source/blender/editors/mesh/SConscript @@ -8,7 +8,7 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../gpu ../../blenloader' incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern' -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/object/SConscript b/source/blender/editors/object/SConscript index 660643fbb0f..ca048cb59f9 100644 --- a/source/blender/editors/object/SConscript +++ b/source/blender/editors/object/SConscript @@ -10,7 +10,7 @@ incs += ' ../../render/extern/include ../../gpu' # for object_bake.c defs = [] -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/physics/SConscript b/source/blender/editors/physics/SConscript index 274819c918c..188416eb04c 100644 --- a/source/blender/editors/physics/SConscript +++ b/source/blender/editors/physics/SConscript @@ -10,7 +10,7 @@ incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern' defs = '' -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/render/SConscript b/source/blender/editors/render/SConscript index 2b9737557cd..53418500ea6 100644 --- a/source/blender/editors/render/SConscript +++ b/source/blender/editors/render/SConscript @@ -9,7 +9,7 @@ incs += ' ../../gpu' incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern' incs += ' ../../blenloader' -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/screen/SConscript b/source/blender/editors/screen/SConscript index 61f3429521d..1381c820224 100644 --- a/source/blender/editors/screen/SConscript +++ b/source/blender/editors/screen/SConscript @@ -10,7 +10,7 @@ incs += ' #/intern/guardedalloc #/extern/glew/include' defs = '' -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/sculpt_paint/SConscript b/source/blender/editors/sculpt_paint/SConscript index 90b56ded2cd..b3927fcee68 100644 --- a/source/blender/editors/sculpt_paint/SConscript +++ b/source/blender/editors/sculpt_paint/SConscript @@ -10,7 +10,7 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../render/extern/include' incs += ' ../../gpu ../../makesrna ../../blenloader' -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript index 7c55b40e816..ad96840f7b9 100644 --- a/source/blender/editors/space_file/SConscript +++ b/source/blender/editors/space_file/SConscript @@ -19,7 +19,7 @@ if env['WITH_BF_OPENEXR']: if env['WITH_BF_TIFF']: defs.append('WITH_TIFF') -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/space_node/SConscript b/source/blender/editors/space_node/SConscript index 634d4b777d9..c4309dcfca3 100644 --- a/source/blender/editors/space_node/SConscript +++ b/source/blender/editors/space_node/SConscript @@ -15,7 +15,7 @@ if env['CC'] == 'gcc': #cf.append('-Werror') pass -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index b706db5e64c..1cb24630fbe 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -54,7 +54,7 @@ if env['WITH_BF_PYTHON']: if env['WITH_BF_COLLADA']: defs.append('WITH_COLLADA') -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 5e43ed9b2fb..24c892b96c4 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -91,7 +91,7 @@ if env['WITH_BF_PYTHON']: if env['WITH_BF_COLLADA']: defs.append('WITH_COLLADA') -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' @@ -140,7 +140,7 @@ targetpath = root_build_dir+'/makesrna' if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'): targetpath = '#' + targetpath -if env['OURPLATFORM'] == 'linux2' and root_build_dir[0]==os.sep: +if env['OURPLATFORM'] == 'linux' and root_build_dir[0]==os.sep: makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib']) else: makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib']) diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript index 4bed612144c..8d17c6f5e16 100644 --- a/source/blender/nodes/SConscript +++ b/source/blender/nodes/SConscript @@ -26,7 +26,7 @@ if env['WITH_BF_PYTHON']: if env['BF_DEBUG']: defs.append('_DEBUG') -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/render/SConscript b/source/blender/render/SConscript index bff7797e0c7..4ec1ce3de6b 100644 --- a/source/blender/render/SConscript +++ b/source/blender/render/SConscript @@ -31,7 +31,7 @@ if env['OURPLATFORM'] == 'darwin': cflags_raytrace = env['CFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS'] cxxflags_raytrace = env['CXXFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS'] -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': if env['WITH_BF_RAYOPTIMIZATION']: cflags_raytrace = env['CCFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS'] cxxflags_raytrace = env['CXXFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS'] diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript index 5b6e8b1ab30..e548d99e9a5 100644 --- a/source/blender/windowmanager/SConscript +++ b/source/blender/windowmanager/SConscript @@ -26,7 +26,7 @@ if env['WITH_BF_PYTHON']: if env['WITH_BF_COLLADA']: defs.append('WITH_COLLADA') -if env['OURPLATFORM'] == 'linux2': +if env['OURPLATFORM'] == 'linux': cflags='-pthread' incs += ' ../../../extern/binreloc/include' From 826614d66eccb79e51478af18fc4e0eb6514b1d7 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sun, 21 Aug 2011 21:11:26 +0000 Subject: [PATCH 35/48] name mandatory driver for OSX NDOF compile - testcommit same time --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index e2b83f2811f..7f11397a286 100644 --- a/SConstruct +++ b/SConstruct @@ -269,7 +269,7 @@ if env['OURPLATFORM']=='darwin': else: print B.bc.OKGREEN + "Found recommended sdk :" + B.bc.ENDC + " using MacOSX10.5.sdk" - # for now, Mac builders must download and install the driver framework from 3Dconnexion + # for now, Mac builders must download and install the 3DxWare 10 Beta 4 driver framework from 3Dconnexion # necessary header file lives here when installed: # /Library/Frameworks/3DconnexionClient.framework/Versions/Current/Headers/ConnexionClientAPI.h if env['WITH_BF_3DMOUSE'] == 1 and not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'): From 17c8621cc819b5082cc356c8da9735eb2e481455 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Aug 2011 21:17:55 +0000 Subject: [PATCH 36/48] fix [bf-blender-Patches][27924] Redundant applying of SetNetworkDevice noticed by Jorge Bernal (lordloki) --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 1 - source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index a3ea85b605c..f00dd279361 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -233,7 +233,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c ketsjiengine->SetCanvas(canvas); ketsjiengine->SetRenderTools(rendertools); ketsjiengine->SetRasterizer(rasterizer); - ketsjiengine->SetNetworkDevice(networkdevice); ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index f2b322084ed..a4824e0004d 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -616,7 +616,6 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) m_ketsjiengine->SetCanvas(m_canvas); m_ketsjiengine->SetRenderTools(m_rendertools); m_ketsjiengine->SetRasterizer(m_rasterizer); - m_ketsjiengine->SetNetworkDevice(m_networkdevice); m_ketsjiengine->SetTimingDisplay(frameRate, false, false); #ifdef WITH_PYTHON From aa7545b0ea0920c6ee403d305fc0c0a4af9138ae Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Aug 2011 08:47:48 +0000 Subject: [PATCH 37/48] patch [#28320] Small change to trunk needed for Motion Capture Addon - GSoC 2011 - Pepper Branch from Benjy Cook (benjycook) --- release/scripts/startup/bl_operators/nla.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/nla.py b/release/scripts/startup/bl_operators/nla.py index 44ed846e530..714b889da26 100644 --- a/release/scripts/startup/bl_operators/nla.py +++ b/release/scripts/startup/bl_operators/nla.py @@ -84,6 +84,7 @@ def bake(frame_start, do_pose=True, do_object=True, do_constraint_clear=False, + action=None, ): scene = bpy.context.scene @@ -121,7 +122,8 @@ def bake(frame_start, # incase animation data hassnt been created atd = obj.animation_data_create() - action = bpy.data.actions.new("Action") + if action is None: + action = bpy.data.actions.new("Action") atd.action = action if do_pose: From 1324173e99788a168322cd65fb6dc4a3067a3b6a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Aug 2011 09:01:49 +0000 Subject: [PATCH 38/48] pep8 edits and change '!= None' to 'is not None' --- .../scripts/modules/bpy_extras/mesh_utils.py | 2 +- .../bl_operators/uvcalc_smart_project.py | 4 ++-- .../startup/bl_ui/properties_data_camera.py | 2 +- .../startup/bl_ui/properties_particle.py | 8 ++++---- release/scripts/startup/bl_ui/space_console.py | 2 +- .../scripts/startup/bl_ui/space_dopesheet.py | 2 +- release/scripts/startup/bl_ui/space_image.py | 18 +++++++++--------- release/scripts/startup/bl_ui/space_info.py | 8 ++++---- .../startup/bl_ui/space_view3d_toolbar.py | 2 +- release/scripts/templates/operator_export.py | 2 +- release/scripts/templates/operator_simple.py | 2 +- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index c965169ff04..4b5e3eeb066 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -426,7 +426,7 @@ def ngon_tesselate(from_data, indices, fix_loops=True): # See if its flipped the wrong way. flip = None for fi in fill: - if flip != None: + if flip is not None: break for i, vi in enumerate(fi): if vi == 0 and fi[i - 1] == 1: diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 78b68418322..23838588f43 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -178,7 +178,7 @@ def pointInEdges(pt, edges): intersectCount = 0 for ed in edges: xi, yi = lineIntersection2D(x1,y1, x2,y2, ed[0][0], ed[0][1], ed[1][0], ed[1][1]) - if xi != None: # Is there an intersection. + if xi is not None: # Is there an intersection. intersectCount+=1 return intersectCount % 2 @@ -1131,7 +1131,7 @@ class SmartProject(Operator): @classmethod def poll(cls, context): - return context.active_object != None + return context.active_object is not None def execute(self, context): main(context, diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index f484d7b59e1..5255af40951 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -107,7 +107,7 @@ class DATA_PT_camera(CameraButtonsPanel, Panel): col = split.column() - if cam.dof_object != None: + if cam.dof_object is not None: col.enabled = False col.prop(cam, "dof_distance", text="Distance") diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 03243d1153b..6f58f060504 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -156,7 +156,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): if part: split = layout.split(percentage=0.65) if part.type == 'HAIR': - if psys != None and psys.is_edited: + if psys is not None and psys.is_edited: split.operator("particle.edited_clear", text="Free Edit") else: row = split.row() @@ -166,12 +166,12 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): row = split.row() row.enabled = particle_panel_enabled(context, psys) row.prop(part, "hair_step") - if psys != None and psys.is_edited: + if psys is not None and psys.is_edited: if psys.is_global_hair: layout.operator("particle.connect_hair") else: layout.operator("particle.disconnect_hair") - elif psys != None and part.type == 'REACTOR': + elif psys is not None and part.type == 'REACTOR': split.enabled = particle_panel_enabled(context, psys) split.prop(psys, "reactor_target_object") split.prop(psys, "reactor_target_particle_system", text="Particle System") @@ -654,7 +654,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel): if settings is None: return False - if psys != None and psys.point_cache.use_external: + if psys is not None and psys.point_cache.use_external: return False return settings.physics_type == 'BOIDS' and engine in cls.COMPAT_ENGINES diff --git a/release/scripts/startup/bl_ui/space_console.py b/release/scripts/startup/bl_ui/space_console.py index b517e0d86fb..cbbefa01a3c 100644 --- a/release/scripts/startup/bl_ui/space_console.py +++ b/release/scripts/startup/bl_ui/space_console.py @@ -41,7 +41,7 @@ class CONSOLE_MT_console(Menu): def draw(self, context): layout = self.layout - + layout.operator("console.clear") layout.operator("console.copy") layout.operator("console.paste") diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index dfbd7b3ae14..ae55e1373db 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -101,7 +101,7 @@ class DOPESHEET_HT_header(Header): row.menu("DOPESHEET_MT_select") row.menu("DOPESHEET_MT_marker") - if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action != None): + if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action is not None): row.menu("DOPESHEET_MT_channel") elif st.mode == 'GPENCIL': row.menu("DOPESHEET_MT_gpencil_channel") diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 2042fa1729d..97b5d8457e0 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -452,7 +452,7 @@ class IMAGE_PT_game_properties(Panel): split = layout.split() col = split.column() - + col.prop(ima, "use_animation") sub = col.column(align=True) sub.active = ima.use_animation @@ -507,7 +507,7 @@ class IMAGE_PT_view_waveform(Panel): layout = self.layout sima = context.space_data - + layout.template_waveform(sima, "scopes") row = layout.split(percentage=0.75) row.prop(sima.scopes, "waveform_alpha") @@ -544,9 +544,9 @@ class IMAGE_PT_sample_line(Panel): def draw(self, context): layout = self.layout - + sima = context.space_data - + layout.operator("image.sample_line") layout.template_histogram(sima, "sample_histogram") layout.prop(sima.sample_histogram, "mode") @@ -564,9 +564,9 @@ class IMAGE_PT_scope_sample(Panel): def draw(self, context): layout = self.layout - + sima = context.space_data - + row = layout.row() row.prop(sima.scopes, "use_full_resolution") sub = row.row() @@ -613,14 +613,14 @@ class IMAGE_PT_view_properties(Panel): col = layout.column() col.label("Cursor Location:") col.row().prop(uvedit, "cursor_location", text="") - + col.separator() - + col.label(text="UVs:") col.row().prop(uvedit, "edge_draw_type", expand=True) split = layout.split() - + col = split.column() col.prop(uvedit, "show_faces") col.prop(uvedit, "show_smooth_edges", text="Smooth") diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 38c1e24f27e..5afc5edf6eb 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -194,7 +194,7 @@ class INFO_MT_mesh_add(Menu): def draw(self, context): layout = self.layout - + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane") layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube") @@ -215,7 +215,7 @@ class INFO_MT_curve_add(Menu): def draw(self, context): layout = self.layout - + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier") layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle") @@ -246,7 +246,7 @@ class INFO_MT_surface_add(Menu): def draw(self, context): layout = self.layout - + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve") layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle") @@ -262,7 +262,7 @@ class INFO_MT_armature_add(Menu): def draw(self, context): layout = self.layout - + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA') diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 864d59f0cdb..b71593add96 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1049,7 +1049,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel): ob = context.active_object col = layout.column() - col.active = ob.vertex_groups.active != None + col.active = ob.vertex_groups.active is not None col.operator("object.vertex_group_normalize_all", text="Normalize All") col.operator("object.vertex_group_normalize", text="Normalize") col.operator("object.vertex_group_invert", text="Invert") diff --git a/release/scripts/templates/operator_export.py b/release/scripts/templates/operator_export.py index aeda4ce36fb..b1d53e6ee0c 100644 --- a/release/scripts/templates/operator_export.py +++ b/release/scripts/templates/operator_export.py @@ -47,7 +47,7 @@ class ExportSomeData(bpy.types.Operator, ExportHelper): @classmethod def poll(cls, context): - return context.active_object != None + return context.active_object is not None def execute(self, context): return write_some_data(context, self.filepath, self.use_setting) diff --git a/release/scripts/templates/operator_simple.py b/release/scripts/templates/operator_simple.py index 8348c7a95b1..05d9afc0ad1 100644 --- a/release/scripts/templates/operator_simple.py +++ b/release/scripts/templates/operator_simple.py @@ -13,7 +13,7 @@ class SimpleOperator(bpy.types.Operator): @classmethod def poll(cls, context): - return context.active_object != None + return context.active_object is not None def execute(self, context): main(context) From 5394cabe244bea5c01f03bcf9511fd0a54738a67 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Aug 2011 11:54:40 +0000 Subject: [PATCH 39/48] remove workaround for bug in python 3.2.0 loading web pages on *nix --- release/scripts/startup/bl_operators/wm.py | 64 ---------------------- 1 file changed, 64 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 74f125e0ad3..aa09a088c4f 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -738,7 +738,6 @@ class WM_OT_url_open(Operator): def execute(self, context): import webbrowser - _webbrowser_bug_fix() webbrowser.open(self.url) return {'FINISHED'} @@ -830,7 +829,6 @@ class WM_OT_doc_view(Operator): return {'PASS_THROUGH'} import webbrowser - _webbrowser_bug_fix() webbrowser.open(url) return {'FINISHED'} @@ -1181,65 +1179,3 @@ class WM_OT_copy_prev_settings(Operator): return {'FINISHED'} return {'CANCELLED'} - - -def _webbrowser_bug_fix(): - # test for X11 - import os - - if os.environ.get("DISPLAY"): - - # BSD licenced code copied from python, temp fix for bug - # http://bugs.python.org/issue11432, XXX == added code - def _invoke(self, args, remote, autoraise): - # XXX, added imports - import io - import subprocess - import time - - raise_opt = [] - if remote and self.raise_opts: - # use autoraise argument only for remote invocation - autoraise = int(autoraise) - opt = self.raise_opts[autoraise] - if opt: - raise_opt = [opt] - - cmdline = [self.name] + raise_opt + args - - if remote or self.background: - inout = io.open(os.devnull, "r+") - else: - # for TTY browsers, we need stdin/out - inout = None - # if possible, put browser in separate process group, so - # keyboard interrupts don't affect browser as well as Python - setsid = getattr(os, 'setsid', None) - if not setsid: - setsid = getattr(os, 'setpgrp', None) - - p = subprocess.Popen(cmdline, close_fds=True, # XXX, stdin=inout, - stdout=(self.redirect_stdout and inout or None), - stderr=inout, preexec_fn=setsid) - if remote: - # wait five secons. If the subprocess is not finished, the - # remote invocation has (hopefully) started a new instance. - time.sleep(1) - rc = p.poll() - if rc is None: - time.sleep(4) - rc = p.poll() - if rc is None: - return True - # if remote call failed, open() will try direct invocation - return not rc - elif self.background: - if p.poll() is None: - return True - else: - return False - else: - return not p.wait() - - import webbrowser - webbrowser.UnixBrowser._invoke = _invoke From 817273931a42f807809a9d0f000564e2bd38dfb8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Aug 2011 12:24:14 +0000 Subject: [PATCH 40/48] buildinfo is now quoted from the build systems, avoids stripping quotes on startup. tested with linux/cmake linux/scons windows/cmake/mingw windows/cmake/msvc --- CMakeLists.txt | 16 ++++++++++++++++ build_files/cmake/buildinfo.cmake | 6 +++--- build_files/cmake/macros.cmake | 5 ----- build_files/scons/tools/Blender.py | 12 ++++++------ source/creator/CMakeLists.txt | 3 --- source/creator/buildinfo.c | 24 ++++++++++-------------- source/creator/creator.c | 26 -------------------------- 7 files changed, 35 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cdf1fb9da9..ccd101dd46d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,22 @@ set(CMAKE_BUILD_TYPE_INIT "Release") # quiet output for Makefiles, 'make -s' helps too # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF) +#----------------------------------------------------------------------------- +# Set policy + +# see "cmake --help-policy CMP0003" +# So library linking is more sane +cmake_policy(SET CMP0003 NEW) + +# So BUILDINFO and BLENDERPATH strings are automatically quoted +cmake_policy(SET CMP0005 NEW) + +# So syntax problems are errors +cmake_policy(SET CMP0010 NEW) + +# Input directories must have CMakeLists.txt +cmake_policy(SET CMP0014 NEW) + #----------------------------------------------------------------------------- # Load some macros. include(build_files/cmake/macros.cmake) diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index bfc17ae2cfe..e68015e36d3 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -27,9 +27,9 @@ endif() # Write a file with the SVNVERSION define file(WRITE buildinfo.h.txt - "#define BUILD_REV ${MY_WC_REVISION}\n" - "#define BUILD_DATE ${BUILD_DATE}\n" - "#define BUILD_TIME ${BUILD_TIME}\n" + "#define BUILD_REV \"${MY_WC_REVISION}\"\n" + "#define BUILD_DATE \"${BUILD_DATE}\"\n" + "#define BUILD_TIME \"${BUILD_TIME}\"\n" ) # Copy the file to the final header only if the version changes diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 27694bcb875..58938c8b0b0 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -145,11 +145,6 @@ endmacro() macro(SETUP_LIBDIRS) - # see "cmake --help-policy CMP0003" - if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) - endif() - link_directories(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH}) if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 0b1f3fcd8a8..271f555522c 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -364,16 +364,16 @@ def buildinfo(lenv, build_type): obj = [] if lenv['BF_BUILDINFO']: - lenv.Append (CPPDEFINES = ['BUILD_TIME="%s"'%(build_time), - 'BUILD_DATE="%s"'%(build_date), - 'BUILD_TYPE="%s"'%(build_type), - 'BUILD_REV="%s"'%(build_rev), + lenv.Append (CPPDEFINES = ['BUILD_TIME=\\"%s\\"'%(build_time), + 'BUILD_DATE=\\"%s\\"'%(build_date), + 'BUILD_TYPE=\\"%s\\"'%(build_type), + 'BUILD_REV=\\"%s\\"'%(build_rev), 'NAN_BUILDINFO', - 'BUILD_PLATFORM="%s:%s"'%(platform.system(), platform.architecture()[0]), + 'BUILD_PLATFORM=\\"%s:%s\\"'%(platform.system(), platform.architecture()[0]), 'BUILD_CFLAGS=\\"%s\\"'%(build_cflags), 'BUILD_CXXFLAGS=\\"%s\\"'%(build_cxxflags), 'BUILD_LINKFLAGS=\\"%s\\"'%(build_linkflags), - 'BUILD_SYSTEM="SCons"' + 'BUILD_SYSTEM=\\"SCons\\"' ]) lenv.Append (CPPPATH = [root_build_dir+'source/blender/blenkernel']) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 43fec85b5bf..129ddca8c38 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -25,9 +25,6 @@ # # ***** END GPL LICENSE BLOCK ***** -# So BUILDINFO and BLENDERPATH strings are automatically quoted -cmake_policy(SET CMP0005 NEW) - setup_libdirs() blender_include_dirs( diff --git a/source/creator/buildinfo.c b/source/creator/buildinfo.c index 48a4352b11b..3853d6ca693 100644 --- a/source/creator/buildinfo.c +++ b/source/creator/buildinfo.c @@ -33,28 +33,24 @@ #ifdef WITH_BUILDINFO_HEADER -#include "buildinfo.h" +# include "buildinfo.h" #endif #ifdef BUILD_DATE -/* copied from BLI_utildefines.h */ -#define STRINGIFY_ARG(x) #x -#define STRINGIFY(x) STRINGIFY_ARG(x) - /* currently only these are defined in the header */ -char build_date[]= STRINGIFY(BUILD_DATE); -char build_time[]= STRINGIFY(BUILD_TIME); -char build_rev[]= STRINGIFY(BUILD_REV); +char build_date[]= BUILD_DATE; +char build_time[]= BUILD_TIME; +char build_rev[]= BUILD_REV; -char build_platform[]= STRINGIFY(BUILD_PLATFORM); -char build_type[]= STRINGIFY(BUILD_TYPE); +char build_platform[]= BUILD_PLATFORM; +char build_type[]= BUILD_TYPE; #ifdef BUILD_CFLAGS -char build_cflags[]= STRINGIFY(BUILD_CFLAGS); -char build_cxxflags[]= STRINGIFY(BUILD_CXXFLAGS); -char build_linkflags[]= STRINGIFY(BUILD_LINKFLAGS); -char build_system[]= STRINGIFY(BUILD_SYSTEM); +char build_cflags[]= BUILD_CFLAGS; +char build_cxxflags[]= BUILD_CXXFLAGS; +char build_linkflags[]= BUILD_LINKFLAGS; +char build_system[]= BUILD_SYSTEM; #else char build_cflags[]= "unmaintained buildsystem alert!"; char build_cxxflags[]= "unmaintained buildsystem alert!"; diff --git a/source/creator/creator.c b/source/creator/creator.c index 36209dbda78..6aa1773be5a 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -182,20 +182,6 @@ static void blender_esc(int sig) } #endif -/* buildinfo can have quotes */ -#ifdef BUILD_DATE -static void strip_quotes(char *str) -{ - if(str[0] == '"') { - int len= strlen(str) - 1; - memmove(str, str+1, len); - if(str[len-1] == '"') { - str[len-1]= '\0'; - } - } -} -#endif - static int print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { printf (BLEND_VERSION_STRING_FMT); @@ -1181,18 +1167,6 @@ int main(int argc, const char **argv) // need this. BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]); - -#ifdef BUILD_DATE - strip_quotes(build_date); - strip_quotes(build_time); - strip_quotes(build_rev); - strip_quotes(build_platform); - strip_quotes(build_type); - strip_quotes(build_cflags); - strip_quotes(build_cxxflags); - strip_quotes(build_linkflags); - strip_quotes(build_system); -#endif BLI_threadapi_init(); From 7d316b70b842ff376d07f5ba55302d31d92e6dbb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Aug 2011 16:54:26 +0000 Subject: [PATCH 41/48] rename NAN_BUILDINFO --> WITH_BUILDINFO --- build_files/scons/tools/Blender.py | 2 +- source/blender/blenloader/CMakeLists.txt | 2 +- source/blender/blenloader/intern/writefile.c | 2 +- source/blender/collada/CMakeLists.txt | 2 +- source/blender/collada/DocumentExporter.cpp | 4 ++-- source/blender/windowmanager/CMakeLists.txt | 2 +- source/blender/windowmanager/intern/wm_operators.c | 8 ++++---- source/creator/CMakeLists.txt | 1 + source/creator/creator.c | 4 ++-- 9 files changed, 14 insertions(+), 13 deletions(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 271f555522c..94d09732be7 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -368,7 +368,7 @@ def buildinfo(lenv, build_type): 'BUILD_DATE=\\"%s\\"'%(build_date), 'BUILD_TYPE=\\"%s\\"'%(build_type), 'BUILD_REV=\\"%s\\"'%(build_rev), - 'NAN_BUILDINFO', + 'WITH_BUILDINFO', 'BUILD_PLATFORM=\\"%s:%s\\"'%(platform.system(), platform.architecture()[0]), 'BUILD_CFLAGS=\\"%s\\"'%(build_cflags), 'BUILD_CXXFLAGS=\\"%s\\"'%(build_cxxflags), diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index be15b191c8a..4088481c844 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -55,7 +55,7 @@ set(SRC ) if(WITH_BUILDINFO) - add_definitions(-DNAN_BUILDINFO) + add_definitions(-DWITH_BUILDINFO) endif() blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 7d65248c0e9..085cd2cb29c 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2461,7 +2461,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) fg.subversion= BLENDER_SUBVERSION; fg.minversion= BLENDER_MINVERSION; fg.minsubversion= BLENDER_MINSUBVERSION; -#ifdef NAN_BUILDINFO +#ifdef WITH_BUILDINFO { extern char build_rev[]; fg.revision= atoi(build_rev); diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index e2a68d19682..b5c84bc3c84 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -107,7 +107,7 @@ set(SRC ) if(WITH_BUILDINFO) - add_definitions(-DNAN_BUILDINFO) + add_definitions(-DWITH_BUILDINFO) endif() if(CMAKE_COMPILER_IS_GNUCXX) diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index e6e0953680c..b26318f6114 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -52,7 +52,7 @@ extern "C" #include "BLI_path_util.h" #include "BLI_fileops.h" #include "ED_keyframing.h" -#ifdef NAN_BUILDINFO +#ifdef WITH_BUILDINFO extern char build_rev[]; #endif } @@ -1002,7 +1002,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool else { asset.getContributor().mAuthor = "Blender User"; } -#ifdef NAN_BUILDINFO +#ifdef WITH_BUILDINFO char version_buf[128]; sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION, build_rev); asset.getContributor().mAuthoringTool = version_buf; diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index dc83e29b497..7c34c086b2e 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -130,7 +130,7 @@ if(APPLE) endif() if(WITH_BUILDINFO) - add_definitions(-DNAN_BUILDINFO) + add_definitions(-DWITH_BUILDINFO) endif() blender_add_lib_nolist(bf_windowmanager "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index fdf89cfd2be..d794685ea70 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1202,7 +1202,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar MenuType *mt= WM_menutype_find("USERPREF_MT_splash", TRUE); char url[96]; -#ifdef NAN_BUILDINFO +#ifdef WITH_BUILDINFO int ver_width, rev_width; char *version_str = NULL; char *revision_str = NULL; @@ -1219,7 +1219,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi); ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_str) + 5; rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_str) + 5; -#endif //NAN_BUILDINFO +#endif //WITH_BUILDINFO block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); @@ -1228,10 +1228,10 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiButSetFunc(but, wm_block_splash_close, block, NULL); uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL); -#ifdef NAN_BUILDINFO +#ifdef WITH_BUILDINFO uiDefBut(block, LABEL, 0, version_str, 494-ver_width, 282-24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); uiDefBut(block, LABEL, 0, revision_str, 494-rev_width, 282-36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); -#endif //NAN_BUILDINFO +#endif //WITH_BUILDINFO layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, 480, 110, style); diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 129ddca8c38..c4a5222a719 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -133,6 +133,7 @@ if(WIN32 AND NOT UNIX) endif() if(WITH_BUILDINFO) + add_definitions(-DWITH_BUILDINFO) # -------------------------------------------------------------------------- # These defines could all be moved into the header below string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}") diff --git a/source/creator/creator.c b/source/creator/creator.c index 6aa1773be5a..9b2cfb08382 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -355,9 +355,9 @@ static int debug_mode(int UNUSED(argc), const char **UNUSED(argv), void *data) printf(BLEND_VERSION_STRING_FMT); MEM_set_memory_debug(); -#ifdef NAN_BUILDINFO +#ifdef WITH_BUILDINFO printf("Build: %s %s %s %s\n", build_date, build_time, build_platform, build_type); -#endif // NAN_BUILDINFO +#endif // WITH_BUILDINFO BLI_argsPrint(data); return 0; From a937729f38875a57f589b8ccb114b13a5b22fd3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Aug 2011 18:13:37 +0000 Subject: [PATCH 42/48] properly escape chars for pythons bpy objects __repr__ --- source/blender/python/intern/bpy_rna.c | 42 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 1b8f986e71c..72553872057 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -814,34 +814,40 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self) static PyObject *pyrna_struct_repr(BPy_StructRNA *self) { ID *id= self->ptr.id.data; + PyObject *tmp_str; + PyObject *ret; + if(id == NULL || !PYRNA_STRUCT_IS_VALID(self)) return pyrna_struct_str(self); /* fallback */ + tmp_str= PyUnicode_FromString(id->name+2); + if(RNA_struct_is_ID(self->ptr.type)) { - return PyUnicode_FromFormat("bpy.data.%s[\"%s\"]", + ret= PyUnicode_FromFormat("bpy.data.%s[%R]", BKE_idcode_to_name_plural(GS(id->name)), - id->name+2); + tmp_str); } else { - PyObject *ret; const char *path; path= RNA_path_from_ID_to_struct(&self->ptr); if(path) { - ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"].%s", + ret= PyUnicode_FromFormat("bpy.data.%s[%R].%s", BKE_idcode_to_name_plural(GS(id->name)), - id->name+2, + tmp_str, path); MEM_freeN((void *)path); } else { /* cant find, print something sane */ - ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"]...%s", + ret= PyUnicode_FromFormat("bpy.data.%s[%R]...%s", BKE_idcode_to_name_plural(GS(id->name)), - id->name+2, + tmp_str, RNA_struct_identifier(self->ptr.type)); } - - return ret; } + + Py_DECREF(tmp_str); + + return ret; } static PyObject *pyrna_prop_str(BPy_PropertyRNA *self) @@ -911,27 +917,35 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self) static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) { - ID *id; + ID *id= self->ptr.id.data; + PyObject *tmp_str; PyObject *ret; const char *path; PYRNA_PROP_CHECK_OBJ(self) - if((id= self->ptr.id.data) == NULL) + if(id == NULL) return pyrna_prop_str(self); /* fallback */ + tmp_str= PyUnicode_FromString(id->name+2); + path= RNA_path_from_ID_to_property(&self->ptr, self->prop); if(path) { - ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"].%s", BKE_idcode_to_name_plural(GS(id->name)), id->name+2, path); + ret= PyUnicode_FromFormat("bpy.data.%s[%R].%s", + BKE_idcode_to_name_plural(GS(id->name)), + tmp_str, + path); MEM_freeN((void *)path); } else { /* cant find, print something sane */ - ret= PyUnicode_FromFormat("bpy.data.%s[\"%s\"]...%s", + ret= PyUnicode_FromFormat("bpy.data.%s[%R]...%s", BKE_idcode_to_name_plural(GS(id->name)), - id->name+2, + tmp_str, RNA_property_identifier(self->prop)); } + Py_DECREF(tmp_str); + return ret; } From a33a26ca07d32f4460f67775150bfacdd8f793c7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 22 Aug 2011 18:49:42 +0000 Subject: [PATCH 43/48] FFmpeg library update: - Update scons/cmake rules to use new versions of libs/dlls. - Update rules for buildbot. --- CMakeLists.txt | 12 ++++----- build_files/buildbot/slave_compile.py | 26 +++---------------- build_files/buildbot/slave_pack.py | 26 +++---------------- build_files/scons/config/linuxcross-config.py | 2 +- .../scons/config/win32-mingw-config.py | 2 +- build_files/scons/config/win32-vc-config.py | 4 +-- build_files/scons/config/win64-vc-config.py | 4 +-- source/creator/CMakeLists.txt | 10 +++---- 8 files changed, 23 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccd101dd46d..4a544cbfa05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -710,11 +710,11 @@ elseif(WIN32) ${LIBDIR}/ffmpeg/include/msvc ) set(FFMPEG_LIBRARIES - ${LIBDIR}/ffmpeg/lib/avcodec-52.lib - ${LIBDIR}/ffmpeg/lib/avformat-52.lib - ${LIBDIR}/ffmpeg/lib/avdevice-52.lib - ${LIBDIR}/ffmpeg/lib/avutil-50.lib - ${LIBDIR}/ffmpeg/lib/swscale-0.lib + ${LIBDIR}/ffmpeg/lib/avcodec-53.lib + ${LIBDIR}/ffmpeg/lib/avformat-53.lib + ${LIBDIR}/ffmpeg/lib/avdevice-53.lib + ${LIBDIR}/ffmpeg/lib/avutil-51.lib + ${LIBDIR}/ffmpeg/lib/swscale-2.lib ) endif() @@ -841,7 +841,7 @@ elseif(WIN32) if(WITH_CODEC_FFMPEG) set(FFMPEG ${LIBDIR}/ffmpeg) set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include ${FFMPEG}/include) - set(FFMPEG_LIBRARIES avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0) + set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2) set(FFMPEG_LIBPATH ${FFMPEG}/lib) endif() diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index b83a65f2466..415f95a516f 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -108,32 +108,12 @@ else: sys.exit(0) else: - bitness = '32' - # Switch to new FFmpeg library if builder.find('win') != -1: - if builder.find('win32') != -1: - LCGDIR = '#../lib/windows' - elif builder.find('win64') != -1: - LCGDIR = '#../lib/win64' + bitness = '32' + + if builder.find('win64') != -1: bitness = '64' - all_ffmpeg_libs = ['avcodec-53', - 'avdevice-53', - 'avformat-53', - 'avutil-51', - 'swscale-2'] - - ffmpeg_lib = [] - ffmpeg_dll = [] - - for lib in all_ffmpeg_libs: - ffmpeg_lib.append(lib + '.lib') - ffmpeg_dll.append('${BF_FFMPEG_LIBPATH}/' + lib + '.dll') - - scons_options.append('BF_FFMPEG=' + LCGDIR + '/ffmpeg-0.8') - scons_options.append('BF_FFMPEG_LIB=' + (' '.join(ffmpeg_lib))) - scons_options.append('BF_FFMPEG_DLL=' + (' '.join(ffmpeg_dll))) - scons_options.append('BF_BITNESS=' + bitness) retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index 5fdeb4a8ad5..af8d99893b4 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -72,32 +72,12 @@ if builder.find('scons') != -1: retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) sys.exit(retcode) else: - bitness = '32' - # Switch to new FFmpeg library if builder.find('win') != -1: - if builder.find('win32') != -1: - LCGDIR = '#../lib/windows' - elif builder.find('win64') != -1: - LCGDIR = '#../lib/win64' + bitness = '32' + + if builder.find('win64') != -1: bitness = '64' - all_ffmpeg_libs = ['avcodec-53', - 'avdevice-53', - 'avformat-53', - 'avutil-51', - 'swscale-2'] - - ffmpeg_lib = [] - ffmpeg_dll = [] - - for lib in all_ffmpeg_libs: - ffmpeg_lib.append(lib + '.lib') - ffmpeg_dll.append('${BF_FFMPEG_LIBPATH}/' + lib + '.dll') - - scons_options.append('BF_FFMPEG=' + LCGDIR + '/ffmpeg-0.8') - scons_options.append('BF_FFMPEG_LIB=' + (' '.join(ffmpeg_lib))) - scons_options.append('BF_FFMPEG_DLL=' + (' '.join(ffmpeg_dll))) - scons_options.append('BF_BITNESS=' + bitness) retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) diff --git a/build_files/scons/config/linuxcross-config.py b/build_files/scons/config/linuxcross-config.py index 62474527825..563b1ad980c 100644 --- a/build_files/scons/config/linuxcross-config.py +++ b/build_files/scons/config/linuxcross-config.py @@ -126,7 +126,7 @@ WITH_BF_BINRELOC = False # enable ffmpeg support WITH_BF_FFMPEG = True # -DWITH_FFMPEG BF_FFMPEG = LIBDIR + '/ffmpeg' -BF_FFMPEG_LIB = 'avformat-52 avcodec-52 avdevice-52 avutil-50 swscale-0' +BF_FFMPEG_LIB = 'avformat-53 avcodec-53 avdevice-53 avutil-51 swscale-2' BF_FFMPEG_INC = '${BF_FFMPEG}/include' BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib' diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py index 6dac29b37f7..b29c4845a9c 100644 --- a/build_files/scons/config/win32-mingw-config.py +++ b/build_files/scons/config/win32-mingw-config.py @@ -18,7 +18,7 @@ BF_OPENAL_LIB = 'wrap_oal' BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' WITH_BF_FFMPEG = False -BF_FFMPEG_LIB = 'avformat-52 avcodec-52 avdevice-52 avutil-50 swscale-0' +BF_FFMPEG_LIB = 'avformat-53 avcodec-53 avdevice-53 avutil-51 swscale-2' BF_FFMPEG_LIBPATH = LIBDIR + '/ffmpeg/lib' BF_FFMPEG_INC = LIBDIR + '/ffmpeg/include' diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index 4baada7f9bf..2f8fa297667 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -6,8 +6,8 @@ WITH_BF_FFMPEG = True # -DWITH_FFMPEG BF_FFMPEG = LIBDIR +'/ffmpeg' BF_FFMPEG_INC = '${BF_FFMPEG}/include ${BF_FFMPEG}/include/msvc' BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' -BF_FFMPEG_LIB = 'avformat-52.lib avcodec-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib' -BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-52.dll ${BF_FFMPEG_LIBPATH}/avcodec-52.dll ${BF_FFMPEG_LIBPATH}/avdevice-52.dll ${BF_FFMPEG_LIBPATH}/avutil-50.dll ${BF_FFMPEG_LIBPATH}/swscale-0.dll' +BF_FFMPEG_LIB = 'avformat-53.lib avcodec-53.lib avdevice-53.lib avutil-51.lib swscale-2.lib' +BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll' BF_PYTHON = LIBDIR + '/python' BF_PYTHON_VERSION = '3.2' diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index db7c8d09af8..ba9633a6b4c 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -6,8 +6,8 @@ WITH_BF_FFMPEG = True # -DWITH_FFMPEG BF_FFMPEG = LIBDIR +'/ffmpeg' BF_FFMPEG_INC = '${BF_FFMPEG}/include ${BF_FFMPEG}/include/msvc ' BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' -BF_FFMPEG_LIB = 'avformat-52.lib avcodec-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib' -BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-52.dll ${BF_FFMPEG_LIBPATH}/avcodec-52.dll ${BF_FFMPEG_LIBPATH}/avdevice-52.dll ${BF_FFMPEG_LIBPATH}/avutil-50.dll ${BF_FFMPEG_LIBPATH}/swscale-0.dll' +BF_FFMPEG_LIB = 'avformat-53.lib avcodec-53.lib avdevice-53.lib avutil-51.lib swscale-2.lib' +BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll' BF_PYTHON = LIBDIR + '/python' BF_PYTHON_VERSION = '3.2' diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index c4a5222a719..315cd5312cf 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -545,11 +545,11 @@ elseif(WIN32) if(WITH_CODEC_FFMPEG) install( FILES - ${LIBDIR}/ffmpeg/lib/avcodec-52.dll - ${LIBDIR}/ffmpeg/lib/avformat-52.dll - ${LIBDIR}/ffmpeg/lib/avdevice-52.dll - ${LIBDIR}/ffmpeg/lib/avutil-50.dll - ${LIBDIR}/ffmpeg/lib/swscale-0.dll + ${LIBDIR}/ffmpeg/lib/avcodec-53.dll + ${LIBDIR}/ffmpeg/lib/avformat-53.dll + ${LIBDIR}/ffmpeg/lib/avdevice-53.dll + ${LIBDIR}/ffmpeg/lib/avutil-51.dll + ${LIBDIR}/ffmpeg/lib/swscale-2.dll DESTINATION ${TARGETDIR} ) From a9d9a8e569d00d98d487980f00a5626a581cd4c8 Mon Sep 17 00:00:00 2001 From: Morten Mikkelsen Date: Mon, 22 Aug 2011 18:56:13 +0000 Subject: [PATCH 44/48] actually, this if is still marginally good to have --- source/blender/imbuf/intern/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 3f391b91c0f..7f1eef80318 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -397,10 +397,10 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) float acc[4]={0,0,0,0}; k = 0; - /*if (check_pixel_assigned(srcbuf, srcmask, filter_make_index(x-1, y, width, height), depth, is_float) || + if (check_pixel_assigned(srcbuf, srcmask, filter_make_index(x-1, y, width, height), depth, is_float) || check_pixel_assigned(srcbuf, srcmask, filter_make_index(x+1, y, width, height), depth, is_float) || check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y-1, width, height), depth, is_float) || - check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y+1, width, height), depth, is_float))*/ { + check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y+1, width, height), depth, is_float)) { for(i= -n; i<=n; i++) { for(j=-n; j<=n; j++) { if(i != 0 || j != 0) { From e39cb8a0401c876fcfb9d7d00a1daffd8c970549 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 22 Aug 2011 19:00:32 +0000 Subject: [PATCH 45/48] Forgot this in previous commit --- build_files/buildbot/config/user-config-i686.py | 2 +- build_files/buildbot/config/user-config-player-i686.py | 2 +- build_files/buildbot/config/user-config-player-x86_64.py | 2 +- build_files/buildbot/config/user-config-x86_64.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build_files/buildbot/config/user-config-i686.py b/build_files/buildbot/config/user-config-i686.py index e09fecede59..07dc4a9d831 100644 --- a/build_files/buildbot/config/user-config-i686.py +++ b/build_files/buildbot/config/user-config-i686.py @@ -22,7 +22,7 @@ BF_EXPAT_LIB = '' WITH_BF_FFMPEG = True WITH_BF_STATICFFMPEG = True -BF_FFMPEG = '/home/sources/staticlibs/ffmpeg-0.8' +BF_FFMPEG = '/home/sources/staticlibs/ffmpeg' BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib32' BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ '${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \ diff --git a/build_files/buildbot/config/user-config-player-i686.py b/build_files/buildbot/config/user-config-player-i686.py index 279f2d66804..54e66e847df 100644 --- a/build_files/buildbot/config/user-config-player-i686.py +++ b/build_files/buildbot/config/user-config-player-i686.py @@ -16,7 +16,7 @@ WITH_BF_COLLADA = False WITH_BF_FFMPEG = True WITH_BF_STATICFFMPEG = True -BF_FFMPEG = '/home/sources/staticlibs/ffmpeg-0.8' +BF_FFMPEG = '/home/sources/staticlibs/ffmpeg' BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib32' BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ '${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \ diff --git a/build_files/buildbot/config/user-config-player-x86_64.py b/build_files/buildbot/config/user-config-player-x86_64.py index d1914338510..5d594229d3e 100644 --- a/build_files/buildbot/config/user-config-player-x86_64.py +++ b/build_files/buildbot/config/user-config-player-x86_64.py @@ -16,7 +16,7 @@ WITH_BF_COLLADA = False WITH_BF_FFMPEG = True WITH_BF_STATICFFMPEG = True -BF_FFMPEG = '/home/sources/staticlibs/ffmpeg-0.8' +BF_FFMPEG = '/home/sources/staticlibs/ffmpeg' BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib64' BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ '${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \ diff --git a/build_files/buildbot/config/user-config-x86_64.py b/build_files/buildbot/config/user-config-x86_64.py index bdba8892bf8..9c569ff4458 100644 --- a/build_files/buildbot/config/user-config-x86_64.py +++ b/build_files/buildbot/config/user-config-x86_64.py @@ -22,7 +22,7 @@ BF_EXPAT_LIB = '' WITH_BF_FFMPEG = True WITH_BF_STATICFFMPEG = True -BF_FFMPEG = '/home/sources/staticlibs/ffmpeg-0.8' +BF_FFMPEG = '/home/sources/staticlibs/ffmpeg' BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib64' BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ '${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \ From c33e0c053ad3f842d1f07454e42e045f5f4fec1c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Aug 2011 19:13:26 +0000 Subject: [PATCH 46/48] fix for buildinfo changes with blenderplayer --- source/blenderplayer/bad_level_call_stubs/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt index f852d061cf7..0610cf2fdbe 100644 --- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt +++ b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt @@ -49,7 +49,12 @@ if(WITH_BUILDINFO) list(APPEND SRC ../../creator/buildinfo.c ) - add_definitions(-DBUILD_DATE) + add_definitions(-DBUILD_DATE="\"\"" + -DBUILD_TIME="\"\"" + -DBUILD_REV="\"\"" + -DBUILD_PLATFORM="\"\"" + -DBUILD_TYPE="\"\"" + ) endif() if(WITH_GAMEENGINE) From 0e3b8ff6a5fe0d926b34612f75281deff0e63f0d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 22 Aug 2011 19:27:54 +0000 Subject: [PATCH 47/48] Update rules for linux cross and mingw: list of DLLs for FFmpeg should be defined there. --- build_files/scons/config/linuxcross-config.py | 1 + build_files/scons/config/win32-mingw-config.py | 1 + 2 files changed, 2 insertions(+) diff --git a/build_files/scons/config/linuxcross-config.py b/build_files/scons/config/linuxcross-config.py index 563b1ad980c..1bdf735f458 100644 --- a/build_files/scons/config/linuxcross-config.py +++ b/build_files/scons/config/linuxcross-config.py @@ -129,6 +129,7 @@ BF_FFMPEG = LIBDIR + '/ffmpeg' BF_FFMPEG_LIB = 'avformat-53 avcodec-53 avdevice-53 avutil-51 swscale-2' BF_FFMPEG_INC = '${BF_FFMPEG}/include' BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib' +BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll' WITH_BF_OPENJPEG = True BF_OPENJPEG = '#extern/libopenjpeg' diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py index b29c4845a9c..c815b76ef73 100644 --- a/build_files/scons/config/win32-mingw-config.py +++ b/build_files/scons/config/win32-mingw-config.py @@ -21,6 +21,7 @@ WITH_BF_FFMPEG = False BF_FFMPEG_LIB = 'avformat-53 avcodec-53 avdevice-53 avutil-51 swscale-2' BF_FFMPEG_LIBPATH = LIBDIR + '/ffmpeg/lib' BF_FFMPEG_INC = LIBDIR + '/ffmpeg/include' +BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll' BF_LIBSAMPLERATE = LIBDIR + '/samplerate' BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' From 6a374d266d8213629f74a9f4c9a4984ddf59ef4c Mon Sep 17 00:00:00 2001 From: Morten Mikkelsen Date: Mon, 22 Aug 2011 19:57:54 +0000 Subject: [PATCH 48/48] glsl and render support for derivative maps --- .../startup/bl_ui/properties_texture.py | 16 +++++--- source/blender/gpu/intern/gpu_material.c | 29 +++++++++---- .../gpu/intern/gpu_shader_material.glsl | 16 ++++++++ .../gpu/intern/gpu_shader_material.glsl.c | 20 ++++++++- source/blender/makesdna/DNA_texture_types.h | 1 + source/blender/makesrna/intern/rna_texture.c | 6 +++ .../render/intern/source/render_texture.c | 41 ++++++++++++++----- 7 files changed, 104 insertions(+), 25 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index ead65b92c3f..0172fbcbadd 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -414,6 +414,10 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, Panel): row = col.row() row.active = tex.use_normal_map row.prop(slot, "normal_map_space", text="") + + row = col.row() + row.active = not tex.use_normal_map + row.prop(tex, "use_derivative_map") col.prop(tex, "use_mipmap") row = col.row() @@ -1025,12 +1029,14 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel): # only show bump settings if activated but not for normalmap images row = layout.row() - row.active = (tex.use_map_normal or tex.use_map_warp) and not (tex.texture.type == 'IMAGE' and tex.texture.use_normal_map) - - row.prop(tex, "bump_method", text="Method") - + sub = row.row() - sub.active = tex.bump_method in {'BUMP_DEFAULT', 'BUMP_BEST_QUALITY'} + sub.active = (tex.use_map_normal or tex.use_map_warp) and not (tex.texture.type == 'IMAGE' and (tex.texture.use_normal_map or tex.texture.use_derivative_map)) + sub.prop(tex, "bump_method", text="Method") + + # the space setting is supported for: derivmaps + bumpmaps (DEFAULT,BEST_QUALITY), not for normalmaps + sub = row.row() + sub.active = (tex.use_map_normal or tex.use_map_warp) and not (tex.texture.type == 'IMAGE' and tex.texture.use_normal_map) and ((tex.bump_method in {'BUMP_DEFAULT', 'BUMP_BEST_QUALITY'}) or (tex.texture.type == 'IMAGE' and tex.texture.use_derivative_map)) sub.prop(tex, "bump_objectspace", text="Space") diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 274884000db..28624e9350c 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -906,6 +906,7 @@ static void do_material_tex(GPUShadeInput *shi) int init_done = 0, iBumpSpacePrev; GPUNodeLink *vNorg, *vNacc, *fPrevMagnitude; int iFirstTimeNMap=1; + int found_deriv_map = 0; GPU_link(mat, "set_value", GPU_uniform(&one), &stencil); @@ -1043,6 +1044,8 @@ static void do_material_tex(GPUShadeInput *shi) if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { if(tex->type==TEX_IMAGE) { + found_deriv_map = tex->imaflag & TEX_DERIVATIVEMAP; + if(tex->imaflag & TEX_NORMALMAP) { /* normalmap image */ GPU_link(mat, "mtex_normal", texco, GPU_image(tex->ima, &tex->iuser), &tnor ); @@ -1082,9 +1085,10 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "mtex_blend_normal", tnorfac, shi->vn, newnor, &shi->vn); } - } else if( mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) { + } else if( (mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) || found_deriv_map) { /* ntap bumpmap image */ int iBumpSpace; + float ima_x, ima_y; float hScale = 0.1f; // compatibility adjustment factor for all bumpspace types float hScaleTex = 13.0f; // factor for scaling texspace bumps @@ -1142,9 +1146,24 @@ static void do_material_tex(GPUShadeInput *shi) iBumpSpacePrev = iBumpSpace; } + + // resolve texture resolution + if( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) { + ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser); + ima_x= 512.0f; ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only + if(ibuf) { + ima_x= ibuf->x; + ima_y= ibuf->y; + } + } - if( mtex->texflag & MTEX_3TAP_BUMP ) + if(found_deriv_map) { + GPU_link( mat, "mtex_bump_deriv", + texco, GPU_image(tex->ima, &tex->iuser), GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac, + &dBs, &dBt ); + } + else if( mtex->texflag & MTEX_3TAP_BUMP ) GPU_link( mat, "mtex_bump_tap3", texco, GPU_image(tex->ima, &tex->iuser), tnorfac, &dBs, &dBt ); @@ -1155,12 +1174,6 @@ static void do_material_tex(GPUShadeInput *shi) if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - float ima_x= 512.0f, ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only - ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser); - if(ibuf) { - ima_x= ibuf->x; - ima_y= ibuf->y; - } GPU_link( mat, "mtex_bump_apply_texspace", fDet, dBs, dBt, vR1, vR2, diff --git a/source/blender/gpu/intern/gpu_shader_material.glsl b/source/blender/gpu/intern/gpu_shader_material.glsl index feb0a84fa87..0aae6d84a01 100644 --- a/source/blender/gpu/intern/gpu_shader_material.glsl +++ b/source/blender/gpu/intern/gpu_shader_material.glsl @@ -1226,6 +1226,22 @@ void mtex_bump_tap5( vec3 texco, sampler2D ima, float hScale, dBt = hScale * (Hu - Hd); } +void mtex_bump_deriv( vec3 texco, sampler2D ima, float ima_x, float ima_y, float hScale, + out float dBs, out float dBt ) +{ + float s = 1; // negate this if flipped texture coordinate + vec2 TexDx = dFdx(texco.xy); + vec2 TexDy = dFdy(texco.xy); + + // this variant using a derivative map is described here + // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html + vec2 dim = vec2(ima_x, ima_y); + vec2 dBduv = hScale*dim*(2*texture2D(ima, texco.xy).xy-1); + + dBs = dBduv.x*TexDx.x + s*dBduv.y*TexDx.y; + dBt = dBduv.x*TexDy.x + s*dBduv.y*TexDy.y; +} + void mtex_bump_apply( float fDet, float dBs, float dBt, vec3 vR1, vec3 vR2, vec3 vNacc_in, out vec3 vNacc_out, out vec3 perturbed_norm ) { diff --git a/source/blender/gpu/intern/gpu_shader_material.glsl.c b/source/blender/gpu/intern/gpu_shader_material.glsl.c index b60f7f1555e..8b23e2b205d 100644 --- a/source/blender/gpu/intern/gpu_shader_material.glsl.c +++ b/source/blender/gpu/intern/gpu_shader_material.glsl.c @@ -1,6 +1,6 @@ /* DataToC output of file */ -int datatoc_gpu_shader_material_glsl_size= 39207; +int datatoc_gpu_shader_material_glsl_size= 39783; char datatoc_gpu_shader_material_glsl[]= { 10,102,108,111, 97,116, 32, 101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111, 97,116, 32,102, 41, 10,123, 10, 9,114,101,116,117,114,110, 32,112, @@ -838,6 +838,24 @@ char datatoc_gpu_shader_material_glsl[]= { 119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,117, 41, 44, 32, 72,117, 32, 41, 59, 10, 9, 10, 9,100, 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,114, 32, 45, 32, 72,108, 41, 59, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,117, 32, 45, 32, 72,100, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116, +101,120, 95, 98,117,109,112, 95,100,101,114,105,118, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108, +101,114, 50, 68, 32,105,109, 97, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,120, 44, 32,102,108,111, 97,116, 32,105,109, 97, + 95,121, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, + 32,100, 66,116, 32, 41, 32, 10,123, 10, 9,102,108,111, 97,116, 32,115, 32, 61, 32, 49, 59, 9, 9, 47, 47, 32,110,101,103, 97, +116,101, 32,116,104,105,115, 32,105,102, 32,102,108,105,112,112,101,100, 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100, +105,110, 97,116,101, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120, +121, 41, 59, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, + 59, 10, 9, 10, 9, 47, 47, 32,116,104,105,115, 32,118, 97,114,105, 97,110,116, 32,117,115,105,110,103, 32, 97, 32,100,101,114, +105,118, 97,116,105,118,101, 32,109, 97,112, 32,105,115, 32,100,101,115, 99,114,105, 98,101,100, 32,104,101,114,101, 10, 9, 47, + 47, 32,104,116,116,112, 58, 47, 47,109,109,105,107,107,101,108,115,101,110, 51,100, 46, 98,108,111,103,115,112,111,116, 46, 99, +111,109, 47, 50, 48, 49, 49, 47, 48, 55, 47,100,101,114,105,118, 97,116,105,118,101, 45,109, 97,112,115, 46,104,116,109,108, 10, + 9,118,101, 99, 50, 32,100,105,109, 32, 61, 32,118,101, 99, 50, 40,105,109, 97, 95,120, 44, 32,105,109, 97, 95,121, 41, 59, 10, + 9,118,101, 99, 50, 32,100, 66,100,117,118, 32, 61, 32,104, 83, 99, 97,108,101, 42,100,105,109, 42, 40, 50, 42,116,101,120,116, +117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 46,120,121, 45, 49, 41, 59, 10, 9, 10, 9,100, + 66,115, 32, 61, 32,100, 66,100,117,118, 46,120, 42, 84,101,120, 68,120, 46,120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, + 42, 84,101,120, 68,120, 46,121, 59, 10, 9,100, 66,116, 32, 61, 32,100, 66,100,117,118, 46,120, 42, 84,101,120, 68,121, 46,120, + 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, 84,101,120, 68,121, 46,121, 59, 10,125, 10, 10,118,111,105,100, 32,109,116, 101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, 40, 32,102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,102,108,111, 97,116, 32,100, 66,116, 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, 51, 32, 118, 82, 50, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 10, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118, diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index e81a9979c12..6e850a07d94 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -342,6 +342,7 @@ typedef struct TexMapping { #define TEX_NORMALMAP 2048 #define TEX_GAUSS_MIP 4096 #define TEX_FILTER_MIN 8192 +#define TEX_DERIVATIVEMAP 16384 /* texfilter */ // TXF_BOX -> blender's old texture filtering method diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 9e3a31ddb2e..f459563f49e 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1147,6 +1147,12 @@ static void rna_def_texture_image(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_NORMALMAP); RNA_def_property_ui_text(prop, "Normal Map", "Uses image RGB values for normal mapping"); RNA_def_property_update(prop, 0, "rna_Texture_update"); + + /* Derivative Map */ + prop= RNA_def_property(srna, "use_derivative_map", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_DERIVATIVEMAP); + RNA_def_property_ui_text(prop, "Derivative Map", "Uses red and green as derivative values"); + RNA_def_property_update(prop, 0, "rna_Texture_update"); } static void rna_def_texture_plugin(BlenderRNA *brna) diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index ef1b1cd159c..a4c1778c624 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1905,11 +1905,13 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); float Hscale = Tnor*mtex->norfac; + int dimx=512, dimy=512; // 2 channels for 2D texture and 3 for 3D textures. const int nr_channels = (mtex->texco == TEXCO_UV)? 2 : 3; int c, rgbnor, iBumpSpace; float dHdx, dHdy; + int found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP); // disable internal bump eval in sampler, save pointer float *nvec = texres->nor; @@ -1929,8 +1931,31 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T ntap_bump->init_done = 1; } + + // resolve image dimensions + if(found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) { + ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + if (ibuf) { + dimx = ibuf->x; + dimy = ibuf->y; + } + } - if(!(mtex->texflag & MTEX_5TAP_BUMP)) { + if(found_deriv_map) { + float dBdu, dBdv; + float s = 1; // negate this if flipped texture coordinate + texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); + rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); + + // this variant using a derivative map is described here + // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html + dBdu = Hscale*dimx*(2*texres->tr-1); + dBdv = Hscale*dimy*(2*texres->tg-1); + + dHdx = dBdu*dxt[0] + s * dBdv*dxt[1]; + dHdy = dBdu*dyt[0] + s * dBdv*dyt[1]; + } + else if(!(mtex->texflag & MTEX_5TAP_BUMP)) { // compute height derivatives with respect to output image pixel coordinates x and y float STll[3], STlr[3], STul[3]; float Hll, Hlr, Hul; @@ -2084,15 +2109,8 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if(tex->ima) { - float vec[2]; - int dimx=512, dimy=512; - ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); - if (ibuf) { - dimx = ibuf->x; - dimy = ibuf->y; - } - // crazy hack solution that gives results similar to normal mapping - part 2 + float vec[2]; vec[0] = dimx*dxt[0]; vec[1] = dimy*dxt[1]; @@ -2126,7 +2144,7 @@ void do_material_tex(ShadeInput *shi) float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], warpvec[3]={0.0f, 0.0f, 0.0f}, Tnor=1.0; int tex_nr, rgbnor= 0, warpdone=0; int use_compat_bump = 0, use_ntap_bump = 0; - int found_nmapping = 0; + int found_nmapping = 0, found_deriv_map = 0; int iFirstTimeNMap=1; compatible_bump_init(&compat_bump); @@ -2146,8 +2164,9 @@ void do_material_tex(ShadeInput *shi) tex= mtex->tex; if(tex==0) continue; + found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP); use_compat_bump= (mtex->texflag & MTEX_COMPAT_BUMP); - use_ntap_bump= (mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)); + use_ntap_bump= ((mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP))!=0 || found_deriv_map!=0) ? 1 : 0; /* XXX texture node trees don't work for this yet */ if(tex->nodetree && tex->use_nodes) {