Tweak PanelAttachable::setTransforms.

Use reference instead of pointer, and make it virtual.
This commit is contained in:
Zander Otavka 2015-07-24 20:07:38 -07:00
parent c37c3ec2d2
commit 9bd72e5769
4 changed files with 11 additions and 12 deletions

View file

@ -39,7 +39,7 @@ BillboardOverlay::BillboardOverlay(const BillboardOverlay* billboardOverlay) :
{
}
void BillboardOverlay::setTransforms(Transform *transform) {
void BillboardOverlay::setTransforms(Transform& transform) {
PanelAttachable::setTransforms(transform);
if (_isFacingAvatar) {
glm::quat rotation = Application::getInstance()->getCamera()->getOrientation();
@ -49,7 +49,7 @@ void BillboardOverlay::setTransforms(Transform *transform) {
}
void BillboardOverlay::update(float deltatime) {
setTransforms(&_transform);
setTransforms(_transform);
}
void BillboardOverlay::render(RenderArgs* args) {
@ -98,7 +98,7 @@ void BillboardOverlay::render(RenderArgs* args) {
xColor color = getColor();
float alpha = getAlpha();
setTransforms(&_transform);
setTransforms(_transform);
Transform transform = _transform;
transform.postScale(glm::vec3(getDimensions(), 1.0f));
@ -197,7 +197,7 @@ bool BillboardOverlay::findRayIntersection(const glm::vec3& origin, const glm::v
float& distance, BoxFace& face) {
if (_texture && _texture->isLoaded()) {
// Make sure position and rotation is updated.
setTransforms(&_transform);
setTransforms(_transform);
// Produce the dimensions of the billboard based on the image's aspect ratio and the overlay's scale.
bool isNull = _fromImage.isNull();

View file

@ -43,7 +43,7 @@ public:
virtual BillboardOverlay* createClone() const;
protected:
void setTransforms(Transform* transform);
virtual void setTransforms(Transform& transform);
private:
void setBillboardURL(const QString& url);

View file

@ -26,13 +26,12 @@ PanelAttachable::PanelAttachable(const PanelAttachable* panelAttachable) :
{
}
void PanelAttachable::setTransforms(Transform* transform) {
Q_ASSERT(transform != nullptr);
void PanelAttachable::setTransforms(Transform& transform) {
if (getAttachedPanel()) {
transform->setTranslation(getAttachedPanel()->getAnchorPosition());
transform->setRotation(getAttachedPanel()->getOffsetRotation());
transform->postTranslate(getOffsetPosition() + getAttachedPanel()->getOffsetPosition());
transform->postRotate(getFacingRotation() * getAttachedPanel()->getFacingRotation());
transform.setTranslation(getAttachedPanel()->getAnchorPosition());
transform.setRotation(getAttachedPanel()->getOffsetRotation());
transform.postTranslate(getOffsetPosition() + getAttachedPanel()->getOffsetPosition());
transform.postRotate(getFacingRotation() * getAttachedPanel()->getFacingRotation());
}
}

View file

@ -34,7 +34,7 @@ public:
void setProperties(const QScriptValue& properties);
protected:
void setTransforms(Transform* transform);
virtual void setTransforms(Transform& transform);
private:
FloatingUIPanel::Pointer _attachedPanel;