- Timestamp:
- May 19, 2011, 4:16:55 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.cc
r8506 r8513 84 84 float distance = this->computeDistance(currentPawn); 85 85 if(distance <= this->maxDistance_) 86 { 87 pawnsIn_.push_back(currentPawn); 88 } 89 } else if (this->reaction_ == 2) { 90 float distance = this->computeDistance(currentPawn); 91 if(distance >= this->maxDistance_) 86 92 { 87 93 pawnsIn_.push_back(currentPawn); … … 122 128 if(billy != NULL) 123 129 { 124 billy->setMaterial(" Shield");130 billy->setMaterial("Grid"); 125 131 billy->setVisible(true); 126 132 } … … 216 222 } 217 223 } 218 if( humanItem &&(this->maxDistance_ - distance) < this->showDistance_ )224 if(/* humanItem &&*/ abs(this->maxDistance_ - distance) < this->showDistance_ ) 219 225 { 220 226 this->displayBoundaries(currentPawn); // Zeige Grenze an! … … 233 239 this->conditionalBounceBack(currentPawn, distance, dt); 234 240 } 241 if( this->reaction_ == 2 && (distance - 100 < this->maxDistance_) ) 242 { 243 this->conditionalBounceBack(currentPawn, distance, dt); 244 } 235 245 } 236 246 } … … 273 283 /* Checke, ob das Pawn innerhalb des nächsten Ticks, das erlaubte Gebiet verlassen würde. 274 284 Falls ja: Spicke es zurück. */ 275 if( currentDistance + normalSpeed * dt > this->maxDistance_ - 20 ) // -20: "security measure" 276 { 277 float dampingFactor = 0.5; 278 velocity = velocity.reflect(normal); 279 Vector3 acceleration = item->getAcceleration(); 280 acceleration = acceleration.reflect(normal); 281 282 item->lookAt( velocity + this->getPosition() ); 283 284 item->setAcceleration(acceleration * dampingFactor); 285 item->setVelocity(velocity * dampingFactor); 286 287 item->setPosition( item->getPosition() - normal * 10 ); 288 } 285 if( this->reaction_ == 0 && currentDistance + normalSpeed * dt > this->maxDistance_ - 10 ) // -10: "security measure" 286 { 287 bounceBack(item, &normal, &velocity); 288 } else if (this->reaction_ == 2 && currentDistance - normalSpeed * dt < this->maxDistance_ + 10 ) // 10: "security measure" 289 { 290 normal = normal * (-1); 291 bounceBack(item, &normal, &velocity); 292 } 293 } 294 295 void SpaceBoundaries::bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity) 296 { 297 float dampingFactor = 0.5; 298 *velocity = velocity->reflect(*normal); 299 Vector3 acceleration = item->getAcceleration(); 300 acceleration = acceleration.reflect(*normal); 301 302 item->lookAt( *velocity + this->getPosition() ); 303 304 item->setAcceleration(acceleration * dampingFactor); 305 item->setVelocity(*velocity * dampingFactor); 306 307 item->setPosition( item->getPosition() - *normal * 10 ); // Setze das SpaceShip noch etwas von der Grenze weg. 289 308 } 290 309
Note: See TracChangeset
for help on using the changeset viewer.