diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-17 18:01:43 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-17 18:03:10 +0300 |
commit | 4be752a93cf37700668c604296f37ea08248f13b (patch) | |
tree | 0f838c87eaa6bf289b76f232e6b1571a28a55cba /source/gameengine/Physics/Bullet | |
parent | 5513da65b24a3ce77b1709acea841475115f3a7a (diff) |
Cleanup: trailing space in source/gameengine/
Diffstat (limited to 'source/gameengine/Physics/Bullet')
6 files changed, 209 insertions, 209 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp index 470a5431843..8ddd4cbdada 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp @@ -7,8 +7,8 @@ Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 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. @@ -95,8 +95,8 @@ void CcdGraphicController::GetAabb(btVector3& aabbMin, btVector3& aabbMax) btVector3 localHalfExtents = btScalar(0.5f)*(localAabbMax-localAabbMin); btVector3 localCenter = btScalar(0.5f)*(localAabbMax+localAabbMin); - - btMatrix3x3 abs_b = rot.absolute(); + + btMatrix3x3 abs_b = rot.absolute(); btVector3 center = rot*localCenter + pos; btVector3 extent = abs_b*localHalfExtents; aabbMin = center - extent; @@ -105,7 +105,7 @@ void CcdGraphicController::GetAabb(btVector3& aabbMin, btVector3& aabbMax) bool CcdGraphicController::SetGraphicTransform() { - if (!m_handle) + if (!m_handle) return false; btVector3 aabbMin; btVector3 aabbMax; @@ -121,7 +121,7 @@ PHY_IGraphicController* CcdGraphicController::GetReplica(class PHY_IMotionState* replica->m_motionState = motionState; replica->m_newClientInfo = NULL; replica->m_handle = NULL; - // don't add the graphic controller now: work around a bug in Bullet with rescaling, + // don't add the graphic controller now: work around a bug in Bullet with rescaling, // (the scale of the controller is not yet defined). //m_phyEnv->addCcdGraphicController(replica); return replica; diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h index e76ad86301e..d1ce61ca672 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.h +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h @@ -4,8 +4,8 @@ Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 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. @@ -70,7 +70,7 @@ public: virtual void* GetNewClientInfo() { return m_newClientInfo; } virtual void SetNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; } virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate); - + private: // unscaled aabb corner btVector3 m_localAabbMin; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index c79e1c23ef6..74a99b3c668 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -7,8 +7,8 @@ Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 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. @@ -105,7 +105,7 @@ void BlenderBulletCharacterController::jump() { if (!canJump()) return; - + m_verticalVelocity = m_jumpSpeed; m_wasJumping = true; m_jumps++; @@ -151,7 +151,7 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) m_shapeInfo->AddRef(); m_bulletChildShape = NULL; - + m_bulletMotionState = 0; m_characterController = 0; m_savedCollisionFlags = 0; @@ -160,7 +160,7 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) m_savedMass = 0.0f; m_savedDyna = false; m_suspended = false; - + CreateRigidbody(); } @@ -279,7 +279,7 @@ bool CcdPhysicsController::CreateSoftbody() rbci.m_angularDamping = m_cci.m_angularDamping; rbci.m_friction = m_cci.m_friction; rbci.m_restitution = m_cci.m_restitution; - + btVector3 p(0.0f,0.0f,0.0f);// = getOrigin(); //btSoftBody* psb=btSoftBodyHelpers::CreateRope(worldInfo, btVector3(-10,0,i*0.25),btVector3(10,0,i*0.25), 16,1+2); btSoftBody* psb = 0; @@ -296,7 +296,7 @@ bool CcdPhysicsController::CreateSoftbody() HullLibrary hlib; /*??*/ hdsc.mMaxVertices=nvertices; hlib.CreateConvexHull(hdsc,hres); - + psb = new btSoftBody(&worldInfo, (int)hres.mNumOutputVertices, &hres.m_OutputVertices[0], 0); for (int i = 0; i < (int)hres.mNumFaces; ++i) { @@ -356,7 +356,7 @@ bool CcdPhysicsController::CreateSoftbody() int indexstride; PHY_ScalarType indexType; trimeshshape->getMeshInterface()->getLockedVertexIndexBase(&vertexBase,numverts,vertexType,vertexstride,&indexbase,indexstride,numtris,indexType); - + psb = btSoftBodyHelpers::CreateFromTriMesh(worldInfo,(const btScalar*)vertexBase,(const int*)indexbase,numtris,false); } } @@ -376,7 +376,7 @@ bool CcdPhysicsController::CreateSoftbody() psb->updateBounds(); } m_object = psb; - + //btSoftBody::Material* pm=psb->appendMaterial(); btSoftBody::Material* pm=psb->m_materials[0]; pm->m_kLST = m_cci.m_soft_linStiff; @@ -440,7 +440,7 @@ bool CcdPhysicsController::CreateSoftbody() { psb->setPose(true,false); } - + psb->randomizeConstraints(); if (m_cci.m_soft_collisionflags & (CCD_BSB_COL_CL_RS+CCD_BSB_COL_CL_SS)) @@ -449,7 +449,7 @@ bool CcdPhysicsController::CreateSoftbody() } psb->setTotalMass(m_cci.m_mass); - + psb->setCollisionFlags(0); ///create a mapping between graphics mesh vertices and soft body vertices @@ -473,7 +473,7 @@ bool CcdPhysicsController::CreateSoftbody() for (slot->begin(it); !slot->end(it); slot->next(it)) { int index = 0; - for (i=it.startvertex; i<it.endvertex; i++,index++) + for (i=it.startvertex; i<it.endvertex; i++,index++) { RAS_TexVert* vertex = &it.vertex[i]; //search closest index, and store it in vertex @@ -487,7 +487,7 @@ bool CcdPhysicsController::CreateSoftbody() if (distSqr<maxDistSqr) { maxDistSqr = distSqr; - + vertex->setSoftBodyIndex(n); } } @@ -520,7 +520,7 @@ bool CcdPhysicsController::CreateCharacterController() { if (!m_cci.m_bCharacter) return false; - + m_object = new btPairCachingGhostObject(); m_object->setCollisionShape(m_collisionShape); m_object->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT); @@ -556,11 +556,11 @@ void CcdPhysicsController::CreateRigidbody() rbci.m_friction = m_cci.m_friction; rbci.m_restitution = m_cci.m_restitution; m_object = new btRigidBody(rbci); - + // // init the rigidbody properly // - + //setMassProps this also sets collisionFlags //convert collision flags! //special case: a near/radar sensor controller should not be defined static or it will @@ -594,7 +594,7 @@ void CcdPhysicsController::CreateRigidbody() { m_object->setAnisotropicFriction(m_cci.m_anisotropicFriction); } - + } static void DeleteBulletShape(btCollisionShape* shape, bool free) @@ -738,7 +738,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) btSoftBody* sb = GetSoftBody(); if (sb) { - if (sb->m_pose.m_bframe) + if (sb->m_pose.m_bframe) { btVector3 worldPos = sb->m_pose.m_com; btQuaternion worldquat; @@ -747,7 +747,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]); m_MotionState->SetWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); } - else + else { btVector3 aabbMin,aabbMax; sb->getAabb(aabbMin,aabbMax); @@ -784,10 +784,10 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) m_MotionState->getWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); btTransform oldTrans = m_body->getCenterOfMassTransform(); btTransform newTrans(worldquat,worldPos); - + SetCenterOfMassTransform(newTrans); //need to keep track of previous position for friction effects... - + m_MotionState->calculateWorldTransformations(); */ float scale[3]; @@ -802,7 +802,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) /** * WriteMotionStateToDynamics synchronizes dynas, kinematic and deformable entities (and do 'late binding') */ - + void CcdPhysicsController::WriteMotionStateToDynamics(bool nondynaonly) { btTransform& xform = CcdPhysicsController::GetTransformFromMotionState(m_MotionState); @@ -835,13 +835,13 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta // new shape has no scaling, apply initial scaling //m_collisionShape->setMargin(m_cci.m_margin); m_collisionShape->setLocalScaling(m_cci.m_scaling); - + if (m_cci.m_mass) m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); } } - // load some characterists that are not + // load some characterists that are not btRigidBody* oldbody = GetRigidBody(); m_object = 0; CreateRigidbody(); @@ -873,7 +873,7 @@ void CcdPhysicsController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment * // can safely assume CCD environment CcdPhysicsEnvironment *physicsEnv = static_cast<CcdPhysicsEnvironment*>(env); - if (m_cci.m_physicsEnv != physicsEnv) + if (m_cci.m_physicsEnv != physicsEnv) { // since the environment is changing, we must also move the controler to the // new environment. Note that we don't handle sensor explicitly: this @@ -934,7 +934,7 @@ void CcdPhysicsController::RelativeTranslate(const MT_Vector3& dlocin,bool loca btVector3 dloc(dlocin.x(), dlocin.y(), dlocin.z()); btTransform xform = m_object->getWorldTransform(); - + if (local) dloc = xform.getBasis()*dloc; @@ -966,8 +966,8 @@ void CcdPhysicsController::RelativeRotate(const MT_Matrix3x3& rotval,bool local GetWorldOrientation(currentOrn); btTransform xform = m_object->getWorldTransform(); - - xform.setBasis(xform.getBasis()*(local ? + + xform.setBasis(xform.getBasis()*(local ? drotmat : (currentOrn.inverse() * drotmat * currentOrn))); SetCenterOfMassTransform(xform); @@ -1141,15 +1141,15 @@ void CcdPhysicsController::SetScaling(const MT_Vector3& scale) { m_object->activate(true); // without this, sleeping objects scale wont be applied in bullet if python changes the scale - Campbell. m_object->getCollisionShape()->setLocalScaling(m_cci.m_scaling); - + //printf("no inertia recalc for fixed objects with mass=0\n"); btRigidBody* body = GetRigidBody(); if (body && m_cci.m_mass) { body->getCollisionShape()->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); - } - + } + } } } @@ -1202,13 +1202,13 @@ void CcdPhysicsController::SetMass(MT_Scalar newmass) handle->m_collisionFilterMask); } } - + // physics methods void CcdPhysicsController::ApplyTorque(const MT_Vector3& torquein,bool local) { btVector3 torque(torquein.x(),torquein.y(),torquein.z()); btTransform xform = m_object->getWorldTransform(); - + if (m_object && torque.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { @@ -1239,15 +1239,15 @@ void CcdPhysicsController::ApplyTorque(const MT_Vector3& torquein,bool local) body->setAngularFactor(tmpFac); body->applyTorque(torque); body->setAngularFactor(angFac); - } - } + } + } } } void CcdPhysicsController::ApplyForce(const MT_Vector3& forcein,bool local) { btVector3 force(forcein.x(),forcein.y(),forcein.z()); - + if (m_object && force.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { @@ -1259,7 +1259,7 @@ void CcdPhysicsController::ApplyForce(const MT_Vector3& forcein,bool local) return; } btTransform xform = m_object->getWorldTransform(); - + if (local) { force = xform.getBasis()*force; @@ -1324,7 +1324,7 @@ void CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool loc m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); return; } - + btSoftBody* soft = GetSoftBody(); if (soft) { @@ -1360,7 +1360,7 @@ void CcdPhysicsController::ApplyImpulse(const MT_Point3& attach, const MT_Vecto m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); return; } - + btTransform xform = m_object->getWorldTransform(); if (local) @@ -1377,7 +1377,7 @@ void CcdPhysicsController::ApplyImpulse(const MT_Point3& attach, const MT_Vecto btRigidBody* body = GetRigidBody(); if (body) body->applyImpulse(impulse,pos); - + } } @@ -1479,7 +1479,7 @@ MT_Vector3 CcdPhysicsController::GetLocalInertia() return inertia; } - // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted + // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted void CcdPhysicsController::SetRigidBody(bool rigid) { btRigidBody* body = GetRigidBody(); @@ -1677,7 +1677,7 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplicaForSensors() { // This situation does not normally happen cinfo.m_collisionShape = m_shapeInfo->CreateBulletShape(m_cci.m_margin, m_cci.m_bGimpact, !m_cci.m_bSoft); - } + } else if (m_collisionShape) { switch (m_collisionShape->getShapeType()) @@ -1741,7 +1741,7 @@ void CcdPhysicsController::ReplicateConstraints(KX_GameObject *replica, std::vec { if (replica->GetConstraints().size() == 0 || !replica->GetPhysicsController()) return; - + PHY_IPhysicsEnvironment *physEnv = GetPhysicsEnvironment(); vector<bRigidBodyJointConstraint*> constraints = replica->GetConstraints(); @@ -1751,7 +1751,7 @@ void CcdPhysicsController::ReplicateConstraints(KX_GameObject *replica, std::vec for (consit = constraints.begin(); consit != constraints.end(); ++consit) { /* Try to find the constraint targets in the list of group objects. */ bRigidBodyJointConstraint *dat = (*consit); - vector<KX_GameObject*>::iterator memit; + vector<KX_GameObject*>::iterator memit; for (memit = constobj.begin(); memit != constobj.end(); ++memit) { KX_GameObject *member = (*memit); /* If the group member is the actual target for the constraint. */ @@ -1801,7 +1801,7 @@ void DefaultMotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,flo quatIma2 = quat.z(); quatReal = quat[3]; } - + void DefaultMotionState::GetWorldOrientation(float* ori) { m_worldTransform.getBasis().getOpenGLSubMatrix(ori); @@ -1822,7 +1822,7 @@ void DefaultMotionState::SetWorldOrientation(float quatIma0,float quatIma1,float btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); m_worldTransform.setRotation( orn ); } - + void DefaultMotionState::CalculateWorldTransformations() { @@ -2505,7 +2505,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, b if (m_shapeType == PHY_SHAPE_PROXY && m_shapeProxy != NULL) return m_shapeProxy->CreateBulletShape(margin, useGimpact, useBvh); - switch (m_shapeType) + switch (m_shapeType) { default: break; @@ -2541,10 +2541,10 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, b break; case PHY_SHAPE_MESH: - // Let's use the latest btScaledBvhTriangleMeshShape: it allows true sharing of - // triangle mesh information between duplicates => drastic performance increase when - // duplicating complex mesh objects. - // BUT it causes a small performance decrease when sharing is not required: + // Let's use the latest btScaledBvhTriangleMeshShape: it allows true sharing of + // triangle mesh information between duplicates => drastic performance increase when + // duplicating complex mesh objects. + // BUT it causes a small performance decrease when sharing is not required: // 9 multiplications/additions and one function call for each triangle that passes the mid phase filtering // One possible optimization is to use directly the btBvhTriangleMeshShape when the scale is 1,1,1 // and btScaledBvhTriangleMeshShape otherwise. @@ -2648,7 +2648,7 @@ CcdShapeConstructionInfo::~CcdShapeConstructionInfo() if (m_triangleIndexVertexArray) delete m_triangleIndexVertexArray; m_vertexArray.clear(); - if (m_shapeType == PHY_SHAPE_MESH && m_meshObject != NULL) + if (m_shapeType == PHY_SHAPE_MESH && m_meshObject != NULL) { std::map<RAS_MeshObject*,CcdShapeConstructionInfo*>::iterator mit = m_meshShapeMap.find(m_meshObject); if (mit != m_meshShapeMap.end() && mit->second == this) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 831e7346df7..d69feda38e5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -4,8 +4,8 @@ Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 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. @@ -63,11 +63,11 @@ class btCollisionShape; class CcdShapeConstructionInfo { public: - struct UVco + struct UVco { float uv[2]; }; - + static CcdShapeConstructionInfo* FindMesh(class RAS_MeshObject* mesh, struct DerivedMesh* dm, bool polytope); CcdShapeConstructionInfo() : @@ -90,7 +90,7 @@ public: ~CcdShapeConstructionInfo(); CcdShapeConstructionInfo* AddRef() - { + { m_refCount++; return this; } @@ -131,7 +131,7 @@ public: CcdShapeConstructionInfo* childInfo = m_shapeArray.at(i); if ((userData == NULL || userData == childInfo->m_userData) && (childInfo == shapeInfo || - (childInfo->m_shapeType == PHY_SHAPE_PROXY && + (childInfo->m_shapeType == PHY_SHAPE_PROXY && childInfo->m_shapeProxy == shapeInfo))) return i; } @@ -177,10 +177,10 @@ public: btAlignedObjectArray<btScalar> m_vertexArray; // Contains both vertex array for polytope shape and // triangle array for concave mesh shape. Each vertex is 3 consecutive values // In this case a triangle is made of 3 consecutive points - std::vector<int> m_polygonIndexArray; // Contains the array of polygon index in the + std::vector<int> m_polygonIndexArray; // Contains the array of polygon index in the // original mesh that correspond to shape triangles. // only set for concave mesh shape. - + std::vector<int> m_triFaceArray; // Contains an array of triplets of face indices // quads turn into 2 tris @@ -194,8 +194,8 @@ public: protected: static std::map<RAS_MeshObject*, CcdShapeConstructionInfo*> m_meshShapeMap; int m_refCount; // this class is shared between replicas - // keep track of users so that we can release it - RAS_MeshObject* m_meshObject; // Keep a pointer to the original mesh + // keep track of users so that we can release it + RAS_MeshObject* m_meshObject; // Keep a pointer to the original mesh // The list of vertexes and indexes for the triangle mesh, shared between Bullet shape. btTriangleIndexVertexArray *m_triangleIndexVertexArray; std::vector<CcdShapeConstructionInfo*> m_shapeArray; // for compound shapes @@ -302,8 +302,8 @@ struct CcdConstructionInfo btVector3 m_linearFactor; btVector3 m_angularFactor; btScalar m_mass; - btScalar m_clamp_vel_min; - btScalar m_clamp_vel_max; + btScalar m_clamp_vel_min; + btScalar m_clamp_vel_max; btScalar m_clamp_angvel_min; // Minimum angular velocity, in radians/sec. btScalar m_clamp_angvel_max; // Maximum angular velocity, in radians/sec. btScalar m_restitution; @@ -377,7 +377,7 @@ struct CcdConstructionInfo class btCollisionShape* m_collisionShape; class PHY_IMotionState* m_MotionState; class CcdShapeConstructionInfo* m_shapeInfo; - + CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication float m_inertiaFactor;//tweak the inertia (hooked up to Blender 'formfactor' bool m_do_anisotropic; @@ -387,10 +387,10 @@ struct CcdConstructionInfo bool m_do_rot_fh; ///< Should the object have an angular Fh spring? btScalar m_fh_spring; ///< Spring constant (both linear and angular) btScalar m_fh_damping; ///< Damping factor (linear and angular) in range [0, 1] - btScalar m_fh_distance; ///< The range above the surface where Fh is active. + btScalar m_fh_distance; ///< The range above the surface where Fh is active. bool m_fh_normal; ///< Should the object slide off slopes? float m_radius;//for fh backwards compatibility - + ///m_contactProcessingThreshold allows to process contact points with positive distance ///normally only contacts with negative distance (penetration) are solved ///however, rigid body stacking is more stable when positive contacts are still passed into the constraint solver @@ -476,7 +476,7 @@ class CcdPhysicsController : public PHY_IPhysicsController protected: btCollisionObject* m_object; BlenderBulletCharacterController* m_characterController; - + class PHY_IMotionState* m_MotionState; btMotionState* m_bulletMotionState; @@ -514,7 +514,7 @@ protected: bool CreateSoftbody(); bool CreateCharacterController(); - bool Register() { + bool Register() { return (m_registerCount++ == 0) ? true : false; } bool Unregister() { @@ -535,9 +535,9 @@ protected: void ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos); public: - + int m_collisionDelay; - + CcdPhysicsController (const CcdConstructionInfo& ci); @@ -572,7 +572,7 @@ protected: CcdShapeConstructionInfo* GetShapeInfo() { return m_shapeInfo; } - btCollisionShape* GetCollisionShape() { + btCollisionShape* GetCollisionShape() { return m_object->getCollisionShape(); } //////////////////////////////////// @@ -594,7 +594,7 @@ protected: /** * WriteMotionStateToDynamics ynchronizes dynas, kinematic and deformable entities (and do 'late binding') */ - + virtual void WriteMotionStateToDynamics(bool nondynaonly); virtual void WriteDynamicsToMotionState(); @@ -614,7 +614,7 @@ protected: virtual MT_Scalar GetMass(); virtual void SetMass(MT_Scalar newmass); - + // physics methods virtual void ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein, bool local); virtual void ApplyTorque(const MT_Vector3& torque,bool local); @@ -636,10 +636,10 @@ protected: virtual MT_Vector3 GetVelocity(const MT_Point3& posin); virtual MT_Vector3 GetLocalInertia(); - // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted + // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted virtual void SetRigidBody(bool rigid); - + virtual void ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ); virtual void RefreshCollisions(); virtual void SuspendDynamics(bool ghost); @@ -654,7 +654,7 @@ protected: virtual void SetNewClientInfo(void* clientinfo); virtual PHY_IPhysicsController* GetReplica(); virtual PHY_IPhysicsController* GetReplicaForSensors(); - + ///There should be no 'SetCollisionFilterGroup' method, as changing this during run-time is will result in errors short int GetCollisionFilterGroup() const { @@ -667,7 +667,7 @@ protected: } virtual void CalcXform() {} - virtual void SetMargin(float margin) + virtual void SetMargin(float margin) { if (m_collisionShape) { m_collisionShape->setMargin(margin); @@ -676,16 +676,16 @@ protected: ((btScaledBvhTriangleMeshShape *)m_collisionShape)->getChildShape()->setMargin(margin); } } - virtual float GetMargin() const + virtual float GetMargin() const { return (m_collisionShape) ? m_collisionShape->getMargin() : 0.f; } - virtual float GetRadius() const - { + virtual float GetRadius() const + { // this is not the actual shape radius, it's only used for Fh support return m_cci.m_radius; } - virtual void SetRadius(float margin) + virtual void SetRadius(float margin) { if (m_collisionShape && m_collisionShape->getShapeType() == SPHERE_SHAPE_PROXYTYPE) { @@ -694,21 +694,21 @@ protected: } m_cci.m_radius = margin; } - + // velocity clamping - virtual void SetLinVelocityMin(float val) + virtual void SetLinVelocityMin(float val) { m_cci.m_clamp_vel_min= val; } - virtual float GetLinVelocityMin() const + virtual float GetLinVelocityMin() const { return m_cci.m_clamp_vel_min; } - virtual void SetLinVelocityMax(float val) + virtual void SetLinVelocityMax(float val) { m_cci.m_clamp_vel_max= val; } - virtual float GetLinVelocityMax() const + virtual float GetLinVelocityMax() const { return m_cci.m_clamp_vel_max; } @@ -811,18 +811,18 @@ class DefaultMotionState : public PHY_IMotionState virtual void GetWorldPosition(float& posX,float& posY,float& posZ); virtual void GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ); virtual void GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal); - + virtual void SetWorldPosition(float posX,float posY,float posZ); virtual void SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal); virtual void GetWorldOrientation(float* ori); virtual void SetWorldOrientation(const float* ori); - + virtual void CalculateWorldTransformations(); - + btTransform m_worldTransform; btVector3 m_localScaling; - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:DefaultMotionState") #endif diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 78d2d88cc65..910b3a7dc84 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -7,8 +7,8 @@ Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 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. @@ -347,7 +347,7 @@ class CcdOverlapFilterCallBack : public btOverlapFilterCallback private: class CcdPhysicsEnvironment* m_physEnv; public: - CcdOverlapFilterCallBack(CcdPhysicsEnvironment* env) : + CcdOverlapFilterCallBack(CcdPhysicsEnvironment* env) : m_physEnv(env) { } @@ -769,7 +769,7 @@ public: m_owner(owner), m_parent(parent) { - + } virtual bool needsCollision(btBroadphaseProxy* proxy0) const @@ -791,7 +791,7 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) std::set<CcdPhysicsController*>::iterator it; // Add epsilon to the tick rate for numerical stability int numIter = (int)(interval*(KX_KetsjiEngine::GetTicRate() + 0.001f)); - + for (it=m_controllers.begin(); it!=m_controllers.end(); it++) { CcdPhysicsController* ctrl = (*it); @@ -817,7 +817,7 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) //btVector3 rayToWorld = rayFromWorld + body->getCenterOfMassTransform().getBasis() * rayDirLocal; //ray always points down the z axis in world space... btVector3 rayToWorld = rayFromWorld + rayDirLocal; - + ClosestRayResultCallbackNotMe resultCallback(rayFromWorld,rayToWorld,body,parentBody); m_dynamicsWorld->rayTest(rayFromWorld,rayToWorld,resultCallback); @@ -840,8 +840,8 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->GetConstructionInfo().m_radius; if (distance >= hitObjShapeProps.m_fh_distance) continue; - - + + //btVector3 ray_dir = cl_object->getCenterOfMassTransform().getBasis()* rayDirLocal.normalized(); btVector3 ray_dir = rayDirLocal.normalized(); @@ -856,7 +856,7 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) rayDirLocal * resultCallback.m_closestHitFraction; - + lspot -= hit_object->getCenterOfMassPosition(); btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot); @@ -865,16 +865,16 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring; btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping; - - cl_object->setLinearVelocity(cl_object->getLinearVelocity() + (-(i_spring + i_damp) * ray_dir)); - if (hitObjShapeProps.m_fh_normal) + + cl_object->setLinearVelocity(cl_object->getLinearVelocity() + (-(i_spring + i_damp) * ray_dir)); + if (hitObjShapeProps.m_fh_normal) { cl_object->setLinearVelocity(cl_object->getLinearVelocity()+(i_spring + i_damp) *(normal - normal.dot(ray_dir) * ray_dir)); } - + btVector3 lateral = rel_vel - rel_vel_ray * ray_dir; - - + + if (ctrl->GetConstructionInfo().m_do_anisotropic) { //Bullet basis contains no scaling/shear etc. const btMatrix3x3& lcs = cl_object->getCenterOfMassTransform().getBasis(); @@ -885,34 +885,34 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) } btScalar rel_vel_lateral = lateral.length(); - + if (rel_vel_lateral > SIMD_EPSILON) { btScalar friction_factor = hit_object->getFriction();//cl_object->getFriction(); btScalar max_friction = friction_factor * btMax(btScalar(0.0f), i_spring); - + btScalar rel_mom_lateral = rel_vel_lateral / cl_object->getInvMass(); - + btVector3 friction = (rel_mom_lateral > max_friction) ? -lateral * (max_friction / rel_vel_lateral) : -lateral; - + cl_object->applyCentralImpulse(friction); } } - + if (ctrl->GetConstructionInfo().m_do_rot_fh) { btVector3 up2 = cl_object->getWorldTransform().getBasis().getColumn(2); btVector3 t_spring = up2.cross(normal) * hitObjShapeProps.m_fh_spring; btVector3 ang_vel = cl_object->getAngularVelocity(); - + // only rotations that tilt relative to the normal are damped ang_vel -= ang_vel.dot(normal) * normal; - - btVector3 t_damp = ang_vel * hitObjShapeProps.m_fh_damping; - + + btVector3 t_damp = ang_vel * hitObjShapeProps.m_fh_damping; + cl_object->setAngularVelocity(cl_object->getAngularVelocity() + (t_spring - t_damp)); } } @@ -1014,8 +1014,8 @@ void CcdPhysicsEnvironment::SetSolverType(int solverType) { m_solver = new btSequentialImpulseConstraintSolver(); - - + + break; } } @@ -1073,18 +1073,18 @@ int CcdPhysicsEnvironment::CreateUniversalD6Constraint( //we could either add some logic to recognize ball-socket and hinge, or let that up to the user //perhaps some warning or hint that hinge/ball-socket is more efficient? - - + + btGeneric6DofConstraint* genericConstraint = 0; CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef; CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther; - + btRigidBody* rb0 = ctrl0->GetRigidBody(); btRigidBody* rb1 = ctrl1->GetRigidBody(); if (rb1) { - + bool useReferenceFrameA = true; genericConstraint = new btGeneric6DofSpringConstraint( @@ -1100,7 +1100,7 @@ int CcdPhysicsEnvironment::CreateUniversalD6Constraint( //No, we can use a fixed rigidbody in above code, rather than unnecessary duplation of code } - + if (genericConstraint) { // m_constraints.push_back(genericConstraint); @@ -1182,7 +1182,7 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul { m_hitTriangleShape = rayResult.m_collisionObject->getCollisionShape(); m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex; - } else + } else { m_hitTriangleShape = NULL; m_hitTriangleIndex = 0; @@ -1194,7 +1194,7 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul static bool GetHitTriangle(btCollisionShape* shape, CcdShapeConstructionInfo* shapeInfo, int hitTriangleIndex, btVector3 triangle[]) { - // this code is copied from Bullet + // this code is copied from Bullet const unsigned char *vertexbase; int numverts; PHY_ScalarType type; @@ -1284,7 +1284,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallbac break; } } - if (shape == rayCallback.m_hitTriangleShape && + if (shape == rayCallback.m_hitTriangleShape && rayCallback.m_hitTriangleIndex < shapeInfo->m_polygonIndexArray.size()) { // save original collision shape triangle for soft body @@ -1319,7 +1319,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallbac v1 = softBody->m_faces[hitTriangleIndex].m_n[0]->m_x; v2 = softBody->m_faces[hitTriangleIndex].m_n[1]->m_x; v3 = softBody->m_faces[hitTriangleIndex].m_n[2]->m_x; - } else + } else { // for rigid body we must apply the world transform triangleOK = GetHitTriangle(shape, shapeInfo, hitTriangleIndex, triangle); @@ -1355,12 +1355,12 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallbac result.m_hitUV[1] = baryCo.getX()*uvCo[0].uv[1] + baryCo.getY()*uvCo[1].uv[1] + baryCo.getZ()*uvCo[2].uv[1]; result.m_hitUVOK = 1; } - + // Bullet returns the normal from "outside". // If the user requests the real normal, compute it now if (filterCallback.m_faceNormal) { - if (shape->isSoftBody()) + if (shape->isSoftBody()) { // we can get the real normal directly from the body const btSoftBody* softBody = static_cast<const btSoftBody*>(rayCallback.m_collisionObject); @@ -1371,7 +1371,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallbac triangleOK = GetHitTriangle(shape, shapeInfo, hitTriangleIndex, triangle); if (triangleOK) { - btVector3 triangleNormal; + btVector3 triangleNormal; triangleNormal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]); rayCallback.m_hitNormalWorld = rayCallback.m_collisionObject->getWorldTransform().getBasis()*triangleNormal; } @@ -1399,7 +1399,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallbac return result.m_controller; } -// Handles occlusion culling. +// Handles occlusion culling. // The implementation is based on the CDTestFramework struct OcclusionBuffer { @@ -1438,7 +1438,7 @@ struct OcclusionBuffer btScalar m_offsets[2]; btScalar m_wtc[16]; // world to clip transform btScalar m_mtc[16]; // model to clip transform - // constructor: size=largest dimension of the buffer. + // constructor: size=largest dimension of the buffer. // Buffer size depends on aspect ratio OcclusionBuffer() { @@ -1488,7 +1488,7 @@ struct OcclusionBuffer m_offsets[0] = m_scales[0] + 0.5f; m_offsets[1] = m_scales[1] + 0.5f; // prepare matrix - // at this time of the rendering, the modelview matrix is the + // at this time of the rendering, the modelview matrix is the // world to camera transformation and the projection matrix is // camera to clip transformation. combine both so that CMmat4mul(m_wtc, projection, modelview); @@ -1508,7 +1508,7 @@ struct OcclusionBuffer if (!m_buffer) { m_buffer = (btScalar *)calloc(1, newsize); m_bufferSize = newsize; - } + } else { // buffer exists already, just clears it memset(m_buffer, 0, newsize); @@ -1687,7 +1687,7 @@ struct OcclusionBuffer else if (width == 1) { // Degenerated in at least 2 vertical lines // The algorithm below doesn't work when face has a single pixel width - // We cannot use general formulas because the plane is degenerated. + // We cannot use general formulas because the plane is degenerated. // We have to interpolate along the 3 edges that overlaps and process each pixel. // sort the y coord to make formula simpler int ytmp; @@ -1752,7 +1752,7 @@ struct OcclusionBuffer else if (height == 1) { // Degenerated in at least 2 horizontal lines // The algorithm below doesn't work when face has a single pixel width - // We cannot use general formulas because the plane is degenerated. + // We cannot use general formulas because the plane is degenerated. // We have to interpolate along the 3 edges that overlaps and process each pixel. int xtmp; btScalar ztmp; @@ -1846,7 +1846,7 @@ struct OcclusionBuffer } return false; } - // clip than write or check a polygon + // clip than write or check a polygon template <const int NP, typename POLICY> inline bool clipDraw(const btVector4 *p, const float face, @@ -1864,7 +1864,7 @@ struct OcclusionBuffer return earlyexit; } // add a triangle (in model coordinate) - // face = 0.f if face is double side, + // face = 0.f if face is double side, // = 1.f if face is single sided and scale is positive // = -1.f if face is single sided and scale is negative void appendOccluderM(const float *a, @@ -2054,12 +2054,12 @@ void CcdPhysicsEnvironment::GetContactPoint(int i,float& hitX,float& hitY,float& btBroadphaseInterface* CcdPhysicsEnvironment::GetBroadphase() -{ - return m_dynamicsWorld->getBroadphase(); +{ + return m_dynamicsWorld->getBroadphase(); } btDispatcher* CcdPhysicsEnvironment::GetDispatcher() -{ +{ return m_dynamicsWorld->getDispatcher(); } @@ -2096,7 +2096,7 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment() //first delete scene, then dispatcher, because pairs have to release manifolds on the dispatcher //delete m_dispatcher; delete m_dynamicsWorld; - + if (NULL != m_ownPairCache) delete m_ownPairCache; @@ -2141,10 +2141,10 @@ float CcdPhysicsEnvironment::GetConstraintParam(int constraintId,int param) { case PHY_GENERIC_6DOF_CONSTRAINT: { - + switch (param) { - case 0: case 1: case 2: + case 0: case 1: case 2: { //param = 0..2 are linear constraint values btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint; @@ -2183,7 +2183,7 @@ void CcdPhysicsEnvironment::SetConstraintParam(int constraintId,int param,float { case PHY_GENERIC_6DOF_CONSTRAINT: { - + switch (param) { case 0: case 1: case 2: case 3: case 4: case 5: @@ -2473,7 +2473,7 @@ bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0 // additional check for sensor object if (proxy0->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger) { - // this is a sensor object, the other one can't be a sensor object because + // this is a sensor object, the other one can't be a sensor object because // they exclude each other in the above test assert(!(proxy1->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger)); colObj0 = (btCollisionObject*)proxy0->m_clientObject; @@ -2530,7 +2530,7 @@ PHY_ICharacter* CcdPhysicsEnvironment::GetCharacterController(KX_GameObject *ob) PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radius,const MT_Vector3& position) { - + CcdConstructionInfo cinfo; memset(&cinfo, 0, sizeof(cinfo)); /* avoid uninitialized values */ cinfo.m_collisionShape = new btSphereShape(radius); // memory leak! The shape is not deleted by Bullet and we cannot add it to the KX_Scene.m_shapes list @@ -2550,7 +2550,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2])); CcdPhysicsController* sphereController = new CcdPhysicsController(cinfo); - + return sphereController; } @@ -2592,7 +2592,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btRigidBody* rb0 = c0 ? c0->GetRigidBody() : 0; btRigidBody* rb1 = c1 ? c1->GetRigidBody() : 0; - + bool rb0static = rb0 ? rb0->isStaticOrKinematicObject() : true; @@ -2606,7 +2606,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btVector3 pivotInA(pivotX,pivotY,pivotZ); - + //it might be a soft body, let's try btSoftBody* sb0 = c0 ? c0->GetSoftBody() : 0; @@ -2658,7 +2658,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl } default: { - + } }; */ @@ -2674,7 +2674,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl } } - + } return 0;//can't remove soft body anchors yet } @@ -2719,7 +2719,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl } default: { - + } };*/ @@ -2735,7 +2735,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl sb1->setMass(node,0.f); } } - + } return 0;//can't remove soft body anchors yet @@ -2743,15 +2743,15 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl if (rb0static && rb1static) { - + return 0; } - + if (!rb0) return 0; - btVector3 pivotInB = rb1 ? rb1->getCenterOfMassTransform().inverse()(rb0->getCenterOfMassTransform()(pivotInA)) : + btVector3 pivotInB = rb1 ? rb1->getCenterOfMassTransform().inverse()(rb0->getCenterOfMassTransform()(pivotInA)) : rb0->getCenterOfMassTransform() * pivotInA; btVector3 axisInA(axisX,axisY,axisZ); @@ -2801,13 +2801,13 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl { btTransform frameInA; btTransform frameInB; - + btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z); if (axis1.length() == 0.0f) { btPlaneSpace1( axisInA, axis1, axis2 ); } - + frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(), axisInA.y(), axis1.y(), axis2.y(), axisInA.z(), axis1.z(), axis2.z() ); @@ -2816,7 +2816,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btTransform inv = rb1->getCenterOfMassTransform().inverse(); btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA; - + frameInB = inv * globalFrameA; bool useReferenceFrameA = true; @@ -2830,7 +2830,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl static btRigidBody s_fixedObject2( 0,0,0); btTransform frameInA; btTransform frameInB; - + btVector3 axis1, axis2; btPlaneSpace1( axisInA, axis1, axis2 ); @@ -2859,7 +2859,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl genericConstraint->setUserConstraintType(type); //64 bit systems can't cast pointer to int. could use size_t instead. return genericConstraint->getUserConstraintId(); - } + } break; } @@ -2870,18 +2870,18 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btConeTwistConstraint* coneTwistContraint = 0; - + if (rb1) { btTransform frameInA; btTransform frameInB; - + btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z); if (axis1.length() == 0.0f) { btPlaneSpace1( axisInA, axis1, axis2 ); } - + frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(), axisInA.y(), axis1.y(), axis2.y(), axisInA.z(), axis1.z(), axis2.z() ); @@ -2890,9 +2890,9 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btTransform inv = rb1->getCenterOfMassTransform().inverse(); btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA; - + frameInB = inv * globalFrameA; - + coneTwistContraint = new btConeTwistConstraint( *rb0,*rb1, frameInA,frameInB); @@ -2902,7 +2902,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl static btRigidBody s_fixedObject2( 0,0,0); btTransform frameInA; btTransform frameInB; - + btVector3 axis1, axis2; btPlaneSpace1( axisInA, axis1, axis2 ); @@ -2930,7 +2930,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl coneTwistContraint->setUserConstraintType(type); //64 bit systems can't cast pointer to int. could use size_t instead. return coneTwistContraint->getUserConstraintId(); - } + } @@ -2953,26 +2953,26 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl // having btHingeConstraint fill in the blanks any way it wants to. btTransform frameInA; btTransform frameInB; - + btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z); if (axis1.length() == 0.0f) { btPlaneSpace1( axisInA, axis1, axis2 ); } - + // Internally btHingeConstraint's hinge-axis is z frameInA.getBasis().setValue( axis1.x(), axis2.x(), axisInA.x(), axis1.y(), axis2.y(), axisInA.y(), axis1.z(), axis2.z(), axisInA.z() ); - + frameInA.setOrigin( pivotInA ); btTransform inv = rb1->getCenterOfMassTransform().inverse(); btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA; - + frameInB = inv * globalFrameA; - + hinge = new btHingeConstraint(*rb0,*rb1,frameInA,frameInB); @@ -2982,7 +2982,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btTransform frameInA; btTransform frameInB; - + btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z); if (axis1.length() == 0.0f) { @@ -3055,7 +3055,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float conera cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_STATIC_OBJECT; DefaultMotionState* motionState = new DefaultMotionState(); cinfo.m_MotionState = motionState; - + // we will add later the possibility to select the filter from option cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter; cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter; @@ -3068,7 +3068,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float conera return sphereController; } - + float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid) { // For soft body constraints @@ -3092,8 +3092,8 @@ float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid) void CcdPhysicsEnvironment::ExportFile(const char* filename) { btDefaultSerializer* serializer = new btDefaultSerializer(); - - + + for (int i=0;i<m_dynamicsWorld->getNumCollisionObjects();i++) { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index a64d2c8f15f..2c7b009a1f8 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -4,8 +4,8 @@ Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 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. @@ -72,7 +72,7 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment protected: btIDebugDraw* m_debugDrawer; - + class btDefaultCollisionConfiguration* m_collisionConfiguration; class btBroadphaseInterface* m_broadphase; // broadphase for dynamic world // for culling only @@ -81,7 +81,7 @@ protected: //solver iterations int m_numIterations; - + //timestep subdivisions int m_numTimeSubSteps; @@ -183,9 +183,9 @@ protected: const btVector3& angularMaxLimits,int flags ); - + virtual void SetConstraintParam(int constraintId,int param,float value,float value1); - + virtual float GetConstraintParam(int constraintId,int param); virtual void RemoveConstraintById(int constraintid); @@ -223,7 +223,7 @@ protected: //These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position); virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight); - + virtual int GetNumContactPoints(); @@ -232,7 +232,7 @@ protected: ////////////////////// //CcdPhysicsEnvironment interface //////////////////////// - + void AddCcdPhysicsController(CcdPhysicsController* ctrl); bool RemoveCcdPhysicsController(CcdPhysicsController* ctrl); @@ -247,7 +247,7 @@ protected: void RemoveCcdGraphicController(CcdGraphicController* ctrl); - /** + /** * Update all physics controllers shape which use the same shape construction info. * Call RecreateControllerShape on controllers which use the same shape * construction info that argument shapeInfo. @@ -259,7 +259,7 @@ protected: btDbvtBroadphase* GetCullingTree() { return m_cullingTree; } btDispatcher* GetDispatcher(); - + bool IsSatCollisionDetectionEnabled() const { @@ -271,17 +271,17 @@ protected: m_enableSatCollisionDetection = enableSat; } - + const btPersistentManifold* GetManifold(int index) const; - + void SyncMotionStates(float timeStep); class btSoftRigidDynamicsWorld* GetDynamicsWorld() { return m_dynamicsWorld; } - + class btConstraintSolver* GetConstraintSolver(); void MergeEnvironment(PHY_IPhysicsEnvironment *other_env); @@ -304,24 +304,24 @@ protected: bRigidBodyJointConstraint *dat); protected: - - + + std::set<CcdPhysicsController*> m_controllers; PHY_ResponseCallback m_triggerCallbacks[PHY_NUM_RESPONSE]; void* m_triggerCallbacksUserPtrs[PHY_NUM_RESPONSE]; - + std::vector<WrapperVehicle*> m_wrapperVehicles; - //use explicit btSoftRigidDynamicsWorld/btDiscreteDynamicsWorld* so that we have access to - //btDiscreteDynamicsWorld::addRigidBody(body,filter,group) - //so that we can set the body collision filter/group at the time of creation + //use explicit btSoftRigidDynamicsWorld/btDiscreteDynamicsWorld* so that we have access to + //btDiscreteDynamicsWorld::addRigidBody(body,filter,group) + //so that we can set the body collision filter/group at the time of creation //and not afterwards (breaks the collision system for radar/near sensor) //Ideally we would like to have access to this function from the btDynamicsWorld interface //class btDynamicsWorld* m_dynamicsWorld; class btSoftRigidDynamicsWorld* m_dynamicsWorld; - + class btConstraintSolver* m_solver; class btOverlappingPairCache* m_ownPairCache; @@ -336,7 +336,7 @@ protected: virtual void ExportFile(const char* filename); - + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsEnvironment") #endif |