mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-25 20:10:19 +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);
|
glm::quat dQ = computeBulletRotationStep(localAngularVelocity, dt);
|
||||||
rotation = glm::normalize(dQ * rotation);
|
rotation = glm::normalize(dQ * rotation);
|
||||||
|
|
||||||
setRotation(rotation);
|
bool success;
|
||||||
|
setOrientation(rotation, success, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocalAngularVelocity(localAngularVelocity);
|
setLocalAngularVelocity(localAngularVelocity);
|
||||||
|
@ -1983,10 +1984,10 @@ void EntityItem::locationChanged(bool tellPhysics) {
|
||||||
requiresRecalcBoxes();
|
requiresRecalcBoxes();
|
||||||
if (tellPhysics) {
|
if (tellPhysics) {
|
||||||
_dirtyFlags |= Simulation::DIRTY_TRANSFORM;
|
_dirtyFlags |= Simulation::DIRTY_TRANSFORM;
|
||||||
}
|
EntityTreePointer tree = getTree();
|
||||||
EntityTreePointer tree = getTree();
|
if (tree) {
|
||||||
if (tree) {
|
tree->entityChanged(getThisPointer());
|
||||||
tree->entityChanged(getThisPointer());
|
}
|
||||||
}
|
}
|
||||||
SpatiallyNestable::locationChanged(tellPhysics); // tell all the children, also
|
SpatiallyNestable::locationChanged(tellPhysics); // tell all the children, also
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ void EntitySimulation::updateEntities() {
|
||||||
callUpdateOnEntitiesThatNeedIt(now);
|
callUpdateOnEntitiesThatNeedIt(now);
|
||||||
moveSimpleKinematics(now);
|
moveSimpleKinematics(now);
|
||||||
updateEntitiesInternal(now);
|
updateEntitiesInternal(now);
|
||||||
|
PerformanceTimer perfTimer("sortingEntities");
|
||||||
sortEntitiesThatMoved();
|
sortEntitiesThatMoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,10 +134,8 @@ void EntitySimulation::callUpdateOnEntitiesThatNeedIt(const quint64& now) {
|
||||||
|
|
||||||
// protected
|
// protected
|
||||||
void EntitySimulation::sortEntitiesThatMoved() {
|
void EntitySimulation::sortEntitiesThatMoved() {
|
||||||
QMutexLocker lock(&_mutex);
|
|
||||||
// NOTE: this is only for entities that have been moved by THIS EntitySimulation.
|
// 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.
|
// External changes to entity position/shape are expected to be sorted outside of the EntitySimulation.
|
||||||
PerformanceTimer perfTimer("sortingEntities");
|
|
||||||
MovingEntitiesOperator moveOperator(_entityTree);
|
MovingEntitiesOperator moveOperator(_entityTree);
|
||||||
AACube domainBounds(glm::vec3((float)-HALF_TREE_SCALE), (float)TREE_SCALE);
|
AACube domainBounds(glm::vec3((float)-HALF_TREE_SCALE), (float)TREE_SCALE);
|
||||||
SetOfEntities::iterator itemItr = _entitiesToSort.begin();
|
SetOfEntities::iterator itemItr = _entitiesToSort.begin();
|
||||||
|
|
|
@ -92,7 +92,7 @@ protected:
|
||||||
|
|
||||||
void expireMortalEntities(const quint64& now);
|
void expireMortalEntities(const quint64& now);
|
||||||
void callUpdateOnEntitiesThatNeedIt(const quint64& now);
|
void callUpdateOnEntitiesThatNeedIt(const quint64& now);
|
||||||
void sortEntitiesThatMoved();
|
virtual void sortEntitiesThatMoved();
|
||||||
|
|
||||||
QMutex _mutex{ QMutex::Recursive };
|
QMutex _mutex{ QMutex::Recursive };
|
||||||
|
|
||||||
|
|
|
@ -132,3 +132,12 @@ void SimpleEntitySimulation::clearEntitiesInternal() {
|
||||||
_entitiesThatNeedSimulationOwner.clear();
|
_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 changeEntityInternal(EntityItemPointer entity) override;
|
||||||
virtual void clearEntitiesInternal() override;
|
virtual void clearEntitiesInternal() override;
|
||||||
|
|
||||||
|
virtual void sortEntitiesThatMoved() override;
|
||||||
|
|
||||||
SetOfEntities _entitiesWithSimulationOwner;
|
SetOfEntities _entitiesWithSimulationOwner;
|
||||||
SetOfEntities _entitiesThatNeedSimulationOwner;
|
SetOfEntities _entitiesThatNeedSimulationOwner;
|
||||||
quint64 _nextOwnerlessExpiry { 0 };
|
quint64 _nextOwnerlessExpiry { 0 };
|
||||||
|
|
|
@ -620,7 +620,7 @@ glm::vec3 SpatiallyNestable::getLocalPosition() const {
|
||||||
return result;
|
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
|
// guard against introducing NaN into the transform
|
||||||
if (isNaN(position)) {
|
if (isNaN(position)) {
|
||||||
qDebug() << "SpatiallyNestable::setLocalPosition -- position contains NaN";
|
qDebug() << "SpatiallyNestable::setLocalPosition -- position contains NaN";
|
||||||
|
@ -629,7 +629,7 @@ void SpatiallyNestable::setLocalPosition(const glm::vec3& position) {
|
||||||
_transformLock.withWriteLock([&] {
|
_transformLock.withWriteLock([&] {
|
||||||
_transform.setTranslation(position);
|
_transform.setTranslation(position);
|
||||||
});
|
});
|
||||||
locationChanged();
|
locationChanged(tellPhysics);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat SpatiallyNestable::getLocalOrientation() const {
|
glm::quat SpatiallyNestable::getLocalOrientation() const {
|
||||||
|
|
|
@ -102,7 +102,7 @@ public:
|
||||||
virtual void setLocalTransform(const Transform& transform);
|
virtual void setLocalTransform(const Transform& transform);
|
||||||
|
|
||||||
virtual glm::vec3 getLocalPosition() const;
|
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 glm::quat getLocalOrientation() const;
|
||||||
virtual void setLocalOrientation(const glm::quat& orientation);
|
virtual void setLocalOrientation(const glm::quat& orientation);
|
||||||
|
|
Loading…
Reference in a new issue