- Timestamp:
- Dec 13, 2008, 9:38:30 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc
r2408 r2427 230 230 if (this->isActive()) 231 231 { 232 // Check whether Bullet doesn't do the physics for us 233 if (!this->isDynamic()) 234 { 235 if (Core::isMaster()) 236 { 237 this->server_position_ = this->getPosition(); 238 this->server_orientation_ = this->getOrientation(); 239 this->server_linear_velocity_ = this->getVelocity(); 240 this->server_angular_velocity_ = this->getAngularVelocity(); 241 } 242 else if (this->bControlled_) 243 { 244 this->client_position_ = this->getPosition(); 245 this->client_orientation_ = this->getOrientation(); 246 this->client_linear_velocity_ = this->getVelocity(); 247 this->client_angular_velocity_ = this->getAngularVelocity(); 248 } 249 } 232 250 } 233 251 } … … 330 348 } 331 349 332 void ControllableEntity:: positionChanged(bool bContinuous)350 void ControllableEntity::setPosition(const Vector3& position) 333 351 { 334 352 if (Core::isMaster()) 335 353 { 354 MobileEntity::setPosition(position); 336 355 this->server_position_ = this->getPosition(); 337 if (!bContinuous) 338 ++this->server_overwrite_; 356 ++this->server_overwrite_; 339 357 } 340 358 else if (this->bControlled_) 341 359 { 360 MobileEntity::setPosition(position); 342 361 this->client_position_ = this->getPosition(); 343 362 } 344 363 } 345 364 346 void ControllableEntity:: orientationChanged(bool bContinuous)365 void ControllableEntity::setOrientation(const Quaternion& orientation) 347 366 { 348 367 if (Core::isMaster()) 349 368 { 369 MobileEntity::setOrientation(orientation); 350 370 this->server_orientation_ = this->getOrientation(); 351 if (!bContinuous) 352 ++this->server_overwrite_; 371 ++this->server_overwrite_; 353 372 } 354 373 else if (this->bControlled_) 355 374 { 375 MobileEntity::setOrientation(orientation); 356 376 this->client_orientation_ = this->getOrientation(); 357 377 } 358 378 } 359 379 360 void ControllableEntity:: linearVelocityChanged(bool bContinuous)380 void ControllableEntity::setVelocity(const Vector3& velocity) 361 381 { 362 382 if (Core::isMaster()) 363 383 { 384 MobileEntity::setVelocity(velocity); 364 385 this->server_linear_velocity_ = this->getVelocity(); 365 if (!bContinuous) 366 ++this->server_overwrite_; 386 ++this->server_overwrite_; 367 387 } 368 388 else if (this->bControlled_) 369 389 { 390 MobileEntity::setVelocity(velocity); 370 391 this->client_linear_velocity_ = this->getVelocity(); 371 392 } 372 393 } 373 394 374 void ControllableEntity:: angularVelocityChanged(bool bContinuous)395 void ControllableEntity::setAngularVelocity(const Vector3& velocity) 375 396 { 376 397 if (Core::isMaster()) 377 398 { 399 MobileEntity::setAngularVelocity(velocity); 378 400 this->server_angular_velocity_ = this->getAngularVelocity(); 379 if (!bContinuous) 380 ++this->server_overwrite_; 401 ++this->server_overwrite_; 381 402 } 382 403 else if (this->bControlled_) 383 404 { 405 MobileEntity::setAngularVelocity(velocity); 384 406 this->client_angular_velocity_ = this->getAngularVelocity(); 385 407 } 386 408 } 409 410 void ControllableEntity::setWorldTransform(const btTransform& worldTrans) 411 { 412 MobileEntity::setWorldTransform(worldTrans); 413 if (Core::isMaster()) 414 { 415 this->server_position_ = this->getPosition(); 416 this->server_orientation_ = this->getOrientation(); 417 this->server_linear_velocity_ = this->getVelocity(); 418 this->server_angular_velocity_ = this->getAngularVelocity(); 419 } 420 else if (this->bControlled_) 421 { 422 this->client_position_ = this->getPosition(); 423 this->client_orientation_ = this->getOrientation(); 424 this->client_linear_velocity_ = this->getVelocity(); 425 this->client_angular_velocity_ = this->getAngularVelocity(); 426 } 427 } 387 428 }
Note: See TracChangeset
for help on using the changeset viewer.