[Bf-extensions-cvs] [0046ef06] master: POV: Improve Line endings and general formatting
Maurice Raybaud
noreply at git.blender.org
Sun Dec 22 00:30:36 CET 2019
Commit: 0046ef0652382b948d34fea8a33a94e92e6350db
Author: Maurice Raybaud
Date: Fri Dec 20 19:17:40 2019 +0100
Branches: master
https://developer.blender.org/rBA0046ef0652382b948d34fea8a33a94e92e6350db
POV: Improve Line endings and general formatting
used black on some files to dust up old formatting
===================================================================
M render_povray/__init__.py
M render_povray/primitives.py
M render_povray/render.py
M render_povray/shading.py
M render_povray/ui.py
M render_povray/update_files.py
===================================================================
diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index a8a5c951..8f67892e 100644
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -3704,6 +3704,7 @@ class RenderPovSettingsTexture(PropertyGroup):
('PARTICLES', "", "Show particles textures", "PARTICLES",3), # "Show particles textures"
('LINESTYLE', "", "Show linestyle textures", "LINE_DATA",4), # "Show linestyle textures"
('OTHER', "", "Show other data textures", "TEXTURE_DATA",5), # "Show other data textures"
+ ),
default = 'MATERIAL',
)
diff --git a/render_povray/primitives.py b/render_povray/primitives.py
index 4d109958..a9d68d44 100644
--- a/render_povray/primitives.py
+++ b/render_povray/primitives.py
@@ -18,7 +18,7 @@
# <pep8 compliant>
-############ To get POV-Ray specific objects In and Out of Blender ###########
+""" Get POV-Ray specific objects In and Out of Blender """
import bpy
import os.path
@@ -29,22 +29,20 @@ from math import atan, pi, degrees, sqrt, cos, sin
from bpy.props import (
- StringProperty,
- BoolProperty,
- IntProperty,
- FloatProperty,
- FloatVectorProperty,
- EnumProperty,
- PointerProperty,
- CollectionProperty,
- )
-
-from mathutils import (
- Vector,
- Matrix,
+ StringProperty,
+ BoolProperty,
+ IntProperty,
+ FloatProperty,
+ FloatVectorProperty,
+ EnumProperty,
+ PointerProperty,
+ CollectionProperty,
)
-#import collections
+from mathutils import Vector, Matrix
+
+# import collections
+
def pov_define_mesh(mesh, verts, edges, faces, name, hide_geometry=True):
"""Generate proxy mesh."""
@@ -52,7 +50,9 @@ def pov_define_mesh(mesh, verts, edges, faces, name, hide_geometry=True):
mesh = bpy.data.meshes.new(name)
mesh.from_pydata(verts, edges, faces)
mesh.update()
- mesh.validate(verbose = False) # Set it to True to see debug messages (helps ensure you generate valid geometry).
+ mesh.validate(
+ verbose=False
+ ) # Set it to True to see debug messages (helps ensure you generate valid geometry).
if hide_geometry:
mesh.vertices.foreach_set("hide", [True] * len(mesh.vertices))
mesh.edges.foreach_set("hide", [True] * len(mesh.edges))
@@ -62,26 +62,26 @@ def pov_define_mesh(mesh, verts, edges, faces, name, hide_geometry=True):
class POVRAY_OT_lathe_add(bpy.types.Operator):
"""Add the representation of POV lathe using a screw modifier."""
+
bl_idname = "pov.addlathe"
bl_label = "Lathe"
- bl_options = {'REGISTER','UNDO'}
+ bl_options = {'REGISTER', 'UNDO'}
bl_description = "adds lathe"
-
def execute(self, context):
- #ayers=[False]*20
- #layers[0]=True
+ # ayers=[False]*20
+ # layers[0]=True
bpy.ops.curve.primitive_bezier_curve_add(
location=context.scene.cursor.location,
rotation=(0, 0, 0),
- #layers=layers,
+ # layers=layers,
)
ob = context.view_layer.objects.active
ob_data = ob.data
ob.name = ob_data.name = "PovLathe"
ob_data.dimensions = '2D'
ob_data.transform(Matrix.Rotation(-pi / 2.0, 4, 'Z'))
- ob.pov.object_as='LATHE'
+ ob.pov.object_as = 'LATHE'
self.report({'INFO'}, "This native POV-Ray primitive")
ob.pov.curveshape = "lathe"
bpy.ops.object.modifier_add(type='SCREW')
@@ -91,7 +91,6 @@ class POVRAY_OT_lathe_add(bpy.types.Operator):
return {'FINISHED'}
-
def pov_superellipsoid_define(context, op, ob):
"""Create the proxy mesh of a POV superellipsoid using the pov_superellipsoid_define() function."""
@@ -103,11 +102,11 @@ def pov_superellipsoid_define(context, op, ob):
n1 = op.se_n1
n2 = op.se_n2
edit = op.se_edit
- se_param1 = n2 # op.se_param1
- se_param2 = n1 # op.se_param2
+ se_param1 = n2 # op.se_param1
+ se_param2 = n1 # op.se_param2
else:
- assert(ob)
+ assert ob
mesh = ob.data
u = ob.pov.se_u
@@ -119,83 +118,85 @@ def pov_superellipsoid_define(context, op, ob):
se_param2 = ob.pov.se_param2
verts = []
- r=1
+ r = 1
- stepSegment=360/v*pi/180
- stepRing=pi/u
- angSegment=0
- angRing=-pi/2
+ stepSegment = 360 / v * pi / 180
+ stepRing = pi / u
+ angSegment = 0
+ angRing = -pi / 2
- step=0
- for ring in range(0,u-1):
+ step = 0
+ for ring in range(0, u - 1):
angRing += stepRing
- for segment in range(0,v):
+ for segment in range(0, v):
step += 1
angSegment += stepSegment
- x = r*(abs(cos(angRing))**n1)*(abs(cos(angSegment))**n2)
- if (cos(angRing) < 0 and cos(angSegment) > 0) or \
- (cos(angRing) > 0 and cos(angSegment) < 0):
+ x = r * (abs(cos(angRing)) ** n1) * (abs(cos(angSegment)) ** n2)
+ if (cos(angRing) < 0 and cos(angSegment) > 0) or (
+ cos(angRing) > 0 and cos(angSegment) < 0
+ ):
x = -x
- y = r*(abs(cos(angRing))**n1)*(abs(sin(angSegment))**n2)
- if (cos(angRing) < 0 and sin(angSegment) > 0) or \
- (cos(angRing) > 0 and sin(angSegment) < 0):
+ y = r * (abs(cos(angRing)) ** n1) * (abs(sin(angSegment)) ** n2)
+ if (cos(angRing) < 0 and sin(angSegment) > 0) or (
+ cos(angRing) > 0 and sin(angSegment) < 0
+ ):
y = -y
- z = r*(abs(sin(angRing))**n1)
+ z = r * (abs(sin(angRing)) ** n1)
if sin(angRing) < 0:
z = -z
- x = round(x,4)
- y = round(y,4)
- z = round(z,4)
- verts.append((x,y,z))
+ x = round(x, 4)
+ y = round(y, 4)
+ z = round(z, 4)
+ verts.append((x, y, z))
if edit == 'TRIANGLES':
- verts.append((0,0,1))
- verts.append((0,0,-1))
+ verts.append((0, 0, 1))
+ verts.append((0, 0, -1))
faces = []
- for i in range(0,u-2):
- m=i*v
- for p in range(0,v):
- if p < v-1:
- face=(m+p,1+m+p,v+1+m+p,v+m+p)
- if p == v-1:
- face=(m+p,m,v+m,v+m+p)
+ for i in range(0, u - 2):
+ m = i * v
+ for p in range(0, v):
+ if p < v - 1:
+ face = (m + p, 1 + m + p, v + 1 + m + p, v + m + p)
+ if p == v - 1:
+ face = (m + p, m, v + m, v + m + p)
faces.append(face)
if edit == 'TRIANGLES':
- indexUp=len(verts)-2
- indexDown=len(verts)-1
- indexStartDown=len(verts)-2-v
- for i in range(0,v):
- if i < v-1:
- face=(indexDown,i,i+1)
+ indexUp = len(verts) - 2
+ indexDown = len(verts) - 1
+ indexStartDown = len(verts) - 2 - v
+ for i in range(0, v):
+ if i < v - 1:
+ face = (indexDown, i, i + 1)
faces.append(face)
- if i == v-1:
- face=(indexDown,i,0)
+ if i == v - 1:
+ face = (indexDown, i, 0)
faces.append(face)
- for i in range(0,v):
- if i < v-1:
- face=(indexUp,i+indexStartDown,i+indexStartDown+1)
+ for i in range(0, v):
+ if i < v - 1:
+ face = (indexUp, i + indexStartDown, i + indexStartDown + 1)
faces.append(face)
- if i == v-1:
- face=(indexUp,i+indexStartDown,indexStartDown)
+ if i == v - 1:
+ face = (indexUp, i + indexStartDown, indexStartDown)
faces.append(face)
if edit == 'NGONS':
- face=[]
- for i in range(0,v):
+ face = []
+ for i in range(0, v):
face.append(i)
faces.append(face)
- face=[]
- indexUp=len(verts)-1
- for i in range(0,v):
- face.append(indexUp-i)
+ face = []
+ indexUp = len(verts) - 1
+ for i in range(0, v):
+ face.append(indexUp - i)
faces.append(face)
mesh = pov_define_mesh(mesh, verts, [], faces, "SuperEllipsoid")
if not ob:
ob = object_utils.object_data_add(context, mesh, operator=None)
- #engine = context.scene.render.engine what for?
+ # engine = context.scene.render.engine what for?
ob = context.object
- ob.name = ob.data.name = "PovSuperellipsoid"
+ ob.name = ob.data.name = "PovSuperellipsoid"
ob.pov.object_as = 'SUPERELLIPSOID'
ob.pov.se_param1 = n2
ob.pov.se_param2 = n1
@@ -210,8 +211,10 @@ def pov_superellipsoid_define(context, op, ob):
bpy.ops.mesh.hide(unselected=False)
bpy.ops.object.mode_set(mode="OBJECT")
+
class POVRAY_OT_superellipsoid_add(bpy.types.Operator):
"""Add the representation of POV superellipsoid using the pov_superellipsoid_define() function."""
+
bl_idname = "pov.addsuperellipsoid"
bl_label = "Add SuperEllipsoid"
bl_description = "Create a SuperEllipsoid"
@@ -221,46 +224,68 @@ class POVRAY_OT_superellipsoid_add(bpy.types.Operator):
# XXX Keep it in sync with __init__'s RenderPovSettingsConePrimitive
# If someone knows how to define operators' props from a func, I'd be delighted to learn it!
se_param1: FloatProperty(
- name="Parameter 1",
- description="",
- min=0.00, max=10.0, default=0.04)
+ name="Parameter 1", description="", min=0.00, max=10.0, default=0.04
+ )
se_param2: FloatProperty(
- name="Parameter 2",
- description="",
- min=0.00, max=10.0, default=0.04)
-
- se_u: IntProperty(name = "U-segments",
- description = "radial segmentation",
- default = 20, min = 4, max = 265)
- se_v: IntProperty(name = "V-segments",
- description = "lateral segmentation",
- default = 20, min = 4, max = 265)
- se_n1: Floa
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list