protected boolean maybeAddPerceivedObject(PerceptionMessage.ObjectNote objectNote) { ObjectType objType = (ObjectType) objectNote.getObjectType(); long perceivedOid = objectNote.getSubject(); long perceiverOid = objectNote.getTarget(); if (perceivedOid == perceiverOid) return true; boolean callbackNixedIt = false; if (remoteObjectFilter != null) callbackNixedIt = !remoteObjectFilter.objectShouldBeTracked(perceivedOid, objectNote); if (callbackNixedIt || !(objType.isMob())) { // if (Log.loggingDebug) // Log.debug("ProximityTracker.maybeAddPerceivedObject: ignoring oid=" + // perceivedOid // + " objType=" + objType // + " detected by " + perceiverOid // + ", instanceOid=" + instanceOid); return false; } if (Log.loggingDebug) Log.debug( "ProximityTracker.maybeAddPerceivedObject: oid=" + perceivedOid + " objType=" + objType + " detected by " + perceiverOid + ", instanceOid=" + instanceOid); lock.lock(); try { PerceiverData perceiverData = perceiverDataMap.get(perceiverOid); if (perceiverData == null) { Log.error( "ProximityTracker.maybeAddPerceivedObject: got perception msg with perceived obj oid=" + perceivedOid + " for unknown perceiver=" + perceiverOid); return false; } perceiverData.perceivedOids.add(perceivedOid); PerceiverData perceivedData = perceiverDataMap.get(perceivedOid); if (perceivedData != null) testProximity(perceiverData, perceivedData, true, false); } finally { lock.unlock(); } return true; }
public void handlePerception(PerceptionMessage perceptionMessage) { long targetOid = perceptionMessage.getTarget(); List<PerceptionMessage.ObjectNote> gain = perceptionMessage.getGainObjects(); List<PerceptionMessage.ObjectNote> lost = perceptionMessage.getLostObjects(); if (Log.loggingDebug) Log.debug( "ProximityTracker.handlePerception: targetOid + " + targetOid + ", instanceOid=" + instanceOid + " " + ((gain == null) ? 0 : gain.size()) + " gain and " + ((lost == null) ? 0 : lost.size()) + " lost"); if (gain != null) for (PerceptionMessage.ObjectNote note : gain) maybeAddPerceivedObject(note); if (lost != null) for (PerceptionMessage.ObjectNote note : lost) maybeRemovePerceivedObject(note.getSubject(), note, targetOid); }