From 2d21eb79ad48485bc7b3385d6df5c2c25fd88ee0 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 3 Oct 2018 10:20:16 +0200 Subject: Units: Support for fixed units Users can select the main unit they want to use now. Previously the displayed unit always depended on the magnitude of the value. The old behavior can be restored by switching to the "Adaptive" mode for length, mass and time units. Meters, kilograms and seconds are the default units for new and old scenes. The selected unit is also the default unit for user input. E.g. if cm is selected, whenever the user inputs a unitless number into a field of type length, it will be interpreted as cm. Reviewer: brecht Differential: https://developer.blender.org/D3740 --- source/blender/blenloader/intern/versioning_280.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index c32cfa433bd..7d059d6f996 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -85,6 +85,7 @@ #include "BKE_object.h" #include "BKE_cloth.h" #include "BKE_key.h" +#include "BKE_unit.h" #include "BLT_translation.h" @@ -2132,4 +2133,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { + UnitSettings *unit = &scene->unit; + if (unit->system != USER_UNIT_NONE) { + unit->length_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_LENGTH); + unit->mass_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_MASS); + } + unit->time_unit = bUnit_GetBaseUnitOfType(USER_UNIT_NONE, B_UNIT_TIME); + } + } } -- cgit v1.2.3