Changeset 2407
- Timestamp:
- Dec 11, 2008, 1:54:35 PM (16 years ago)
- Location:
- code/branches/physics/src/orxonox/objects
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/collisionshapes/CompoundCollisionShape.cc
r2403 r2407 72 72 } 73 73 74 void CompoundCollisionShape::addChildShape(CollisionShape* shape )74 void CompoundCollisionShape::addChildShape(CollisionShape* shape, bool bWorldEntityRoot) 75 75 { 76 76 if (!shape) … … 97 97 98 98 // network synchro 99 shape->setParent(this, this->getObjectID()); 99 if (!bWorldEntityRoot) 100 shape->setParent(this, this->getObjectID()); 100 101 } 101 102 -
code/branches/physics/src/orxonox/objects/collisionshapes/CompoundCollisionShape.h
r2403 r2407 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 46 47 void addChildShape(CollisionShape* shape );47 void addChildShape(CollisionShape* shape, bool bWorldEntityRoot = false); 48 48 CollisionShape* getChildShape(unsigned int index) const; 49 49 -
code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc
r2374 r2407 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Reto Grieder 26 26 * 27 27 */ … … 256 256 { 257 257 if (!this->bControlled_) 258 {259 //COUT(0) << "override with server position: " << this << std::endl;260 258 this->setPosition(this->server_position_); 261 }262 259 } 263 260 … … 282 279 void ControllableEntity::processOverwrite() 283 280 { 284 //if (this->bControlled_)285 //{286 // COUT(0) << "complete override: " << this << std::endl;287 // this->setPosition(this->server_position_);288 // this->setVelocity(this->server_velocity_);289 // this->setOrientation(this->server_orientation_);290 291 //this->client_overwrite_ = this->server_overwrite_;292 //}281 if (this->bControlled_) 282 { 283 this->setPosition(this->server_position_); 284 this->setOrientation(this->server_orientation_); 285 this->setVelocity(this->server_linear_velocity_); 286 this->setAngularVelocity(this->server_angular_velocity_); 287 288 this->client_overwrite_ = this->server_overwrite_; 289 } 293 290 } 294 291 295 292 void ControllableEntity::processClientPosition() 296 293 { 297 //if (this->server_overwrite_ == this->client_overwrite_) 298 if (!this->bControlled_) 299 { 300 //COUT(0) << "override with client position: " << this << std::endl; 301 // COUT(2) << "callback: setting client position" << endl; 294 if (this->server_overwrite_ == this->client_overwrite_) 295 { 302 296 this->setPosition(this->client_position_); 303 //this->server_position_ = this->client_position_; 304 } 305 //else 306 // COUT(2) << "callback: not setting client position" << endl; 297 // The call above increments the overwrite. This is not desired to reduce traffic 298 --this->server_overwrite_; 299 } 307 300 } 308 301 309 302 void ControllableEntity::processClientLinearVelocity() 310 303 { 311 if (!this->bControlled_) 312 //if (this->server_overwrite_ == this->client_overwrite_) 304 if (this->server_overwrite_ == this->client_overwrite_) 313 305 { 314 306 this->setVelocity(this->client_linear_velocity_); 315 //this->server_velocity_ = this->client_velocity_; 307 // The call above increments the overwrite. This is not desired to reduce traffic 308 --this->server_overwrite_; 316 309 } 317 310 } … … 319 312 void ControllableEntity::processClientOrientation() 320 313 { 321 if (!this->bControlled_) 322 //if (this->server_overwrite_ == this->client_overwrite_) 314 if (this->server_overwrite_ == this->client_overwrite_) 323 315 { 324 316 this->setOrientation(this->client_orientation_); 325 //this->server_orientation_ = this->client_orientation_; 317 // The call above increments the overwrite. This is not desired to reduce traffic 318 --this->server_overwrite_; 326 319 } 327 320 } … … 329 322 void ControllableEntity::processClientAngularVelocity() 330 323 { 331 if (!this->bControlled_) 332 //if (this->server_overwrite_ == this->client_overwrite_) 324 if (this->server_overwrite_ == this->client_overwrite_) 333 325 { 334 326 this->setAngularVelocity(this->client_angular_velocity_); 335 //this->server_velocity_ = this->client_velocity_; 327 // The call above increments the overwrite. This is not desired to reduce traffic 328 --this->server_overwrite_; 336 329 } 337 330 } … … 342 335 { 343 336 this->server_position_ = this->getPosition(); 344 ++this->server_overwrite_; 337 if (!bContinuous) 338 ++this->server_overwrite_; 345 339 } 346 340 else if (this->bControlled_) … … 355 349 { 356 350 this->server_orientation_ = this->getOrientation(); 357 ++this->server_overwrite_; 351 if (!bContinuous) 352 ++this->server_overwrite_; 358 353 } 359 354 else if (this->bControlled_) … … 368 363 { 369 364 this->server_linear_velocity_ = this->getVelocity(); 370 ++this->server_overwrite_; 365 if (!bContinuous) 366 ++this->server_overwrite_; 371 367 } 372 368 else if (this->bControlled_) … … 381 377 { 382 378 this->server_angular_velocity_ = this->getAngularVelocity(); 383 ++this->server_overwrite_; 379 if (!bContinuous) 380 ++this->server_overwrite_; 384 381 } 385 382 else if (this->bControlled_) -
code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h
r2374 r2407 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Reto Grieder 26 26 * 27 27 */ -
code/branches/physics/src/orxonox/objects/worldentities/LinearEntity.cc
r2374 r2407 80 80 void LinearEntity::overwritePosition() 81 81 { 82 //COUT(0) << "Setting position on client: " << this->overwrite_position_ << std::endl;83 82 this->setPosition(this->overwrite_position_); 84 83 } … … 86 85 void LinearEntity::overwriteOrientation() 87 86 { 88 //COUT(0) << "Setting orientation on client: " << this->overwrite_orientation_ << std::endl;89 87 this->setOrientation(this->overwrite_orientation_); 90 88 } … … 109 107 { 110 108 if (!bContinuous) 111 {112 //if (Core::isMaster())113 // COUT(0) << "Setting position on server: " << this->getPosition() << std::endl;114 109 this->overwrite_position_ = this->getPosition(); 115 }116 110 } 117 111 … … 119 113 { 120 114 if (!bContinuous) 121 {122 //if (Core::isMaster())123 // COUT(0) << "Setting orientation on server: " << this->getOrientation() << std::endl;124 115 this->overwrite_orientation_ = this->getOrientation(); 125 }126 116 } 127 117 } -
code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.cc
r2374 r2407 108 108 if (this->isDynamic()) 109 109 { 110 //if (this->isPhysicsRunning())111 // return;112 110 btTransform transf = this->physicalBody_->getWorldTransform(); 113 111 transf.setOrigin(btVector3(position.x, position.y, position.z)); … … 115 113 } 116 114 117 //COUT(0) << "setting position: " << position << std::endl;118 115 this->node_->setPosition(position); 119 116 positionChanged(false); … … 212 209 OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \ 213 210 to any other space than TS_LOCAL."); 214 //btTransform transf = this->physicalBody_->getWorldTransform();215 //this->physicalBody_->setWorldTransform(transf);216 211 } 217 212 … … 227 222 OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \ 228 223 to any other space than TS_LOCAL."); 229 //btTransform transf = this->physicalBody_->getWorldTransform();230 //this->physicalBody_->setWorldTransform(transf);231 224 } 232 225 … … 288 281 this->node_->setPosition(Vector3(worldTrans.getOrigin().x(), worldTrans.getOrigin().y(), worldTrans.getOrigin().z())); 289 282 this->node_->setOrientation(Quaternion(worldTrans.getRotation().w(), worldTrans.getRotation().x(), worldTrans.getRotation().y(), worldTrans.getRotation().z())); 290 COUT(0) << "setting world transform: " << omni_cast<std::string>(node_->getPosition()) << std::endl;291 283 this->linearVelocity_.x = this->physicalBody_->getLinearVelocity().x(); 292 284 this->linearVelocity_.y = this->physicalBody_->getLinearVelocity().y(); -
code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h
r2374 r2407 108 108 109 109 private: 110 virtual void positionChanged (bool bContinuous) { }111 virtual void orientationChanged (bool bContinuous) { }110 virtual void positionChanged (bool bContinuous) = 0; 111 virtual void orientationChanged (bool bContinuous) = 0; 112 112 virtual void linearVelocityChanged (bool bContinuous) { } 113 113 virtual void angularVelocityChanged(bool bContinuous) { } -
code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc
r2374 r2407 44 44 45 45 #include "objects/Scene.h" 46 #include "objects/ worldentities/collisionshapes/CollisionShape.h"47 #include "objects/ worldentities/collisionshapes/CompoundCollisionShape.h"46 #include "objects/collisionshapes/CollisionShape.h" 47 #include "objects/collisionshapes/CompoundCollisionShape.h" 48 48 49 49 namespace orxonox … … 191 191 // static to static/kinematic/dynamic --> merge shapes 192 192 this->childMass_ += object->getMass(); 193 this->attachCollisionShape(object->getCollisionShape() );193 this->attachCollisionShape(object->getCollisionShape(), true); 194 194 // Remove the btRigidBody from the child object. 195 195 // That also implies that cannot add a physics WE to the child afterwards. … … 237 237 } 238 238 239 void WorldEntity::attachCollisionShape(CollisionShape* shape )240 { 241 this->collisionShape_->addChildShape(shape );239 void WorldEntity::attachCollisionShape(CollisionShape* shape, bool bWorldEntityRoot) 240 { 241 this->collisionShape_->addChildShape(shape, bWorldEntityRoot); 242 242 243 243 if (this->physicalBody_) -
code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h
r2374 r2407 202 202 { return this->mass_; } 203 203 204 void attachCollisionShape(CollisionShape* shape );204 void attachCollisionShape(CollisionShape* shape, bool bWorldEntityRoot = false); 205 205 CollisionShape* getAttachedCollisionShape(unsigned int index) const; 206 206
Note: See TracChangeset
for help on using the changeset viewer.