mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:09:52 +02:00
remove support for sub-contactAddecCallbacks from PhysicsEngine
This commit is contained in:
parent
dba7cadcae
commit
434af8bdfb
3 changed files with 10 additions and 52 deletions
|
@ -284,10 +284,12 @@ bool CharacterController::checkForSupport(btCollisionWorld* collisionWorld) {
|
||||||
_numStuckSubsteps = NUM_SUBSTEPS_FOR_SAFE_LANDING_RETRY;
|
_numStuckSubsteps = NUM_SUBSTEPS_FOR_SAFE_LANDING_RETRY;
|
||||||
_stuckTransitionCount = 0;
|
_stuckTransitionCount = 0;
|
||||||
if (_isStuck) {
|
if (_isStuck) {
|
||||||
_physicsEngine->addContactAddedCallback(applyPairwiseFilter);
|
// enable pairwise filter
|
||||||
|
_physicsEngine->setContactAddedCallback(applyPairwiseFilter);
|
||||||
_pairwiseFilter.incrementStepCount();
|
_pairwiseFilter.incrementStepCount();
|
||||||
} else {
|
} else {
|
||||||
_physicsEngine->removeContactAddedCallback(applyPairwiseFilter);
|
// disable pairwise filter
|
||||||
|
_physicsEngine->setContactAddedCallback(nullptr);
|
||||||
_appliedStuckRecoveryStrategy = false;
|
_appliedStuckRecoveryStrategy = false;
|
||||||
_pairwiseFilter.clearAllEntries();
|
_pairwiseFilter.clearAllEntries();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,29 +27,6 @@
|
||||||
#include "ThreadSafeDynamicsWorld.h"
|
#include "ThreadSafeDynamicsWorld.h"
|
||||||
#include "PhysicsLogging.h"
|
#include "PhysicsLogging.h"
|
||||||
|
|
||||||
// a list of sub-callbacks
|
|
||||||
std::vector<PhysicsEngine::ContactAddedCallback> _contactAddedCallbacks;
|
|
||||||
|
|
||||||
// a callback that calls each sub-callback in the list
|
|
||||||
// if one returns 'true' --> break and return
|
|
||||||
bool globalContactAddedCallback(btManifoldPoint& cp,
|
|
||||||
const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0,
|
|
||||||
const btCollisionObjectWrapper* colObj1Wrap, int partId1, int index1) {
|
|
||||||
// call each callback
|
|
||||||
for (auto cb : _contactAddedCallbacks) {
|
|
||||||
if (cb(cp, colObj0Wrap, partId0, index0, colObj1Wrap, partId1, index1)) {
|
|
||||||
// Not a Bullet convention, but one we are using for sub-callbacks:
|
|
||||||
// a return value of 'true' indicates the contact has been "disabled"
|
|
||||||
// in which case there is no need to process other callbacks
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// by Bullet convention for its gContactAddedCallback feature:
|
|
||||||
// the return value is currently ignored but to be future-proof:
|
|
||||||
// return true when friction has been modified
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
PhysicsEngine::PhysicsEngine(const glm::vec3& offset) :
|
PhysicsEngine::PhysicsEngine(const glm::vec3& offset) :
|
||||||
_originOffset(offset),
|
_originOffset(offset),
|
||||||
_myAvatarController(nullptr) {
|
_myAvatarController(nullptr) {
|
||||||
|
@ -843,31 +820,11 @@ void PhysicsEngine::setShowBulletConstraintLimits(bool value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsEngine::addContactAddedCallback(PhysicsEngine::ContactAddedCallback newCb) {
|
void PhysicsEngine::setContactAddedCallback(PhysicsEngine::ContactAddedCallback newCb) {
|
||||||
for (auto cb : _contactAddedCallbacks) {
|
// gContactAddedCallback is a special feature hook in Bullet
|
||||||
if (cb == newCb) {
|
// if non-null AND one of the colliding objects has btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK flag set
|
||||||
// newCb is already in the list
|
// then it is called whenever a new candidate contact point is created
|
||||||
return;
|
gContactAddedCallback = newCb;
|
||||||
}
|
|
||||||
}
|
|
||||||
_contactAddedCallbacks.push_back(newCb);
|
|
||||||
gContactAddedCallback = globalContactAddedCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsEngine::removeContactAddedCallback(PhysicsEngine::ContactAddedCallback cb) {
|
|
||||||
int32_t numCallbacks = (int32_t)(_contactAddedCallbacks.size());
|
|
||||||
for (int32_t i = 0; i < numCallbacks; ++i) {
|
|
||||||
if (_contactAddedCallbacks[i] == cb) {
|
|
||||||
// found it --> remove it
|
|
||||||
_contactAddedCallbacks[i] = _contactAddedCallbacks[numCallbacks - 1];
|
|
||||||
_contactAddedCallbacks.pop_back();
|
|
||||||
numCallbacks--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (numCallbacks == 0) {
|
|
||||||
gContactAddedCallback = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AllContactsCallback : public btCollisionWorld::ContactResultCallback {
|
struct AllContactsCallback : public btCollisionWorld::ContactResultCallback {
|
||||||
|
|
|
@ -154,8 +154,7 @@ public:
|
||||||
// See PhysicsCollisionGroups.h for mask flags.
|
// See PhysicsCollisionGroups.h for mask flags.
|
||||||
std::vector<ContactTestResult> contactTest(uint16_t mask, const ShapeInfo& regionShapeInfo, const Transform& regionTransform, uint16_t group = USER_COLLISION_GROUP_DYNAMIC, float threshold = 0.0f) const;
|
std::vector<ContactTestResult> contactTest(uint16_t mask, const ShapeInfo& regionShapeInfo, const Transform& regionTransform, uint16_t group = USER_COLLISION_GROUP_DYNAMIC, float threshold = 0.0f) const;
|
||||||
|
|
||||||
void addContactAddedCallback(ContactAddedCallback cb);
|
void setContactAddedCallback(ContactAddedCallback cb);
|
||||||
void removeContactAddedCallback(ContactAddedCallback cb);
|
|
||||||
|
|
||||||
btDiscreteDynamicsWorld* getDynamicsWorld() const { return _dynamicsWorld; }
|
btDiscreteDynamicsWorld* getDynamicsWorld() const { return _dynamicsWorld; }
|
||||||
void removeContacts(ObjectMotionState* motionState);
|
void removeContacts(ObjectMotionState* motionState);
|
||||||
|
|
Loading…
Reference in a new issue