#1
|
|||
|
|||
Random RuntimeError
I don't know when but probably while removing an Avatar from the world I get a RuntimeError.
Code:
Traceback (most recent call last): File "C:\Program Files (x86)\WorldViz\Vizard4\python\viz.py", line 2581, in _RemoveObject obj.__class__._OnRemoveObject(obj) File "C:\Program Files (x86)\WorldViz\Vizard4\python\viz.py", line 5750, in _OnRemoveObject VizBone._RemoveAvatarBones(obj) File "C:\Program Files (x86)\WorldViz\Vizard4\python\viz.py", line 5968, in _RemoveAvatarBones bones = [ id for id in cls._VizObjectCache.iterkeys() if begin <= id < end ] RuntimeError: dictionary changed size during iteration Could this be the cause? and how could i solve it? |
#2
|
|||
|
|||
You could try preloading all models. For another project with a lot of avatars, I just preload one and clone() that one when I need a new one. That is instant.
Using the director is tricky... |
#3
|
|||
|
|||
I'm already preloading the avatars, but I still need to initialize the code around the avatar, this involves creating some additional helper object on the avatar together with some other time consuming code. In all it takes between 5 to 7 ms to construct an avatar making loading even 1 avatar per frame noticeable. Using the director method it take 70 ms but the framerate is influenced a lot less. I assumed the async methods of Vizard would work well with Vizard?
|
#4
|
|||
|
|||
Most Vizard commands are not thread safe, especially when it comes to adding/removing objects from different threads. The viz.director function mainly exists for backwards compatibility reasons, and is only intended to be used to perform non-Vizard related operations (e.g. file/socket IO).
Having said that, loading models in director threads can work. You just need to be very careful not to add/remove other models while the asynchronous operation is being performed. Additionally, the model should be added to a dummy scene when being loaded asynchronously, to avoid adding the model while the active scene is rendering. Vizard 5 will have built-in support to load models/avatars asynchronously, and all the threading issues will be handled automatically. |
#5
|
|||
|
|||
When i want to load the model in a different scene how can I set the scene of the object back to viz.MainScene? There doesn't seem to be a setScene function on Node3D objects.
|
#6
|
|||
|
|||
The node.setParent command can be used to reparent a node to another scene:
Code:
node.setParent(viz.WORLD, viz.MainScene) |
#7
|
|||
|
|||
When setting the parent do all the children of the node you re-parent also get transferred to the new scene?
And adding children to a node that is in a different scene do they get automatically relinked to that scene? |
#8
|
|||
|
|||
Yes, when you set the parent of the node, all children of that node will be moved to the new scene.
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
random coding | Saz | Vizard | 1 | 05-27-2010 05:44 PM |
random speed and associated coding | Saz | Vizard | 1 | 05-20-2010 04:03 AM |
custom avatar random walk | krimble | Vizard | 2 | 03-20-2007 03:23 AM |
Random head movements | VR_enthusiast | Vizard | 2 | 07-19-2006 11:59 AM |
Random Seeds | Vygreif | Vizard | 1 | 04-27-2006 09:21 PM |