Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
| Show First 20 Lines • Show All 1,277 Lines • ▼ Show 20 Lines | if (soft) | ||||
| force /= soft->m_nodes.size(); | force /= soft->m_nodes.size(); | ||||
| soft->addForce(force); | soft->addForce(force); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void CcdPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local) | void CcdPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local) | ||||
| { | { | ||||
| btVector3 angvel(ang_vel.x(),ang_vel.y(),ang_vel.z()); | btVector3 angvel(ang_vel.x(),ang_vel.y(),ang_vel.z()); | ||||
| if (m_object && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) | |||||
| /* Refuse tiny tiny velocities, as they might cause instabilities. */ | |||||
| float vel_squared = angvel.length2(); | |||||
| if (vel_squared > 0 && vel_squared <= (SIMD_EPSILON*SIMD_EPSILON)) | |||||
| angvel = btVector3(0, 0, 0); | |||||
| if (m_object) | |||||
| { | { | ||||
| m_object->activate(true); | m_object->activate(true); | ||||
| if (m_object->isStaticObject()) | if (m_object->isStaticObject()) | ||||
| { | { | ||||
| if (!m_cci.m_bSensor) | if (!m_cci.m_bSensor) | ||||
| m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); | m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); | ||||
| return; | return; | ||||
| } | } | ||||
| btTransform xform = m_object->getWorldTransform(); | btTransform xform = m_object->getWorldTransform(); | ||||
| if (local) | if (local) | ||||
| { | { | ||||
| angvel = xform.getBasis()*angvel; | angvel = xform.getBasis()*angvel; | ||||
| } | } | ||||
| btRigidBody* body = GetRigidBody(); | btRigidBody* body = GetRigidBody(); | ||||
| if (body) | if (body) | ||||
| body->setAngularVelocity(angvel); | body->setAngularVelocity(angvel); | ||||
| } | } | ||||
| } | } | ||||
| void CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local) | void CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local) | ||||
| { | { | ||||
| btVector3 linVel(lin_vel.x(),lin_vel.y(),lin_vel.z()); | btVector3 linVel(lin_vel.x(),lin_vel.y(),lin_vel.z()); | ||||
| if (m_object/* && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)*/) | |||||
| /* Refuse tiny tiny velocities, as they might cause instabilities. */ | |||||
| float vel_squared = linVel.length2(); | |||||
| if (vel_squared > 0 && vel_squared <= (SIMD_EPSILON*SIMD_EPSILON)) | |||||
| linVel = btVector3(0, 0, 0); | |||||
| if (m_object) | |||||
| { | { | ||||
| m_object->activate(true); | m_object->activate(true); | ||||
| if (m_object->isStaticObject()) | if (m_object->isStaticObject()) | ||||
| { | { | ||||
| if (!m_cci.m_bSensor) | if (!m_cci.m_bSensor) | ||||
| m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); | m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,336 Lines • Show Last 20 Lines | |||||