kivy3 icon indicating copy to clipboard operation
kivy3 copied to clipboard

One step delay in calls

Open KeyWeeUsr opened this issue 8 years ago • 0 comments

There's seriously big delay in updating the 3D content's properties. With this little example you can try it too. Left button for moving left, right for moving right.

How to reproduce:

  • move left
  • move right
  • move left
  • cube doesn't move on first flick, then moves left, then right

like there's everything cached for the next update or something. Any ideas how to resolve this issue?

from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.clock import Clock
from kivy.uix.button import Button
from kivy3 import Renderer, Scene
from kivy3 import PerspectiveCamera
from kivy3.extras.geometries import BoxGeometry
from kivy3 import Material, Mesh


class Test(App):
    def _adjust_aspect(self, *args):
        rsize = self.renderer.size
        aspect = rsize[0] / float(rsize[1])
        self.renderer.camera.aspect = aspect

    def moveright(self, *a):
        self.cube.pos.x += .1

    def moveleft(self, *a):
        self.cube.pos.x -= .1

    def build(self):
        layout = FloatLayout()
        self.renderer = Renderer()
        scene = Scene()
        cube_geo = BoxGeometry(1, 1, 1)
        cube_mat = Material()
        self.cube = Mesh(geometry=cube_geo, material=cube_mat)
        self.cube.pos.z = -5
        self.camera = PerspectiveCamera(
            fov=75, aspect=0, near=1, far=10)
        scene.add(self.cube)
        self.renderer.render(scene, self.camera)
        self.renderer.bind(size=self._adjust_aspect)

        layout.add_widget(self.renderer)

        but = Button(size_hint=(0.1, 0.1))
        but.bind(on_release=self.moveleft)
        layout.add_widget(but)

        but = Button(size_hint=(0.1, 0.1), pos=(500,0))
        but.bind(on_release=self.moveright)
        layout.add_widget(but)

        return layout
Test().run()

Same stuff happens for Camera and for other properties such as rotation, matrices, etc.

Edit: Seems like AliasProperty getters return old values.

Edit2: I think it's not related to the properties, but rather to rendering itself, because when I update the Translate directly with self._translate.x += value, it does nothing until another call is made doesn't matter if it updates position, rotation or something else. For example examples/camera/main.py after excluding this line:

Clock.schedule_interval(self._rotate_obj, 1 / 20)

behaves identical to my example. This was seems as a workaround creating an object somewhere far away from the camera with Clock.schedule_interval to do something with the instructions to get immediate results of manipulation with other objects' properties. It's not nice though, so at least some pointers to what is broken would be nice 😄

KeyWeeUsr avatar Dec 10 '16 18:12 KeyWeeUsr