Merge pull request #5675 from AndrewMeadows/darmstadtium

remove PhysicsEntity class
This commit is contained in:
Seth Alves 2015-09-01 10:06:01 -07:00
commit 7b6d267c06
7 changed files with 50 additions and 118 deletions

View file

@ -51,14 +51,14 @@ void SkeletonModel::initJointStates(QVector<JointState> states) {
int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1; int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1;
int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1; int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1;
_boundingRadius = _rig->initJointStates(states, parentTransform, _rig->initJointStates(states, parentTransform,
rootJointIndex, rootJointIndex,
leftHandJointIndex, leftHandJointIndex,
leftElbowJointIndex, leftElbowJointIndex,
leftShoulderJointIndex, leftShoulderJointIndex,
rightHandJointIndex, rightHandJointIndex,
rightElbowJointIndex, rightElbowJointIndex,
rightShoulderJointIndex); rightShoulderJointIndex);
// Determine the default eye position for avatar scale = 1.0 // Determine the default eye position for avatar scale = 1.0
int headJointIndex = _geometry->getFBXGeometry().headJointIndex; int headJointIndex = _geometry->getFBXGeometry().headJointIndex;
@ -533,7 +533,6 @@ void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) {
glm::vec3 rootPosition = _rig->getJointState(geometry.rootJointIndex).getPosition(); glm::vec3 rootPosition = _rig->getJointState(geometry.rootJointIndex).getPosition();
_boundingCapsuleLocalOffset = 0.5f * (totalExtents.maximum + totalExtents.minimum) - rootPosition; _boundingCapsuleLocalOffset = 0.5f * (totalExtents.maximum + totalExtents.minimum) - rootPosition;
_boundingRadius = 0.5f * glm::length(diagonal);
} }
void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) { void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) {

View file

@ -185,14 +185,14 @@ void Rig::deleteAnimations() {
_animationHandles.clear(); _animationHandles.clear();
} }
float Rig::initJointStates(QVector<JointState> states, glm::mat4 parentTransform, void Rig::initJointStates(QVector<JointState> states, glm::mat4 parentTransform,
int rootJointIndex, int rootJointIndex,
int leftHandJointIndex, int leftHandJointIndex,
int leftElbowJointIndex, int leftElbowJointIndex,
int leftShoulderJointIndex, int leftShoulderJointIndex,
int rightHandJointIndex, int rightHandJointIndex,
int rightElbowJointIndex, int rightElbowJointIndex,
int rightShoulderJointIndex) { int rightShoulderJointIndex) {
_jointStates = states; _jointStates = states;
_rootJointIndex = rootJointIndex; _rootJointIndex = rootJointIndex;
@ -206,19 +206,12 @@ float Rig::initJointStates(QVector<JointState> states, glm::mat4 parentTransform
initJointTransforms(parentTransform); initJointTransforms(parentTransform);
int numStates = _jointStates.size(); int numStates = _jointStates.size();
float radius = 0.0f;
for (int i = 0; i < numStates; ++i) { for (int i = 0; i < numStates; ++i) {
float distance = glm::length(_jointStates[i].getPosition());
if (distance > radius) {
radius = distance;
}
_jointStates[i].buildConstraint(); _jointStates[i].buildConstraint();
} }
for (int i = 0; i < _jointStates.size(); i++) { for (int i = 0; i < _jointStates.size(); i++) {
_jointStates[i].slaveVisibleTransform(); _jointStates[i].slaveVisibleTransform();
} }
return radius;
} }
// We could build and cache a dictionary, too.... // We could build and cache a dictionary, too....

View file

@ -92,14 +92,14 @@ public:
float priority = 1.0f, bool loop = false, bool hold = false, float firstFrame = 0.0f, 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 lastFrame = FLT_MAX, const QStringList& maskedJoints = QStringList(), bool startAutomatically = false);
float initJointStates(QVector<JointState> states, glm::mat4 parentTransform, void initJointStates(QVector<JointState> states, glm::mat4 parentTransform,
int rootJointIndex, int rootJointIndex,
int leftHandJointIndex, int leftHandJointIndex,
int leftElbowJointIndex, int leftElbowJointIndex,
int leftShoulderJointIndex, int leftShoulderJointIndex,
int rightHandJointIndex, int rightHandJointIndex,
int rightElbowJointIndex, int rightElbowJointIndex,
int rightShoulderJointIndex); int rightShoulderJointIndex);
bool jointStatesEmpty() { return _jointStates.isEmpty(); }; bool jointStatesEmpty() { return _jointStates.isEmpty(); };
int getJointStateCount() const { return _jointStates.size(); } int getJointStateCount() const { return _jointStates.size(); }
int indexOfJoint(const QString& jointName) ; int indexOfJoint(const QString& jointName) ;

