mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Merge pull request #7667 from AndrewMeadows/fix-entity-server-crash
fix entity-server crash when entity moves out of bounds
This commit is contained in:
commit
4bf98a80b9
7 changed files with 22 additions and 11 deletions
|
@ -926,7 +926,8 @@ void EntityItem::simulateKinematicMotion(float timeElapsed, bool setFlags) {
|
|||
glm::quat dQ = computeBulletRotationStep(localAngularVelocity, dt);
|
||||
rotation = glm::normalize(dQ * rotation);
|
||||
|
||||
setRotation(rotation);
|
||||
bool success;
|
||||
setOrientation(rotation, success, false);
|
||||
}
|
||||
|
||||
setLocalAngularVelocity(localAngularVelocity);
|
||||
|
@ -1983,10 +1984,10 @@ void EntityItem::locationChanged(bool tellPhysics) {
|
|||
requiresRecalcBoxes();
|
||||
if (tellPhysics) {
|
||||
_dirtyFlags |= Simulation::DIRTY_TRANSFORM;
|
||||
}
|
||||
EntityTreePointer tree = getTree();
|
||||
if (tree) {
|
||||
tree->entityChanged(getThisPointer());
|
||||
EntityTreePointer tree = getTree();
|
||||
if (tree) {
|
||||
tree->entityChanged(getThisPointer());
|
||||
}
|
||||
}
|
||||
SpatiallyNestable::locationChanged(tellPhysics); // tell all the children, also
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ void EntitySimulation::updateEntities() {
|
|||
callUpdateOnEntitiesThatNeedIt(now);
|
||||
moveSimpleKinematics(now);
|
||||
updateEntitiesInternal(now);
|
||||
PerformanceTimer perfTimer("sortingEntities");
|
||||
sortEntitiesThatMoved();
|
||||
}
|
||||
|
||||
|
@ -133,10 +134,8 @@ void EntitySimulation::callUpdateOnEntitiesThatNeedIt(const quint64& now) {
|
|||
|
||||
// protected
|
||||
void EntitySimulation::sortEntitiesThatMoved() {
|
||||
QMutexLocker lock(&_mutex);
|
||||
// NOTE: this is only for entities that have been moved by THIS EntitySimulation.
|
||||
// External changes to entity position/shape are expected to be sorted outside of the EntitySimulation.
|
||||
PerformanceTimer perfTimer("sortingEntities");
|
||||
MovingEntitiesOperator moveOperator(_entityTree);
|
||||
AACube domainBounds(glm::vec3((float)-HALF_TREE_SCALE), (float)TREE_SCALE);
|
||||
SetOfEntities::iterator itemItr = _entitiesToSort.begin();
|
||||
|
|
|
@ -92,7 +92,7 @@ protected:
|
|||
|
||||
void expireMortalEntities(const quint64& now);
|
||||
void callUpdateOnEntitiesThatNeedIt(const quint64& now);
|
||||
void sortEntitiesThatMoved();
|
||||
virtual void sortEntitiesThatMoved();
|
||||
|
||||
QMutex _mutex{ QMutex::Recursive };
|
||||
|
||||
|
|
|
@ -132,3 +132,12 @@ void SimpleEntitySimulation::clearEntitiesInternal() {
|
|||
_entitiesThatNeedSimulationOwner.clear();
|
||||
}
|
||||
|
||||
void SimpleEntitySimulation::sortEntitiesThatMoved() {
|
||||
SetOfEntities::iterator itemItr = _entitiesToSort.begin();
|
||||
while (itemItr != _entitiesToSort.end()) {
|
||||
EntityItemPointer entity = *itemItr;
|
||||
entity->computePuffedQueryAACube();
|
||||
++itemItr;
|
||||
}
|
||||
EntitySimulation::sortEntitiesThatMoved();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ protected:
|
|||
virtual void changeEntityInternal(EntityItemPointer entity) override;
|
||||
virtual void clearEntitiesInternal() override;
|
||||
|
||||
virtual void sortEntitiesThatMoved() override;
|
||||
|
||||
SetOfEntities _entitiesWithSimulationOwner;
|
||||
SetOfEntities _entitiesThatNeedSimulationOwner;
|
||||
quint64 _nextOwnerlessExpiry { 0 };
|
||||
|
|
|
@ -620,7 +620,7 @@ glm::vec3 SpatiallyNestable::getLocalPosition() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setLocalPosition(const glm::vec3& position) {
|
||||
void SpatiallyNestable::setLocalPosition(const glm::vec3& position, bool tellPhysics) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(position)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalPosition -- position contains NaN";
|
||||
|
@ -629,7 +629,7 @@ void SpatiallyNestable::setLocalPosition(const glm::vec3& position) {
|
|||
_transformLock.withWriteLock([&] {
|
||||
_transform.setTranslation(position);
|
||||
});
|
||||
locationChanged();
|
||||
locationChanged(tellPhysics);
|
||||
}
|
||||
|
||||
glm::quat SpatiallyNestable::getLocalOrientation() const {
|
||||
|
|
|
@ -102,7 +102,7 @@ public:
|
|||
virtual void setLocalTransform(const Transform& transform);
|
||||
|
||||
virtual glm::vec3 getLocalPosition() const;
|
||||
virtual void setLocalPosition(const glm::vec3& position);
|
||||
virtual void setLocalPosition(const glm::vec3& position, bool tellPhysics = true);
|
||||
|
||||
virtual glm::quat getLocalOrientation() const;
|
||||
virtual void setLocalOrientation(const glm::quat& orientation);
|
||||
|
|
Loading…
Reference in a new issue