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:
authorChris Want <cwant@ualberta.ca>2006-05-11 21:42:58 +0400
committerChris Want <cwant@ualberta.ca>2006-05-11 21:42:58 +0400
commitd3dd1da8d429ea72ad42afe4b34692c345ef8c78 (patch)
tree22ef7865718b132061e1324669c0e65b6108efd5 /release/scripts
parentcfbbd8a54e5a8f1446c1644dc5469ba52f3b67ba (diff)
The algorithm to export vertex color was very inefficient (for every
vertex it would potentially loop through every face). This fix speeds it up a bit (only loops through all faces once, at the cost of some additional memory). An example of export times for a mesh with 6266 verts and 12528 faces: Before: 2m56s After: 8s
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/vrml97_export.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/release/scripts/vrml97_export.py b/release/scripts/vrml97_export.py
index fbb22a243ab..e7b1267b092 100644
--- a/release/scripts/vrml97_export.py
+++ b/release/scripts/vrml97_export.py
@@ -591,13 +591,19 @@ class VRML2Export:
self.writeIndented("color Color {\n",1)
self.writeIndented("color [\n\t\t\t\t\t\t", 1)
- for i in range(len(mesh.verts)):
- c=self.getVertexColorByIndx(mesh,i)
- if self.verbose > 2:
- print "Debug: vertex[%d].col r=%d g=%d b=%d" % (i, c.r, c.g, c.b)
+ cols = [None] * len(mesh.verts)
- aColor = self.rgbToFS(c)
+ for face in mesh.faces:
+ for vind in range(len(face.v)):
+ vertex = face.v[vind]
+ i = vertex.index
+ if cols[i] == None:
+ cols[i] = face.col[vind]
+
+ for i in range(len(mesh.verts)):
+ aColor = self.rgbToFS(cols[i])
self.file.write("%s, " % aColor)
+
self.writeIndented("\n", 0)
self.writeIndented("]\n",-1)
self.writeIndented("}\n",-1)
@@ -870,15 +876,6 @@ class VRML2Export:
print "Debug: face.image=%s" % face.image.name
print "Debug: face.materialIndex=%d" % face.materialIndex
- def getVertexColorByIndx(self, mesh, indx):
- for face in mesh.faces:
- j=0
- for vertex in face.v:
- if vertex.index == indx:
- c=face.col[j]
- j=j+1
- return c
-
def meshToString(self,mesh):
print "Debug: mesh.hasVertexUV=%d" % mesh.hasVertexUV()
print "Debug: mesh.hasFaceUV=%d" % mesh.hasFaceUV()