View file

@ -60,6 +60,8 @@ float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f;
Model::Model(RigPointer rig, QObject* parent) : Model::Model(RigPointer rig, QObject* parent) :
QObject(parent), QObject(parent),
_translation(0.0f),
_rotation(),
_scale(1.0f, 1.0f, 1.0f), _scale(1.0f, 1.0f, 1.0f),
_scaleToFit(false), _scaleToFit(false),
_scaleToFitDimensions(0.0f), _scaleToFitDimensions(0.0f),
@ -196,6 +198,13 @@ void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model:
AbstractViewStateInterface* Model::_viewState = NULL; 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) { void Model::setScale(const glm::vec3& scale) {
setScaleInternal(scale); setScaleInternal(scale);
@ -434,14 +443,14 @@ void Model::initJointStates(QVector<JointState> states) {
int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1; int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1;
int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1; int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1;
_boundingRadius = _rig->initJointStates(states, parentTransform, _rig->initJointStates(states, parentTransform,
rootJointIndex, rootJointIndex,
leftHandJointIndex, leftHandJointIndex,
leftElbowJointIndex, leftElbowJointIndex,
leftShoulderJointIndex, leftShoulderJointIndex,
rightHandJointIndex, rightHandJointIndex,
rightElbowJointIndex, rightElbowJointIndex,
rightShoulderJointIndex); rightShoulderJointIndex);
} }
bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& direction, float& distance, bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& direction, float& distance,

View file

@ -27,7 +27,6 @@
#include <gpu/Stream.h> #include <gpu/Stream.h>
#include <gpu/Batch.h> #include <gpu/Batch.h>
#include <gpu/Pipeline.h> #include <gpu/Pipeline.h>
#include "PhysicsEntity.h"
#include <render/Scene.h> #include <render/Scene.h>
#include <Transform.h> #include <Transform.h>
@ -54,7 +53,7 @@ inline uint qHash(const std::shared_ptr<MeshPartPayload>& a, uint seed) {
} }
/// A generic 3D model displaying geometry loaded from a URL. /// A generic 3D model displaying geometry loaded from a URL.
class Model : public QObject, public PhysicsEntity { class Model : public QObject {
Q_OBJECT Q_OBJECT
public: public:
@ -173,6 +172,12 @@ public:
/// Returns the extents of the model's mesh /// Returns the extents of the model's mesh
Extents getMeshExtents() const; 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); void setScale(const glm::vec3& scale);
const glm::vec3& getScale() const { return _scale; } const glm::vec3& getScale() const { return _scale; }
@ -233,6 +238,8 @@ protected:
QSharedPointer<NetworkGeometry> _geometry; QSharedPointer<NetworkGeometry> _geometry;
void setGeometry(const QSharedPointer<NetworkGeometry>& newGeometry); void setGeometry(const QSharedPointer<NetworkGeometry>& newGeometry);
glm::vec3 _translation;
glm::quat _rotation;
glm::vec3 _scale; glm::vec3 _scale;
glm::vec3 _offset; glm::vec3 _offset;

View file

@ -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;
}
}

View file

@ -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 <QVector>
#include <QSet>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
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