Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 30, 2008, 11:58:31 PM (16 years ago)
Author:
landauf
Message:

fixed a bug in the event system
fixed a bug in Trigger and tweaked some features

Location:
code/branches/objecthierarchy/src/orxonox/objects/worldentities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/BlinkingBillboard.cc

    r2065 r2069  
    7575    void BlinkingBillboard::tick(float dt)
    7676    {
    77         if (Core::isMaster())
     77        if (Core::isMaster() && this->isActive())
    7878        {
    7979            this->time_ += dt;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    r2029 r2069  
    5454
    5555    XMLPortParam(DistanceTrigger, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(100.0f);
    56     XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode);
     56    XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode).defaultValues("ControllableEntity");
    5757  }
    5858
     
    8181  {
    8282    Identifier* targetId = ClassByString(targets);
    83     targetMask_.include(targetId);
     83    if (!targetId)
     84        return;
     85
     86    this->targetMask_.include(targetId);
     87
    8488    // trigger shouldn't react on itself or other triggers
    85     targetMask_.exclude(Class(Trigger), true);
     89    this->targetMask_.exclude(Class(Trigger), true);
    8690
     91    // we only want WorldEntities
     92    ClassTreeMask WEMask;
     93    WEMask.include(Class(WorldEntity));
     94    this->targetMask_ *= WEMask;
    8795  }
    8896
     
    9098  {
    9199    Identifier* targetId = ClassByString(targets);
    92     targetMask_.exclude(targetId);
     100    this->targetMask_.exclude(targetId);
    93101  }
    94102
    95103  bool DistanceTrigger::checkDistance()
    96104  {
    97     // Iterate through all WorldEntities
    98     for (Iterator<WorldEntity> it = ObjectList<WorldEntity>::begin(); it; ++it)
     105    // Iterate through all objects
     106    for (ClassTreeMaskObjectIterator it = this->targetMask_.begin(); it != this->targetMask_.end(); ++it)
    99107    {
    100       // check if WorldEntity is a target
    101       if (targetMask_.isIncluded(it->getIdentifier()))
    102       {
    103         Vector3 distanceVec = it->getNode()->getWorldPosition() - this->getNode()->getWorldPosition();
    104         if (distanceVec.length() < this->distance_)
    105           return true;
    106       }
     108      WorldEntity* entity = dynamic_cast<WorldEntity*>(*it);
     109      if (!entity)
     110        continue;
     111
     112      Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
     113      if (distanceVec.length() < this->distance_)
     114        return true;
    107115    }
    108116    return false;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r2065 r2069  
    5050    this->mode_ = TM_EventTriggerAND;
    5151
     52    this->bFirstTick_ = true;
    5253    this->bActive_ = false;
    5354    this->bTriggered_ = false;
     
    9293  void Trigger::tick(float dt)
    9394  {
    94 
    95     bool newTriggered = this->isTriggered();
     95    if (this->bFirstTick_)
     96    {
     97      this->bFirstTick_ = false;
     98      this->fireEvent(false);
     99    }
     100
     101    bool newTriggered = this->isTriggered() ^ this->bInvertMode_;
    96102
    97103    // check if new triggering event is really new
     
    173179//      this->bUpdating_ = false;
    174180
    175       if (this->bInvertMode_)
    176         return !returnval;
    177       else
    178         return returnval;
     181      return returnval;
    179182    }
    180183    return true;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.h

    r2029 r2069  
    3535#include "OrxonoxPrereqs.h"
    3636
     37#include "objects/Tickable.h"
    3738#include "objects/worldentities/PositionableEntity.h"
    3839#include "tools/BillboardSet.h"
     
    4748  };
    4849
    49   class _OrxonoxExport Trigger : public PositionableEntity
     50  class _OrxonoxExport Trigger : public PositionableEntity, public Tickable
    5051  {
    5152    public:
     
    111112      bool bActive_;
    112113      bool bTriggered_;
     114      bool bFirstTick_;
    113115
    114116      TriggerMode mode_;
Note: See TracChangeset for help on using the changeset viewer.