Working on streaming edits.

This commit is contained in:
Andrzej Kapolka 2014-01-23 18:05:04 -08:00
parent e6c1aad71f
commit 4414c91f1e
8 changed files with 50 additions and 8 deletions

View file

@ -48,13 +48,12 @@ void MetavoxelSystem::processData(const QByteArray& data, const HifiSockAddr& se
void MetavoxelSystem::simulate(float deltaTime) {
// simulate the clients
foreach (MetavoxelClient* client, _clients) {
client->simulate(deltaTime);
}
_points.clear();
_data.guide(_pointVisitor);
foreach (MetavoxelClient* client, _clients) {
client->simulate(deltaTime, _pointVisitor);
}
_buffer.bind();
int bytes = _points.size() * sizeof(Point);
if (_buffer.size() < bytes) {
@ -188,11 +187,13 @@ MetavoxelClient::MetavoxelClient(const HifiSockAddr& address) :
_receiveRecords.append(record);
}
void MetavoxelClient::simulate(float deltaTime) {
void MetavoxelClient::simulate(float deltaTime, MetavoxelVisitor& visitor) {
Bitstream& out = _sequencer.startPacket();
ClientStateMessage state = { Application::getInstance()->getCamera()->getPosition() };
out << QVariant::fromValue(state);
_sequencer.endPacket();
_data->guide(visitor);
}
void MetavoxelClient::receivedData(const QByteArray& data, const HifiSockAddr& sender) {

View file

@ -90,7 +90,7 @@ public:
const QUuid& getSessionID() const { return _sessionID; }
void simulate(float deltaTime);
void simulate(float deltaTime, MetavoxelVisitor& visitor);
void receivedData(const QByteArray& data, const HifiSockAddr& sender);

View file

@ -375,7 +375,7 @@ bool Applier::visit(MetavoxelInfo& info) {
return false; // entirely contained
}
if (info.size <= _granularity) {
if (volume > 0.5f) {
if (volume >= 0.5f) {
info.outputValues[0] = _value;
}
return false; // reached granularity limit; take best guess

View file

@ -237,6 +237,24 @@ Bitstream& Bitstream::operator>>(QVariant& value) {
return *this;
}
Bitstream& Bitstream::operator<<(const AttributeValue& value) {
_attributeStreamer << value.getAttribute();
if (value.getAttribute()) {
value.getAttribute()->write(*this, value.getValue(), true);
}
return *this;
}
Bitstream& Bitstream::operator>>(AttributeValue& value) {
AttributePointer attribute;
_attributeStreamer >> attribute;
if (attribute) {
void* value;
attribute->read(*this, value, true);
}
return *this;
}
Bitstream& Bitstream::operator<<(const QObject* object) {
if (!object) {
_metaObjectStreamer << NULL;

View file

@ -23,6 +23,7 @@ struct QMetaObject;
class QObject;
class Attribute;
class AttributeValue;
class Bitstream;
class TypeStreamer;
@ -231,6 +232,9 @@ public:
Bitstream& operator<<(const QVariant& value);
Bitstream& operator>>(QVariant& value);
Bitstream& operator<<(const AttributeValue& value);
Bitstream& operator>>(AttributeValue& value);
template<class T> Bitstream& operator<<(const QList<T>& list);
template<class T> Bitstream& operator>>(QList<T>& list);

View file

@ -334,6 +334,9 @@ MetavoxelVisitor::MetavoxelVisitor(const QVector<AttributePointer>& inputs, cons
_outputs(outputs) {
}
MetavoxelVisitor::~MetavoxelVisitor() {
}
PolymorphicData* DefaultMetavoxelGuide::clone() const {
return new DefaultMetavoxelGuide();
}

View file

@ -124,6 +124,7 @@ class MetavoxelVisitor {
public:
MetavoxelVisitor(const QVector<AttributePointer>& inputs, const QVector<AttributePointer>& outputs);
virtual ~MetavoxelVisitor();
/// Returns a reference to the list of input attributes desired.
const QVector<AttributePointer>& getInputs() const { return _inputs; }
@ -142,6 +143,8 @@ protected:
QVector<AttributePointer> _outputs;
};
typedef QSharedPointer<MetavoxelVisitor> MetavoxelVisitorPointer;
/// Interface for objects that guide metavoxel visitors.
class MetavoxelGuide : public PolymorphicData {
public:

View file

@ -29,4 +29,17 @@ class MetavoxelDeltaMessage {
DECLARE_STREAMABLE_METATYPE(MetavoxelDeltaMessage)
/// A simple streamable edit.
class MetavoxelEdit {
STREAMABLE
public:
glm::vec3 minimum;
glm::vec3 maximum;
float granularity;
};
DECLARE_STREAMABLE_METATYPE(MetavoxelEdit)
#endif /* defined(__interface__MetavoxelMessages__) */