Merge pull request #2967 from erwincoumans/master

fix raycast filter masks, they can be negative
This commit is contained in:
erwincoumans 2020-08-03 13:18:27 -07:00 committed by GitHub
commit b623f5d123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 21 deletions

View File

@ -5995,12 +5995,9 @@ struct FilteredClosestRayResultCallback : public btCollisionWorld::ClosestRayRes
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace)
{
if (m_collisionFilterMask >= 0)
{
bool collides = (rayResult.m_collisionObject->getBroadphaseHandle()->m_collisionFilterGroup & m_collisionFilterMask) != 0;
if (!collides)
return m_closestHitFraction;
}
bool collides = (rayResult.m_collisionObject->getBroadphaseHandle()->m_collisionFilterGroup & m_collisionFilterMask) != 0;
if (!collides)
return m_closestHitFraction;
return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
}
};
@ -6019,12 +6016,9 @@ struct FilteredAllHitsRayResultCallback : public btCollisionWorld::AllHitsRayRes
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace)
{
if (m_collisionFilterMask >= 0)
{
bool collides = (rayResult.m_collisionObject->getBroadphaseHandle()->m_collisionFilterGroup & m_collisionFilterMask) != 0;
if (!collides)
return m_closestHitFraction;
}
bool collides = (rayResult.m_collisionObject->getBroadphaseHandle()->m_collisionFilterGroup & m_collisionFilterMask) != 0;
if (!collides)
return m_closestHitFraction;
//remove duplicate hits:
//same collision object, link index and hit fraction
bool isDuplicate = false;

View File

@ -19,7 +19,7 @@ import datetime
import os
import time
import tf.compat.v1 as tf
import tensorflow.compat.v1 as tf
from pybullet_envs.minitaur.envs import minitaur_logging_pb2
NUM_MOTORS = 8

View File

@ -6576,10 +6576,8 @@ static PyObject* pybullet_rayTestObsolete(PyObject* self, PyObject* args, PyObje
to[0], to[1], to[2]);
if (collisionFilterMask >= 0)
{
b3RaycastBatchSetCollisionFilterMask(commandHandle, collisionFilterMask);
}
b3RaycastBatchSetCollisionFilterMask(commandHandle, collisionFilterMask);
if (reportHitNumber >= 0)
{
b3RaycastBatchSetReportHitNumber(commandHandle, reportHitNumber);
@ -6751,10 +6749,8 @@ static PyObject* pybullet_rayTestBatch(PyObject* self, PyObject* args, PyObject*
{
b3RaycastBatchSetReportHitNumber(commandHandle, reportHitNumber);
}
if (collisionFilterMask >= 0)
{
b3RaycastBatchSetCollisionFilterMask(commandHandle, collisionFilterMask);
}
b3RaycastBatchSetCollisionFilterMask(commandHandle, collisionFilterMask);
if (fractionEpsilon >= 0)
{
b3RaycastBatchSetFractionEpsilon(commandHandle, fractionEpsilon);