mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
Merge ClosestNotMeRaycastCallback into header
This commit is contained in:
parent
12f717c67e
commit
2f2e099ca6
22
rwengine/include/dynamics/RaycastCallbacks.hpp
Normal file
22
rwengine/include/dynamics/RaycastCallbacks.hpp
Normal 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 );
|
||||
}
|
||||
};
|
@ -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 );
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user