btCollisionObject.cpp

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 
00017 #include "btCollisionObject.h"
00018 #include "LinearMath/btSerializer.h"
00019 
00020 btCollisionObject::btCollisionObject()
00021         :       m_anisotropicFriction(1.f,1.f,1.f),
00022         m_hasAnisotropicFriction(false),
00023         m_contactProcessingThreshold(BT_LARGE_FLOAT),
00024                 m_broadphaseHandle(0),
00025                 m_collisionShape(0),
00026                 m_rootCollisionShape(0),
00027                 m_collisionFlags(btCollisionObject::CF_STATIC_OBJECT),
00028                 m_islandTag1(-1),
00029                 m_companionId(-1),
00030                 m_activationState1(1),
00031                 m_deactivationTime(btScalar(0.)),
00032                 m_friction(btScalar(0.5)),
00033                 m_restitution(btScalar(0.)),
00034                 m_internalType(CO_COLLISION_OBJECT),
00035                 m_userObjectPointer(0),
00036                 m_hitFraction(btScalar(1.)),
00037                 m_ccdSweptSphereRadius(btScalar(0.)),
00038                 m_ccdMotionThreshold(btScalar(0.)),
00039                 m_checkCollideWith(false)
00040 {
00041         m_worldTransform.setIdentity();
00042 }
00043 
00044 btCollisionObject::~btCollisionObject()
00045 {
00046 }
00047 
00048 void btCollisionObject::setActivationState(int newState) 
00049 { 
00050         if ( (m_activationState1 != DISABLE_DEACTIVATION) && (m_activationState1 != DISABLE_SIMULATION))
00051                 m_activationState1 = newState;
00052 }
00053 
00054 void btCollisionObject::forceActivationState(int newState)
00055 {
00056         m_activationState1 = newState;
00057 }
00058 
00059 void btCollisionObject::activate(bool forceActivation)
00060 {
00061         if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
00062         {
00063                 setActivationState(ACTIVE_TAG);
00064                 m_deactivationTime = btScalar(0.);
00065         }
00066 }
00067 
00068 const char* btCollisionObject::serialize(void* dataBuffer, btSerializer* serializer) const
00069 {
00070 
00071         btCollisionObjectData* dataOut = (btCollisionObjectData*)dataBuffer;
00072 
00073         m_worldTransform.serialize(dataOut->m_worldTransform);
00074         m_interpolationWorldTransform.serialize(dataOut->m_interpolationWorldTransform);
00075         m_interpolationLinearVelocity.serialize(dataOut->m_interpolationLinearVelocity);
00076         m_interpolationAngularVelocity.serialize(dataOut->m_interpolationAngularVelocity);
00077         m_anisotropicFriction.serialize(dataOut->m_anisotropicFriction);
00078         dataOut->m_hasAnisotropicFriction = m_hasAnisotropicFriction;
00079         dataOut->m_contactProcessingThreshold = m_contactProcessingThreshold;
00080         dataOut->m_broadphaseHandle = 0;
00081         dataOut->m_collisionShape = m_collisionShape; //@todo
00082         dataOut->m_rootCollisionShape = 0;//@todo
00083         dataOut->m_collisionFlags = m_collisionFlags;
00084         dataOut->m_islandTag1 = m_islandTag1;
00085         dataOut->m_companionId = m_companionId;
00086         dataOut->m_activationState1 = m_activationState1;
00087         dataOut->m_activationState1 = m_activationState1;
00088         dataOut->m_deactivationTime = m_deactivationTime;
00089         dataOut->m_friction = m_friction;
00090         dataOut->m_restitution = m_restitution;
00091         dataOut->m_internalType = m_internalType;
00092         dataOut->m_name = (char*) serializer->findNameForPointer(this);
00093         if (dataOut->m_name)
00094         {
00095                 serializer->serializeName(dataOut->m_name);
00096         }
00097         dataOut->m_hitFraction = m_hitFraction;
00098         dataOut->m_ccdSweptSphereRadius = m_ccdSweptSphereRadius;
00099         dataOut->m_ccdMotionThreshold = m_ccdMotionThreshold;
00100         dataOut->m_ccdMotionThreshold = m_ccdMotionThreshold;
00101         dataOut->m_checkCollideWith = m_checkCollideWith;
00102 
00103         return btCollisionObjectDataName;
00104 }
00105 
00106 
00107 

Generated on Mon Feb 15 22:17:02 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1