mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 21:36:12 +02:00
namechange SimulationEngine --> PhysicsSimulation
This commit is contained in:
parent
7cd1f75282
commit
a8c2003fe6
8 changed files with 70 additions and 70 deletions
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include <QSettings>
|
||||
|
||||
#include <SimulationEngine.h>
|
||||
#include <PhysicsSimulation.h>
|
||||
|
||||
#include "Avatar.h"
|
||||
|
||||
|
@ -175,7 +175,7 @@ private:
|
|||
float _oculusYawOffset;
|
||||
|
||||
QList<AnimationHandlePointer> _animationHandles;
|
||||
SimulationEngine _simulationEngine;
|
||||
PhysicsSimulation _simulationEngine;
|
||||
|
||||
// private methods
|
||||
float computeDistanceToFloor(const glm::vec3& startPoint);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include <CapsuleShape.h>
|
||||
#include <GeometryUtil.h>
|
||||
#include <PhysicalEntity.h>
|
||||
#include <PhysicsEntity.h>
|
||||
#include <ShapeCollider.h>
|
||||
#include <SphereShape.h>
|
||||
|
||||
|
@ -561,7 +561,7 @@ void Model::setJointStates(QVector<JointState> states) {
|
|||
_jointStates = states;
|
||||
|
||||
// compute an approximate bounding radius for broadphase collision queries
|
||||
// against SimulationEngine boundaries
|
||||
// against PhysicsSimulation boundaries
|
||||
int numJoints = _jointStates.size();
|
||||
float radius = 0.0f;
|
||||
for (int i = 0; i < numJoints; ++i) {
|
||||
|
@ -785,7 +785,7 @@ AnimationHandlePointer Model::createAnimationHandle() {
|
|||
return handle;
|
||||
}
|
||||
|
||||
// virtual override from PhysicalEntity
|
||||
// virtual override from PhysicsEntity
|
||||
void Model::buildShapes() {
|
||||
// TODO: figure out how to load/build collision shapes for general models
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
#include <PhysicalEntity.h>
|
||||
#include <PhysicsEntity.h>
|
||||
|
||||
#include <AnimationCache.h>
|
||||
|
||||
|
@ -33,7 +33,7 @@ typedef QSharedPointer<AnimationHandle> AnimationHandlePointer;
|
|||
typedef QWeakPointer<AnimationHandle> WeakAnimationHandlePointer;
|
||||
|
||||
/// A generic 3D model displaying geometry loaded from a URL.
|
||||
class Model : public QObject, public PhysicalEntity {
|
||||
class Model : public QObject, public PhysicsEntity {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -131,7 +131,7 @@ public:
|
|||
|
||||
const QList<AnimationHandlePointer>& getRunningAnimations() const { return _runningAnimations; }
|
||||
|
||||
// virtual overrides from PhysicalEntity
|
||||
// virtual overrides from PhysicsEntity
|
||||
virtual void buildShapes();
|
||||
virtual void updateShapePositions();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// PhysicalEntity.cpp
|
||||
// PhysicsEntity.cpp
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Andrew Meadows 2014.06.11
|
||||
|
@ -9,11 +9,11 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "PhysicalEntity.h"
|
||||
#include "PhysicsEntity.h"
|
||||
#include "Shape.h"
|
||||
#include "ShapeCollider.h"
|
||||
|
||||
PhysicalEntity::PhysicalEntity() :
|
||||
PhysicsEntity::PhysicsEntity() :
|
||||
_translation(0.0f),
|
||||
_rotation(),
|
||||
_boundingRadius(0.0f),
|
||||
|
@ -22,26 +22,26 @@ PhysicalEntity::PhysicalEntity() :
|
|||
_simulation(NULL) {
|
||||
}
|
||||
|
||||
PhysicalEntity::~PhysicalEntity() {
|
||||
PhysicsEntity::~PhysicsEntity() {
|
||||
// entity should be removed from the simulation before it is deleted
|
||||
assert(_simulation == NULL);
|
||||
}
|
||||
|
||||
void PhysicalEntity::setTranslation(const glm::vec3& translation) {
|
||||
void PhysicsEntity::setTranslation(const glm::vec3& translation) {
|
||||
if (_translation != translation) {
|
||||
_shapesAreDirty = !_shapes.isEmpty();
|
||||
_translation = translation;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicalEntity::setRotation(const glm::quat& rotation) {
|
||||
void PhysicsEntity::setRotation(const glm::quat& rotation) {
|
||||
if (_rotation != rotation) {
|
||||
_shapesAreDirty = !_shapes.isEmpty();
|
||||
_rotation = rotation;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicalEntity::setShapeBackPointers() {
|
||||
void PhysicsEntity::setShapeBackPointers() {
|
||||
for (int i = 0; i < _shapes.size(); i++) {
|
||||
Shape* shape = _shapes[i];
|
||||
if (shape) {
|
||||
|
@ -50,7 +50,7 @@ void PhysicalEntity::setShapeBackPointers() {
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicalEntity::setEnableShapes(bool enable) {
|
||||
void PhysicsEntity::setEnableShapes(bool enable) {
|
||||
if (enable != _enableShapes) {
|
||||
clearShapes();
|
||||
_enableShapes = enable;
|
||||
|
@ -60,14 +60,14 @@ void PhysicalEntity::setEnableShapes(bool enable) {
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicalEntity::clearShapes() {
|
||||
void PhysicsEntity::clearShapes() {
|
||||
for (int i = 0; i < _shapes.size(); ++i) {
|
||||
delete _shapes[i];
|
||||
}
|
||||
_shapes.clear();
|
||||
}
|
||||
|
||||
bool PhysicalEntity::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const {
|
||||
bool PhysicsEntity::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const {
|
||||
/* TODO: Andrew to make this work
|
||||
int numShapes = _shapes.size();
|
||||
float minDistance = FLT_MAX;
|
||||
|
@ -88,7 +88,7 @@ bool PhysicalEntity::findRayIntersection(const glm::vec3& origin, const glm::vec
|
|||
return false;
|
||||
}
|
||||
|
||||
bool PhysicalEntity::findCollisions(const QVector<const Shape*> shapes, CollisionList& collisions) {
|
||||
bool PhysicsEntity::findCollisions(const QVector<const Shape*> shapes, CollisionList& collisions) {
|
||||
bool collided = false;
|
||||
int numTheirShapes = shapes.size();
|
||||
for (int i = 0; i < numTheirShapes; ++i) {
|
||||
|
@ -107,7 +107,7 @@ bool PhysicalEntity::findCollisions(const QVector<const Shape*> shapes, Collisio
|
|||
return collided;
|
||||
}
|
||||
|
||||
bool PhysicalEntity::findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadius,
|
||||
bool PhysicsEntity::findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadius,
|
||||
CollisionList& collisions, int skipIndex) {
|
||||
bool collided = false;
|
||||
// TODO: Andrew to implement this or make it unecessary
|
||||
|
@ -144,7 +144,7 @@ bool PhysicalEntity::findSphereCollisions(const glm::vec3& sphereCenter, float s
|
|||
return collided;
|
||||
}
|
||||
|
||||
bool PhysicalEntity::findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions) {
|
||||
bool PhysicsEntity::findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions) {
|
||||
bool collided = false;
|
||||
PlaneShape planeShape(plane);
|
||||
for (int i = 0; i < _shapes.size(); i++) {
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// PhysicalEntity.h
|
||||
// PhysicsEntity.h
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Andrew Meadows 2014.05.30
|
||||
|
@ -9,8 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_PhysicalEntity_h
|
||||
#define hifi_PhysicalEntity_h
|
||||
#ifndef hifi_PhysicsEntity_h
|
||||
#define hifi_PhysicsEntity_h
|
||||
|
||||
#include <QVector>
|
||||
|
||||
|
@ -20,17 +20,17 @@
|
|||
#include "CollisionInfo.h"
|
||||
|
||||
class Shape;
|
||||
class SimulationEngine;
|
||||
class PhysicsSimulation;
|
||||
|
||||
// PhysicalEntity is the base class for anything that owns one or more Shapes that collide in a
|
||||
// SimulationEngine. Each CollisionInfo generated by a SimulationEngine has back pointers to the
|
||||
// two Shapes involved, and those Shapes may (optionally) have valid back pointers to their PhysicalEntity.
|
||||
// PhysicsEntity is the base class for anything that owns one or more Shapes that collide in a
|
||||
// PhysicsSimulation. Each CollisionInfo generated by a PhysicsSimulation has back pointers to the
|
||||
// two Shapes involved, and those Shapes may (optionally) have valid back pointers to their PhysicsEntity.
|
||||
|
||||
class PhysicalEntity {
|
||||
class PhysicsEntity {
|
||||
|
||||
public:
|
||||
PhysicalEntity();
|
||||
virtual ~PhysicalEntity();
|
||||
PhysicsEntity();
|
||||
virtual ~PhysicsEntity();
|
||||
|
||||
void setTranslation(const glm::vec3& translation);
|
||||
void setRotation(const glm::quat& rotation);
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
virtual void buildShapes() = 0;
|
||||
virtual void clearShapes();
|
||||
|
||||
SimulationEngine* getSimulation() const { return _simulation; }
|
||||
PhysicsSimulation* getSimulation() const { return _simulation; }
|
||||
|
||||
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const;
|
||||
bool findCollisions(const QVector<const Shape*> shapes, CollisionList& collisions);
|
||||
|
@ -54,8 +54,8 @@ public:
|
|||
bool findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions);
|
||||
|
||||
protected:
|
||||
// SimulationEngine is a friend so that it can set the protected _simulation backpointer
|
||||
friend SimulationEngine;
|
||||
// PhysicsSimulation is a friend so that it can set the protected _simulation backpointer
|
||||
friend PhysicsSimulation;
|
||||
|
||||
glm::vec3 _translation;
|
||||
glm::quat _rotation;
|
||||
|
@ -63,7 +63,7 @@ protected:
|
|||
bool _shapesAreDirty;
|
||||
bool _enableShapes;
|
||||
QVector<Shape*> _shapes;
|
||||
SimulationEngine* _simulation;
|
||||
PhysicsSimulation* _simulation;
|
||||
};
|
||||
|
||||
#endif // hifi_PhysicalEntity_h
|
||||
#endif // hifi_PhysicsEntity_h
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// SimulationEngine.cpp
|
||||
// PhysicsSimulation.cpp
|
||||
// interface/src/avatar
|
||||
//
|
||||
// Created by Andrew Meadows 2014.06.06
|
||||
|
@ -11,29 +11,29 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "SimulationEngine.h"
|
||||
#include "PhysicsSimulation.h"
|
||||
|
||||
#include "PhysicalEntity.h"
|
||||
#include "PhysicsEntity.h"
|
||||
#include "Ragdoll.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "ShapeCollider.h"
|
||||
|
||||
int MAX_DOLLS_PER_ENGINE = 16;
|
||||
int MAX_ENTITIES_PER_ENGINE = 64;
|
||||
int MAX_COLLISIONS_PER_ENGINE = 256;
|
||||
int MAX_DOLLS_PER_SIMULATION = 16;
|
||||
int MAX_ENTITIES_PER_SIMULATION = 64;
|
||||
int MAX_COLLISIONS_PER_SIMULATION = 256;
|
||||
|
||||
|
||||
const int NUM_SHAPE_BITS = 6;
|
||||
const int SHAPE_INDEX_MASK = (1 << (NUM_SHAPE_BITS + 1)) - 1;
|
||||
|
||||
SimulationEngine::SimulationEngine() : _collisionList(MAX_COLLISIONS_PER_ENGINE) {
|
||||
PhysicsSimulation::PhysicsSimulation() : _collisionList(MAX_COLLISIONS_PER_SIMULATION) {
|
||||
}
|
||||
|
||||
SimulationEngine::~SimulationEngine() {
|
||||
PhysicsSimulation::~PhysicsSimulation() {
|
||||
_dolls.clear();
|
||||
}
|
||||
|
||||
bool SimulationEngine::addEntity(PhysicalEntity* entity) {
|
||||
bool PhysicsSimulation::addEntity(PhysicsEntity* entity) {
|
||||
if (!entity) {
|
||||
return false;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ bool SimulationEngine::addEntity(PhysicalEntity* entity) {
|
|||
return false;
|
||||
}
|
||||
int numEntities = _entities.size();
|
||||
if (numEntities > MAX_ENTITIES_PER_ENGINE) {
|
||||
if (numEntities > MAX_ENTITIES_PER_SIMULATION) {
|
||||
// list is full
|
||||
return false;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ bool SimulationEngine::addEntity(PhysicalEntity* entity) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void SimulationEngine::removeEntity(PhysicalEntity* entity) {
|
||||
void PhysicsSimulation::removeEntity(PhysicsEntity* entity) {
|
||||
if (!entity || !entity->_simulation || !(entity->_simulation == this)) {
|
||||
return;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void SimulationEngine::removeEntity(PhysicalEntity* entity) {
|
|||
_entities.pop_back();
|
||||
} else {
|
||||
// swap the last for this one
|
||||
PhysicalEntity* lastEntity = _entities[numEntities - 1];
|
||||
PhysicsEntity* lastEntity = _entities[numEntities - 1];
|
||||
_entities.pop_back();
|
||||
_entities[i] = lastEntity;
|
||||
}
|
||||
|
@ -82,12 +82,12 @@ void SimulationEngine::removeEntity(PhysicalEntity* entity) {
|
|||
}
|
||||
}
|
||||
|
||||
bool SimulationEngine::addRagdoll(Ragdoll* doll) {
|
||||
bool PhysicsSimulation::addRagdoll(Ragdoll* doll) {
|
||||
if (!doll) {
|
||||
return false;
|
||||
}
|
||||
int numDolls = _dolls.size();
|
||||
if (numDolls > MAX_DOLLS_PER_ENGINE) {
|
||||
if (numDolls > MAX_DOLLS_PER_SIMULATION) {
|
||||
// list is full
|
||||
return false;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ bool SimulationEngine::addRagdoll(Ragdoll* doll) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void SimulationEngine::removeRagdoll(Ragdoll* doll) {
|
||||
void PhysicsSimulation::removeRagdoll(Ragdoll* doll) {
|
||||
int numDolls = _dolls.size();
|
||||
for (int i = 0; i < numDolls; ++i) {
|
||||
if (doll == _dolls[i]) {
|
||||
|
@ -120,7 +120,7 @@ void SimulationEngine::removeRagdoll(Ragdoll* doll) {
|
|||
}
|
||||
}
|
||||
|
||||
void SimulationEngine::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) {
|
||||
void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) {
|
||||
/* TODO: Andrew to make this work
|
||||
int iterations = 0;
|
||||
float delta = 0.0f;
|
||||
|
@ -143,7 +143,7 @@ void SimulationEngine::stepForward(float deltaTime, float minError, int maxItera
|
|||
|
||||
// collide
|
||||
_collisionList.clear();
|
||||
// TODO: keep track of QSet<PhysicalEntity*> collidedEntities;
|
||||
// TODO: keep track of QSet<PhysicsEntity*> collidedEntities;
|
||||
for (int i = 0; i < numDolls; ++i) {
|
||||
const QVector<Shape*>* shapesA = _dolls.at(i)->getShapes();
|
||||
if (!shapesA) {
|
||||
|
@ -186,10 +186,10 @@ void SimulationEngine::stepForward(float deltaTime, float minError, int maxItera
|
|||
*/
|
||||
}
|
||||
|
||||
int SimulationEngine::computeCollisions() {
|
||||
int PhysicsSimulation::computeCollisions() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void SimulationEngine::processCollisions() {
|
||||
void PhysicsSimulation::processCollisions() {
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// SimulationEngine.h
|
||||
// PhysicsSimulation.h
|
||||
// interface/src/avatar
|
||||
//
|
||||
// Created by Andrew Meadows 2014.06.06
|
||||
|
@ -9,26 +9,26 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_SimulationEngine_h
|
||||
#define hifi_SimulationEngine_h
|
||||
#ifndef hifi_PhysicsSimulation
|
||||
#define hifi_PhysicsSimulation
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include "CollisionInfo.h"
|
||||
|
||||
class PhysicalEntity;
|
||||
class PhysicsEntity;
|
||||
class Ragdoll;
|
||||
|
||||
class SimulationEngine {
|
||||
class PhysicsSimulation {
|
||||
public:
|
||||
|
||||
SimulationEngine();
|
||||
~SimulationEngine();
|
||||
PhysicsSimulation();
|
||||
~PhysicsSimulation();
|
||||
|
||||
/// \return true if entity was added to or is already in the list
|
||||
bool addEntity(PhysicalEntity* entity);
|
||||
bool addEntity(PhysicsEntity* entity);
|
||||
|
||||
void removeEntity(PhysicalEntity* entity);
|
||||
void removeEntity(PhysicsEntity* entity);
|
||||
|
||||
/// \return true if doll was added to or is already in the list
|
||||
bool addRagdoll(Ragdoll* doll);
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
private:
|
||||
CollisionList _collisionList;
|
||||
QVector<PhysicalEntity*> _entities;
|
||||
QVector<PhysicsEntity*> _entities;
|
||||
QVector<Ragdoll*> _dolls;
|
||||
|
||||
// some stats for performance queries
|
||||
|
@ -61,4 +61,4 @@ private:
|
|||
quint64 _enforcementTime;
|
||||
};
|
||||
|
||||
#endif // hifi_SimulationEngine_h
|
||||
#endif // hifi_PhysicsSimulation
|
|
@ -15,7 +15,7 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
class PhysicalEntity;
|
||||
class PhysicsEntity;
|
||||
|
||||
class Shape {
|
||||
public:
|
||||
|
@ -32,8 +32,8 @@ public:
|
|||
|
||||
int getType() const { return _type; }
|
||||
|
||||
void setEntity(PhysicalEntity* entity) { _owningEntity = entity; }
|
||||
PhysicalEntity* getEntity() const { return _owningEntity; }
|
||||
void setEntity(PhysicsEntity* entity) { _owningEntity = entity; }
|
||||
PhysicsEntity* getEntity() const { return _owningEntity; }
|
||||
|
||||
float getBoundingRadius() const { return _boundingRadius; }
|
||||
|
||||
|
@ -58,7 +58,7 @@ protected:
|
|||
void setBoundingRadius(float radius) { _boundingRadius = radius; }
|
||||
|
||||
int _type;
|
||||
PhysicalEntity* _owningEntity;
|
||||
PhysicsEntity* _owningEntity;
|
||||
float _boundingRadius;
|
||||
glm::vec3 _translation;
|
||||
glm::quat _rotation;
|
||||
|
|
Loading…
Reference in a new issue