void BtBody::applyImpulse( const Point3F &origin, const Point3F &force ) { AssertFatal( mActor, "BtBody::applyImpulse - The actor is null!" ); AssertFatal( isDynamic(), "BtBody::applyImpulse - This call is only for dynamics!" ); // Convert the world position to local MatrixF trans = btCast<MatrixF>( mActor->getCenterOfMassTransform() ); trans.inverse(); Point3F localOrigin( origin ); trans.mulP( localOrigin ); if ( mCenterOfMass ) { Point3F relOrigin( localOrigin ); mCenterOfMass->mulP( relOrigin ); Point3F relForce( force ); mCenterOfMass->mulV( relForce ); mActor->applyImpulse( btCast<btVector3>( relForce ), btCast<btVector3>( relOrigin ) ); } else mActor->applyImpulse( btCast<btVector3>( force ), btCast<btVector3>( localOrigin ) ); if ( !mActor->isActive() ) mActor->activate(); }
Point3F PxBody::getAngVelocity() const { AssertFatal( mActor, "PxBody::getAngVelocity - The actor is null!" ); AssertFatal( isDynamic(), "PxBody::getAngVelocity - This call is only for dynamics!" ); return pxCast<Point3F>( mActor->getAngularVelocity() ); }
void PxBody::setAngVelocity( const Point3F &vel ) { AssertFatal( mActor, "PxBody::setAngVelocity - The actor is null!" ); AssertFatal( isDynamic(), "PxBody::setAngVelocity - This call is only for dynamics!" ); mActor->setAngularVelocity( pxCast<NxVec3>( vel ) ); }
void PxBody::setMaterial( F32 restitution, F32 friction, F32 staticFriction ) { AssertFatal( mActor, "PxBody::setMaterial - The actor is null!" ); // If the body is dynamic then wake it up as // it may need to change behavior. if ( isDynamic() ) mActor->wakeUp(); NxMaterialDesc desc; desc.restitution = restitution; desc.dynamicFriction = friction; desc.staticFriction = staticFriction; // If we have a material then just update it as the shapes // should already have them mapped. if ( mMaterial ) { mMaterial->loadFromDesc( desc ); return; } // If we got here then create a new material and // assign it to all our shapes. mMaterial = mWorld->createMaterial( desc ); U32 matIndex = mMaterial->getMaterialIndex(); U32 count = mActor->getNbShapes(); NxShape*const* shapes = mActor->getShapes(); for ( U32 i=0; i < count; i++ ) shapes[i]->setMaterial( matIndex ); }
void Px3Body::setTransform( const MatrixF &transform ) { AssertFatal( mActor, "Px3Body::setTransform - The actor is null!" ); // This sucks, but it has to happen if we want // to avoid write lock errors from PhysX right now. mWorld->releaseWriteLock(); mActor->setGlobalPose(px3Cast<physx::PxTransform>(transform),false); if(mIsStatic) return; physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>(); bool kinematic = actor->getRigidDynamicFlags() & physx::PxRigidDynamicFlag::eKINEMATIC; // If its dynamic we have more to do. if ( isDynamic() && !kinematic ) { actor->setLinearVelocity( physx::PxVec3(0) ); actor->setAngularVelocity( physx::PxVec3(0) ); actor->wakeUp(); } }
BooleanType PIDcontroller::isStatic( ) const { if ( isDynamic() == BT_TRUE ) return BT_FALSE; else return BT_TRUE; }
void PxBody::setSimulationEnabled( bool enabled ) { if ( mIsEnabled == enabled ) return; // This sucks, but it has to happen if we want // to avoid write lock errors from PhysX right now. mWorld->releaseWriteLock(); if ( enabled ) { mIsEnabled = true; mActor->clearActorFlag( NX_AF_DISABLE_RESPONSE ); mActor->clearActorFlag( NX_AF_DISABLE_COLLISION ); // Don't clear the flag if its supposed to be kinematic. if ( !(mBodyFlags & BF_KINEMATIC) ) mActor->clearBodyFlag( NX_BF_KINEMATIC ); if ( isDynamic() ) mActor->wakeUp(); } else { mIsEnabled = false; mActor->raiseActorFlag( NX_AF_DISABLE_RESPONSE ); mActor->raiseActorFlag( NX_AF_DISABLE_COLLISION ); mActor->raiseBodyFlag( NX_BF_KINEMATIC ); } NxShape *const* shapes = mActor->getShapes(); for ( S32 i = 0; i < mActor->getNbShapes(); i++ ) shapes[i]->setFlag( NX_SF_DISABLE_RAYCASTING, !mIsEnabled ); }
ofVec3f PhysicsObject::getVelocity() const { if (isDynamic()) { return trajectory->getInstantaneousVelocity(); } else { return ofVec3f(0, 0, 0); } }
const ofVec3f& PhysicsObject::getPosition() const { if (isDynamic()) { return trajectory->getPosition(); } else { return staticPosition; } }
bool Body::createBody() { if( body ) return true; btCollisionShape* bulletShape = getBulletShape(); if( !bulletShape ) return false; motionState = new BodyMotionState( entity->getTransform() ); btVector3 localInertia; localInertia.setZero(); if( isDynamic() ) bulletShape->calculateLocalInertia(mass, localInertia); btRigidBody::btRigidBodyConstructionInfo info( mass, motionState, bulletShape, localInertia); body = AllocateThis(btRigidBody, info); updateProperties(); addWorld(); return true; }
void VariantProperty::setValue(const QVariant &value) { Internal::WriteLocker locker(model()); if (!isValid()) throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); if (isDynamic()) qWarning() << "Calling VariantProperty::setValue on dynamic property."; if (value.isNull()) throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, name()); if (internalNode()->hasProperty(name())) { //check if oldValue != value Internal::InternalProperty::Pointer internalProperty = internalNode()->property(name()); if (internalProperty->isVariantProperty() && internalProperty->toVariantProperty()->value() == value && dynamicTypeName().isEmpty()) return; } if (internalNode()->hasProperty(name()) && !internalNode()->property(name())->isVariantProperty()) model()->d->removeProperty(internalNode()->property(name())); model()->d->setVariantProperty(internalNode(), name(), value); }
void BtBody::setLinVelocity( const Point3F &vel ) { AssertFatal( mActor, "BtBody::setLinVelocity - The actor is null!" ); AssertFatal( isDynamic(), "BtBody::setLinVelocity - This call is only for dynamics!" ); mActor->setLinearVelocity( btCast<btVector3>( vel ) ); }
Point3F BtBody::getLinVelocity() const { AssertFatal( mActor, "BtBody::getLinVelocity - The actor is null!" ); AssertFatal( isDynamic(), "BtBody::getLinVelocity - This call is only for dynamics!" ); return btCast<Point3F>( mActor->getLinearVelocity() ); }
BooleanType FeedforwardLaw::isStatic( ) const { if ( isDynamic() == BT_TRUE ) return BT_FALSE; else return BT_TRUE; }
float PhysicsObject::getRotation() const { if (isDynamic()) { return trajectory->getRotation(); } else { return staticRotation; } }
void BindingProperty::setExpression(const QString &expression) { Internal::WriteLocker locker(model()); if (!isValid()) throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); if (isDynamic()) qWarning() << "Calling BindingProperty::setExpression on dynamic property."; if (name() == "id") { // the ID for a node is independent of the state, so it has to be set with ModelNode::setId throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, name()); } if (expression.isEmpty()) throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, name()); if (internalNode()->hasProperty(name())) { //check if oldValue != value Internal::InternalProperty::Pointer internalProperty = internalNode()->property(name()); if (internalProperty->isBindingProperty() && internalProperty->toBindingProperty()->expression() == expression) return; } if (internalNode()->hasProperty(name()) && !internalNode()->property(name())->isBindingProperty()) model()->d->removeProperty(internalNode()->property(name())); model()->d->setBindingProperty(internalNode(), name(), expression); }
void PhysicsObject::setPosition(const ofVec3f& newPosition) { if (isDynamic()) { trajectory->setPosition(newPosition); } else { staticPosition = newPosition; } updateBoundingBox(); }
void SelectionData::refreshMassesAndCharges(const t_topology *top) { if (top != NULL && isDynamic() && !hasFlag(efSelection_DynamicMask)) { computeMassesAndCharges(top, rawPositions_, &posMass_, &posCharge_); } }
void SymbolTable::print(){ char tmpstr[__MAX_STRING_SIZE]; PRINT_INFOR("SymbolTable : %d aka sect %d with %d symbols",index,getSectionIndex(),symbols.size()); PRINT_INFOR("\tdyn? : %s", isDynamic() ? "yes" : "no"); for (uint32_t i = 0; i < symbols.size(); i++){ symbols[i]->print(); } }
void Px3Body::setAngVelocity( const Point3F &vel ) { AssertFatal( mActor, "Px3Body::setAngVelocity - The actor is null!" ); AssertFatal( isDynamic(), "Px3Body::setAngVelocity - This call is only for dynamics!" ); physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>(); actor->setAngularVelocity(px3Cast<physx::PxVec3>( vel ) ); }
Point3F Px3Body::getAngVelocity() const { AssertFatal( mActor, "Px3Body::getAngVelocity - The actor is null!" ); AssertFatal( isDynamic(), "Px3Body::getAngVelocity - This call is only for dynamics!" ); physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>(); return px3Cast<Point3F>( actor->getAngularVelocity() ); }
void Px3Body::applyForce( const Point3F &force ) { AssertFatal(mActor, "Px3Body::applyTorque - The actor is null!"); mWorld->releaseWriteLock(); physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>(); if (mIsEnabled && isDynamic()) actor->addForce( px3Cast<physx::PxVec3>(force), physx::PxForceMode::eFORCE, true); }
void Selection::printInfo(FILE *fp) const { fprintf(fp, "\"%s\" (%d position%s, %d atom%s%s)", name(), posCount(), posCount() == 1 ? "" : "s", atomCount(), atomCount() == 1 ? "" : "s", isDynamic() ? ", dynamic" : ""); fprintf(fp, "\n"); }
void PxBody::setSleeping( bool sleeping ) { AssertFatal( mActor, "PxBody::setSleeping - The actor is null!" ); AssertFatal( isDynamic(), "PxBody::setSleeping - This call is only for dynamics!" ); if ( sleeping ) mActor->putToSleep(); else mActor->wakeUp(); }
void Px3Body::applyCorrection( const MatrixF &transform ) { AssertFatal( mActor, "Px3Body::applyCorrection - The actor is null!" ); AssertFatal( isDynamic(), "Px3Body::applyCorrection - This call is only for dynamics!" ); // This sucks, but it has to happen if we want // to avoid write lock errors from PhysX right now. mWorld->releaseWriteLock(); mActor->setGlobalPose( px3Cast<physx::PxTransform>(transform) ); }
void SelectionData::restoreOriginalPositions(const t_topology *top) { if (isDynamic()) { gmx_ana_pos_t &p = rawPositions_; gmx_ana_indexmap_update(&p.m, rootElement().v.u.g, hasFlag(gmx::efSelection_DynamicMask)); refreshMassesAndCharges(top); } }
void NormalizationPropertyOwner::updateCurrentValue( const String& name, const String& value) { // make sure the property is dynamic before updating the value. if (!isDynamic(name)) { throw NonDynamicConfigProperty(name); } initCurrentValue(name, value); }
void Px3Body::setSleeping( bool sleeping ) { AssertFatal( mActor, "Px3Body::setSleeping - The actor is null!" ); AssertFatal( isDynamic(), "Px3Body::setSleeping - This call is only for dynamics!" ); physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>(); if ( sleeping ) actor->putToSleep(); else actor->wakeUp(); }
/** Update current value of the specified property to the specified value */ void DefaultPropertyOwner::updateCurrentValue( const String& name, const String& value, const String& userName, Uint32 timeoutSeconds) { // // make sure the property is dynamic before updating the value. // if (!isDynamic(name)) { throw NonDynamicConfigProperty(name); } #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT if (String::equal(name, "enableIndicationService")) { ConfigProperty *configProperty = 0; for (Uint32 i = 0; i < NUM_PROPERTIES; i++) { if (String::equal(_configProperties.get()[i].propertyName, name)) { configProperty = &_configProperties.get()[i]; break; } } PEGASUS_ASSERT(configProperty); _requestIndicationServiceStateChange( userName, ConfigManager::parseBooleanValue(value), timeoutSeconds); configProperty->currentValue = value; return; } #endif // // Since the validations done in initCurrrentValue are sufficient and // no additional validations required for update, we shall call // initCurrrentValue. // initCurrentValue(name, value); #ifdef PEGASUS_ENABLE_AUDIT_LOGGER if (String::equal(name, "enableAuditLog") && isValid(name, value)) { Boolean enableAuditLog = ConfigManager::parseBooleanValue(value); AuditLogger::setEnabled(enableAuditLog); } #endif }
void NormalizationPropertyOwner::updateCurrentValue(const String & name, const String & value) { // make sure the property is dynamic before updating the value. if(!isDynamic(name)) { throw NonDynamicConfigProperty(name); } struct ConfigProperty * configProperty = _lookupConfigProperty(name); configProperty->currentValue = value; }