mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-16 01:59:15 +02:00
Merge pull request #7746 from AndrewMeadows/supress-spurious-logs
reduce warnings about truncated kinematic timesteps
This commit is contained in:
commit
8c7ef31636
2 changed files with 28 additions and 16 deletions
|
@ -884,7 +884,24 @@ void EntityItem::simulate(const quint64& now) {
|
|||
}
|
||||
|
||||
bool EntityItem::stepKinematicMotion(float timeElapsed) {
|
||||
// get all the data
|
||||
Transform transform;
|
||||
glm::vec3 linearVelocity;
|
||||
glm::vec3 angularVelocity;
|
||||
getLocalTransformAndVelocities(transform, linearVelocity, angularVelocity);
|
||||
|
||||
// find out if it is moving
|
||||
bool isSpinning = (glm::length2(angularVelocity) > 0.0f);
|
||||
float linearSpeedSquared = glm::length2(linearVelocity);
|
||||
bool isTranslating = linearSpeedSquared > 0.0f;
|
||||
bool moving = isTranslating || isSpinning;
|
||||
if (!moving) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (timeElapsed <= 0.0f) {
|
||||
// someone gave us a useless time value so bail early
|
||||
// but return 'true' because it is moving
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -894,13 +911,7 @@ bool EntityItem::stepKinematicMotion(float timeElapsed) {
|
|||
}
|
||||
timeElapsed = glm::min(timeElapsed, MAX_TIME_ELAPSED);
|
||||
|
||||
Transform transform;
|
||||
glm::vec3 linearVelocity;
|
||||
glm::vec3 angularVelocity;
|
||||
getLocalTransformAndVelocities(transform, linearVelocity, angularVelocity);
|
||||
|
||||
bool moving = false;
|
||||
if (glm::length2(angularVelocity) > 0.0f) {
|
||||
if (isSpinning) {
|
||||
// angular damping
|
||||
if (_angularDamping > 0.0f) {
|
||||
angularVelocity *= powf(1.0f - _angularDamping, timeElapsed);
|
||||
|
@ -922,14 +933,12 @@ bool EntityItem::stepKinematicMotion(float timeElapsed) {
|
|||
}
|
||||
transform.setRotation(rotation);
|
||||
}
|
||||
moving = true;
|
||||
}
|
||||
|
||||
glm::vec3 position = transform.getTranslation();
|
||||
float linearSpeedSquared = glm::length2(linearVelocity);
|
||||
const float MIN_KINEMATIC_LINEAR_SPEED_SQUARED =
|
||||
KINEMATIC_LINEAR_SPEED_THRESHOLD * KINEMATIC_LINEAR_SPEED_THRESHOLD;
|
||||
if (linearSpeedSquared > 0.0f) {
|
||||
if (isTranslating) {
|
||||
glm::vec3 deltaVelocity = Vectors::ZERO;
|
||||
|
||||
// linear damping
|
||||
|
@ -971,14 +980,12 @@ bool EntityItem::stepKinematicMotion(float timeElapsed) {
|
|||
linearVelocity += deltaVelocity;
|
||||
}
|
||||
}
|
||||
moving = true;
|
||||
}
|
||||
|
||||
if (moving) {
|
||||
transform.setTranslation(position);
|
||||
setLocalTransformAndVelocities(transform, linearVelocity, angularVelocity);
|
||||
}
|
||||
return moving;
|
||||
transform.setTranslation(position);
|
||||
setLocalTransformAndVelocities(transform, linearVelocity, angularVelocity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EntityItem::isMoving() const {
|
||||
|
|
|
@ -74,13 +74,18 @@ void EntitySimulation::addEntityInternal(EntityItemPointer entity) {
|
|||
if (entity->isMovingRelativeToParent() && !entity->getPhysicsInfo()) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
_simpleKinematicEntities.insert(entity);
|
||||
entity->setLastSimulated(usecTimestampNow());
|
||||
}
|
||||
}
|
||||
|
||||
void EntitySimulation::changeEntityInternal(EntityItemPointer entity) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
if (entity->isMovingRelativeToParent() && !entity->getPhysicsInfo()) {
|
||||
int numKinematicEntities = _simpleKinematicEntities.size();
|
||||
_simpleKinematicEntities.insert(entity);
|
||||
if (numKinematicEntities != _simpleKinematicEntities.size()) {
|
||||
entity->setLastSimulated(usecTimestampNow());
|
||||
}
|
||||
} else {
|
||||
_simpleKinematicEntities.remove(entity);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue