WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 03-04-2014, 10:08 AM
fordprefect fordprefect is offline
Join Date: Oct 2012
Location: Vienna, Austria, Europe
Posts: 39
Exclamation Bug in vizproximity.Manager.removeSensor

When moving our code from using hotspots to vizproximity I seem to have discovered a bug in this module (both already available in Vizard4). The method vizproximity.Manager.getActiveSensors() can return sensors which have already been deleted through vizproximity.Manager.removeSensor(). Which, when you have the need to add and remove frequently, leads to accumulation of (not available) sensors in the active list of a target.

I took the liberty to check the module and found this: the update routine adds a set of sensors that are currently triggered to each target and stores this in the self._target dictionary:
	def update(self):
		"""Update state of proximity sensors and trigger enter/exit events if needed"""

		# Don't bother checking if no targets or sensors
		if not (self._targets and self._sensors):

		# Set of active sensors for debugging purposes
		activeSensors = None
		if self._debugRoot is not None:
			activeSensors = set()

		# Check if each target is in range of each sensor
		events = []
		for t,active in self._targets.iteritems():			pos = t.getPosition()
			for s in self._sensors.iterkeys():
				isInside = s.containsPoint(pos)
				if isInside and activeSensors is not None:
				wasInside = s in active
				if wasInside != isInside:
					if isInside:
						events.append( (ENTER_PROXIMITY_EVENT, ProximityEvent(s,t,self)) )
						events.append( (EXIT_PROXIMITY_EVENT, ProximityEvent(s,t,self)) )
Unfortunately, when a sensor is deleted, this set of active sensors at each target is not updated. The code highlighted does correct the problem (get in touch about my fee, please )
	def removeSensor(self,sensor):
		"""Remove a proximity sensor from the manager"""
			data = self._sensors[sensor]
		except KeyError:

		# Remove debug node of sensor
		if data.debug:

		# Remove sensor from target's active list (C) Siemens AG
		for active in self._targets.itervalues():

		# Remove sensor from dictionary
		del self._sensors[sensor]
Hope this helps to make the Vizard5 release even better!
21 is only half the truth.
Reply With Quote
Old 03-18-2014, 11:50 PM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,471
Thanks for taking the time to report this bug and also find a fix!
Reply With Quote
Old 11-07-2014, 01:04 AM
mape2k mape2k is offline
Join Date: Mar 2013
Posts: 60
Could you please include this fix in a future release of both 4 and 5? I have multiple machines on which I run Vizard and I don't want to fix this error on all of them...

Reply With Quote
Old 11-10-2014, 12:48 AM
fordprefect fordprefect is offline
Join Date: Oct 2012
Location: Vienna, Austria, Europe
Posts: 39
As far as I have checked, the patch is included in the final release of Vizard5.
If Vizard4 will receive another patch - I don't think so. But that's up to WorldViz, of course.

Best Regards, Walter
21 is only half the truth.
Reply With Quote

bug, vizproximity

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 07:15 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2023, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC