Merge branch 'master' of https://github.com/highfidelity/hifi into metavoxels

This commit is contained in:
Andrzej Kapolka 2014-12-09 18:09:38 -08:00
commit 65bd3a3d26
13 changed files with 31 additions and 46 deletions

View file

@ -22,7 +22,7 @@ var velocity = {
y: 0,
z: 1 };
var damping = 0.1;
var damping = 0;
var color = {
red: 255,

View file

@ -9,8 +9,7 @@
//
Script.load("lookWithTouch.js");
Script.load("editVoxels.js");
Script.load("editModels.js");
Script.load("editEntities.js");
Script.load("selectAudioDevice.js");
Script.load("hydraMove.js");
Script.load("headMove.js");

View file

@ -15,6 +15,7 @@ var panelWall = false;
var orbShell = false;
var reticle = false;
var descriptionText = false;
var showText = false;
// used for formating the description text, in meters
var textWidth = 4;
@ -313,7 +314,7 @@ function handleLookAt(pickRay) {
var actionLocation = locations[panelIndex];
if (actionLocation.description == "") {
Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: true });
Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: showText });
} else {
// handle line wrapping
var allWords = actionLocation.description.split(" ");
@ -345,7 +346,7 @@ function handleLookAt(pickRay) {
}
}
formatedDescription += currentGoodLine;
Overlays.editOverlay(descriptionText, { text: formatedDescription, visible: true });
Overlays.editOverlay(descriptionText, { text: formatedDescription, visible: showText });
}
} else {
Overlays.editOverlay(descriptionText, { text: "", visible: false });

View file

@ -170,12 +170,6 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
quint64 now = usecTimestampNow();
Collision collision;
collision.penetration = penetration;
// for now the contactPoint is the average between the the two paricle centers
collision.contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition());
emitGlobalEntityCollisionWithEntity(entityA, entityB, collision);
glm::vec3 axis = glm::normalize(penetration);
glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
@ -232,7 +226,13 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
// thereby waking up static non-moving entities.
_entityTree->updateEntity(entityB, propertiesB);
_packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB);
}
}
// NOTE: Do this after updating the entities so that the callback can delete the entities if they want to
Collision collision;
collision.penetration = penetration;
collision.contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition());
emitGlobalEntityCollisionWithEntity(entityA, entityB, collision);
}
}
}

View file

@ -227,8 +227,6 @@ public:
float getSize() const; /// get maximum dimension in domain scale units (0.0 - 1.0)
AACube getMaximumAACube() const;
AACube getMinimumAACube() const;
AACube getOldMaximumAACube() const { return _oldMaximumAACube; }
void setOldMaximumAACube(const AACube& cube) { _oldMaximumAACube = cube; }
AABox getAABox() const; /// axis aligned bounding box in domain scale units (0.0 - 1.0)
static const QString DEFAULT_SCRIPT;
@ -347,7 +345,6 @@ protected:
void setRadius(float value);
AACubeShape _collisionShape;
AACube _oldMaximumAACube; // remember this so we know where the entity used to live in the tree
// DirtyFlags are set whenever a property changes that the EntitySimulation needs to know about.
uint32_t _dirtyFlags; // things that have changed from EXTERNAL changes (via script or packet) but NOT from simulation

View file

@ -106,7 +106,6 @@ void EntitySimulation::sortEntitiesThatMoved() {
if (moveOperator.hasMovingEntities()) {
PerformanceTimer perfTimer("recurseTreeWithOperator");
_entityTree->recurseTreeWithOperator(&moveOperator);
moveOperator.finish();
}
}

View file

@ -83,7 +83,6 @@ EntityItem* EntityTree::getOrCreateEntityItem(const EntityItemID& entityID, cons
/// Adds a new entity item to the tree
void EntityTree::postAddEntity(EntityItem* entity) {
assert(entity);
entity->setOldMaximumAACube(entity->getMaximumAACube());
// check to see if we need to simulate this entity..
if (_simulation) {
_simulation->addEntity(entity);
@ -138,7 +137,6 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro
UpdateEntityOperator theOperator(this, containingElement, entity, properties);
recurseTreeWithOperator(&theOperator);
entity->setOldMaximumAACube(entity->getMaximumAACube());
_isDirty = true;
if (_simulation && entity->getDirtyFlags() != 0) {

View file

@ -52,14 +52,10 @@ MovingEntitiesOperator::~MovingEntitiesOperator() {
void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACube& newCube) {
EntityTreeElement* oldContainingElement = _tree->getContainingElement(entity->getEntityItemID());
AABox newCubeClamped = newCube.clamp(0.0f, 1.0f);
AACube oldCube = entity->getOldMaximumAACube();
AABox oldCubeClamped = oldCube.clamp(0.0f, 1.0f);
if (_wantDebug) {
qDebug() << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------";
qDebug() << " oldCube:" << oldCube;
qDebug() << " newCube:" << newCube;
qDebug() << " oldCubeClamped:" << oldCubeClamped;
qDebug() << " newCubeClamped:" << newCubeClamped;
if (oldContainingElement) {
qDebug() << " oldContainingElement:" << oldContainingElement->getAACube();
@ -86,9 +82,7 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACub
details.entity = entity;
details.oldFound = false;
details.newFound = false;
details.oldCube = oldCube;
details.newCube = newCube;
details.oldCubeClamped = oldCubeClamped;
details.newCubeClamped = newCubeClamped;
_entitiesToMove << details;
_lookingCount++;
@ -97,7 +91,6 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACub
qDebug() << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------";
qDebug() << " details.entity:" << details.entity->getEntityItemID();
qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube;
qDebug() << " details.oldCube:" << details.oldCube;
qDebug() << " details.newCube:" << details.newCube;
qDebug() << " details.newCubeClamped:" << details.newCubeClamped;
qDebug() << " _lookingCount:" << _lookingCount;
@ -130,17 +123,14 @@ bool MovingEntitiesOperator::shouldRecurseSubTree(OctreeElement* element) {
qDebug() << " element:" << element->getAACube();
qDebug() << " details.entity:" << details.entity->getEntityItemID();
qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube;
qDebug() << " details.oldCube:" << details.oldCube;
qDebug() << " details.newCube:" << details.newCube;
qDebug() << " details.newCubeClamped:" << details.newCubeClamped;
qDebug() << " elementCube.contains(details.oldCube)" << elementCube.contains(details.oldCube);
qDebug() << " elementCube.contains(details.newCube)" << elementCube.contains(details.newCube);
qDebug() << " elementCube.contains(details.oldCubeClamped)" << elementCube.contains(details.oldCubeClamped);
qDebug() << " elementCube.contains(details.newCubeClamped)" << elementCube.contains(details.newCubeClamped);
qDebug() << "--------------------------------------------------------------------------";
}
if (elementCube.contains(details.oldCubeClamped) || elementCube.contains(details.newCubeClamped)) {
if (elementCube.contains(details.oldContainingElementCube) || elementCube.contains(details.newCubeClamped)) {
containsEntity = true;
break; // if it contains at least one, we're good to go
}
@ -179,7 +169,6 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) {
qDebug() << " details.entity:" << details.entity->getEntityItemID();
qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube;
qDebug() << " entityTreeElement:" << entityTreeElement;
qDebug() << " details.oldCube:" << details.oldCube;
qDebug() << " details.newCube:" << details.newCube;
qDebug() << " details.newCubeClamped:" << details.newCubeClamped;
qDebug() << " _lookingCount:" << _lookingCount;
@ -291,9 +280,3 @@ OctreeElement* MovingEntitiesOperator::possiblyCreateChildAt(OctreeElement* elem
}
return NULL;
}
void MovingEntitiesOperator::finish() {
foreach(const EntityToMoveDetails& details, _entitiesToMove) {
details.entity->setOldMaximumAACube(details.newCube);
}
}

View file

@ -17,7 +17,6 @@ public:
EntityItem* entity;
AACube oldCube;
AACube newCube;
AABox oldCubeClamped;
AABox newCubeClamped;
EntityTreeElement* oldContainingElement;
AACube oldContainingElementCube;
@ -43,7 +42,6 @@ public:
virtual bool postRecursion(OctreeElement* element);
virtual OctreeElement* possiblyCreateChildAt(OctreeElement* element, int childIndex);
bool hasMovingEntities() const { return _entitiesToMove.size() > 0; }
void finish();
private:
EntityTree* _tree;
QSet<EntityToMoveDetails> _entitiesToMove;

View file

@ -19,7 +19,7 @@
#include "MetavoxelMessages.h"
// in sequencer parlance, a "packet" may consist of multiple datagrams. clarify when we refer to actual datagrams
const int MAX_DATAGRAM_SIZE = 1450;
const int MAX_DATAGRAM_SIZE = MAX_PACKET_SIZE;
const int DEFAULT_MAX_PACKET_SIZE = 3000;
@ -45,7 +45,8 @@ DatagramSequencer::DatagramSequencer(const QByteArray& datagramHeader, QObject*
_packetsToWrite(0.0f),
_slowStartThreshold(DEFAULT_SLOW_START_THRESHOLD),
_packetRateIncreasePacketNumber(0),
_packetRateDecreasePacketNumber(0) {
_packetRateDecreasePacketNumber(0),
_packetDropCount(0) {
_outgoingPacketStream.setByteOrder(QDataStream::LittleEndian);
_incomingDatagramStream.setByteOrder(QDataStream::LittleEndian);
@ -348,11 +349,18 @@ void DatagramSequencer::sendRecordLost(const SendRecord& record) {
}
}
// halve the rate and remember as threshold
if (record.packetNumber >= _packetRateDecreasePacketNumber) {
_packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f);
_slowStartThreshold = _packetsPerGroup;
_packetRateDecreasePacketNumber = _outgoingPacketNumber + 1;
// if we've lost three in a row, halve the rate and remember as threshold
if (_packetDropCount == 0 || record.packetNumber == _lastPacketDropped + 1) {
_packetDropCount++;
_lastPacketDropped = record.packetNumber;
const int CONSECUTIVE_DROPS_BEFORE_REDUCTION = 3;
if (_packetDropCount >= CONSECUTIVE_DROPS_BEFORE_REDUCTION && record.packetNumber >= _packetRateDecreasePacketNumber) {
_packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f);
_slowStartThreshold = _packetsPerGroup;
_packetRateDecreasePacketNumber = _outgoingPacketNumber + 1;
}
} else {
_packetDropCount = 0;
}
}

View file

@ -238,6 +238,8 @@ private:
float _slowStartThreshold;
int _packetRateIncreasePacketNumber;
int _packetRateDecreasePacketNumber;
int _packetDropCount;
int _lastPacketDropped;
QHash<int, ReliableChannel*> _reliableOutputChannels;
QHash<int, ReliableChannel*> _reliableInputChannels;

View file

@ -31,7 +31,7 @@
#include "DomainHandler.h"
#include "Node.h"
const int MAX_PACKET_SIZE = 1500;
const int MAX_PACKET_SIZE = 1450;
const quint64 NODE_SILENCE_THRESHOLD_MSECS = 2 * 1000;