Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 24, 2007, 6:13:17 PM (17 years ago)
Author:
marcscha
Message:

SegFault prevention hack in fast factory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/projectiles/swarm_projectile.cc

    r10271 r10345  
    6262  //this->trail->setParent( this);
    6363  this->trail->setTexture( "maps/laser.png");
     64
     65
     66  this->origList = this->getOMListNumber();
     67  this->toList(OM_ENVIRON);
    6468}
    6569
     
    190194    this->deactivate();
    191195
    192 /*
    193   Vector targetFarFarAway = this->getAbsCoor() + Vector(100000, 0, 0);
    194 
    195   {
    196     speed = velocity.len();
    197     diffVector = ((targetFarFarAway - this->getAbsCoor()).getNormalized());
    198 
    199     if(velocity.dot(diffVector) != 0)
    200     {
    201       correctionVector = (( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;
    202 
    203       if( (diffVector *  (speed * speed/( velocity.dot(diffVector ) ) ) -velocity).len() < agility )
    204         velocity = ((diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )).getNormalized())*agility;
    205       else if(velocity.dot(diffVector) > 0)
    206         velocity += correctionVector;
    207       else if (velocity.dot(diffVector) < 0)
    208         velocity -= correctionVector;
    209     }
    210     else
    211       velocity += diffVector * agility;
    212 
    213     this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
    214   }
    215 
    216   velocity *= maxVelocity/velocity.len();
    217   Vector v = this->velocity * (time);
    218   this->shiftCoor(v);*/
    219196
    220197
     
    235212  this->shiftCoor(this->velocity * time);
    236213
    237 /*
    238 
    239   Vector pjV = this->getVelocity();
    240   Vector tV = this->target->getVelocity();
    241   Vector pT = this->target->getAbsCoor() - this->getAbsCoor(); // vector projectile target
    242 
    243   Vector a = tV.getNormalized() * pT.dot(tV.getNormalized());
    244 
    245   float A = 2 * pT.len() * pT.len();
    246   float B = 2 * a.len() * a.len();
    247   float D = 2 * sqrt(B * B - 4 * pT.len() * pT.len() *(tV.len() * tV.len() - pjV.len() * pjV.len()));
    248   float tti;
    249 
    250   if (A != 0){
    251     if ( B < D ) tti = ( B + D ) / A;
    252     else tti = ( B + D ) / A;
    253   }
    254   else tti = 0;
    255 
    256 
    257   Vector estTargetDir;
    258   if (tti == 0)
    259     estTargetDir = pT.getNormalized() * pjV.len();
    260   else
    261     estTargetDir = pT / tti + pjV;
    262 
    263   this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time );
    264 
    265   this->shiftCoor(this->velocity * (this->maxVelocity * time));*/
    266 
    267214  if(this->tickLifeCycle(time))
    268215    this->deactivate();
     
    276223  this->lastDir = this->curDir;
    277224  this->curDir = this->velocity;
    278   if( (this->getAbsCoor() - this->target->getAbsCoor()).len() < 3)   // FIXME  Temp fake workaround for collision :)
     225
     226  if( this->target != NULL && (this->getAbsCoor() - this->target->getAbsCoor()).len() < 3)   // FIXME  Temp fake workaround for collision :)
    279227  {
    280     dynamic_cast<WorldEntity*>(target)->destroy( this);
    281     this->destroy( this);
     228    dynamic_cast<WorldEntity*>(target)->hit(this->getDamage(), this);
     229    this->deactivate();
    282230  }
    283231}
Note: See TracChangeset for help on using the changeset viewer.