[Bf-extensions-cvs] [682d9fb] temp-x3d_import-T44758: Cleanup: trailing space

Campbell Barton noreply at git.blender.org
Sat May 23 06:00:04 CEST 2015


Commit: 682d9fbb461690e4a66ac66454abfa5e0fab8b5b
Author: Campbell Barton
Date:   Thu May 21 09:40:37 2015 +1000
Branches: temp-x3d_import-T44758
https://developer.blender.org/rBA682d9fbb461690e4a66ac66454abfa5e0fab8b5b

Cleanup: trailing space

===================================================================

M	io_scene_x3d/import_x3d.py

===================================================================

diff --git a/io_scene_x3d/import_x3d.py b/io_scene_x3d/import_x3d.py
index 2c59855..7fbe381 100644
--- a/io_scene_x3d/import_x3d.py
+++ b/io_scene_x3d/import_x3d.py
@@ -342,7 +342,7 @@ class vrmlNode(object):
         self.parent = parent
         self.blendObject = None
         self.x3dNode = None  # for x3d import only
-        self.parsed = None  # We try to reuse objects in a smart way 
+        self.parsed = None  # We try to reuse objects in a smart way
         if parent:
             parent.children.append(self)
 
@@ -476,7 +476,7 @@ class vrmlNode(object):
         else:
             # Check inside a list of optional types
             return [child for child in self_real.children if child.getSpec() in node_spec]
-        
+
     def getChildrenBySpecCondition(self, cond):  # spec could be Transform, Shape, Appearance
         self_real = self.getRealNode()
         # using getSpec functions allows us to use the spec of USE children that dont have their spec in their ID
@@ -489,7 +489,7 @@ class vrmlNode(object):
             return ls[0]
         else:
             return None
-        
+
     def getChildBySpecCondition(self, cond):  # spec could be Transform, Shape, Appearance
         # Use in cases where there is only ever 1 child of this type
         ls = self.getChildrenBySpecCondition(cond)
@@ -1232,12 +1232,12 @@ class vrmlNode(object):
                         else:
                             self.fields.append(value)
                 i += 1
-                
+
     # This is a prerequisite for DEF/USE-based material caching
     def canHaveReferences(self):
         return self.node_type == NODE_NORMAL and self.getDefName()
-    
-    # This is a prerequisite for raw XML-based material caching. For now, only for X3D 
+
+    # This is a prerequisite for raw XML-based material caching. For now, only for X3D
     def desc(self):
         return None
 
@@ -1379,10 +1379,10 @@ class x3dNode(vrmlNode):
             return value.split()
         else:
             return None
-        
+
     def canHaveReferences(self):
         return self.x3dNode.getAttributeNode('DEF')
-    
+
     def desc(self):
         return self.getRealNode().x3dNode.toxml()
 
@@ -1577,7 +1577,7 @@ def importMesh_ApplyColors(bpymesh, geom, ancestry):
     colors = geom.getChildBySpec(['ColorRGBA', 'Color'])
     if colors:
         if colors.getSpec() == 'ColorRGBA': # Array of arrays; no need to flatten
-            rgb = [c[:3] for c in colors.getFieldAsArray('color', 4, ancestry)] 
+            rgb = [c[:3] for c in colors.getFieldAsArray('color', 4, ancestry)]
         else:
             rgb = colors.getFieldAsArray('color', 3, ancestry)
         tc = bpymesh.tessface_vertex_colors.new()
@@ -1605,11 +1605,11 @@ def importMesh_ApplyNormals(bpymesh, geom, ancestry):
 def importMesh_ReadVertices(bpymesh, geom, ancestry):
     # We want points here as a flat array, but the caching logic in IndexedFaceSet presumes a 2D one.
     # The case for caching is stronger over there.
