mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 09:29:02 +02:00
fix animating entities
This commit is contained in:
parent
23bb8608b1
commit
fb1c075a12
3 changed files with 25 additions and 18 deletions
|
@ -153,7 +153,7 @@ bool RenderableModelEntityItem::needsUpdateModelBounds() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMovingRelativeToParent() || isAnimatingSomething()) {
|
if (isAnimatingSomething()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,14 +195,10 @@ void RenderableModelEntityItem::updateModelBounds() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* adebug TODO: figure out if we need to DO anything when isAnimatingSomething()
|
bool updateRenderItems = false;
|
||||||
if (isAnimatingSomething()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (model->needsReload()) {
|
if (model->needsReload()) {
|
||||||
model->updateGeometry();
|
model->updateGeometry();
|
||||||
|
updateRenderItems = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model->getScaleToFitDimensions() != getDimensions() ||
|
if (model->getScaleToFitDimensions() != getDimensions() ||
|
||||||
|
@ -217,23 +213,28 @@ void RenderableModelEntityItem::updateModelBounds() {
|
||||||
// now recalculate the bounds and registration
|
// now recalculate the bounds and registration
|
||||||
model->setScaleToFit(true, getDimensions());
|
model->setScaleToFit(true, getDimensions());
|
||||||
model->setSnapModelToRegistrationPoint(true, getRegistrationPoint());
|
model->setSnapModelToRegistrationPoint(true, getRegistrationPoint());
|
||||||
|
updateRenderItems = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
auto transform = getTransform(success);
|
auto transform = getTransform(success);
|
||||||
if (success) {
|
if (success && (model->getTranslation() != transform.getTranslation() ||
|
||||||
if (model->getTranslation() != transform.getTranslation()) {
|
model->getRotation() != transform.getRotation())) {
|
||||||
model->setTranslation(transform.getTranslation());
|
model->setTransformNoUpdateRenderItems(transform);
|
||||||
}
|
updateRenderItems = true;
|
||||||
if (model->getRotation() != transform.getRotation()) {
|
|
||||||
model->setRotation(transform.getRotation());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_needsInitialSimulation || _needsJointSimulation) {
|
if (_needsInitialSimulation || _needsJointSimulation || isAnimatingSomething()) {
|
||||||
|
// NOTE: on isAnimatingSomething() we need to call Model::simulate() which calls Rig::updateRig()
|
||||||
|
// TODO: there is opportunity to further optimize the isAnimatingSomething() case.
|
||||||
model->simulate(0.0f);
|
model->simulate(0.0f);
|
||||||
_needsInitialSimulation = false;
|
_needsInitialSimulation = false;
|
||||||
_needsJointSimulation = false;
|
_needsJointSimulation = false;
|
||||||
|
updateRenderItems = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateRenderItems) {
|
||||||
|
model->updateRenderItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,7 +930,6 @@ void RenderableModelEntityItem::copyAnimationJointDataToModel() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// relay any inbound joint changes from scripts/animation/network to the model/rig
|
// relay any inbound joint changes from scripts/animation/network to the model/rig
|
||||||
_jointDataLock.withWriteLock([&] {
|
_jointDataLock.withWriteLock([&] {
|
||||||
for (int index = 0; index < _localJointData.size(); ++index) {
|
for (int index = 0; index < _localJointData.size(); ++index) {
|
||||||
|
|
|
@ -121,8 +121,6 @@ bool Model::needsFixupInScene() const {
|
||||||
return (_needsFixupInScene || !_addedToScene) && !_needsReload && isLoaded();
|
return (_needsFixupInScene || !_addedToScene) && !_needsReload && isLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO?: should we combine translation and rotation into single method to avoid double-work?
|
|
||||||
// (figure out where we call these)
|
|
||||||
void Model::setTranslation(const glm::vec3& translation) {
|
void Model::setTranslation(const glm::vec3& translation) {
|
||||||
_translation = translation;
|
_translation = translation;
|
||||||
updateRenderItems();
|
updateRenderItems();
|
||||||
|
@ -133,6 +131,14 @@ void Model::setRotation(const glm::quat& rotation) {
|
||||||
updateRenderItems();
|
updateRenderItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// temporary HACK: set transform while avoiding implicit calls to updateRenderItems()
|
||||||
|
// TODO: make setRotation() and friends set flag to be used later to decide to updateRenderItems()
|
||||||
|
void Model::setTransformNoUpdateRenderItems(const Transform& transform) {
|
||||||
|
_translation = transform.getTranslation();
|
||||||
|
_rotation = transform.getRotation();
|
||||||
|
// DO NOT call updateRenderItems() here!
|
||||||
|
}
|
||||||
|
|
||||||
Transform Model::getTransform() const {
|
Transform Model::getTransform() const {
|
||||||
if (_spatiallyNestableOverride) {
|
if (_spatiallyNestableOverride) {
|
||||||
bool success;
|
bool success;
|
||||||
|
|
|
@ -206,6 +206,7 @@ public:
|
||||||
|
|
||||||
void setTranslation(const glm::vec3& translation);
|
void setTranslation(const glm::vec3& translation);
|
||||||
void setRotation(const glm::quat& rotation);
|
void setRotation(const glm::quat& rotation);
|
||||||
|
void setTransformNoUpdateRenderItems(const Transform& transform); // temporary HACK
|
||||||
|
|
||||||
const glm::vec3& getTranslation() const { return _translation; }
|
const glm::vec3& getTranslation() const { return _translation; }
|
||||||
const glm::quat& getRotation() const { return _rotation; }
|
const glm::quat& getRotation() const { return _rotation; }
|
||||||
|
|
Loading…
Reference in a new issue