enabled the vehicle demo again (still needs lots of tuning before it drives well)
fixed some warnings
This commit is contained in:
@@ -66,7 +66,7 @@ class btOverlappingPairCache : public btBroadphaseInterface
|
||||
|
||||
inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
|
||||
{
|
||||
bool collides = proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask;
|
||||
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
|
||||
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
|
||||
|
||||
return collides;
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
int getNumManifolds() const
|
||||
{
|
||||
return m_manifoldsPtr.size();
|
||||
return int( m_manifoldsPtr.size());
|
||||
}
|
||||
|
||||
btPersistentManifold** getInternalManifoldPointer()
|
||||
|
||||
@@ -79,26 +79,26 @@ struct btCollisionObject
|
||||
inline bool mergesSimulationIslands() const
|
||||
{
|
||||
///static objects, kinematic and object without contact response don't merge islands
|
||||
return !(m_collisionFlags & (CF_STATIC_OBJECT | CF_KINEMATIC_OJBECT | CF_NO_CONTACT_RESPONSE) );
|
||||
return ((m_collisionFlags & (CF_STATIC_OBJECT | CF_KINEMATIC_OJBECT | CF_NO_CONTACT_RESPONSE) )==0);
|
||||
}
|
||||
|
||||
|
||||
inline bool isStaticObject() const {
|
||||
return m_collisionFlags & CF_STATIC_OBJECT;
|
||||
return (m_collisionFlags & CF_STATIC_OBJECT) != 0;
|
||||
}
|
||||
|
||||
inline bool isKinematicObject() const
|
||||
{
|
||||
return m_collisionFlags & CF_KINEMATIC_OJBECT;
|
||||
return (m_collisionFlags & CF_KINEMATIC_OJBECT) != 0;
|
||||
}
|
||||
|
||||
inline bool isStaticOrKinematicObject() const
|
||||
{
|
||||
return m_collisionFlags & (CF_KINEMATIC_OJBECT | CF_STATIC_OBJECT);
|
||||
return (m_collisionFlags & (CF_KINEMATIC_OJBECT | CF_STATIC_OBJECT)) != 0 ;
|
||||
}
|
||||
|
||||
inline bool hasContactResponse() const {
|
||||
return !(m_collisionFlags & CF_NO_CONTACT_RESPONSE);
|
||||
return (m_collisionFlags & CF_NO_CONTACT_RESPONSE)==0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
|
||||
int getNumCollisionObjects() const
|
||||
{
|
||||
return m_collisionObjects.size();
|
||||
return int(m_collisionObjects.size());
|
||||
}
|
||||
|
||||
/// rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
|
||||
#include "LinearMath/btScalar.h"
|
||||
#include "btSimulationIslandManager.h"
|
||||
#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
|
||||
@@ -51,7 +53,7 @@ void btSimulationIslandManager::findUnions(btDispatcher* dispatcher)
|
||||
void btSimulationIslandManager::updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher)
|
||||
{
|
||||
|
||||
initUnionFind(colWorld->getCollisionObjectArray().size());
|
||||
initUnionFind( int (colWorld->getCollisionObjectArray().size()));
|
||||
|
||||
// put the index into m_controllers into m_tag
|
||||
{
|
||||
@@ -253,7 +255,7 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
|
||||
}
|
||||
}
|
||||
|
||||
int numManifolds = islandmanifold.size();
|
||||
int numManifolds = int (islandmanifold.size());
|
||||
|
||||
// Sort manifolds, based on islands
|
||||
// Sort the vector using predicate and std::sort
|
||||
|
||||
@@ -45,7 +45,7 @@ class btUnionFind
|
||||
|
||||
inline int getNumElements() const
|
||||
{
|
||||
return m_elements.size();
|
||||
return int(m_elements.size());
|
||||
}
|
||||
inline bool isRoot(int x) const
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
int getNumChildShapes() const
|
||||
{
|
||||
return m_childShapes.size();
|
||||
return int (m_childShapes.size());
|
||||
}
|
||||
|
||||
btCollisionShape* getChildShape(int index)
|
||||
|
||||
@@ -390,7 +390,7 @@ void btDiscreteDynamicsWorld::solveNoncontactConstraints(btContactSolverInfo& so
|
||||
BEGIN_PROFILE("solveNoncontactConstraints");
|
||||
|
||||
int i;
|
||||
int numConstraints = m_constraints.size();
|
||||
int numConstraints = int(m_constraints.size());
|
||||
|
||||
///constraint preparation: building jacobians
|
||||
for (i=0;i< numConstraints ; i++ )
|
||||
@@ -424,7 +424,7 @@ void btDiscreteDynamicsWorld::calculateSimulationIslands()
|
||||
|
||||
{
|
||||
int i;
|
||||
int numConstraints = m_constraints.size();
|
||||
int numConstraints = int(m_constraints.size());
|
||||
for (i=0;i< numConstraints ; i++ )
|
||||
{
|
||||
btTypedConstraint* constraint = m_constraints[i];
|
||||
@@ -691,10 +691,10 @@ void btDiscreteDynamicsWorld::debugDrawObject(const btTransform& worldTransform,
|
||||
float radius = coneShape->getRadius();//+coneShape->getMargin();
|
||||
float height = coneShape->getHeight();//+coneShape->getMargin();
|
||||
btVector3 start = worldTransform.getOrigin();
|
||||
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(0,0,0.5*height),start+worldTransform.getBasis() * btVector3(radius,0,-0.5*height),color);
|
||||
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(0,0,0.5*height),start+worldTransform.getBasis() * btVector3(-radius,0,-0.5*height),color);
|
||||
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(0,0,0.5*height),start+worldTransform.getBasis() * btVector3(0,radius,-0.5*height),color);
|
||||
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(0,0,0.5*height),start+worldTransform.getBasis() * btVector3(0,-radius,-0.5*height),color);
|
||||
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(0.f,0.f,0.5f*height),start+worldTransform.getBasis() * btVector3(radius,0.f,-0.5f*height),color);
|
||||
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(0.f,0.f,0.5f*height),start+worldTransform.getBasis() * btVector3(-radius,0.f,-0.5f*height),color);
|
||||
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(0.f,0.f,0.5f*height),start+worldTransform.getBasis() * btVector3(0.f,radius,-0.5f*height),color);
|
||||
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(0.f,0.f,0.5f*height),start+worldTransform.getBasis() * btVector3(0.f,-radius,-0.5f*height),color);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ subject to the following restrictions:
|
||||
|
||||
#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
|
||||
class btTypedConstraint;
|
||||
class btRaycastVehicle;
|
||||
|
||||
///btDynamicsWorld is the baseclass for several dynamics implementation, basic, discrete, parallel, and continuous
|
||||
class btDynamicsWorld : public btCollisionWorld
|
||||
@@ -47,6 +48,11 @@ class btDynamicsWorld : public btCollisionWorld
|
||||
|
||||
virtual void removeConstraint(btTypedConstraint* constraint) {};
|
||||
|
||||
virtual void addVehicle(btRaycastVehicle* vehicle) {};
|
||||
|
||||
virtual void removeVehicle(btRaycastVehicle* vehicle) {};
|
||||
|
||||
|
||||
virtual void setDebugDrawer(btIDebugDraw* debugDrawer) = 0;
|
||||
|
||||
virtual btIDebugDraw* getDebugDrawer() = 0;
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
* It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "btRaycastVehicle.h"
|
||||
#include "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h"
|
||||
#include "BulletDynamics/ConstraintSolver/btJacobianEntry.h"
|
||||
#include "LinearMath/btQuaternion.h"
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
|
||||
#include "btVehicleRaycaster.h"
|
||||
#include "btWheelInfo.h"
|
||||
|
||||
@@ -141,8 +142,12 @@ void btRaycastVehicle::updateWheelTransformsWS(btWheelInfo& wheel )
|
||||
{
|
||||
wheel.m_raycastInfo.m_isInContact = false;
|
||||
|
||||
const btTransform& chassisTrans = getRigidBody()->getCenterOfMassTransform();
|
||||
|
||||
btTransform chassisTrans;
|
||||
if (getRigidBody()->getMotionState())
|
||||
getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
|
||||
else
|
||||
chassisTrans = getRigidBody()->getCenterOfMassTransform();
|
||||
|
||||
wheel.m_raycastInfo.m_hardPointWS = chassisTrans( wheel.m_chassisConnectionPointCS );
|
||||
wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.getBasis() * wheel.m_wheelDirectionCS ;
|
||||
wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.getBasis() * wheel.m_wheelAxleCS;
|
||||
@@ -166,6 +171,8 @@ btScalar btRaycastVehicle::rayCast(btWheelInfo& wheel)
|
||||
|
||||
btVehicleRaycaster::btVehicleRaycasterResult rayResults;
|
||||
|
||||
assert(m_vehicleRaycaster);
|
||||
|
||||
void* object = m_vehicleRaycaster->castRay(source,target,rayResults);
|
||||
|
||||
wheel.m_raycastInfo.m_groundObject = 0;
|
||||
@@ -593,3 +600,28 @@ void btRaycastVehicle::updateFriction(btScalar timeStep)
|
||||
delete[]forwardImpulse;
|
||||
delete[] sideImpulse;
|
||||
}
|
||||
|
||||
|
||||
void* btDefaultVehicleRaycaster::castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result)
|
||||
{
|
||||
// RayResultCallback& resultCallback;
|
||||
|
||||
btCollisionWorld::ClosestRayResultCallback rayCallback(from,to);
|
||||
|
||||
m_dynamicsWorld->rayTest(from, to, rayCallback);
|
||||
|
||||
if (rayCallback.HasHit())
|
||||
{
|
||||
|
||||
btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
|
||||
if (body)
|
||||
{
|
||||
result.m_hitPointInWorld = rayCallback.m_hitPointWorld;
|
||||
result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld;
|
||||
result.m_hitNormalInWorld.normalize();
|
||||
result.m_distFraction = rayCallback.m_closestHitFraction;
|
||||
return body;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
|
||||
#include "BulletDynamics/Dynamics/btRigidBody.h"
|
||||
#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
|
||||
|
||||
#include "btVehicleRaycaster.h"
|
||||
class btDynamicsWorld;
|
||||
|
||||
#include "btWheelInfo.h"
|
||||
|
||||
struct btVehicleRaycaster;
|
||||
class btVehicleTuning;
|
||||
|
||||
///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
btWheelInfo& addWheel( const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS,btScalar suspensionRestLength,btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel);
|
||||
|
||||
inline int getNumWheels() const {
|
||||
return m_wheelInfo.size();
|
||||
return int (m_wheelInfo.size());
|
||||
}
|
||||
|
||||
std::vector<btWheelInfo> m_wheelInfo;
|
||||
@@ -163,5 +163,19 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class btDefaultVehicleRaycaster : public btVehicleRaycaster
|
||||
{
|
||||
btDynamicsWorld* m_dynamicsWorld;
|
||||
public:
|
||||
btDefaultVehicleRaycaster(btDynamicsWorld* world)
|
||||
:m_dynamicsWorld(world)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //RAYCASTVEHICLE_H
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ struct btDefaultMotionState : public btMotionState
|
||||
btTransform m_startWorldTrans;
|
||||
void* m_userPointer;
|
||||
|
||||
btDefaultMotionState(const btTransform& startTrans,const btTransform& centerOfMassOffset = btTransform::getIdentity())
|
||||
btDefaultMotionState(const btTransform& startTrans = btTransform::getIdentity(),const btTransform& centerOfMassOffset = btTransform::getIdentity())
|
||||
: m_graphicsWorldTrans(startTrans),
|
||||
m_centerOfMassOffset(centerOfMassOffset),
|
||||
m_startWorldTrans(startTrans),
|
||||
|
||||
@@ -49,11 +49,12 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/BroadphaseCollision/btAxisSweep3.h"
|
||||
|
||||
|
||||
///Math library
|
||||
///Math library & Utils
|
||||
#include "LinearMath/btQuaternion.h"
|
||||
#include "LinearMath/btTransform.h"
|
||||
|
||||
|
||||
#include "LinearMath/btDefaultMotionState.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
|
||||
#endif //BULLET_COLLISION_COMMON_H
|
||||
|
||||
|
||||
@@ -34,5 +34,8 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //BULLET_DYNAMICS_COMMON_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user