Skip to content

Commit

Permalink
fix picking for actor in actor trees
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlem committed Mar 31, 2022
1 parent 33e3d39 commit 590f9c1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
9 changes: 5 additions & 4 deletions QtQmlViewport/InFboRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,19 @@ def synchronize(self, viewport):
continue

if not hasattr(actor, 'bo_actor'):
actor.bo_actor = {}
actor.productDirty.connect(lambda actor=actor: setattr(actor, "bo_actor", {}))
actor.bo_actor = {"dirty":True}
actor.productDirty.connect(lambda a=actor: a.bo_actor.update({"dirty": True}))



if not actor.bo_actor: # actor was dirty or is new
if actor.bo_actor["dirty"]: # actor was dirty or is new

try:
indices = actor.geometry.indices
attribs = actor.geometry.attribs.get_attributes()

bo_actor = {"attribs": {}
bo_actor = {"dirty": False
, "attribs": {}
, "textures": {}
, "out_textures": {}
, "uniforms": copy.deepcopy(actor.effect.shader0.uniforms)
Expand Down
12 changes: 8 additions & 4 deletions QtQmlViewport/Product.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def RWProperty(classvars, typename, name, init_value, callback = None, before_wr
This function adds a QProperty named 'name' to a class's vars() dictionary.
It create the getter, setter, and signal named 'nameChanged'.
*Important* a member variable named '_name' will be expected by the getter and setter.
*Important* if not already present, a member variable named '_name'
will be added to the instance by the first call to the getter or setter.
A QProperty is exposed to QML.
'''
Expand All @@ -138,7 +139,8 @@ def ROProperty(classvars, typename, name, init_value):
It creates the getter, and signal named 'nameChanged'. It also creates
a set_name() setter outside of the Qt property system.
*Important* a member variable named '_name' will be expected by the getter.
*Important* if not already present, a member variable named '_name'
will be added to the instance by the first call to the getter.
A QProperty is exposed to QML.
'''
Expand All @@ -151,7 +153,8 @@ def ConstProperty(classvars, typename, name, init_value):
This function adds a QProperty named 'name' to a class's vars() dictionary.
It create the getter.
*Important* a member variable named '_name' will be expected by the getter.
*Important* if not already present, a member variable named '_name'
will be added to the instance by the first call to the getter.
A QProperty is exposed to QML.
'''
Expand All @@ -165,7 +168,8 @@ def InputProperty(classvars, typename, name, init_value, callback = None, before
This function adds a QProperty named 'name' to a class's vars() dictionary.
It create the getter, setter, and signal named 'nameChanged'.
*Important* a member variable named '_name' will be expected by the getter and setter.
*Important* if not already present, a member variable named '_name'
will be added to the instance by the first call to the getter or setter.
'callback()->None' will be called if
(and only if) a new value is set. see InputSetter for more information on 'callback'
Expand Down
5 changes: 4 additions & 1 deletion QtQmlViewport/Viewport.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ def pick(self, clicked_x, clicked_y, modifiers = None):

def to_local(self, world_origin, world_direction, actor):
# bring back the actor at the origin
m = actor.transform.worldTransform(True) if actor.transform else QMatrix4x4()
if not "transform" in actor.bo_actor:
actor.update()
print(actor.dirty)
m = actor.bo_actor["transform"]
m_inv = m.inverted()[0]

# bring the ray in the actor's referential
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def build_extension(self, ext):

kwargs = dict(
name='QtQmlViewport',
version='0.2.1',
version='0.2.2',
author='Maxime Lemonnier',
description='Python QtQml 3D viewer toolkit',
long_description='',
Expand Down

0 comments on commit 590f9c1

Please sign in to comment.