1.1 --- a/examples/PyGmy/ppygmy_reuse.py Sun Sep 16 16:54:17 2007 +0000
1.2 +++ b/examples/PyGmy/ppygmy_reuse.py Sun Sep 16 17:58:48 2007 +0000
1.3 @@ -322,49 +322,39 @@
1.4 self.imageplane=5.0
1.5 self.aspect=self.width/float(self.height)
1.6
1.7 - def render_row(self, channel, sy):
1.8 + def render_row(self, sy):
1.9
1.10 """
1.11 - Render the given row, using the 'channel' provided to communicate
1.12 - result data back to the coordinating process. The row position 'sy',
1.13 - provided for the first row, will subsequently be read from the
1.14 - 'channel' for the rendering of new rows. A tuple containing 'sy' and a
1.15 - list of result numbers is returned by this function via the given
1.16 - 'channel'.
1.17 + Render the given row, using 'sy' as the row position, and returning a
1.18 + tuple containing 'sy' and a list of result numbers.
1.19 """
1.20
1.21 - while 1:
1.22 -
1.23 - row = []
1.24 - for sx in range(0,self.width):
1.25 - x=2*(0.5-sx/float(self.width))*self.aspect
1.26 - y=2*(0.5-sy/float(self.height))
1.27 - if self.cameratype=="ortho":
1.28 - ray = line(vec(x,y,0),vec(x,y,self.backplane))
1.29 - else:
1.30 - ray = line(vec(0,0,0),vec(x,y,self.imageplane))
1.31 - ray.end=ray.end*self.backplane
1.32 -
1.33 - col=vec(0,0,0)
1.34 - depth=self.backplane
1.35 - shaderinfo={"ray":ray,"lights":self.lights,"objects":self.objects,"depth":2}
1.36 + row = []
1.37 + for sx in range(0,self.width):
1.38 + x=2*(0.5-sx/float(self.width))*self.aspect
1.39 + y=2*(0.5-sy/float(self.height))
1.40 + if self.cameratype=="ortho":
1.41 + ray = line(vec(x,y,0),vec(x,y,self.backplane))
1.42 + else:
1.43 + ray = line(vec(0,0,0),vec(x,y,self.imageplane))
1.44 + ray.end=ray.end*self.backplane
1.45
1.46 - for obj in self.objects:
1.47 - intersects,position,normal = obj.intersect(ray)
1.48 - if intersects is not "none":
1.49 - if position.z<depth and position.z>0:
1.50 - depth=position.z
1.51 - shaderinfo["thisobj"]=obj
1.52 - shaderinfo["position"]=position
1.53 - shaderinfo["normal"]=normal
1.54 - col=obj.shader.shade(shaderinfo)
1.55 - row.append(col)
1.56 + col=vec(0,0,0)
1.57 + depth=self.backplane
1.58 + shaderinfo={"ray":ray,"lights":self.lights,"objects":self.objects,"depth":2}
1.59
1.60 - channel.send((sy, row))
1.61 - t = channel.receive()
1.62 - if t is None:
1.63 - break
1.64 - (sy,), kw = t
1.65 + for obj in self.objects:
1.66 + intersects,position,normal = obj.intersect(ray)
1.67 + if intersects is not "none":
1.68 + if position.z<depth and position.z>0:
1.69 + depth=position.z
1.70 + shaderinfo["thisobj"]=obj
1.71 + shaderinfo["position"]=position
1.72 + shaderinfo["normal"]=normal
1.73 + col=obj.shader.shade(shaderinfo)
1.74 + row.append(col)
1.75 +
1.76 + return sy, row
1.77
1.78 def render(self, filename, limit):
1.79
1.80 @@ -375,7 +365,7 @@
1.81
1.82 image = Image.new("RGB", (self.width, self.height))
1.83 exchange = PyGmyExchange(self.width, self.height, image, limit=limit, reuse=1)
1.84 - render_row = exchange.manage(self.render_row)
1.85 + render_row = exchange.manage(pprocess.MakeReusable(self.render_row))
1.86
1.87 for y in range(0, self.height):
1.88 render_row(y)