Allow place item and rescue on driveable objects
This commit is contained in:
parent
ade94465b3
commit
64442e5ac9
@ -2659,10 +2659,16 @@ void Track::itemCommand(const XMLNode *node)
|
||||
#ifndef DEBUG
|
||||
m_track_mesh->castRay(loc, loc + (-10000 * quad_normal), &hit_point,
|
||||
&m, &normal);
|
||||
m_track_object_manager->castRay(loc,
|
||||
loc + (-10000 * quad_normal), &hit_point, &m, &normal,
|
||||
/*interpolate*/false);
|
||||
#else
|
||||
bool drop_success = m_track_mesh->castRay(loc, loc +
|
||||
(-10000 * quad_normal), &hit_point, &m, &normal);
|
||||
if (!drop_success)
|
||||
bool over_driveable = m_track_object_manager->castRay(loc,
|
||||
loc + (-10000 * quad_normal), &hit_point, &m, &normal,
|
||||
/*interpolate*/false);
|
||||
if (!drop_success && !over_driveable)
|
||||
{
|
||||
Log::warn("track",
|
||||
"Item at position (%f,%f,%f) can not be dropped",
|
||||
@ -2746,7 +2752,15 @@ bool Track::findGround(AbstractKart *kart)
|
||||
Vec3 hit_point, normal;
|
||||
bool over_ground = m_track_mesh->castRay(xyz, down, &hit_point,
|
||||
&m, &normal);
|
||||
if(!over_ground)
|
||||
|
||||
// Now also raycast against all track objects (that are driveable). If
|
||||
// there should be a closer result (than the one against the main track
|
||||
// mesh), its data will be returned.
|
||||
// From TerrainInfo::update
|
||||
bool over_driveable = m_track_object_manager->castRay(xyz, down,
|
||||
&hit_point, &m, &normal, /*interpolate*/false);
|
||||
|
||||
if (!over_ground && !over_driveable)
|
||||
{
|
||||
Log::warn("physics", "Kart at (%f %f %f) can not be dropped.",
|
||||
xyz.getX(),xyz.getY(),xyz.getZ());
|
||||
|
@ -215,12 +215,13 @@ void TrackObjectManager::update(float dt)
|
||||
* variable will be set.
|
||||
|
||||
*/
|
||||
void TrackObjectManager::castRay(const btVector3 &from,
|
||||
const btVector3 &to, btVector3 *hit_point,
|
||||
bool TrackObjectManager::castRay(const btVector3 &from,
|
||||
const btVector3 &to, btVector3 *hit_point,
|
||||
const Material **material,
|
||||
btVector3 *normal,
|
||||
bool interpolate_normal) const
|
||||
{
|
||||
bool result = false;
|
||||
float distance = 9999.9f;
|
||||
// If there was a hit already, compute the current distance
|
||||
if(*material)
|
||||
@ -249,9 +250,11 @@ void TrackObjectManager::castRay(const btVector3 &from,
|
||||
*hit_point = new_hit_point;
|
||||
*normal = new_normal;
|
||||
distance = new_distance;
|
||||
result = true;
|
||||
} // if new_distance < distance
|
||||
} // if hit
|
||||
} // for all track objects.
|
||||
return result;
|
||||
} // castRay
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
void update(float dt);
|
||||
void handleExplosion(const Vec3 &pos, const PhysicalObject *mp,
|
||||
bool secondary_hits=true);
|
||||
void castRay(const btVector3 &from,
|
||||
bool castRay(const btVector3 &from,
|
||||
const btVector3 &to, btVector3 *hit_point,
|
||||
const Material **material, btVector3 *normal = NULL,
|
||||
bool interpolate_normal = false) const;
|
||||
|
Loading…
Reference in New Issue
Block a user