-    
+
     points = geom.getChildBySpec('Coordinate').getFieldAsArray('point', 0, ancestry)
     bpymesh.vertices.add(len(points)//3)
-    bpymesh.vertices.foreach_set("co", points)    
-    
+    bpymesh.vertices.foreach_set("co", points)
+
 # Assumes the mesh only contains triangular tessfaces, and the order
 # of vertices matches the source.
 # Relies upon texture coordinates in the node; if a coordinate generation
@@ -1623,11 +1623,11 @@ def importMesh_ApplyTextureToTessfaces(bpymesh, geom, ancestry, bpyima):
             if coord_points:
                 d = bpymesh.tessface_uv_textures.new().data
                 for face in d: # No foreach_set for nonscalars
-                    face.image = bpyima 
+                    face.image = bpyima
                 d.foreach_set('uv', [i for face in bpymesh.tessfaces for vno in range(3) for i in coord_points[face.vertices[vno]]])
-                
+
 # Common steps for all triangle meshes once the geometry has been set: normals, vertex colors, and texture.
-def importMesh_FinalizeTriangleMesh(bpymesh, geom, ancestry, bpyima):        
+def importMesh_FinalizeTriangleMesh(bpymesh, geom, ancestry, bpyima):
     bpymesh.validate()
     importMesh_ApplyNormals(bpymesh, geom, ancestry)
     importMesh_ApplyColors(bpymesh, geom, ancestry)
@@ -1640,13 +1640,13 @@ def importMesh_FinalizeTriangleMesh(bpymesh, geom, ancestry, bpyima):
 # The loops array must be flat.
 def importMesh_ApplyTextureToLoops(bpymesh, bpyima, loops):
     for f in bpymesh.uv_textures.new().data:
-        f.image = bpyima   
+        f.image = bpyima
     bpymesh.uv_layers[0].data.foreach_set('uv', loops)
 
-        
+
 def flip(r, ccw):
-    return r if ccw else r[::-1]        
-        
+    return r if ccw else r[::-1]
+
 # -----------------------------------------------------------------------------------
 # Now specific geometry importers
 
@@ -1655,7 +1655,7 @@ def importMesh_IndexedTriangleSet(geom, ancestry, bpyima):
     # Ignoring solid
     # colorPerVertex is always true
     ccw = geom.getFieldAsBool('ccw', True, ancestry)
-    
+
     bpymesh = bpy.data.meshes.new(name="XXX")
     importMesh_ReadVertices(bpymesh, geom, ancestry)
 
@@ -1665,7 +1665,7 @@ def importMesh_IndexedTriangleSet(geom, ancestry, bpyima):
         index = [index[3*i+j] for i in range(n//3) for j in (1, 0, 2)]
     bpymesh.tessfaces.add(len(index)//3)
     bpymesh.tessfaces.foreach_set("vertices", index)
-    
+
     return importMesh_FinalizeTriangleMesh(bpymesh, geom, ancestry, bpyima)
 
 def importMesh_IndexedTriangleStripSet(geom, ancestry, bpyima):
@@ -1674,7 +1674,7 @@ def importMesh_IndexedTriangleStripSet(geom, ancestry, bpyima):
     cw = 0 if geom.getFieldAsBool('ccw', True, ancestry) else 1
     bpymesh = bpy.data.meshes.new(name="IndexedTriangleStripSet")
     importMesh_ReadVertices(bpymesh, geom, ancestry)
- 
+
     # Read the faces
     index = geom.getFieldAsArray('index', 0, ancestry)
     while index[-1] == -1:
@@ -1704,7 +1704,7 @@ def importMesh_IndexedTriangleFanSet(geom, ancestry, bpyima):
     cw = 0 if geom.getFieldAsBool('ccw', True, ancestry) else 1
     bpymesh = bpy.data.meshes.new(name="IndexedTriangleFanSet")
     importMesh_ReadVertices(bpymesh, geom, ancestry)
- 
+
     # Read the faces
     index = geom.getFieldAsArray('index', 0, ancestry)
     while index[-1] == -1:
@@ -1735,9 +1735,9 @@ def importMesh_TriangleSet(geom, ancestry, bpyima):
     importMesh_ReadVertices(bpymesh, geom, ancestry)
     n = len(bpymesh.vertices)
     bpymesh.tessfaces.add(n//3)
-    fv = [i for i in range(n)] if ccw else [3*i+j for i in range(n//3) for j in (1, 0, 2)] 
+    fv = [i for i in range(n)] if ccw else [3*i+j for i in range(n//3) for j in (1, 0, 2)]
     bpymesh.tessfaces.foreach_set("vertices", fv)
-     
+
     return importMesh_FinalizeTriangleMesh(bpymesh, geom, ancestry, bpyima)
 
 def importMesh_TriangleStripSet(geom, ancestry, bpyima):
@@ -1757,7 +1757,7 @@ def importMesh_TriangleStripSet(geom, ancestry, bpyima):
                 yield b + j + 2
             b += counts[i]
     bpymesh.tessfaces.foreach_set("vertices", [x for x in triangles()])
-     
+
     return importMesh_FinalizeTriangleMesh(bpymesh, geom, ancestry, bpyima)
 
 def importMesh_TriangleFanSet(geom, ancestry, bpyima):
@@ -1787,7 +1787,7 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
     # In Blender, to the best of my knowledge, there's no way to reuse the vertex set
     # between meshes. So we have culling logic instead - for each mesh, only use leave vertices
     # that are used for faces.
-    
+
     ccw = geom.getFieldAsBool('ccw', True, ancestry)
     coord = geom.getChildBySpec('Coordinate')
     if coord.reference:
@@ -1797,11 +1797,11 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
         if coord.canHaveReferences():
             coord.parsed = points
     index = geom.getFieldAsArray('coordIndex', 0, ancestry)
-    
+
     while index[-1] == -1:
         del index[-1]
-    
-    cull = None    
+
+    cull = None
     if len(points) >= 2*len(index): # Need to cull
         culled_points = []
         cull = {}  #  Maps old vertex indices to new ones
@@ -1809,7 +1809,7 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
         new_index = 0
     else:
         uncull = cull = None
-    
+
     faces = []
     face = []
     for i in index:
@@ -1828,16 +1828,16 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
                     i = cull[i]
             face.append(i)
     faces.append(flip(face, ccw))  # The last face
-    
+
     if cull:
         points = culled_points
-    
+
     bpymesh = bpy.data.meshes.new(name="IndexedFaceSet")
     bpymesh.from_pydata(points, [], faces)
     bpymesh.validate(False)
-    
+
     # Similar treatment for normal and color indices
-    
+
     def processPerVertexIndex(ind):
         if ind:  # Deflatten into an array of arrays by face; the latter might need to be flipped
             i = 0
@@ -1850,7 +1850,7 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
             return [[uncull[v] for v in f] for f in faces]
         else:
             return faces # Reuse coordIndex, as per the spec
-    
+
     # Normals
     normals = geom.getChildBySpec('Normal')
     if normals:
@@ -1861,12 +1861,12 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
             bpymesh.vertices.foreach_set("normal", [co for f in processPerVertexIndex(normal_index) for v in f for co in vectors[v]])
         else:
             bpymesh.polygons.foreach_set("normal", [co for (i, f) in enumerate(faces) for j in f for co in vectors[normal_index[i] if normal_index else i]])
-    
+
     # Apply vertex/face colors
     colors = geom.getChildBySpec(['ColorRGBA', 'Color'])
     if colors:
         if colors.getSpec() == 'ColorRGBA': # Array of arrays; no need to flatten
-            rgb = [c[:3] for c in colors.getFieldAsArray('color', 4, ancestry)] 
+            rgb = [c[:3] for c in colors.getFieldAsArray('color', 4, ancestry)]
         else:
             rgb = colors.getFieldAsArray('color', 3, ancestry)
 
@@ -1875,10 +1875,10 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
 
         d = bpymesh.v

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list