mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
only update cauterization of child entities when something relevant changes
This commit is contained in:
parent
bdf6736a54
commit
14d5029f4d
3 changed files with 36 additions and 11 deletions
|
@ -504,6 +504,16 @@ void MyAvatar::updateEyeContactTarget(float deltaTime) {
|
||||||
extern QByteArray avatarStateToFrame(const AvatarData* _avatar);
|
extern QByteArray avatarStateToFrame(const AvatarData* _avatar);
|
||||||
extern void avatarStateFromFrame(const QByteArray& frameData, AvatarData* _avatar);
|
extern void avatarStateFromFrame(const QByteArray& frameData, AvatarData* _avatar);
|
||||||
|
|
||||||
|
void MyAvatar::beParentOfChild(SpatiallyNestablePointer newChild) const {
|
||||||
|
_cauterizationNeedsUpdate = true;
|
||||||
|
SpatiallyNestable::beParentOfChild(newChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::forgetChild(SpatiallyNestablePointer newChild) const {
|
||||||
|
_cauterizationNeedsUpdate = true;
|
||||||
|
SpatiallyNestable::forgetChild(newChild);
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::updateChildCauterization(SpatiallyNestablePointer object) {
|
void MyAvatar::updateChildCauterization(SpatiallyNestablePointer object) {
|
||||||
if (object->getNestableType() == NestableType::Entity) {
|
if (object->getNestableType() == NestableType::Entity) {
|
||||||
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
|
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
|
||||||
|
@ -516,16 +526,19 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
animateScaleChanges(deltaTime);
|
animateScaleChanges(deltaTime);
|
||||||
|
|
||||||
const std::unordered_set<int>& headBoneSet = _skeletonModel->getCauterizeBoneSet();
|
if (_cauterizationNeedsUpdate) {
|
||||||
forEachChild([&](SpatiallyNestablePointer object) {
|
const std::unordered_set<int>& headBoneSet = _skeletonModel->getCauterizeBoneSet();
|
||||||
bool isChildOfHead = headBoneSet.find(object->getParentJointIndex()) != headBoneSet.end();
|
forEachChild([&](SpatiallyNestablePointer object) {
|
||||||
if (isChildOfHead) {
|
bool isChildOfHead = headBoneSet.find(object->getParentJointIndex()) != headBoneSet.end();
|
||||||
updateChildCauterization(object);
|
if (isChildOfHead) {
|
||||||
object->forEachDescendant([&](SpatiallyNestablePointer descendant) {
|
updateChildCauterization(object);
|
||||||
updateChildCauterization(descendant);
|
object->forEachDescendant([&](SpatiallyNestablePointer descendant) {
|
||||||
});
|
updateChildCauterization(descendant);
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
_cauterizationNeedsUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("transform");
|
PerformanceTimer perfTimer("transform");
|
||||||
|
@ -1438,6 +1451,7 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
||||||
Avatar::setSkeletonModelURL(skeletonModelURL);
|
Avatar::setSkeletonModelURL(skeletonModelURL);
|
||||||
_skeletonModel->setVisibleInScene(true, qApp->getMain3DScene(), render::ItemKey::TAG_BITS_NONE);
|
_skeletonModel->setVisibleInScene(true, qApp->getMain3DScene(), render::ItemKey::TAG_BITS_NONE);
|
||||||
_headBoneSet.clear();
|
_headBoneSet.clear();
|
||||||
|
_cauterizationNeedsUpdate = true;
|
||||||
emit skeletonChanged();
|
emit skeletonChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1809,6 +1823,8 @@ void MyAvatar::initHeadBones() {
|
||||||
}
|
}
|
||||||
q.pop();
|
q.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cauterizationNeedsUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl MyAvatar::getAnimGraphOverrideUrl() const {
|
QUrl MyAvatar::getAnimGraphOverrideUrl() const {
|
||||||
|
@ -1879,6 +1895,7 @@ void MyAvatar::postUpdate(float deltaTime, const render::ScenePointer& scene) {
|
||||||
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
||||||
initAnimGraph();
|
initAnimGraph();
|
||||||
_isAnimatingScale = true;
|
_isAnimatingScale = true;
|
||||||
|
_cauterizationNeedsUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_enableDebugDrawDefaultPose || _enableDebugDrawAnimPose) {
|
if (_enableDebugDrawDefaultPose || _enableDebugDrawAnimPose) {
|
||||||
|
@ -1967,6 +1984,7 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) {
|
||||||
// toggle using the cauterizedBones depending on where the camera is and the rendering pass type.
|
// toggle using the cauterizedBones depending on where the camera is and the rendering pass type.
|
||||||
const bool shouldDrawHead = shouldRenderHead(renderArgs);
|
const bool shouldDrawHead = shouldRenderHead(renderArgs);
|
||||||
if (shouldDrawHead != _prevShouldDrawHead) {
|
if (shouldDrawHead != _prevShouldDrawHead) {
|
||||||
|
_cauterizationNeedsUpdate = true;
|
||||||
_skeletonModel->setEnableCauterization(!shouldDrawHead);
|
_skeletonModel->setEnableCauterization(!shouldDrawHead);
|
||||||
|
|
||||||
for (int i = 0; i < _attachmentData.size(); i++) {
|
for (int i = 0; i < _attachmentData.size(); i++) {
|
||||||
|
|
|
@ -633,6 +633,11 @@ signals:
|
||||||
private slots:
|
private slots:
|
||||||
void leaveDomain();
|
void leaveDomain();
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void beParentOfChild(SpatiallyNestablePointer newChild) const override;
|
||||||
|
virtual void forgetChild(SpatiallyNestablePointer newChild) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& positionOut);
|
bool requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& positionOut);
|
||||||
|
@ -812,6 +817,8 @@ private:
|
||||||
bool _enableDebugDrawIKChains { false };
|
bool _enableDebugDrawIKChains { false };
|
||||||
bool _enableDebugDrawDetailedCollision { false };
|
bool _enableDebugDrawDetailedCollision { false };
|
||||||
|
|
||||||
|
mutable bool _cauterizationNeedsUpdate; // do we need to scan children and update their "cauterized" state?
|
||||||
|
|
||||||
AudioListenerMode _audioListenerMode;
|
AudioListenerMode _audioListenerMode;
|
||||||
glm::vec3 _customListenPosition;
|
glm::vec3 _customListenPosition;
|
||||||
glm::quat _customListenOrientation;
|
glm::quat _customListenOrientation;
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace render {
|
||||||
ItemKey::Builder builder;
|
ItemKey::Builder builder;
|
||||||
builder.withTypeLight();
|
builder.withTypeLight();
|
||||||
builder.withTagBits(ItemKey::TAG_BITS_ALL);
|
builder.withTagBits(ItemKey::TAG_BITS_ALL);
|
||||||
if (!payload) {
|
if (payload) {
|
||||||
if (!payload->isVisible()) {
|
if (!payload->isVisible()) {
|
||||||
builder.withInvisible();
|
builder.withInvisible();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue