mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 03:44:26 +02:00
Merge pull request #5542 from ZappoMan/RenderableModelEntityItemOptimization
Renderable model entity item optimizations
This commit is contained in:
commit
b26d6d2b9c
4 changed files with 17 additions and 10 deletions
libraries
animation/src
entities-renderer/src
entities/src
|
@ -230,11 +230,13 @@ void JointState::setRotationInConstrainedFrame(glm::quat targetRotation, float p
|
|||
}
|
||||
|
||||
void JointState::setRotationInConstrainedFrameInternal(const glm::quat& targetRotation) {
|
||||
glm::quat parentRotation = computeParentRotation();
|
||||
_rotationInConstrainedFrame = targetRotation;
|
||||
_transformChanged = true;
|
||||
// R' = Rp * Rpre * r' * Rpost
|
||||
_rotation = parentRotation * _preRotation * _rotationInConstrainedFrame * _postRotation;
|
||||
if (_rotationInConstrainedFrame != targetRotation) {
|
||||
glm::quat parentRotation = computeParentRotation();
|
||||
_rotationInConstrainedFrame = targetRotation;
|
||||
_transformChanged = true;
|
||||
// R' = Rp * Rpre * r' * Rpost
|
||||
_rotation = parentRotation * _preRotation * _rotationInConstrainedFrame * _postRotation;
|
||||
}
|
||||
}
|
||||
|
||||
void JointState::setVisibleRotationInConstrainedFrame(const glm::quat& targetRotation) {
|
||||
|
|
|
@ -275,9 +275,12 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
}
|
||||
|
||||
if (jointsMapped()) {
|
||||
auto frameData = getAnimationFrame();
|
||||
for (int i = 0; i < frameData.size(); i++) {
|
||||
_model->setJointState(i, true, frameData[i]);
|
||||
bool newFrame;
|
||||
auto frameData = getAnimationFrame(newFrame);
|
||||
if (newFrame) {
|
||||
for (int i = 0; i < frameData.size(); i++) {
|
||||
_model->setJointState(i, true, frameData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,8 @@ void ModelEntityItem::mapJoints(const QStringList& modelJointNames) {
|
|||
}
|
||||
}
|
||||
|
||||
const QVector<glm::quat>& ModelEntityItem::getAnimationFrame() {
|
||||
const QVector<glm::quat>& ModelEntityItem::getAnimationFrame(bool& newFrame) {
|
||||
newFrame = false;
|
||||
|
||||
if (!hasAnimation() || !_jointMappingCompleted) {
|
||||
return _lastKnownFrameData;
|
||||
|
@ -238,6 +239,7 @@ const QVector<glm::quat>& ModelEntityItem::getAnimationFrame() {
|
|||
|
||||
if (animationFrameIndex != _lastKnownFrameIndex) {
|
||||
_lastKnownFrameIndex = animationFrameIndex;
|
||||
newFrame = true;
|
||||
|
||||
const QVector<glm::quat>& rotations = frames[animationFrameIndex].rotations;
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
float getAnimationLastFrame() const { return _animationLoop.getLastFrame(); }
|
||||
|
||||
void mapJoints(const QStringList& modelJointNames);
|
||||
const QVector<glm::quat>& getAnimationFrame();
|
||||
const QVector<glm::quat>& getAnimationFrame(bool& newFrame);
|
||||
bool jointsMapped() const { return _jointMappingCompleted; }
|
||||
|
||||
bool getAnimationIsPlaying() const { return _animationLoop.isRunning(); }
|
||||
|
|
Loading…
Reference in a new issue