cleanup includes in Avatar.cpp and remove cruft

This commit is contained in:
Andrew Meadows 2017-04-12 13:30:08 -07:00
parent 5a458c9923
commit a3682a1a0e
7 changed files with 9 additions and 88 deletions

View file

@ -1,44 +0,0 @@
//
// Physics.cpp
// interface/src
//
// Copyright 2013 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 <glm/glm.hpp>
#include <SharedUtil.h>
#include "Util.h"
#include "world.h"
#include "Physics.h"
//
// Applies static friction: maxVelocity is the largest velocity for which there
// there is friction, and strength is the amount of friction force applied to reduce
// velocity.
//
void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength) {
float v = glm::length(velocity);
if (v < maxVelocity) {
velocity *= glm::clamp((1.0f - deltaTime * strength * (1.0f - v / maxVelocity)), 0.0f, 1.0f);
}
}
//
// Applies velocity damping, with a strength value for linear and squared velocity damping
//
void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength) {
if (squaredStrength == 0.0f) {
velocity *= glm::clamp(1.0f - deltaTime * linearStrength, 0.0f, 1.0f);
} else {
velocity *= glm::clamp(1.0f - deltaTime * (linearStrength + glm::length(velocity) * squaredStrength), 0.0f, 1.0f);
}
}
void applyDampedSpring(float deltaTime, glm::vec3& velocity, glm::vec3& position, glm::vec3& targetPosition, float k, float damping) {
}

View file

@ -1,18 +0,0 @@
//
// Physics.h
// interface/src
//
// Created by Philip on 4/25/13.
// Copyright 2013 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_Physics_h
#define hifi_Physics_h
void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength);
void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength);
#endif // hifi_Physics_h

View file

@ -9,20 +9,14 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <vector> #include "Avatar.h"
#include <QDesktopWidget> #include <QtCore/QThread>
#include <QWindow> #include <glm/gtx/transform.hpp>
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtx/vector_angle.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/vector_query.hpp> #include <glm/gtx/vector_query.hpp>
#include <DeferredLightingEffect.h> #include <DeferredLightingEffect.h>
#include <GeometryUtil.h> #include <EntityTreeRenderer.h>
#include <LODManager.h>
#include <NodeList.h> #include <NodeList.h>
#include <NumericalConstants.h> #include <NumericalConstants.h>
#include <OctreeUtils.h> #include <OctreeUtils.h>
@ -31,19 +25,13 @@
#include <Rig.h> #include <Rig.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <TextRenderer3D.h> #include <TextRenderer3D.h>
#include <TextureCache.h>
#include <VariantMapToScriptValue.h> #include <VariantMapToScriptValue.h>
#include <DebugDraw.h> #include <DebugDraw.h>
#include "Application.h"
#include "Avatar.h"
#include "AvatarManager.h" #include "AvatarManager.h"
#include "AvatarMotionState.h" #include "AvatarMotionState.h"
#include "Head.h" #include "Camera.h"
#include "Menu.h" #include "Menu.h"
#include "Physics.h"
#include "Util.h"
#include "world.h"
#include "InterfaceLogging.h" #include "InterfaceLogging.h"
#include "SceneScriptingInterface.h" #include "SceneScriptingInterface.h"
#include "SoftAttachmentModel.h" #include "SoftAttachmentModel.h"
@ -583,7 +571,7 @@ void Avatar::render(RenderArgs* renderArgs) {
auto& batch = *renderArgs->_batch; auto& batch = *renderArgs->_batch;
PROFILE_RANGE_BATCH(batch, __FUNCTION__); PROFILE_RANGE_BATCH(batch, __FUNCTION__);
if (glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(), getPosition()) < 10.0f) { if (glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatarPosition(), getPosition()) < 10.0f) {
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
// render pointing lasers // render pointing lasers

View file

@ -14,19 +14,15 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
#include <QtCore/QScopedPointer>
#include <QtCore/QUuid> #include <QtCore/QUuid>
#include <AvatarData.h> #include <AvatarData.h>
#include <ShapeInfo.h> #include <ShapeInfo.h>
#include <render/Scene.h> #include <render/Scene.h>
#include "Camera.h"
#include "Head.h" #include "Head.h"
#include "SkeletonModel.h" #include "SkeletonModel.h"
#include "world.h"
#include "Rig.h" #include "Rig.h"
#include <ThreadSafeValueCache.h> #include <ThreadSafeValueCache.h>

View file

@ -23,6 +23,7 @@
#include <shared/RateCounter.h> #include <shared/RateCounter.h>
#include "Avatar.h" #include "Avatar.h"
#include "MyAvatar.h"
#include "AvatarMotionState.h" #include "AvatarMotionState.h"
#include "ScriptAvatar.h" #include "ScriptAvatar.h"
@ -42,6 +43,7 @@ public:
void init(); void init();
std::shared_ptr<MyAvatar> getMyAvatar() { return _myAvatar; } std::shared_ptr<MyAvatar> getMyAvatar() { return _myAvatar; }
glm::vec3 getMyAvatarPosition() const { return _myAvatar->getPosition(); }
// Null/Default-constructed QUuids will return MyAvatar // Null/Default-constructed QUuids will return MyAvatar
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) override { return new ScriptAvatar(getAvatarBySessionID(avatarID)); } Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) override { return new ScriptAvatar(getAvatarBySessionID(avatarID)); }
@ -110,7 +112,7 @@ private:
QVector<AvatarSharedPointer> _avatarsToFade; QVector<AvatarSharedPointer> _avatarsToFade;
SetOfAvatarMotionStates _motionStatesThatMightUpdate; QSet<AvatarMotionState*> _motionStatesThatMightUpdate;
VectorOfMotionStates _motionStatesToRemoveFromPhysics; VectorOfMotionStates _motionStatesToRemoveFromPhysics;
SetOfMotionStates _motionStatesToAddToPhysics; SetOfMotionStates _motionStatesToAddToPhysics;

View file

@ -83,6 +83,4 @@ protected:
uint32_t _dirtyFlags; uint32_t _dirtyFlags;
}; };
typedef QSet<AvatarMotionState*> SetOfAvatarMotionStates;
#endif // hifi_AvatarMotionState_h #endif // hifi_AvatarMotionState_h

View file

@ -48,7 +48,6 @@
#include "AvatarActionHold.h" #include "AvatarActionHold.h"
#include "Menu.h" #include "Menu.h"
#include "MyAvatar.h" #include "MyAvatar.h"
#include "Physics.h"
#include "Util.h" #include "Util.h"
#include "InterfaceLogging.h" #include "InterfaceLogging.h"
#include "DebugDraw.h" #include "DebugDraw.h"