1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-18 16:32:32 +02:00

Fixed more broken vehicle interaction

This commit is contained in:
Daniel Evans 2014-05-31 19:22:43 +01:00
parent 7acec24597
commit c8f5e7ead2
7 changed files with 17 additions and 9 deletions

View File

@ -9,6 +9,7 @@ class GTAPlayerAIController : public GTAAIController
glm::quat cameraRotation;
glm::vec3 direction;
glm::vec3 _rawDirection;
glm::quat lastRotation;
@ -22,7 +23,7 @@ public:
void updateCameraDirection(const glm::quat& rot);
void updateMovementDirection(const glm::vec3& pos);
void updateMovementDirection(const glm::vec3& pos, const glm::vec3& rawdirection);
void exitVehicle();

View File

@ -24,12 +24,14 @@ struct AnimationGroup
Animation* car_sit;
Animation* car_sit_low;
Animation* car_open_lhs;
Animation* car_getin_lhs;
AnimationGroup()
: idle(nullptr), walk(nullptr), walk_start(nullptr), run(nullptr),
jump_start(nullptr), jump_glide(nullptr), jump_land(nullptr),
car_sit(nullptr), car_sit_low(nullptr), car_getin_lhs(nullptr)
car_sit(nullptr), car_sit_low(nullptr), car_open_lhs(nullptr),
car_getin_lhs(nullptr)
{}
};

View File

@ -90,6 +90,8 @@ bool Activities::EnterVehicle::update(GTACharacter *character, GTAAIController *
if( glm::length(targetDirection) <= 0.4f ) {
entering = true;
// Warp character to vehicle orientation
character->rotation = vehicle->getRotation();
character->enterAction(GTACharacter::VehicleGetIn);
}
else {

View File

@ -20,9 +20,10 @@ void GTAPlayerAIController::updateCameraDirection(const glm::quat& rot)
cameraRotation = rot;
}
void GTAPlayerAIController::updateMovementDirection(const glm::vec3& dir)
void GTAPlayerAIController::updateMovementDirection(const glm::vec3& dir, const glm::vec3 &rawdirection)
{
direction = dir;
_rawDirection = rawdirection;
}
void GTAPlayerAIController::exitVehicle()
@ -73,10 +74,10 @@ void GTAPlayerAIController::update(float dt)
}
if( character->getCurrentVehicle() ) {
character->getCurrentVehicle()->setSteeringAngle(-direction.x * 3.131f);
character->getCurrentVehicle()->setSteeringAngle(_rawDirection.x);
// TODO what is handbraking.
character->getCurrentVehicle()->setThrottle(direction.y);
character->getCurrentVehicle()->setThrottle(-_rawDirection.y);
}
else if( glm::length(direction) > 0.001f ) {
character->rotation = cameraRotation * glm::quat(glm::vec3(0.f, 0.f, -atan2(direction.x, direction.y)));

View File

@ -26,6 +26,7 @@ GTACharacter::GTACharacter(GameWorld* engine, const glm::vec3& pos, const glm::q
animations.car_sit = engine->gameData.animations["car_sit"];
animations.car_sit_low = engine->gameData.animations["car_lsit"];
animations.car_open_lhs = engine->gameData.animations["car_open_lhs"];
animations.car_getin_lhs = engine->gameData.animations["car_getin_lhs"];
if(model) {
@ -136,8 +137,10 @@ void GTACharacter::tick(float dt)
}
} break;
case VehicleGetIn: {
if(animator->getAnimation() != animations.car_getin_lhs) {
animator->setAnimation(animations.car_getin_lhs, false);
if(animator->getAnimation() != animations.car_getin_lhs
&& animator->getAnimation() != animations.car_open_lhs) {
animator->setAnimation(animations.car_open_lhs, false);
animator->queueAnimation(animations.car_getin_lhs);
}
else if( animator->getAnimation() == nullptr ) {
enterAction(Idle);

View File

@ -63,7 +63,7 @@ void IngameState::tick(float dt)
glm::quat vR = glm::normalize(glm::angleAxis(_lookAngles.x, glm::vec3{0.f, 0.f, 1.f}));
_player->updateMovementDirection(vR * _movement);
_player->updateMovementDirection(vR * _movement, _movement);
float viewDistance = _playerCharacter->getCurrentVehicle() ? -3.5f : -2.5f;

View File

@ -68,7 +68,6 @@ BOOST_AUTO_TEST_CASE(test_activities)
controller->setNextActivity( new Activities::EnterVehicle( vehicle, 0 ) );
for(float t = 0.f; t < 0.5f; t+=(1.f/60.f)) {
controller->update(1.f/60.f);
character->tick(1.f/60.f);
Global::get().e->dynamicsWorld->stepSimulation(1.f/60.f);
}