// // Billboard3DOverlay.cpp // hifi/interface/src/ui/overlays // // Created by Zander Otavka on 8/4/15. // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Billboard3DOverlay.h" Billboard3DOverlay::Billboard3DOverlay(const Billboard3DOverlay* billboard3DOverlay) : Planar3DOverlay(billboard3DOverlay), PanelAttachable(*billboard3DOverlay), Billboardable(*billboard3DOverlay) { } void Billboard3DOverlay::setProperties(const QVariantMap& properties) { Planar3DOverlay::setProperties(properties); PanelAttachable::setProperties(properties); Billboardable::setProperties(properties); } QVariant Billboard3DOverlay::getProperty(const QString &property) { QVariant value; value = Billboardable::getProperty(property); if (value.isValid()) { return value; } value = PanelAttachable::getProperty(property); if (value.isValid()) { return value; } return Planar3DOverlay::getProperty(property); } void Billboard3DOverlay::update(float duration) { // Billboard's transform needs to constantly be adjusted if it faces the avatar // if (isFacingAvatar()) { notifyRenderTransformChange(); // } Base3DOverlay::update(duration); } bool Billboard3DOverlay::applyTransformTo(Transform& transform, bool force) { bool transformChanged = false; if (force || usecTimestampNow() > _transformExpiry) { transformChanged = PanelAttachable::applyTransformTo(transform, true); transformChanged |= pointTransformAtCamera(transform, getOffsetRotation()); } return transformChanged; } Transform Billboard3DOverlay::evalRenderTransform() { Transform transform = getTransform(); bool transformChanged = applyTransformTo(transform, true); // If the transform is not modified, setting the transform to // itself will cause drift over time due to floating point errors. if (transformChanged) { setTransform(transform); } return transform; }