overte-HifiExperiments/libraries/physics/src/PhysicalEntitySimulation.h
Brad Davis 9b81842850 Merge branch 'master' into homer
Conflicts:
	assignment-client/src/octree/OctreeSendThread.cpp
	interface/src/Application.cpp
	libraries/entities-renderer/src/EntityTreeRenderer.cpp
	libraries/entities/src/EntityItem.cpp
	libraries/entities/src/EntityTree.cpp
	libraries/entities/src/EntityTreeElement.cpp
	libraries/entities/src/EntityTreeElement.h
	libraries/entities/src/EntityTreeHeadlessViewer.cpp
	libraries/entities/src/RecurseOctreeToMapOperator.cpp
	libraries/octree/src/Octree.h
	libraries/physics/src/EntityMotionState.cpp
2015-09-11 16:31:18 -07:00

77 lines
2.8 KiB
C++

//
// PhysicalEntitySimulation.h
// libraries/physcis/src
//
// Created by Andrew Meadows 2015.04.27
// 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_PhysicalEntitySimulation_h
#define hifi_PhysicalEntitySimulation_h
#include <stdint.h>
#include <btBulletDynamicsCommon.h>
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <EntityItem.h>
#include <EntitySimulation.h>
#include "PhysicsEngine.h"
#include "EntityMotionState.h"
typedef QSet<EntityMotionState*> SetOfEntityMotionStates;
class PhysicalEntitySimulation :public EntitySimulation {
public:
PhysicalEntitySimulation();
~PhysicalEntitySimulation();
void init(EntityTreePointer tree, PhysicsEnginePointer engine, EntityEditPacketSender* packetSender);
virtual void addAction(EntityActionPointer action) override;
virtual void applyActionChanges() override;
protected: // only called by EntitySimulation
// overrides for EntitySimulation
virtual void updateEntitiesInternal(const quint64& now) override;
virtual void addEntityInternal(EntityItemPointer entity) override;
virtual void removeEntityInternal(EntityItemPointer entity) override;
virtual void changeEntityInternal(EntityItemPointer entity) override;
virtual void clearEntitiesInternal() override;
public:
void getObjectsToDelete(VectorOfMotionStates& result);
void getObjectsToAdd(VectorOfMotionStates& result);
void setObjectsToChange(const VectorOfMotionStates& objectsToChange);
void getObjectsToChange(VectorOfMotionStates& result);
void handleOutgoingChanges(const VectorOfMotionStates& motionStates, const QUuid& sessionID);
void handleCollisionEvents(const CollisionEvents& collisionEvents);
EntityEditPacketSender* getPacketSender() { return _entityPacketSender; }
private:
// incoming changes
SetOfEntityMotionStates _pendingRemoves; // EntityMotionStates to be removed from PhysicsEngine (and deleted)
SetOfEntities _pendingAdds; // entities to be be added to PhysicsEngine (and a their EntityMotionState created)
SetOfEntityMotionStates _pendingChanges; // EntityMotionStates already in PhysicsEngine that need their physics changed
// outgoing changes
SetOfEntityMotionStates _outgoingChanges; // EntityMotionStates for which we need to send updates to entity-server
SetOfMotionStates _physicalObjects; // MotionStates of entities in PhysicsEngine
PhysicsEnginePointer _physicsEngine = nullptr;
EntityEditPacketSender* _entityPacketSender = nullptr;
uint32_t _lastStepSendPackets = 0;
};
typedef std::shared_ptr<PhysicalEntitySimulation> PhysicalEntitySimulationPointer;
#endif // hifi_PhysicalEntitySimulation_h