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

View File

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