mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
fix collisions for newly added avatars
This commit is contained in:
parent
bd21d0589a
commit
21a4da4d5f
3 changed files with 9 additions and 15 deletions
|
@ -417,7 +417,7 @@ void AvatarManager::buildPhysicsTransaction(PhysicsEngine::Transaction& transact
|
|||
avatar->resetDetailedMotionStates();
|
||||
|
||||
} else {
|
||||
{
|
||||
if (avatar->_motionState == nullptr) {
|
||||
ShapeInfo shapeInfo;
|
||||
avatar->computeShapeInfo(shapeInfo);
|
||||
btCollisionShape* shape = const_cast<btCollisionShape*>(ObjectMotionState::getShapeManager()->getShape(shapeInfo));
|
||||
|
@ -427,21 +427,20 @@ void AvatarManager::buildPhysicsTransaction(PhysicsEngine::Transaction& transact
|
|||
avatar->_motionState = motionState;
|
||||
transaction.objectsToAdd.push_back(motionState);
|
||||
}
|
||||
else {
|
||||
failedShapeBuilds.insert(avatar);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto& detailedMotionStates = avatar->getDetailedMotionStates();
|
||||
if (detailedMotionStates.size() == 0) {
|
||||
for (int i = 0; i < avatar->getJointCount(); i++) {
|
||||
avatar->addNewMotionState(avatar, i);
|
||||
}
|
||||
auto& detailedMotionStates = avatar->getDetailedMotionStates();
|
||||
for (auto& mState : detailedMotionStates) {
|
||||
transaction.objectsToAdd.push_back(mState);
|
||||
}
|
||||
qCDebug(animation) << "Creating " << detailedMotionStates.size() << " detailed motion states from " << avatar->getSessionUUID();
|
||||
}
|
||||
if (avatar->_motionState == nullptr || detailedMotionStates.size() == 0) {
|
||||
failedShapeBuilds.insert(avatar);
|
||||
}
|
||||
}
|
||||
} else if (isInPhysics) {
|
||||
transaction.objectsToChange.push_back(avatar->_motionState);
|
||||
|
|
|
@ -118,7 +118,6 @@ int OtherAvatar::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
}
|
||||
|
||||
void OtherAvatar::addNewMotionState(std::shared_ptr<OtherAvatar> avatar, int jointIndex) {
|
||||
std::lock_guard<std::mutex> lock(_mStateLock);
|
||||
if (jointIndex > -1 && jointIndex < _multiSphereShapes.size()) {
|
||||
auto& data = _multiSphereShapes[jointIndex].getSpheresData();
|
||||
std::vector<btVector3> positions;
|
||||
|
@ -138,10 +137,7 @@ void OtherAvatar::addNewMotionState(std::shared_ptr<OtherAvatar> avatar, int joi
|
|||
}
|
||||
}
|
||||
}
|
||||
const std::vector<DetailedMotionState*>& OtherAvatar::getDetailedMotionStates() {
|
||||
std::lock_guard<std::mutex> lock(_mStateLock);
|
||||
return _detailedMotionStates;
|
||||
}
|
||||
|
||||
void OtherAvatar::resetDetailedMotionStates() {
|
||||
for (size_t i = 0; i < _detailedMotionStates.size(); i++) {
|
||||
_detailedMotionStates[i] = nullptr;
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
int parseDataFromBuffer(const QByteArray& buffer) override;
|
||||
|
||||
bool isInPhysicsSimulation() const { return _motionState != nullptr; }
|
||||
bool isInPhysicsSimulation() const { return _motionState != nullptr && _detailedMotionStates.size() > 0; }
|
||||
void rebuildCollisionShape() override;
|
||||
|
||||
void setWorkloadRegion(uint8_t region);
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
bool needsPhysicsUpdate() const;
|
||||
|
||||
void addNewMotionState(std::shared_ptr<OtherAvatar> avatar, int jointIndex);
|
||||
const std::vector<DetailedMotionState*>& getDetailedMotionStates();
|
||||
const std::vector<DetailedMotionState*>& getDetailedMotionStates() { return _detailedMotionStates; }
|
||||
void resetDetailedMotionStates();
|
||||
|
||||
friend AvatarManager;
|
||||
|
@ -59,7 +59,6 @@ protected:
|
|||
std::vector<DetailedMotionState*> _detailedMotionStates;
|
||||
int32_t _spaceIndex { -1 };
|
||||
uint8_t _workloadRegion { workload::Region::INVALID };
|
||||
std::mutex _mStateLock;
|
||||
};
|
||||
|
||||
using OtherAvatarPointer = std::shared_ptr<OtherAvatar>;
|
||||
|
|
Loading…
Reference in a new issue