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:
authorLukas Tönne <lukas.toenne@gmail.com>2016-04-20 17:45:29 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2016-04-20 17:45:29 +0300
commitaae0598aa233d43d0ffc81a070b2ce20d6871c1d (patch)
tree378100f45cf1db972c671a6886496a5604f7ab29 /release/scripts/templates_py
parent95d7d3c2a6aa91f1dcb33ff0cdfc751e2886d8cd (diff)
parentd7e4f920fd93a4ae5679e0eb6b228a349ab3b082 (diff)
Merge branch 'master' into temp_depsgraph_split_ubereval
Diffstat (limited to 'release/scripts/templates_py')
-rw-r--r--release/scripts/templates_py/background_job.py22
-rw-r--r--release/scripts/templates_py/operator_file_export.py1
-rw-r--r--release/scripts/templates_py/operator_file_import.py1
-rw-r--r--release/scripts/templates_py/operator_mesh_add.py13
-rw-r--r--release/scripts/templates_py/operator_modal_view3d_raycast.py15
5 files changed, 28 insertions, 24 deletions
diff --git a/release/scripts/templates_py/background_job.py b/release/scripts/templates_py/background_job.py
index 11b51e5a9b5..2911740abf9 100644
--- a/release/scripts/templates_py/background_job.py
+++ b/release/scripts/templates_py/background_job.py
@@ -11,7 +11,7 @@
#
# Notice:
# '--factory-startup' is used to avoid the user default settings from
-# interfearing with automated scene generation.
+# interfering with automated scene generation.
#
# '--' causes blender to ignore all following arguments so python can use them.
#
@@ -51,18 +51,7 @@ def example_function(text, save_path, render_path):
lamp_ob.location = 2.0, 2.0, 5.0
if save_path:
- try:
- f = open(save_path, 'w')
- f.close()
- ok = True
- except:
- print("Cannot save to path %r" % save_path)
-
- import traceback
- traceback.print_exc()
-
- if ok:
- bpy.ops.wm.save_as_mainfile(filepath=save_path)
+ bpy.ops.wm.save_as_mainfile(filepath=save_path)
if render_path:
render = scene.render
@@ -85,9 +74,10 @@ def main():
argv = argv[argv.index("--") + 1:] # get all args after "--"
# When --help or no args are given, print this help
- usage_text = \
- "Run blender in background mode with this script:"
- " blender --background --python " + __file__ + " -- [options]"
+ usage_text = (
+ "Run blender in background mode with this script:"
+ " blender --background --python " + __file__ + " -- [options]"
+ )
parser = argparse.ArgumentParser(description=usage_text)
diff --git a/release/scripts/templates_py/operator_file_export.py b/release/scripts/templates_py/operator_file_export.py
index 9511cb163bc..38c88069845 100644
--- a/release/scripts/templates_py/operator_file_export.py
+++ b/release/scripts/templates_py/operator_file_export.py
@@ -28,6 +28,7 @@ class ExportSomeData(Operator, ExportHelper):
filter_glob = StringProperty(
default="*.txt",
options={'HIDDEN'},
+ maxlen=255, # Max internal buffer length, longer would be clamped.
)
# List of operator properties, the attributes will be assigned
diff --git a/release/scripts/templates_py/operator_file_import.py b/release/scripts/templates_py/operator_file_import.py
index 9940a1b98eb..0ec57544f3d 100644
--- a/release/scripts/templates_py/operator_file_import.py
+++ b/release/scripts/templates_py/operator_file_import.py
@@ -31,6 +31,7 @@ class ImportSomeData(Operator, ImportHelper):
filter_glob = StringProperty(
default="*.txt",
options={'HIDDEN'},
+ maxlen=255, # Max internal buffer length, longer would be clamped.
)
# List of operator properties, the attributes will be assigned
diff --git a/release/scripts/templates_py/operator_mesh_add.py b/release/scripts/templates_py/operator_mesh_add.py
index 5fabaaf3f7f..2590d53e49a 100644
--- a/release/scripts/templates_py/operator_mesh_add.py
+++ b/release/scripts/templates_py/operator_mesh_add.py
@@ -33,7 +33,12 @@ def add_box(width, height, depth):
return verts, faces
-from bpy.props import FloatProperty, BoolProperty, FloatVectorProperty
+from bpy.props import (
+ BoolProperty,
+ BoolVectorProperty,
+ FloatProperty,
+ FloatVectorProperty,
+ )
class AddBox(bpy.types.Operator):
@@ -60,6 +65,12 @@ class AddBox(bpy.types.Operator):
min=0.01, max=100.0,
default=1.0,
)
+ layers = BoolVectorProperty(
+ name="Layers",
+ description="Object Layers",
+ size=20,
+ options={'HIDDEN', 'SKIP_SAVE'},
+ )
# generic transform props
view_align = BoolProperty(
diff --git a/release/scripts/templates_py/operator_modal_view3d_raycast.py b/release/scripts/templates_py/operator_modal_view3d_raycast.py
index b72b2f76750..c4d661b4c1f 100644
--- a/release/scripts/templates_py/operator_modal_view3d_raycast.py
+++ b/release/scripts/templates_py/operator_modal_view3d_raycast.py
@@ -2,7 +2,7 @@ import bpy
from bpy_extras import view3d_utils
-def main(context, event, ray_max=1000.0):
+def main(context, event):
"""Run this function on left mouse, execute the ray cast"""
# get the context arguments
scene = context.scene
@@ -14,7 +14,7 @@ def main(context, event, ray_max=1000.0):
view_vector = view3d_utils.region_2d_to_vector_3d(region, rv3d, coord)
ray_origin = view3d_utils.region_2d_to_origin_3d(region, rv3d, coord)
- ray_target = ray_origin + (view_vector * ray_max)
+ ray_target = ray_origin + view_vector
def visible_objects_and_duplis():
"""Loop over (object, matrix) pairs (mesh only)"""
@@ -39,17 +39,18 @@ def main(context, event, ray_max=1000.0):
matrix_inv = matrix.inverted()
ray_origin_obj = matrix_inv * ray_origin
ray_target_obj = matrix_inv * ray_target
+ ray_direction_obj = ray_target_obj - ray_origin_obj
# cast the ray
- hit, normal, face_index = obj.ray_cast(ray_origin_obj, ray_target_obj)
+ success, location, normal, face_index = obj.ray_cast(ray_origin_obj, ray_direction_obj)
- if face_index != -1:
- return hit, normal, face_index
+ if success:
+ return location, normal, face_index
else:
return None, None, None
# cast rays and find the closest object
- best_length_squared = ray_max * ray_max
+ best_length_squared = -1.0
best_obj = None
for obj, matrix in visible_objects_and_duplis():
@@ -59,7 +60,7 @@ def main(context, event, ray_max=1000.0):
hit_world = matrix * hit
scene.cursor_location = hit_world
length_squared = (hit_world - ray_origin).length_squared
- if length_squared < best_length_squared:
+ if best_obj is None or length_squared < best_length_squared:
best_length_squared = length_squared
best_obj = obj