Browse Source

Fixed segfault, added debug build

ogre-integration
Macoy Madson 1 year ago
parent
commit
66b46b42a4
4 changed files with 82 additions and 23 deletions
  1. +1
    -1
      .dir-locals.el
  2. +14
    -15
      Jamrules
  3. +63
    -7
      src/PhysicsVehicle.cpp
  4. +4
    -0
      src/PhysicsVehicle.hpp

+ 1
- 1
.dir-locals.el View File

@ -1,5 +1,5 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((c++-mode . ((compile-command . "cd /home/macoy/Development/code/repositories/spargus-vehicle-prototype && jam -j4 && ./spargus_vehicle_prototype")))
((c++-mode . ((compile-command . "cd /home/macoy/Development/code/repositories/spargus-vehicle-prototype && ./Build_Debug.sh && ./spargus_vehicle_prototype")))
(c-or-c++-mode . ((codesearch-dir-to-index . "/home/macoy/Development/code/repositories/spargus-vehicle-prototype"))))

+ 14
- 15
Jamrules View File

@ -14,14 +14,14 @@ LINK = clang++ ;
# Arguments used on all projects, regardless of any variables
# BT_USE_DOUBLE_PRECISION solves the Dantzig LCP missing definition
C++FLAGS = -std=c++11 -Wall -Wextra -Wno-unused-parameter -DBT_USE_DOUBLE_PRECISION ;
C++FLAGS = -std=c++11 -Wall -Wextra -Wno-unused-parameter -DBT_USE_DOUBLE_PRECISION -g ;
HDRS = src bullet3/src base2.0 ;
# Enable debug symbols
ALLLIBSC++FLAGS = -g ;
# Required arguments for linux
# LINUXC++FLAGS = -g ;
if $(DEBUG_BUILD)
{ BULLET3_BUILD_DIR = bullet3/build_cmake_debug ; }
else
{ BULLET3_BUILD_DIR = bullet3/build_cmake ; }
OPTIM = -O0 ;
@ -40,10 +40,10 @@ LINKLIBS =
-Lbase2.0 -lBase20
# Bullet libraries
-Lbullet3/build_cmake/src/BulletDynamics
-Lbullet3/build_cmake/src/BulletCollision
-Lbullet3/build_cmake/src/Bullet3Common
-Lbullet3/build_cmake/src/LinearMath
-L$(BULLET3_BUILD_DIR)/src/BulletDynamics
-L$(BULLET3_BUILD_DIR)/src/BulletCollision
-L$(BULLET3_BUILD_DIR)/src/Bullet3Common
-L$(BULLET3_BUILD_DIR)/src/LinearMath
-lBullet3Common
-lBulletDynamics
@ -51,9 +51,9 @@ LINKLIBS =
-lLinearMath
# Stuff I'm not using, but could use
# -Lbullet3/build_cmake/src/BulletSoftBody
# -Lbullet3/build_cmake/src/BulletInverseDynamics
# -Lbullet3/build_cmake/src/Bullet3InverseDynamicsUtils
# -L$(BULLET3_BUILD_DIR)/src/BulletSoftBody
# -L$(BULLET3_BUILD_DIR)/src/BulletInverseDynamics
# -L$(BULLET3_BUILD_DIR)/src/Bullet3InverseDynamicsUtils
# -lBulletSoftBody
# -lBulletInverseDynamics
# -lBulletInverseDynamicsUtils
@ -62,9 +62,8 @@ LINKLIBS =
# LINKFLAGS = -Wl,-rpath,. ;
# TODO: Copy libs to better directory, or static link?
LINKFLAGS =
-Wl,-rpath,.:bullet3/build_cmake/src/BulletSoftBody:bullet3/build_cmake/Extras/InverseDynamics:bullet3/build_cmake/src/BulletInverseDynamics:bullet3/build_cmake/examples/ThirdPartyLibs/Gwen:bullet3/build_cmake/examples/ThirdPartyLibs/BussIK:bullet3/build_cmake/src/BulletDynamics:bullet3/build_cmake/src/BulletCollision:bullet3/build_cmake/src/LinearMath:bullet3/build_cmake/src/Bullet3Common:bullet3/build_cmake/src/Bullet3Collision
;
LINKFLAGS = -g
-Wl,-rpath,.:$(BULLET3_BUILD_DIR)/src/BulletSoftBody:$(BULLET3_BUILD_DIR)/Extras/InverseDynamics:$(BULLET3_BUILD_DIR)/src/BulletInverseDynamics:$(BULLET3_BUILD_DIR)/examples/ThirdPartyLibs/BussIK:$(BULLET3_BUILD_DIR)/src/BulletDynamics:$(BULLET3_BUILD_DIR)/src/BulletCollision:$(BULLET3_BUILD_DIR)/src/LinearMath:$(BULLET3_BUILD_DIR)/src/Bullet3Common:$(BULLET3_BUILD_DIR)/src/Bullet3Collision ;
##
## Jam stuff


+ 63
- 7
src/PhysicsVehicle.cpp View File

@ -40,11 +40,8 @@ btScalar suspensionRestLength(0.6);
// Vehicle implementation
//
PhysicsVehicle::PhysicsVehicle(PhysicsWorld& physicsWorld)
PhysicsVehicle::PhysicsVehicle(PhysicsWorld& physicsWorld) : ownerWorld(physicsWorld)
{
vehicleRayCaster = new btDefaultVehicleRaycaster(physicsWorld.world);
vehicle = new btRaycastVehicle(tuning, carChassis, vehicleRayCaster);
// Create chassis
{
btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f, 0.5f, 2.f));
@ -74,11 +71,14 @@ PhysicsVehicle::PhysicsVehicle(PhysicsWorld& physicsWorld)
transform.setOrigin(btVector3(0, 0.f, 0));
carChassis = physicsWorld.localCreateRigidBody(800, transform, compound);
// m_carChassis->setDamping(0.2,0.2);
// carChassis->setDamping(0.2,0.2);
/// never deactivate the vehicle
carChassis->setActivationState(DISABLE_DEACTIVATION);
}
/// never deactivate the vehicle
carChassis->setActivationState(DISABLE_DEACTIVATION);
vehicleRayCaster = new btDefaultVehicleRaycaster(physicsWorld.world);
vehicle = new btRaycastVehicle(tuning, carChassis, vehicleRayCaster);
physicsWorld.world->addVehicle(vehicle);
@ -118,6 +118,62 @@ PhysicsVehicle::PhysicsVehicle(PhysicsWorld& physicsWorld)
wheel.m_frictionSlip = wheelFriction;
wheel.m_rollInfluence = rollInfluence;
}
Reset();
}
void PhysicsVehicle::Reset()
{
gVehicleSteering = 0.f;
gBreakingForce = defaultBreakingForce;
gEngineForce = 0.f;
carChassis->setCenterOfMassTransform(btTransform::getIdentity());
carChassis->setLinearVelocity(btVector3(0, 0, 0));
carChassis->setAngularVelocity(btVector3(0, 0, 0));
ownerWorld.world->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(
carChassis->getBroadphaseHandle(), ownerWorld.world->getDispatcher());
if (vehicle)
{
vehicle->resetSuspension();
for (int i = 0; i < vehicle->getNumWheels(); i++)
{
// synchronize the wheels with the (interpolated) chassis worldtransform
vehicle->updateWheelTransform(i, true);
}
}
// btTransform liftTrans;
// liftTrans.setIdentity();
// liftTrans.setOrigin(m_liftStartPos);
// liftBody->activate();
// liftBody->setCenterOfMassTransform(liftTrans);
// liftBody->setLinearVelocity(btVector3(0, 0, 0));
// liftBody->setAngularVelocity(btVector3(0, 0, 0));
// btTransform forkTrans;
// forkTrans.setIdentity();
// forkTrans.setOrigin(m_forkStartPos);
// m_forkBody->activate();
// m_forkBody->setCenterOfMassTransform(forkTrans);
// m_forkBody->setLinearVelocity(btVector3(0, 0, 0));
// m_forkBody->setAngularVelocity(btVector3(0, 0, 0));
// // m_liftHinge->setLimit(-LIFT_EPS, LIFT_EPS);
// m_liftHinge->setLimit(0.0f, 0.0f);
// m_liftHinge->enableAngularMotor(false, 0, 0);
// m_forkSlider->setLowerLinLimit(0.1f);
// m_forkSlider->setUpperLinLimit(0.1f);
// m_forkSlider->setPoweredLinMotor(false);
// btTransform loadTrans;
// loadTrans.setIdentity();
// loadTrans.setOrigin(m_loadStartPos);
// m_loadBody->activate();
// m_loadBody->setCenterOfMassTransform(loadTrans);
// m_loadBody->setLinearVelocity(btVector3(0, 0, 0));
// m_loadBody->setAngularVelocity(btVector3(0, 0, 0));
}
void PhysicsVehicle::Update(float deltaTime)


+ 4
- 0
src/PhysicsVehicle.hpp View File

@ -14,9 +14,13 @@ struct PhysicsVehicle
btVehicleRaycaster* vehicleRayCaster;
btRaycastVehicle* vehicle;
PhysicsWorld& ownerWorld;
// For cleanup only
std::vector<btCollisionShape*> collisionShapes;
PhysicsVehicle(PhysicsWorld& physicsWorld);
void Update(float deltaTime);
void Reset();
};

Loading…
Cancel
Save