Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9688 in orxonox.OLD for branches/new_class_id/src


Ignore:
Timestamp:
Aug 22, 2006, 3:09:23 PM (18 years ago)
Author:
bensch
Message:

new_class_id: adapted the CREngine
@patrick: changed long classID to the new structure, where the Name and the new generic ID is stored.
Also i saw, that implementing CollisionHandle::targetList as a std::set would be much faster

Location:
branches/new_class_id/src/lib/collision_reaction
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/collision_reaction/collision.cc

    r9406 r9688  
    1818#include "collision.h"
    1919#include "debug.h"
    20 
    21 
    22 
    2320
    2421/**
  • branches/new_class_id/src/lib/collision_reaction/collision.h

    r8490 r9688  
    2121class Collision
    2222{
    23 
    2423  public:
    2524    Collision();
  • branches/new_class_id/src/lib/collision_reaction/collision_event.cc

    r9406 r9688  
    1818#include "collision_event.h"
    1919#include "debug.h"
    20 
    21 
    22 
    2320
    2421/**
  • branches/new_class_id/src/lib/collision_reaction/collision_event.h

    r8894 r9688  
    2020//! A class representing a simple collision
    2121class CollisionEvent {
    22 
    2322 public:
    2423   CollisionEvent();
  • branches/new_class_id/src/lib/collision_reaction/collision_handle.cc

    r9406 r9688  
    3030
    3131
    32 
     32NewObjectListDefinition(CollisionHandle);
    3333
    3434/**
     
    3838CollisionHandle::CollisionHandle (WorldEntity* owner, CREngine::CRType type)
    3939{
    40   this->setClassID(CL_COLLISION_HANDLE, "CollisionHandle");
     40  this->registerObject(this, CollisionHandle::_objectList);
    4141
    4242  this->owner = owner;
     
    9494 *  @param classID the classid to look for
    9595 */
    96 void CollisionHandle::addTarget(long target)
     96void CollisionHandle::addTarget(const NewClassID& target)
    9797{
    9898  // make sure there is no dublicate
    99   std::vector<long>::iterator it = this->targetList.begin();
     99  std::vector<NewClassID>::iterator it = this->targetList.begin();
    100100  for( ; it < this->targetList.end(); it++)
    101101    if( (*it) == target)
    102102      return;
    103103
     104
    104105  // add element
    105    PRINTF(5)("addTarget: %i \n", target);
    106 
    107    this->targetList.push_back(target);
     106  this->targetList.push_back(target);
     107   PRINTF(5)("addTarget: %i \n", target.id());
    108108}
    109109
     
    227227bool CollisionHandle::filterCollisionEvent(CollisionEvent* collisionEvent)
    228228{
    229   std::vector<long>::iterator it = this->targetList.begin();
     229  std::vector<NewClassID>::iterator it = this->targetList.begin();
    230230  for(; it < this->targetList.end(); it++)
    231231  {
     
    253253
    254254    if( collisionEvent->getEntityA() == this->owner) {
    255       if( collisionEvent->getEntityB()->isA((ClassID)(*it))) {
     255      if( collisionEvent->getEntityB()->isA((*it))) {
    256256        PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
    257                   collisionEvent->getEntityB()->getClassCName(), *it);
     257        collisionEvent->getEntityB()->getClassCName(), (*it).id());
    258258        return true; }
    259259    }
    260260    else {
    261       if( collisionEvent->getEntityA()->isA((ClassID)(*it))) {
     261      if( collisionEvent->getEntityA()->isA((*it))) {
    262262        PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
    263                   collisionEvent->getEntityA()->getClassCName(), *it);
     263        collisionEvent->getEntityA()->getClassCName(), (*it).id());
    264264      return true; }
    265265    }
     
    276276bool CollisionHandle::filterCollision(Collision* collision)
    277277{
    278   std::vector<long>::iterator it = this->targetList.begin();
     278  std::vector<NewClassID>::iterator it = this->targetList.begin();
    279279  for(; it < this->targetList.end(); it++)
    280280  {
     
    302302
    303303    if( collision->getEntityA() == this->owner) {
    304       if( collision->getEntityA()->isA((ClassID)(*it)))
     304      if( collision->getEntityA()->isA(*it))
    305305        return true; }
    306306      else {
    307         if( collision->getEntityB()->isA((ClassID)(*it)))
     307        if( collision->getEntityB()->isA(*it))
    308308          return true; }
    309309  }
  • branches/new_class_id/src/lib/collision_reaction/collision_handle.h

    r8490 r9688  
    2323class CollisionHandle : public BaseObject
    2424{
    25 
     25  NewObjectListDeclaration(CollisionHandle);
    2626  public:
    2727    CollisionHandle(WorldEntity* owner, CREngine::CRType type);
     
    3030    void reset();
    3131
    32     void addTarget(long target);
     32    void addTarget(const NewClassID& target);
    3333    Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB);
    3434    void registerSharedCollision(Collision* collision);
     
    6464
    6565    std::vector<Collision*>       collisionList;           //!< a list full of collisions
    66     std::vector<long>             targetList;              //!< a list of target classes for filtering
     66    std::vector<NewClassID>          targetList;              //!< a list of target classes for filtering @TODO TAKE SET INSTEAD OF VECTOR HERE
    6767
    6868    CollisionReaction*            collisionReaction;       //!< reference to the collision reaction object
  • branches/new_class_id/src/lib/collision_reaction/collision_reaction.cc

    r9406 r9688  
    2020
    2121
    22 
     22NewObjectListDefinition(CollisionReaction);
    2323
    2424/**
     
    2828  : BaseObject()
    2929{
    30   this->setClassID(CL_COLLISION_REACTION, "CollisionReaction");
     30  this->registerObject(this, CollisionReaction::_objectList);
    3131}
    3232
  • branches/new_class_id/src/lib/collision_reaction/collision_reaction.h

    r8490 r9688  
    1818class CollisionReaction : public BaseObject
    1919{
    20 
     20  NewObjectListDeclaration(CollisionReaction);
    2121  public:
    2222    CollisionReaction();
  • branches/new_class_id/src/lib/collision_reaction/cr_engine.cc

    r9406 r9688  
    2929
    3030
    31 
     31NewObjectListDefinition(CREngine);
    3232/**
    3333 * standard constructor
     
    3636  : BaseObject()
    3737{
    38    this->setClassID(CL_CR_ENGINE, "CREngine");
     38  this->registerObject(this, CREngine::_objectList);
    3939   this->setName("CREngine");
    4040
  • branches/new_class_id/src/lib/collision_reaction/cr_engine.h

    r9235 r9688  
    2525class CREngine : public BaseObject
    2626{
     27  NewObjectListDeclaration(CREngine);
    2728
    2829  public:
  • branches/new_class_id/src/lib/collision_reaction/cr_object_damage.cc

    r9406 r9688  
    2828
    2929
    30 
     30NewObjectListDefinition(CRObjectDamage);
    3131/**
    3232 *  standard constructor
     
    3535  : CollisionReaction()
    3636{
    37   this->setClassID(CL_CR_OBJECT_DAMAGE, "CRObjectDamage");
    38 
     37  this->registerObject(this, CRObjectDamage::_objectList);
    3938}
    4039
  • branches/new_class_id/src/lib/collision_reaction/cr_object_damage.h

    r8190 r9688  
    1515class CRObjectDamage : public CollisionReaction
    1616{
     17  NewObjectListDeclaration(CRObjectDamage);
    1718  public:
    1819    CRObjectDamage();
  • branches/new_class_id/src/lib/collision_reaction/cr_physics_full_walk.cc

    r9406 r9688  
    3535
    3636
    37 
     37NewObjectListDefinition(CRPhysicsFullWalk);
    3838/**
    3939 *  standard constructor
     
    4242    : CollisionReaction()
    4343{
    44   this->setClassID(CL_CR_PHYSICS_FULL_WALK, "CRPhysicsFullWalk");
     44  this->registerObject(this, CRPhysicsFullWalk::_objectList);
    4545}
    4646
  • branches/new_class_id/src/lib/collision_reaction/cr_physics_full_walk.h

    r9235 r9688  
    1515class CRPhysicsFullWalk : public CollisionReaction
    1616{
     17  NewObjectListDeclaration(CRPhysicsFullWalk);
    1718  public:
    1819    CRPhysicsFullWalk();
  • branches/new_class_id/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r9406 r9688  
    3535
    3636
    37 
     37NewObjectListDefinition(CRPhysicsGroundWalk);
    3838/**
    3939 *  standard constructor
     
    4242    : CollisionReaction()
    4343{
    44   this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk");
     44  this->registerObject(this, CRPhysicsGroundWalk::_objectList);
    4545}
    4646
  • branches/new_class_id/src/lib/collision_reaction/cr_physics_ground_walk.h

    r8894 r9688  
    1515class CRPhysicsGroundWalk : public CollisionReaction
    1616{
     17  NewObjectListDeclaration(CRPhysicsGroundWalk);
    1718  public:
    1819    CRPhysicsGroundWalk();
Note: See TracChangeset for help on using the changeset viewer.