Better input node.

This commit is contained in:
Roz K 2022-12-31 22:08:06 +01:00
parent dd786ef2b4
commit 7c2d3d81ae
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
2 changed files with 14 additions and 22 deletions

View File

@ -162,16 +162,14 @@ def create_scene(keyboard, mouse):
FuncNode(update_camera, (mouse, camera, environment)), FuncNode(update_camera, (mouse, camera, environment)),
TextureNode({0: tiles_texture}, TextureNode({0: tiles_texture},
ShaderNode(tiles_shader, ShaderNode(tiles_shader,
InputNode(tiles_shader, camera), InputNode(tiles_shader, camera, environment),
InputNode(tiles_shader, environment),
DrawNode(tiles_batch) DrawNode(tiles_batch)
) )
), ),
FuncNode(update_tests, (blob, cube, clouds)), FuncNode(update_tests, (blob, cube, clouds)),
TextureNode({0: tests_texture}, TextureNode({0: tests_texture},
ShaderNode(tests_shader, ShaderNode(tests_shader,
InputNode(tests_shader, camera), InputNode(tests_shader, camera, environment),
InputNode(tests_shader, environment),
DrawNode(tests_batch) DrawNode(tests_batch)
) )
) )
@ -179,9 +177,7 @@ def create_scene(keyboard, mouse):
FuncNode(update_sea, (camera, sea_phase)), FuncNode(update_sea, (camera, sea_phase)),
TextureNode({0: sea_polar_textures, 1: sea_detail_texture}, TextureNode({0: sea_polar_textures, 1: sea_detail_texture},
ShaderNode(sea_shader, ShaderNode(sea_shader,
InputNode(sea_shader, camera), InputNode(sea_shader, camera, environment, sea_phase),
InputNode(sea_shader, environment),
InputNode(sea_shader, sea_phase),
DrawNode(sea_triangles) DrawNode(sea_triangles)
) )
) )

View File

@ -53,37 +53,33 @@ class ShaderNode(Node):
Node.draw(self, time) Node.draw(self, time)
self._shader.unselect() self._shader.unselect()
class InputNode(Node): class InputNode:
__slots__ = '_shader', '_input' __slots__ = '_shader', '_inputs'
def __init__(self, shader, input, *subnodes): def __init__(self, shader, *inputs):
Node.__init__(self, *subnodes)
self._shader = shader self._shader = shader
self._input = input self._inputs = inputs
def draw(self, time): def draw(self, time):
self._input.set_inputs(self._shader) shader = self._shader
Node.draw(self, time) for input in self._inputs:
input.set_inputs(shader)
class DrawNode(Node): class DrawNode:
__slots__ = '_drawable' __slots__ = '_drawable'
def __init__(self, drawable, *subnodes): def __init__(self, drawable):
Node.__init__(self, *subnodes)
self._drawable = drawable self._drawable = drawable
def draw(self, time): def draw(self, time):
self._drawable.draw() self._drawable.draw()
Node.draw(self, time)
class FuncNode(Node): class FuncNode:
__slots__ = '_func', '_params' __slots__ = '_func', '_params'
def __init__(self, func, params, *subnodes): def __init__(self, func, params):
Node.__init__(self, *subnodes)
self._func = func self._func = func
self._params = params self._params = params
def draw(self, time): def draw(self, time):
self._func(time, *self._params) self._func(time, *self._params)
Node.draw(self, time)