mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
less word salad
This commit is contained in:
parent
3d3bfcf7a3
commit
75b5635d2f
4 changed files with 47 additions and 61 deletions
|
@ -1610,37 +1610,6 @@ void EntityItem::setPosition(const glm::vec3& value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItem::setWorldTransformAndVelocitiesUnlessDirtyFlags(
|
|
||||||
const glm::vec3& position,
|
|
||||||
const glm::quat& orientation,
|
|
||||||
const glm::vec3& linearVelocity,
|
|
||||||
const glm::vec3& angularVelocity) {
|
|
||||||
// only ever call this for harvesting results of physics simulation
|
|
||||||
// if a dirty bit is set then an update arrived (via script or network) overriding the physics simulation
|
|
||||||
uint32_t flags = _dirtyFlags & (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES);
|
|
||||||
if (!flags) {
|
|
||||||
// flags are clear
|
|
||||||
setWorldTransform(position, orientation);
|
|
||||||
setWorldVelocity(linearVelocity);
|
|
||||||
setWorldAngularVelocity(angularVelocity);
|
|
||||||
setLastSimulated(usecTimestampNow());
|
|
||||||
} else {
|
|
||||||
// only set properties NOT flagged
|
|
||||||
if (!(flags & Simulation::DIRTY_TRANSFORM)) {
|
|
||||||
setWorldTransform(position, orientation);
|
|
||||||
}
|
|
||||||
if (!(flags & Simulation::DIRTY_LINEAR_VELOCITY)) {
|
|
||||||
setWorldVelocity(linearVelocity);
|
|
||||||
}
|
|
||||||
if (!(flags & Simulation::DIRTY_ANGULAR_VELOCITY)) {
|
|
||||||
setWorldAngularVelocity(angularVelocity);
|
|
||||||
}
|
|
||||||
if (flags != (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES)) {
|
|
||||||
setLastSimulated(usecTimestampNow());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EntityItem::setParentID(const QUuid& value) {
|
void EntityItem::setParentID(const QUuid& value) {
|
||||||
QUuid oldParentID = getParentID();
|
QUuid oldParentID = getParentID();
|
||||||
if (oldParentID != value) {
|
if (oldParentID != value) {
|
||||||
|
@ -1770,22 +1739,6 @@ void EntityItem::setVelocity(const glm::vec3& value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItem::zeroAllVelocitiesUnlessDirtyFlags() {
|
|
||||||
uint32_t flags = _dirtyFlags & (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES);
|
|
||||||
if (!flags) {
|
|
||||||
setWorldVelocity(glm::vec3(0.0f));
|
|
||||||
setWorldAngularVelocity(glm::vec3(0.0f));
|
|
||||||
} else {
|
|
||||||
if (!(flags & Simulation::DIRTY_LINEAR_VELOCITY)) {
|
|
||||||
setWorldVelocity(glm::vec3(0.0f));
|
|
||||||
}
|
|
||||||
if (!(flags & Simulation::DIRTY_ANGULAR_VELOCITY)) {
|
|
||||||
setWorldAngularVelocity(glm::vec3(0.0f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_acceleration = glm::vec3(0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EntityItem::setDamping(float value) {
|
void EntityItem::setDamping(float value) {
|
||||||
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
|
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
|
|
|
@ -355,7 +355,6 @@ public:
|
||||||
|
|
||||||
void setRotation(glm::quat orientation);
|
void setRotation(glm::quat orientation);
|
||||||
void setVelocity(const glm::vec3& velocity);
|
void setVelocity(const glm::vec3& velocity);
|
||||||
void zeroAllVelocitiesUnlessDirtyFlags();
|
|
||||||
|
|
||||||
uint32_t getDirtyFlags() const;
|
uint32_t getDirtyFlags() const;
|
||||||
void markDirtyFlags(uint32_t mask);
|
void markDirtyFlags(uint32_t mask);
|
||||||
|
@ -370,12 +369,6 @@ public:
|
||||||
|
|
||||||
void setPhysicsInfo(void* data) { _physicsInfo = data; }
|
void setPhysicsInfo(void* data) { _physicsInfo = data; }
|
||||||
|
|
||||||
void setWorldTransformAndVelocitiesUnlessDirtyFlags(
|
|
||||||
const glm::vec3& position,
|
|
||||||
const glm::quat& orientation,
|
|
||||||
const glm::vec3& linearVelocity,
|
|
||||||
const glm::vec3& angularVelocity);
|
|
||||||
|
|
||||||
EntityTreeElementPointer getElement() const { return _element; }
|
EntityTreeElementPointer getElement() const { return _element; }
|
||||||
EntityTreePointer getTree() const;
|
EntityTreePointer getTree() const;
|
||||||
virtual SpatialParentTree* getParentTree() const override;
|
virtual SpatialParentTree* getParentTree() const override;
|
||||||
|
|
|
@ -257,11 +257,31 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
|
||||||
assert(entityTreeIsLocked());
|
assert(entityTreeIsLocked());
|
||||||
measureBodyAcceleration();
|
measureBodyAcceleration();
|
||||||
|
|
||||||
_entity->setWorldTransformAndVelocitiesUnlessDirtyFlags(
|
// If transform or velocities are flagged as dirty it means a network or scripted change
|
||||||
bulletToGLM(worldTrans.getOrigin()),
|
// occured between the beginning and end of the stepSimulation() and we DON'T want to apply
|
||||||
bulletToGLM(worldTrans.getRotation()),
|
// these physics simulation results.
|
||||||
getBodyLinearVelocity(),
|
uint32_t flags = _entity->getDirtyFlags() & (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES);
|
||||||
getBodyAngularVelocity());
|
if (!flags) {
|
||||||
|
// flags are clear
|
||||||
|
_entity->setWorldTransform(bulletToGLM(worldTrans.getOrigin()), bulletToGLM(worldTrans.getRotation()));
|
||||||
|
_entity->setWorldVelocity(getBodyLinearVelocity());
|
||||||
|
_entity->setWorldAngularVelocity(getBodyAngularVelocity());
|
||||||
|
_entity->setLastSimulated(usecTimestampNow());
|
||||||
|
} else {
|
||||||
|
// only set properties NOT flagged
|
||||||
|
if (!(flags & Simulation::DIRTY_TRANSFORM)) {
|
||||||
|
_entity->setWorldTransform(bulletToGLM(worldTrans.getOrigin()), bulletToGLM(worldTrans.getRotation()));
|
||||||
|
}
|
||||||
|
if (!(flags & Simulation::DIRTY_LINEAR_VELOCITY)) {
|
||||||
|
_entity->setWorldVelocity(getBodyLinearVelocity());
|
||||||
|
}
|
||||||
|
if (!(flags & Simulation::DIRTY_ANGULAR_VELOCITY)) {
|
||||||
|
_entity->setWorldAngularVelocity(getBodyAngularVelocity());
|
||||||
|
}
|
||||||
|
if (flags != (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES)) {
|
||||||
|
_entity->setLastSimulated(usecTimestampNow());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_entity->getSimulatorID().isNull()) {
|
if (_entity->getSimulatorID().isNull()) {
|
||||||
_loopsWithoutOwner++;
|
_loopsWithoutOwner++;
|
||||||
|
@ -517,7 +537,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
||||||
|
|
||||||
if (!_body->isActive()) {
|
if (!_body->isActive()) {
|
||||||
// make sure all derivatives are zero
|
// make sure all derivatives are zero
|
||||||
_entity->zeroAllVelocitiesUnlessDirtyFlags();
|
zeroCleanObjectVelocities();
|
||||||
_numInactiveUpdates++;
|
_numInactiveUpdates++;
|
||||||
} else {
|
} else {
|
||||||
glm::vec3 gravity = _entity->getGravity();
|
glm::vec3 gravity = _entity->getGravity();
|
||||||
|
@ -544,7 +564,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
||||||
if (movingSlowly) {
|
if (movingSlowly) {
|
||||||
// velocities might not be zero, but we'll fake them as such, which will hopefully help convince
|
// velocities might not be zero, but we'll fake them as such, which will hopefully help convince
|
||||||
// other simulating observers to deactivate their own copies
|
// other simulating observers to deactivate their own copies
|
||||||
_entity->zeroAllVelocitiesUnlessDirtyFlags();
|
zeroCleanObjectVelocities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_numInactiveUpdates = 0;
|
_numInactiveUpdates = 0;
|
||||||
|
@ -801,3 +821,22 @@ bool EntityMotionState::shouldBeLocallyOwned() const {
|
||||||
void EntityMotionState::upgradeOutgoingPriority(uint8_t priority) {
|
void EntityMotionState::upgradeOutgoingPriority(uint8_t priority) {
|
||||||
_outgoingPriority = glm::max<uint8_t>(_outgoingPriority, priority);
|
_outgoingPriority = glm::max<uint8_t>(_outgoingPriority, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityMotionState::zeroCleanObjectVelocities() const {
|
||||||
|
// If transform or velocities are flagged as dirty it means a network or scripted change
|
||||||
|
// occured between the beginning and end of the stepSimulation() and we DON'T want to apply
|
||||||
|
// these physics simulation results.
|
||||||
|
uint32_t flags = _entity->getDirtyFlags() & (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES);
|
||||||
|
if (!flags) {
|
||||||
|
_entity->setWorldVelocity(glm::vec3(0.0f));
|
||||||
|
_entity->setWorldAngularVelocity(glm::vec3(0.0f));
|
||||||
|
} else {
|
||||||
|
if (!(flags & Simulation::DIRTY_LINEAR_VELOCITY)) {
|
||||||
|
_entity->setWorldVelocity(glm::vec3(0.0f));
|
||||||
|
}
|
||||||
|
if (!(flags & Simulation::DIRTY_ANGULAR_VELOCITY)) {
|
||||||
|
_entity->setWorldAngularVelocity(glm::vec3(0.0f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_entity->setAcceleration(glm::vec3(0.0f));
|
||||||
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// changes _outgoingPriority only if priority is larger
|
// changes _outgoingPriority only if priority is larger
|
||||||
void upgradeOutgoingPriority(uint8_t priority);
|
void upgradeOutgoingPriority(uint8_t priority);
|
||||||
|
void zeroCleanObjectVelocities() const;
|
||||||
|
|
||||||
#ifdef WANT_DEBUG_ENTITY_TREE_LOCKS
|
#ifdef WANT_DEBUG_ENTITY_TREE_LOCKS
|
||||||
bool entityTreeIsLocked() const;
|
bool entityTreeIsLocked() const;
|
||||||
|
|
Loading…
Reference in a new issue