1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 11:22:45 +01:00

Merge ClosestNotMeRaycastCallback into header

This commit is contained in:
Daniel Evans 2015-04-04 20:00:59 +01:00
parent 12f717c67e
commit 2f2e099ca6
3 changed files with 24 additions and 40 deletions

View File

@ -0,0 +1,22 @@
#pragma once
#include <bullet/btBulletDynamicsCommon.h>
/**
* Implements raycast callback that ignores a specified btCollisionObject
*/
class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
{
btCollisionObject* _self;
public:
ClosestNotMeRayResultCallback( btCollisionObject* self, const btVector3& from, const btVector3& to )
: ClosestRayResultCallback( from, to ), _self( self ) {}
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
{
if( rayResult.m_collisionObject == _self ) {
return 1.0;
}
return ClosestRayResultCallback::addSingleResult( rayResult, normalInWorldSpace );
}
};

View File

@ -2,7 +2,7 @@
#include <objects/CharacterObject.hpp>
#include <engine/GameWorld.hpp>
#include <BulletDynamics/Vehicle/btRaycastVehicle.h>
#include <sys/stat.h>
#include <dynamics/RaycastCallbacks.hpp>
#include <data/CollisionModel.hpp>
#include <data/Skeleton.hpp>
#include <render/Model.hpp>
@ -718,25 +718,6 @@ void VehicleObject::destroyObjectHinge(Part* part)
}
}
// Dammnit Bullet
class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
{
btCollisionObject* _self;
public:
ClosestNotMeRayResultCallback( btCollisionObject* self, const btVector3& from, const btVector3& to )
: ClosestRayResultCallback( from, to ), _self( self ) {}
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
{
if( rayResult.m_collisionObject == _self ) {
return 1.0;
}
return ClosestRayResultCallback::addSingleResult( rayResult, normalInWorldSpace );
}
};
void *VehicleRaycaster::castRay(const btVector3 &from, const btVector3 &to, btVehicleRaycaster::btVehicleRaycasterResult &result)
{
ClosestNotMeRayResultCallback rayCallback( _vehicle->physBody, from, to );

View File

@ -12,29 +12,10 @@
#include <items/WeaponItem.hpp>
#include <engine/GameWorld.hpp>
#include <script/ScriptMachine.hpp>
#include <dynamics/RaycastCallbacks.hpp>
#define AUTOLOOK_TIME 2.f
/**
* This should be kept in rwengine/physics
*/
class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
{
btCollisionObject* _self;
public:
ClosestNotMeRayResultCallback( btCollisionObject* self, const btVector3& from, const btVector3& to )
: ClosestRayResultCallback( from, to ), _self( self ) {}
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
{
if( rayResult.m_collisionObject == _self ) {
return 1.0;
}
return ClosestRayResultCallback::addSingleResult( rayResult, normalInWorldSpace );
}
};
IngameState::IngameState(RWGame* game, bool test)
: State(game), started(false), test(test), autolookTimer(0.f)
{