From d3f06af892145b897507f0b0b46b4775267c5ddb Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 27 Aug 2015 18:22:12 -0700 Subject: [PATCH] remove PhysicsEntity class --- interface/src/avatar/SkeletonModel.cpp | 17 ++++---- libraries/animation/src/Rig.cpp | 23 ++++------- libraries/animation/src/Rig.h | 16 ++++---- libraries/render-utils/src/Model.cpp | 25 ++++++++---- libraries/render-utils/src/Model.h | 11 ++++- libraries/render-utils/src/PhysicsEntity.cpp | 34 ---------------- libraries/render-utils/src/PhysicsEntity.h | 42 -------------------- 7 files changed, 50 insertions(+), 118 deletions(-) delete mode 100644 libraries/render-utils/src/PhysicsEntity.cpp delete mode 100644 libraries/render-utils/src/PhysicsEntity.h diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 752fb55ce6..acd2f038f4 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -51,14 +51,14 @@ void SkeletonModel::initJointStates(QVector states) { int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1; int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1; - _boundingRadius = _rig->initJointStates(states, parentTransform, - rootJointIndex, - leftHandJointIndex, - leftElbowJointIndex, - leftShoulderJointIndex, - rightHandJointIndex, - rightElbowJointIndex, - rightShoulderJointIndex); + _rig->initJointStates(states, parentTransform, + rootJointIndex, + leftHandJointIndex, + leftElbowJointIndex, + leftShoulderJointIndex, + rightHandJointIndex, + rightElbowJointIndex, + rightShoulderJointIndex); // Determine the default eye position for avatar scale = 1.0 int headJointIndex = _geometry->getFBXGeometry().headJointIndex; @@ -533,7 +533,6 @@ void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) { glm::vec3 rootPosition = _rig->getJointState(geometry.rootJointIndex).getPosition(); _boundingCapsuleLocalOffset = 0.5f * (totalExtents.maximum + totalExtents.minimum) - rootPosition; - _boundingRadius = 0.5f * glm::length(diagonal); } void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) { diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 3e466b94d6..8adb53024c 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -185,14 +185,14 @@ void Rig::deleteAnimations() { _animationHandles.clear(); } -float Rig::initJointStates(QVector states, glm::mat4 parentTransform, - int rootJointIndex, - int leftHandJointIndex, - int leftElbowJointIndex, - int leftShoulderJointIndex, - int rightHandJointIndex, - int rightElbowJointIndex, - int rightShoulderJointIndex) { +void Rig::initJointStates(QVector states, glm::mat4 parentTransform, + int rootJointIndex, + int leftHandJointIndex, + int leftElbowJointIndex, + int leftShoulderJointIndex, + int rightHandJointIndex, + int rightElbowJointIndex, + int rightShoulderJointIndex) { _jointStates = states; _rootJointIndex = rootJointIndex; @@ -206,19 +206,12 @@ float Rig::initJointStates(QVector states, glm::mat4 parentTransform initJointTransforms(parentTransform); int numStates = _jointStates.size(); - float radius = 0.0f; for (int i = 0; i < numStates; ++i) { - float distance = glm::length(_jointStates[i].getPosition()); - if (distance > radius) { - radius = distance; - } _jointStates[i].buildConstraint(); } for (int i = 0; i < _jointStates.size(); i++) { _jointStates[i].slaveVisibleTransform(); } - - return radius; } // We could build and cache a dictionary, too.... diff --git a/libraries/animation/src/Rig.h b/libraries/animation/src/Rig.h index 8da20062cf..a574807eb4 100644 --- a/libraries/animation/src/Rig.h +++ b/libraries/animation/src/Rig.h @@ -92,14 +92,14 @@ public: float priority = 1.0f, bool loop = false, bool hold = false, float firstFrame = 0.0f, float lastFrame = FLT_MAX, const QStringList& maskedJoints = QStringList(), bool startAutomatically = false); - float initJointStates(QVector states, glm::mat4 parentTransform, - int rootJointIndex, - int leftHandJointIndex, - int leftElbowJointIndex, - int leftShoulderJointIndex, - int rightHandJointIndex, - int rightElbowJointIndex, - int rightShoulderJointIndex); + void initJointStates(QVector states, glm::mat4 parentTransform, + int rootJointIndex, + int leftHandJointIndex, + int leftElbowJointIndex, + int leftShoulderJointIndex, + int rightHandJointIndex, + int rightElbowJointIndex, + int rightShoulderJointIndex); bool jointStatesEmpty() { return _jointStates.isEmpty(); }; int getJointStateCount() const { return _jointStates.size(); } int indexOfJoint(const QString& jointName) ; diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index c2d723a323..14b1c58321 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -60,6 +60,8 @@ float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f; Model::Model(RigPointer rig, QObject* parent) : QObject(parent), + _translation(0.0f), + _rotation(), _scale(1.0f, 1.0f, 1.0f), _scaleToFit(false), _scaleToFitDimensions(0.0f), @@ -196,6 +198,13 @@ void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model: AbstractViewStateInterface* Model::_viewState = NULL; +void Model::setTranslation(const glm::vec3& translation) { + _translation = translation; +} + +void Model::setRotation(const glm::quat& rotation) { + _rotation = rotation; +} void Model::setScale(const glm::vec3& scale) { setScaleInternal(scale); @@ -434,14 +443,14 @@ void Model::initJointStates(QVector states) { int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1; int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1; - _boundingRadius = _rig->initJointStates(states, parentTransform, - rootJointIndex, - leftHandJointIndex, - leftElbowJointIndex, - leftShoulderJointIndex, - rightHandJointIndex, - rightElbowJointIndex, - rightShoulderJointIndex); + _rig->initJointStates(states, parentTransform, + rootJointIndex, + leftHandJointIndex, + leftElbowJointIndex, + leftShoulderJointIndex, + rightHandJointIndex, + rightElbowJointIndex, + rightShoulderJointIndex); } bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& direction, float& distance, diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index e55bff6aca..1a960f443b 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -27,7 +27,6 @@ #include #include #include -#include "PhysicsEntity.h" #include #include @@ -54,7 +53,7 @@ inline uint qHash(const std::shared_ptr& a, uint seed) { } /// A generic 3D model displaying geometry loaded from a URL. -class Model : public QObject, public PhysicsEntity { +class Model : public QObject { Q_OBJECT public: @@ -173,6 +172,12 @@ public: /// Returns the extents of the model's mesh Extents getMeshExtents() const; + void setTranslation(const glm::vec3& translation); + void setRotation(const glm::quat& rotation); + + const glm::vec3& getTranslation() const { return _translation; } + const glm::quat& getRotation() const { return _rotation; } + void setScale(const glm::vec3& scale); const glm::vec3& getScale() const { return _scale; } @@ -233,6 +238,8 @@ protected: QSharedPointer _geometry; void setGeometry(const QSharedPointer& newGeometry); + glm::vec3 _translation; + glm::quat _rotation; glm::vec3 _scale; glm::vec3 _offset; diff --git a/libraries/render-utils/src/PhysicsEntity.cpp b/libraries/render-utils/src/PhysicsEntity.cpp deleted file mode 100644 index 5d58d87e84..0000000000 --- a/libraries/render-utils/src/PhysicsEntity.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// PhysicsEntity.cpp -// libraries/physics/src -// -// Created by Andrew Meadows 2014.06.11 -// 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 "PhysicsEntity.h" - -PhysicsEntity::PhysicsEntity() : - _translation(0.0f), - _rotation(), - _boundingRadius(0.0f) { -} - -PhysicsEntity::~PhysicsEntity() { -} - -void PhysicsEntity::setTranslation(const glm::vec3& translation) { - if (_translation != translation) { - _translation = translation; - } -} - -void PhysicsEntity::setRotation(const glm::quat& rotation) { - if (_rotation != rotation) { - _rotation = rotation; - } -} - diff --git a/libraries/render-utils/src/PhysicsEntity.h b/libraries/render-utils/src/PhysicsEntity.h deleted file mode 100644 index f36473af26..0000000000 --- a/libraries/render-utils/src/PhysicsEntity.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// PhysicsEntity.h -// libraries/physics/src -// -// Created by Andrew Meadows 2014.05.30 -// 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 -// - -#ifndef hifi_PhysicsEntity_h -#define hifi_PhysicsEntity_h - -#include -#include - -#include -#include - -class PhysicsEntity { - -public: - PhysicsEntity(); - virtual ~PhysicsEntity(); - - virtual void stepForward(float deltaTime) { } - - void setTranslation(const glm::vec3& translation); - void setRotation(const glm::quat& rotation); - - const glm::vec3& getTranslation() const { return _translation; } - const glm::quat& getRotation() const { return _rotation; } - float getBoundingRadius() const { return _boundingRadius; } - -protected: - glm::vec3 _translation; - glm::quat _rotation; - float _boundingRadius; -}; - -#endif // hifi_PhysicsEntity_h