1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-09 20:32:43 +01:00

Add isStopped() in VehicleObject and CharacterObject

This commit is contained in:
Jannik Vogel 2016-06-11 13:25:41 +02:00
parent 63711a55ab
commit d1131a63a8
4 changed files with 20 additions and 15 deletions

View File

@ -132,6 +132,12 @@ public:
void setPrimaryColour(uint8_t color);
void setSecondaryColour(uint8_t color);
/**
* @brief isStopped
* @return True if the vehicle isn't moving
*/
bool isStopped() const;
private:
void registerPart(ModelFrame* mf);

View File

@ -467,8 +467,11 @@ bool CharacterObject::enterVehicle(VehicleObject* vehicle, size_t seat)
bool CharacterObject::isStopped() const
{
RW_UNIMPLEMENTED("Checking if character is stopped");
return true;
if (currentVehicle != nullptr) {
return currentVehicle->isStopped();
}
return controller->getCurrentActivity() == nullptr;
}
VehicleObject *CharacterObject::getCurrentVehicle() const

View File

@ -752,6 +752,11 @@ void VehicleObject::setSecondaryColour(uint8_t color)
colourSecondary = engine->data->vehicleColours[color];
}
bool VehicleObject::isStopped() const
{
return fabsf(physVehicle->getCurrentSpeedKmHour()) < 0.75f;
}
void *VehicleRaycaster::castRay(const btVector3 &from, const btVector3 &to, btVehicleRaycaster::btVehicleRaycasterResult &result)
{
ClosestNotMeRayResultCallback rayCallback( _vehicle->physBody, from, to );

View File

@ -687,21 +687,12 @@ bool game_character_stoped_in_volume(const ScriptArguments& args)
glm::vec3 pp = character->getPosition();
if( pp.x >= min.x && pp.y >= min.y && pp.z >= min.z &&
pp.x <= max.x && pp.y <= max.y && pp.z <= max.z )
{
if( character->getCurrentVehicle() != nullptr )
{
return character->getCurrentVehicle()->physVehicle->getCurrentSpeedKmHour() < 0.75f;
}
else
{
return character->controller->getCurrentActivity() == nullptr;
}
if (pp.x >= min.x && pp.y >= min.y && pp.z >= min.z &&
pp.x <= max.x && pp.y <= max.y && pp.z <= max.z) {
return character->isStopped();
}
if( drawCylinder )
{
if (drawCylinder) {
args.getWorld()->drawAreaIndicator(AreaIndicatorInfo::Cylinder, (max+min)/2.f, (max-min)/2.f);
}