Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-10-19 16:53:03 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-10-19 16:53:03 +0400
commita75f11d03678b094d608382c50d0bb299c53ed1c (patch)
treec7b30eb780bfe1203fd36419a9d58e8b4cba085b /release
parent3a41ab73ff4e480fe5b86c2845f0fb4f9df113d7 (diff)
Fix #32219: Inconsistent influence of Units Scale on new objects
Made it so meshes, curves, surfaces and metaballs are scaling to a grid cell size, which makes them behave consistently now. There're still issues to be resolved still: - Lattice is not scaled to grid cell size yet, it uses slightly different add function which makes scaling a bit tricky and hacky. Would prefer to do a bit bigger refactor here, so it's a TODO for now. - Cameras, speakers and other helpers are not scaling. They don't have data on which scale could be applied and perhaps it should be some kind of draw scale. Also would consider it's a TODO for now.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy_extras/object_utils.py13
-rw-r--r--release/scripts/startup/bl_operators/add_mesh_torus.py6
2 files changed, 17 insertions, 2 deletions
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index b1de1fd47a4..46731b807f7 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -187,3 +187,16 @@ class AddObjectHelper:
name="Rotation",
subtype='EULER',
)
+
+
+def object_add_grid_scale(context):
+ """
+ Return scale which should be applied on object data to align it to grid scale
+ """
+
+ space_data = context.space_data
+
+ if space_data and space_data.type == 'VIEW_3D':
+ return space_data.grid_scale_unit
+
+ return 1.0
diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py
index 7da4d8a480d..552247f0940 100644
--- a/release/scripts/startup/bl_operators/add_mesh_torus.py
+++ b/release/scripts/startup/bl_operators/add_mesh_torus.py
@@ -133,13 +133,15 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
)
def execute(self, context):
+ grid_scale = object_utils.object_add_grid_scale(context)
+
if self.use_abso is True:
extra_helper = (self.abso_major_rad - self.abso_minor_rad) * 0.5
self.major_radius = self.abso_minor_rad + extra_helper
self.minor_radius = extra_helper
- verts_loc, faces = add_torus(self.major_radius,
- self.minor_radius,
+ verts_loc, faces = add_torus(self.major_radius * grid_scale,
+ self.minor_radius * grid_scale,
self.major_segments,
self.minor_segments)