/** * Checks the soccer balls to see if they crossed the line and trigger the goal accordingly. */ void CheckGoal::update(float dt) { World *world = World::getWorld(); assert(world); Track* track = world->getTrack(); assert(track); TrackObjectManager* tom = track->getTrackObjectManager(); assert(tom); PtrVector<TrackObject>& objects = tom->getObjects(); unsigned int ball_index = 0; for(int i=0; i<objects.size(); i++) { TrackObject* obj = objects.get(i); if(!obj->isSoccerBall()) continue; const Vec3 &xyz = obj->getPresentation<TrackObjectPresentationMesh>()->getNode()->getPosition(); if(isTriggered(m_previous_position[ball_index], xyz, ball_index)) { if(UserConfigParams::m_check_debug) printf("CHECK: Goal check structure %d triggered for object %s.\n", m_index, obj->getPresentation<TrackObjectPresentationMesh>()->getNode()->getDebugName()); trigger(ball_index); } m_previous_position[ball_index] = xyz; ball_index++; } }
/** Updates all check structures. Called one per time step. * \param dt Time since last call. */ void CheckStructure::update(float dt) { World *world = World::getWorld(); for(unsigned int i=0; i<world->getNumKarts(); i++) { const Vec3 &xyz = world->getKart(i)->getXYZ(); // Only check active checklines. if(m_is_active[i] && isTriggered(m_previous_position[i], xyz, i)) { if(UserConfigParams::m_check_debug) printf("CHECK: Check structure %d triggered for kart %s.\n", m_index, world->getKart(i)->getIdent().c_str()); trigger(i); } m_previous_position[i] = xyz; } // for i<getNumKarts } // update
bool Event::isRipe() const { return ((isPersistent() || isTriggered()) && (delay == 0.0 || assignTime <= model.getTime())); }
SwipeDetector::Swipe SwipeDetector::detect(int left, int right) { return filter((char) (isTriggered(left) * 2 | isTriggered(right))); }