Exemplo n.º 1
0
  void RayDistanceSensor::
  sensorUpdate (Body const & body)
  {
    // deciding which bodies to ignore could be smarter...
    //
    if ((&body == &body_) || (parent_ && (&body == &parent_->body_))) {
      return;
    }
    
    for (size_t il(0); il < body.getLines().size(); ++il) {
      Line const & ll (body.getLines()[il]);
      double const dd (LineRayIntersect (ll.X0(), ll.Y0(), ll.X1(), ll.Y1(),
					 global_.X(), global_.Y(),
					 global_.Costheta(), global_.Sintheta()));
      if ((dd > 0) && (dd < distance_)) {
	distance_ = dd;
      }
    }
  }