WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 03-04-2014, 11: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

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 08:53 PM.

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