ObjectMotionState puts self on outgoing queue

This commit is contained in:
Andrew Meadows 2014-12-11 12:40:43 -08:00
parent 572ceb75a4
commit 4977bfb708
4 changed files with 24 additions and 2 deletions

View file

@ -68,6 +68,8 @@ void EntityMotionState::setWorldTransform (const btTransform &worldTrans) {
_entity->setAngularVelocity(v);
_outgoingPacketFlags = DIRTY_PHYSICS_FLAGS;
ObjectMotionState::enqueueOutgoingPacket(this);
}
#endif // USE_BULLET_PHYSICS

View file

@ -31,6 +31,7 @@ const float DEFAULT_RESTITUTION = 0.0f;
// origin of physics simulation in world frame
glm::vec3 _worldOffset(0.0f);
QSet<ObjectMotionState*>* _outgoingPacketQueue;
// static
void ObjectMotionState::setWorldOffset(const glm::vec3& offset) {
@ -42,6 +43,18 @@ const glm::vec3& ObjectMotionState::getWorldOffset() {
return _worldOffset;
}
// static
void ObjectMotionState::setOutgoingPacketQueue(QSet<ObjectMotionState*>* outgoing) {
assert(outgoing);
_outgoingPacketQueue = outgoing;
}
// static
void ObjectMotionState::enqueueOutgoingPacket(ObjectMotionState* state) {
assert(_outgoingPacketQueue);
_outgoingPacketQueue->insert(state);
}
ObjectMotionState::ObjectMotionState() :
_density(DEFAULT_DENSITY),
_volume(DEFAULT_VOLUME),

View file

@ -51,6 +51,11 @@ public:
static void setWorldOffset(const glm::vec3& offset);
static const glm::vec3& getWorldOffset();
// The OutgoingPacketQueue is a QSet of ObjectMotionState*'s that need to send update packets to the EntityServer.
// All ObjectMotionState's with outgoing changes put themselves on the list.
static void setOutgoingPacketQueue(QSet<ObjectMotionState*>* queue);
static void enqueueOutgoingPacket(ObjectMotionState* state);
ObjectMotionState();
~ObjectMotionState();

View file

@ -10,10 +10,11 @@
//
// TODO DONE: make _incomingChanges to be list of MotionState*'s.
// TODO DONE: make MotionState able to clear incoming flags
// TODO: make MotionState::setWorldTransform() put itself on _incomingChanges list
// TODO: make sure incoming and outgoing pipelines are connected
// TODO DONE: make MotionState::setWorldTransform() put itself on _incomingChanges list
// TODO: give PhysicsEngine instance an _entityPacketSender
// TODO: make sure incoming and outgoing pipelines are connected
// TODO: provide some sort of "reliable" send for "stopped" update
// TODO: make sure code compiles when BULLET is not found
#include "PhysicsEngine.h"
#ifdef USE_BULLET_PHYSICS
@ -165,6 +166,7 @@ void PhysicsEngine::init() {
_dynamicsWorld->addCollisionObject(groundObject);
}
}
ObjectMotionState::setOutgoingPacketQueue(&_outgoingPackets);
}
const float FIXED_SUBSTEP = 1.0f / 60.0f;