Blender V4.3
btCollisionObject.cpp
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#include "btCollisionObject.h"
19
20btCollisionObject::btCollisionObject()
21 : m_interpolationLinearVelocity(0.f, 0.f, 0.f),
22 m_interpolationAngularVelocity(0.f, 0.f, 0.f),
23 m_anisotropicFriction(1.f, 1.f, 1.f),
30 m_collisionFlags(btCollisionObject::CF_STATIC_OBJECT),
31 m_islandTag1(-1),
32 m_companionId(-1),
36 m_friction(btScalar(0.5)),
44 m_userIndex2(-1),
45 m_userIndex(-1),
46 m_userIndex3(-1),
52{
53 m_worldTransform.setIdentity();
55}
56
57btCollisionObject::~btCollisionObject()
58{
59}
60
61void btCollisionObject::setActivationState(int newState) const
62{
64 m_activationState1 = newState;
65}
66
67void btCollisionObject::forceActivationState(int newState) const
68{
69 m_activationState1 = newState;
70}
71
72void btCollisionObject::activate(bool forceActivation) const
73{
74 if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT | CF_KINEMATIC_OBJECT)))
75 {
78 }
79}
80
81const char* btCollisionObject::serialize(void* dataBuffer, btSerializer* serializer) const
82{
83 btCollisionObjectData* dataOut = (btCollisionObjectData*)dataBuffer;
84
85 m_worldTransform.serialize(dataOut->m_worldTransform);
86 m_interpolationWorldTransform.serialize(dataOut->m_interpolationWorldTransform);
87 m_interpolationLinearVelocity.serialize(dataOut->m_interpolationLinearVelocity);
88 m_interpolationAngularVelocity.serialize(dataOut->m_interpolationAngularVelocity);
89 m_anisotropicFriction.serialize(dataOut->m_anisotropicFriction);
90 dataOut->m_hasAnisotropicFriction = m_hasAnisotropicFriction;
91 dataOut->m_contactProcessingThreshold = m_contactProcessingThreshold;
92 dataOut->m_broadphaseHandle = 0;
93 dataOut->m_collisionShape = serializer->getUniquePointer(m_collisionShape);
94 dataOut->m_rootCollisionShape = 0; //@todo
95 dataOut->m_collisionFlags = m_collisionFlags;
96 dataOut->m_islandTag1 = m_islandTag1;
97 dataOut->m_companionId = m_companionId;
98 dataOut->m_activationState1 = m_activationState1;
99 dataOut->m_deactivationTime = m_deactivationTime;
100 dataOut->m_friction = m_friction;
101 dataOut->m_rollingFriction = m_rollingFriction;
102 dataOut->m_contactDamping = m_contactDamping;
103 dataOut->m_contactStiffness = m_contactStiffness;
104 dataOut->m_restitution = m_restitution;
105 dataOut->m_internalType = m_internalType;
106
107 char* name = (char*)serializer->findNameForPointer(this);
108 dataOut->m_name = (char*)serializer->getUniquePointer(name);
109 if (dataOut->m_name)
110 {
111 serializer->serializeName(name);
112 }
113 dataOut->m_hitFraction = m_hitFraction;
114 dataOut->m_ccdSweptSphereRadius = m_ccdSweptSphereRadius;
115 dataOut->m_ccdMotionThreshold = m_ccdMotionThreshold;
116 dataOut->m_checkCollideWith = m_checkCollideWith;
118 {
119 dataOut->m_collisionFilterGroup = m_broadphaseHandle->m_collisionFilterGroup;
120 dataOut->m_collisionFilterMask = m_broadphaseHandle->m_collisionFilterMask;
121 dataOut->m_uniqueId = m_broadphaseHandle->m_uniqueId;
122 }
123 else
124 {
125 dataOut->m_collisionFilterGroup = 0;
126 dataOut->m_collisionFilterMask = 0;
127 dataOut->m_uniqueId = -1;
128 }
130}
131
132void btCollisionObject::serializeSingleObject(class btSerializer* serializer) const
133{
135 btChunk* chunk = serializer->allocate(len, 1);
136 const char* structType = serialize(chunk->m_oldPtr, serializer);
137 serializer->finalizeChunk(chunk, structType, BT_COLLISIONOBJECT_CODE, (void*)this);
138}
btScalar m_contactStiffness
btVector3 m_interpolationAngularVelocity
int m_islandTag1
#define ACTIVE_TAG
btVector3 m_anisotropicFriction
#define btCollisionObjectData
void * m_extensionPointer
m_extensionPointer is used by some internal low-level Bullet extensions.
int m_hasAnisotropicFriction
#define DISABLE_DEACTIVATION
btScalar m_ccdMotionThreshold
Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold...
btScalar m_deactivationTime
@ CF_KINEMATIC_OBJECT
@ CF_STATIC_OBJECT
btTransform m_interpolationWorldTransform
void setActivationState(int newState) const
btScalar m_contactProcessingThreshold
void * m_userObjectPointer
users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPoin...
btScalar m_restitution
int m_checkCollideWith
If some object should have elaborate collision filtering by sub-classes.
@ CO_COLLISION_OBJECT
btScalar m_hitFraction
time of impact calculation
btScalar m_rollingFriction
int m_userIndex
int m_companionId
btScalar m_friction
btScalar m_spinningFriction
#define btCollisionObjectDataName
int m_userIndex3
btCollisionShape * m_rootCollisionShape
int m_worldArrayIndex
int m_collisionFlags
btScalar m_ccdSweptSphereRadius
Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
btVector3 m_interpolationLinearVelocity
int m_userIndex2
#define DISABLE_SIMULATION
btScalar m_contactDamping
int m_internalType
int m_updateRevision
internal update revision number. It will be increased when the object changes. This allows some subsy...
int m_activationState1
btCollisionShape * m_collisionShape
btBroadphaseProxy * m_broadphaseHandle
unsigned calculateSerializeBufferSize() const
virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const
Data buffer MUST be 16 byte aligned.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
#define BT_LARGE_FLOAT
Definition btScalar.h:316
#define BT_COLLISIONOBJECT_CODE
btTransform m_worldTransform
void * m_oldPtr
virtual btChunk * allocate(size_t size, int numElements)=0
virtual void * getUniquePointer(void *oldPtr)=0
virtual void serializeName(const char *ptr)=0
virtual const char * findNameForPointer(const void *ptr) const =0
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
int len