mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 01:23:57 +02:00
stubbery for collidable avatars
This commit is contained in:
parent
ead1d9f4d1
commit
f86c419988
15 changed files with 238 additions and 39 deletions
|
@ -2456,6 +2456,11 @@ void Application::update(float deltaTime) {
|
|||
_physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());
|
||||
_entitySimulation.unlock();
|
||||
|
||||
AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();
|
||||
_physicsEngine.deleteObjects(avatarManager->getObjectsToDelete());
|
||||
_physicsEngine.addObjects(avatarManager->getObjectsToAdd());
|
||||
_physicsEngine.changeObjects(avatarManager->getObjectsToChange());
|
||||
|
||||
_physicsEngine.stepSimulation();
|
||||
|
||||
if (_physicsEngine.hasOutgoingChanges()) {
|
||||
|
@ -2463,6 +2468,10 @@ void Application::update(float deltaTime) {
|
|||
_entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges(), _physicsEngine.getSessionID());
|
||||
_entitySimulation.handleCollisionEvents(_physicsEngine.getCollisionEvents());
|
||||
_entitySimulation.unlock();
|
||||
|
||||
avatarManager->handleOutgoingChanges(_physicsEngine.getOutgoingChanges());
|
||||
avatarManager->handleCollisionEvents(_physicsEngine.getCollisionEvents());
|
||||
|
||||
_physicsEngine.dumpStatsIfNecessary();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,9 +146,9 @@ public:
|
|||
|
||||
Q_INVOKABLE glm::vec3 getNeckPosition() const;
|
||||
|
||||
Q_INVOKABLE glm::vec3 getAcceleration() const { return _acceleration; }
|
||||
Q_INVOKABLE glm::vec3 getAngularVelocity() const { return _angularVelocity; }
|
||||
Q_INVOKABLE glm::vec3 getAngularAcceleration() const { return _angularAcceleration; }
|
||||
Q_INVOKABLE const glm::vec3& getAcceleration() const { return _acceleration; }
|
||||
Q_INVOKABLE const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
||||
Q_INVOKABLE const glm::vec3& getAngularAcceleration() const { return _angularAcceleration; }
|
||||
|
||||
|
||||
/// Scales a world space position vector relative to the avatar position and scale
|
||||
|
|
|
@ -215,3 +215,21 @@ QVector<AvatarManager::LocalLight> AvatarManager::getLocalLights() const {
|
|||
return _localLights;
|
||||
}
|
||||
|
||||
VectorOfMotionStates& AvatarManager::getObjectsToDelete() {
|
||||
return _tempMotionStates;
|
||||
}
|
||||
|
||||
VectorOfMotionStates& AvatarManager::getObjectsToAdd() {
|
||||
return _tempMotionStates;
|
||||
}
|
||||
|
||||
VectorOfMotionStates& AvatarManager::getObjectsToChange() {
|
||||
return _tempMotionStates;
|
||||
}
|
||||
|
||||
void AvatarManager::handleOutgoingChanges(VectorOfMotionStates& motionStates) {
|
||||
}
|
||||
|
||||
void AvatarManager::handleCollisionEvents(CollisionEvents& collisionEvents) {
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#include <AvatarHashMap.h>
|
||||
#include <PhysicsEngine.h>
|
||||
|
||||
#include "Avatar.h"
|
||||
#include "AvatarMotionState.h"
|
||||
|
||||
class MyAvatar;
|
||||
|
||||
|
@ -51,6 +53,12 @@ public:
|
|||
|
||||
Q_INVOKABLE void setLocalLights(const QVector<AvatarManager::LocalLight>& localLights);
|
||||
Q_INVOKABLE QVector<AvatarManager::LocalLight> getLocalLights() const;
|
||||
|
||||
VectorOfMotionStates& getObjectsToDelete();
|
||||
VectorOfMotionStates& getObjectsToAdd();
|
||||
VectorOfMotionStates& getObjectsToChange();
|
||||
void handleOutgoingChanges(VectorOfMotionStates& motionStates);
|
||||
void handleCollisionEvents(CollisionEvents& collisionEvents);
|
||||
|
||||
public slots:
|
||||
void setShouldShowReceiveStats(bool shouldShowReceiveStats) { _shouldShowReceiveStats = shouldShowReceiveStats; }
|
||||
|
@ -62,7 +70,7 @@ private:
|
|||
void simulateAvatarFades(float deltaTime);
|
||||
void renderAvatarFades(const glm::vec3& cameraPosition, RenderArgs::RenderMode renderMode);
|
||||
|
||||
AvatarSharedPointer newSharedAvatar();
|
||||
virtual AvatarSharedPointer newSharedAvatar();
|
||||
|
||||
// virtual overrides
|
||||
AvatarHash::iterator erase(const AvatarHash::iterator& iterator);
|
||||
|
@ -74,6 +82,9 @@ private:
|
|||
QVector<AvatarManager::LocalLight> _localLights;
|
||||
|
||||
bool _shouldShowReceiveStats = false;
|
||||
|
||||
VectorOfAvatarMotionStates _avatarMotionStates;
|
||||
VectorOfMotionStates _tempMotionStates;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(AvatarManager::LocalLight)
|
||||
|
|
116
interface/src/avatar/AvatarMotionState.cpp
Normal file
116
interface/src/avatar/AvatarMotionState.cpp
Normal file
|
@ -0,0 +1,116 @@
|
|||
//
|
||||
// AvatarMotionState.cpp
|
||||
// interface/src/avatar/
|
||||
//
|
||||
// Created by Andrew Meadows 2015.05.14
|
||||
// Copyright 2015 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 "Avatar.h"
|
||||
#include "AvatarMotionState.h"
|
||||
|
||||
AvatarMotionState::AvatarMotionState(Avatar* avatar, btCollisionShape* shape) : ObjectMotionState(shape), _avatar(avatar) {
|
||||
}
|
||||
|
||||
AvatarMotionState::~AvatarMotionState() {
|
||||
_avatar = nullptr;
|
||||
}
|
||||
|
||||
// virtual
|
||||
void AvatarMotionState::handleEasyChanges(uint32_t flags) {
|
||||
}
|
||||
|
||||
// virtual
|
||||
void AvatarMotionState::handleHardAndEasyChanges(uint32_t flags, PhysicsEngine* engine) {
|
||||
}
|
||||
|
||||
// virtual
|
||||
void AvatarMotionState::updateBodyMaterialProperties() {
|
||||
}
|
||||
|
||||
// virtual
|
||||
void AvatarMotionState::updateBodyVelocities() {
|
||||
}
|
||||
|
||||
// virtual
|
||||
uint32_t AvatarMotionState::getAndClearIncomingDirtyFlags() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// virtual
|
||||
MotionType AvatarMotionState::computeObjectMotionType() const {
|
||||
return _motionType;
|
||||
}
|
||||
|
||||
// virtual
|
||||
void AvatarMotionState::computeObjectShapeInfo(ShapeInfo& shapeInfo) {
|
||||
}
|
||||
|
||||
// virtual
|
||||
bool AvatarMotionState::isMoving() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
// These pure virtual methods must be implemented for each MotionState type
|
||||
// and make it possible to implement more complicated methods in this base class.
|
||||
|
||||
// virtual
|
||||
float AvatarMotionState::getObjectRestitution() const {
|
||||
return 0.5f;
|
||||
}
|
||||
// virtual
|
||||
float AvatarMotionState::getObjectFriction() const {
|
||||
return 0.5f;
|
||||
}
|
||||
// virtual
|
||||
float AvatarMotionState::getObjectLinearDamping() const {
|
||||
return 0.5f;
|
||||
}
|
||||
// virtual
|
||||
float AvatarMotionState::getObjectAngularDamping() const {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
// virtual
|
||||
glm::vec3 AvatarMotionState::getObjectPosition() const {
|
||||
return glm::vec3(0.0f);
|
||||
}
|
||||
// virtual
|
||||
glm::quat AvatarMotionState::getObjectRotation() const {
|
||||
return _avatar->getOrientation();
|
||||
}
|
||||
// virtual
|
||||
const glm::vec3& AvatarMotionState::getObjectLinearVelocity() const {
|
||||
return _avatar->getVelocity();
|
||||
}
|
||||
|
||||
// virtual
|
||||
const glm::vec3& AvatarMotionState::getObjectAngularVelocity() const {
|
||||
return _avatar->getAngularVelocity();
|
||||
}
|
||||
|
||||
// virtual
|
||||
const glm::vec3& AvatarMotionState::getObjectGravity() const {
|
||||
return _avatar->getAcceleration();
|
||||
}
|
||||
|
||||
// virtual
|
||||
const QUuid& AvatarMotionState::getObjectID() const {
|
||||
return _avatar->getSessionUUID();
|
||||
}
|
||||
|
||||
// virtual
|
||||
QUuid AvatarMotionState::getSimulatorID() const {
|
||||
return _avatar->getSessionUUID();
|
||||
}
|
||||
|
||||
// virtual
|
||||
void AvatarMotionState::bump() {
|
||||
}
|
||||
|
||||
// protected, virtual
|
||||
void AvatarMotionState::setMotionType(MotionType motionType) {
|
||||
}
|
67
interface/src/avatar/AvatarMotionState.h
Normal file
67
interface/src/avatar/AvatarMotionState.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
//
|
||||
// AvatarMotionState.h
|
||||
// interface/src/avatar/
|
||||
//
|
||||
// Created by Andrew Meadows 2015.05.14
|
||||
// Copyright 2015 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_AvatarMotionState_h
|
||||
#define hifi_AvatarMotionState_h
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include <ObjectMotionState.h>
|
||||
|
||||
class Avatar;
|
||||
|
||||
class AvatarMotionState : public ObjectMotionState {
|
||||
public:
|
||||
AvatarMotionState(Avatar* avatar, btCollisionShape* shape);
|
||||
~AvatarMotionState();
|
||||
|
||||
virtual void handleEasyChanges(uint32_t flags);
|
||||
virtual void handleHardAndEasyChanges(uint32_t flags, PhysicsEngine* engine);
|
||||
|
||||
virtual void updateBodyMaterialProperties();
|
||||
virtual void updateBodyVelocities();
|
||||
|
||||
virtual MotionType getMotionType() const { return _motionType; }
|
||||
|
||||
virtual uint32_t getAndClearIncomingDirtyFlags() const = 0;
|
||||
|
||||
virtual MotionType computeObjectMotionType() const = 0;
|
||||
virtual void computeObjectShapeInfo(ShapeInfo& shapeInfo) = 0;
|
||||
|
||||
virtual bool isMoving() const = 0;
|
||||
|
||||
// These pure virtual methods must be implemented for each MotionState type
|
||||
// and make it possible to implement more complicated methods in this base class.
|
||||
|
||||
virtual float getObjectRestitution() const = 0;
|
||||
virtual float getObjectFriction() const = 0;
|
||||
virtual float getObjectLinearDamping() const = 0;
|
||||
virtual float getObjectAngularDamping() const = 0;
|
||||
|
||||
virtual glm::vec3 getObjectPosition() const = 0;
|
||||
virtual glm::quat getObjectRotation() const = 0;
|
||||
virtual const glm::vec3& getObjectLinearVelocity() const = 0;
|
||||
virtual const glm::vec3& getObjectAngularVelocity() const = 0;
|
||||
virtual const glm::vec3& getObjectGravity() const = 0;
|
||||
|
||||
virtual const QUuid& getObjectID() const = 0;
|
||||
|
||||
virtual QUuid getSimulatorID() const = 0;
|
||||
virtual void bump() = 0;
|
||||
|
||||
protected:
|
||||
virtual void setMotionType(MotionType motionType);
|
||||
Avatar* _avatar;
|
||||
};
|
||||
|
||||
typedef QVector<AvatarMotionState*> VectorOfAvatarMotionStates;
|
||||
|
||||
#endif // hifi_AvatarMotionState_h
|
|
@ -301,8 +301,8 @@ public:
|
|||
int getReceiveRate() const;
|
||||
|
||||
void setVelocity(const glm::vec3 velocity) { _velocity = velocity; }
|
||||
Q_INVOKABLE glm::vec3 getVelocity() const { return _velocity; }
|
||||
glm::vec3 getTargetVelocity() const { return _targetVelocity; }
|
||||
Q_INVOKABLE const glm::vec3& getVelocity() const { return _velocity; }
|
||||
const glm::vec3& getTargetVelocity() const { return _targetVelocity; }
|
||||
|
||||
public slots:
|
||||
void sendAvatarDataPacket();
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
virtual float getObjectAngularDamping() const { return _entity->getAngularDamping(); }
|
||||
|
||||
virtual glm::vec3 getObjectPosition() const { return _entity->getPosition() - ObjectMotionState::getWorldOffset(); }
|
||||
virtual const glm::quat& getObjectRotation() const { return _entity->getRotation(); }
|
||||
virtual glm::quat getObjectRotation() const { return _entity->getRotation(); }
|
||||
virtual const glm::vec3& getObjectLinearVelocity() const { return _entity->getVelocity(); }
|
||||
virtual const glm::vec3& getObjectAngularVelocity() const { return _entity->getAngularVelocity(); }
|
||||
virtual const glm::vec3& getObjectGravity() const { return _entity->getGravity(); }
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include <btBulletDynamicsCommon.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
|
||||
#include <EntityItem.h>
|
||||
|
||||
#include "ContactInfo.h"
|
||||
|
@ -109,7 +112,7 @@ public:
|
|||
virtual float getObjectAngularDamping() const = 0;
|
||||
|
||||
virtual glm::vec3 getObjectPosition() const = 0;
|
||||
virtual const glm::quat& getObjectRotation() const = 0;
|
||||
virtual glm::quat getObjectRotation() const = 0;
|
||||
virtual const glm::vec3& getObjectLinearVelocity() const = 0;
|
||||
virtual const glm::vec3& getObjectAngularVelocity() const = 0;
|
||||
virtual const glm::vec3& getObjectGravity() const = 0;
|
||||
|
@ -137,4 +140,7 @@ protected:
|
|||
uint32_t _lastKinematicStep;
|
||||
};
|
||||
|
||||
typedef QSet<ObjectMotionState*> SetOfMotionStates;
|
||||
typedef QVector<ObjectMotionState*> VectorOfMotionStates;
|
||||
|
||||
#endif // hifi_ObjectMotionState_h
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "EntityMotionState.h"
|
||||
#include "PhysicalEntitySimulation.h"
|
||||
#include "PhysicsHelpers.h"
|
||||
#include "PhysicsLogging.h"
|
||||
|
|
|
@ -21,9 +21,8 @@
|
|||
#include <EntitySimulation.h>
|
||||
|
||||
#include "PhysicsEngine.h"
|
||||
#include "PhysicsTypedefs.h"
|
||||
#include "EntityMotionState.h"
|
||||
|
||||
class EntityMotionState;
|
||||
class ShapeManager;
|
||||
|
||||
typedef QSet<EntityMotionState*> SetOfEntityMotionStates;
|
||||
|
|
|
@ -22,13 +22,11 @@
|
|||
#include "BulletUtil.h"
|
||||
#include "ContactInfo.h"
|
||||
#include "DynamicCharacterController.h"
|
||||
#include "PhysicsTypedefs.h"
|
||||
#include "ObjectMotionState.h"
|
||||
#include "ThreadSafeDynamicsWorld.h"
|
||||
|
||||
const float HALF_SIMULATION_EXTENT = 512.0f; // meters
|
||||
|
||||
class ObjectMotionState;
|
||||
|
||||
// simple class for keeping track of contacts
|
||||
class ContactKey {
|
||||
public:
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
//
|
||||
// PhysicsTypedefs.h
|
||||
// libraries/physcis/src
|
||||
//
|
||||
// Created by Andrew Meadows 2015.04.29
|
||||
// Copyright 2015 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_PhysicsTypedefs_h
|
||||
#define hifi_PhysicsTypedefs_h
|
||||
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
|
||||
class ObjectMotionState;
|
||||
|
||||
typedef QSet<ObjectMotionState*> SetOfMotionStates;
|
||||
typedef QVector<ObjectMotionState*> VectorOfMotionStates;
|
||||
|
||||
#endif //hifi_PhysicsTypedefs_h
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include <LinearMath/btQuickprof.h>
|
||||
|
||||
#include "ObjectMotionState.h"
|
||||
#include "ThreadSafeDynamicsWorld.h"
|
||||
|
||||
ThreadSafeDynamicsWorld::ThreadSafeDynamicsWorld(
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
||||
#include <BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h>
|
||||
|
||||
#include "PhysicsTypedefs.h"
|
||||
#include "ObjectMotionState.h"
|
||||
|
||||
ATTRIBUTE_ALIGNED16(class) ThreadSafeDynamicsWorld : public btDiscreteDynamicsWorld {
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue