History

if an entity is being moved and has no sim-id, set sim-id to local node-id. if it has a sim-id, and it's not the same as the local node's, don't broadcast the change

Seth Alves committed 11 years ago

Commit eace91e1 parent e2af93d2 files · +39 −3Browse files

Showing the changes to libraries/physics/src/EntityMotionState.cpp (1 of 2 files). Show all

Unified · Split

libraries/physics/src/EntityMotionState.cpp+38−3
@@ -179,12 +179,41 @@ float EntityMotionState::computeMass(const ShapeInfo& shapeInfo) const { · 178 unmodified lines
179 return _entity->computeMass();179 return _entity->computeMass();
180}180}
181 181
182void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_t frame) {
183 182
184 qDebug() << "-------------------------------------------";183bool EntityMotionState::shouldSendUpdate(uint32_t simulationFrame) {
185 qDebug() << "EntityMotionState::sendUpdate" << _type << _motionType << _isKinematic;184 bool baseResult = this->ObjectMotionState::shouldSendUpdate(simulationFrame);
185
186 if (!baseResult) {
187 return false;
188 }
189
186 auto nodeList = DependencyManager::get<NodeList>();190 auto nodeList = DependencyManager::get<NodeList>();
191 QString myNodeID = nodeList->getSessionUUID().toString();
192 QString simulatorID = _entity->getSimulatorID();
193
194 if (simulatorID.isEmpty() && _body->isActive()) {
195 // The object is moving and nobody thinks they own the motion. set this Node as the simulator
196 _entity->setSimulatorID(myNodeID);
197 simulatorID = myNodeID;
198 } else if (simulatorID == myNodeID && !_body->isActive()) {
199 // we are the simulator and the object has stopped. give up "simulator" status
200 _entity->setSimulatorID("");
201 simulatorID = "";
202 }
203
204 if (simulatorID != myNodeID) {
205 // some other Node is simulating this, so don't broadcast our computations.
206 qDebug() << "EntityMotionState::shouldSendUpdate baseResult=" << baseResult << "but"
207 << simulatorID << "!=" << myNodeID;
208 return false;
209 }
187 210
211 qDebug() << "EntityMotionState::shouldSendUpdate baseResult=" << baseResult;
212 return baseResult;
213}
214
215
216void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_t frame) {
188 if (!_entity->isKnownID()) {217 if (!_entity->isKnownID()) {
189 return; // never update entities that are unknown218 return; // never update entities that are unknown
190 }219 }
@@ -218,6 +247,12 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ · 27 unmodified lines
218 }247 }
219 248
220 _sentMoving = ! (zeroSpeed && zeroSpin);249 _sentMoving = ! (zeroSpeed && zeroSpin);
250
251
252 qDebug() << "-------------------------------------------";
253 qDebug() << "EntityMotionState::sendUpdate" << _sentMoving << _body->isActive();
254
255
221 } else {256 } else {
222 _sentVelocity = _sentAngularVelocity = glm::vec3(0.0f);257 _sentVelocity = _sentAngularVelocity = glm::vec3(0.0f);
223 _sentMoving = false;258 _sentMoving = false;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t