mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 18:46:19 +02:00
Working on streaming edits.
This commit is contained in:
parent
e6c1aad71f
commit
4414c91f1e
8 changed files with 50 additions and 8 deletions
|
@ -48,12 +48,11 @@ void MetavoxelSystem::processData(const QByteArray& data, const HifiSockAddr& se
|
||||||
|
|
||||||
void MetavoxelSystem::simulate(float deltaTime) {
|
void MetavoxelSystem::simulate(float deltaTime) {
|
||||||
// simulate the clients
|
// simulate the clients
|
||||||
foreach (MetavoxelClient* client, _clients) {
|
|
||||||
client->simulate(deltaTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
_points.clear();
|
_points.clear();
|
||||||
_data.guide(_pointVisitor);
|
_data.guide(_pointVisitor);
|
||||||
|
foreach (MetavoxelClient* client, _clients) {
|
||||||
|
client->simulate(deltaTime, _pointVisitor);
|
||||||
|
}
|
||||||
|
|
||||||
_buffer.bind();
|
_buffer.bind();
|
||||||
int bytes = _points.size() * sizeof(Point);
|
int bytes = _points.size() * sizeof(Point);
|
||||||
|
@ -188,11 +187,13 @@ MetavoxelClient::MetavoxelClient(const HifiSockAddr& address) :
|
||||||
_receiveRecords.append(record);
|
_receiveRecords.append(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetavoxelClient::simulate(float deltaTime) {
|
void MetavoxelClient::simulate(float deltaTime, MetavoxelVisitor& visitor) {
|
||||||
Bitstream& out = _sequencer.startPacket();
|
Bitstream& out = _sequencer.startPacket();
|
||||||
ClientStateMessage state = { Application::getInstance()->getCamera()->getPosition() };
|
ClientStateMessage state = { Application::getInstance()->getCamera()->getPosition() };
|
||||||
out << QVariant::fromValue(state);
|
out << QVariant::fromValue(state);
|
||||||
_sequencer.endPacket();
|
_sequencer.endPacket();
|
||||||
|
|
||||||
|
_data->guide(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetavoxelClient::receivedData(const QByteArray& data, const HifiSockAddr& sender) {
|
void MetavoxelClient::receivedData(const QByteArray& data, const HifiSockAddr& sender) {
|
||||||
|
|
|
@ -90,7 +90,7 @@ public:
|
||||||
|
|
||||||
const QUuid& getSessionID() const { return _sessionID; }
|
const QUuid& getSessionID() const { return _sessionID; }
|
||||||
|
|
||||||
void simulate(float deltaTime);
|
void simulate(float deltaTime, MetavoxelVisitor& visitor);
|
||||||
|
|
||||||
void receivedData(const QByteArray& data, const HifiSockAddr& sender);
|
void receivedData(const QByteArray& data, const HifiSockAddr& sender);
|
||||||
|
|
||||||
|
|
|
@ -375,7 +375,7 @@ bool Applier::visit(MetavoxelInfo& info) {
|
||||||
return false; // entirely contained
|
return false; // entirely contained
|
||||||
}
|
}
|
||||||
if (info.size <= _granularity) {
|
if (info.size <= _granularity) {
|
||||||
if (volume > 0.5f) {
|
if (volume >= 0.5f) {
|
||||||
info.outputValues[0] = _value;
|
info.outputValues[0] = _value;
|
||||||
}
|
}
|
||||||
return false; // reached granularity limit; take best guess
|
return false; // reached granularity limit; take best guess
|
||||||
|
|
|
@ -237,6 +237,24 @@ Bitstream& Bitstream::operator>>(QVariant& value) {
|
||||||
return *this;
|
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) {
|
Bitstream& Bitstream::operator<<(const QObject* object) {
|
||||||
if (!object) {
|
if (!object) {
|
||||||
_metaObjectStreamer << NULL;
|
_metaObjectStreamer << NULL;
|
||||||
|
|
|
@ -23,6 +23,7 @@ struct QMetaObject;
|
||||||
class QObject;
|
class QObject;
|
||||||
|
|
||||||
class Attribute;
|
class Attribute;
|
||||||
|
class AttributeValue;
|
||||||
class Bitstream;
|
class Bitstream;
|
||||||
class TypeStreamer;
|
class TypeStreamer;
|
||||||
|
|
||||||
|
@ -231,6 +232,9 @@ public:
|
||||||
Bitstream& operator<<(const QVariant& value);
|
Bitstream& operator<<(const QVariant& value);
|
||||||
Bitstream& operator>>(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<<(const QList<T>& list);
|
||||||
template<class T> Bitstream& operator>>(QList<T>& list);
|
template<class T> Bitstream& operator>>(QList<T>& list);
|
||||||
|
|
||||||
|
|
|
@ -334,6 +334,9 @@ MetavoxelVisitor::MetavoxelVisitor(const QVector<AttributePointer>& inputs, cons
|
||||||
_outputs(outputs) {
|
_outputs(outputs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetavoxelVisitor::~MetavoxelVisitor() {
|
||||||
|
}
|
||||||
|
|
||||||
PolymorphicData* DefaultMetavoxelGuide::clone() const {
|
PolymorphicData* DefaultMetavoxelGuide::clone() const {
|
||||||
return new DefaultMetavoxelGuide();
|
return new DefaultMetavoxelGuide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ class MetavoxelVisitor {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MetavoxelVisitor(const QVector<AttributePointer>& inputs, const QVector<AttributePointer>& outputs);
|
MetavoxelVisitor(const QVector<AttributePointer>& inputs, const QVector<AttributePointer>& outputs);
|
||||||
|
virtual ~MetavoxelVisitor();
|
||||||
|
|
||||||
/// Returns a reference to the list of input attributes desired.
|
/// Returns a reference to the list of input attributes desired.
|
||||||
const QVector<AttributePointer>& getInputs() const { return _inputs; }
|
const QVector<AttributePointer>& getInputs() const { return _inputs; }
|
||||||
|
@ -142,6 +143,8 @@ protected:
|
||||||
QVector<AttributePointer> _outputs;
|
QVector<AttributePointer> _outputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef QSharedPointer<MetavoxelVisitor> MetavoxelVisitorPointer;
|
||||||
|
|
||||||
/// Interface for objects that guide metavoxel visitors.
|
/// Interface for objects that guide metavoxel visitors.
|
||||||
class MetavoxelGuide : public PolymorphicData {
|
class MetavoxelGuide : public PolymorphicData {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -29,4 +29,17 @@ class MetavoxelDeltaMessage {
|
||||||
|
|
||||||
DECLARE_STREAMABLE_METATYPE(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__) */
|
#endif /* defined(__interface__MetavoxelMessages__) */
|
||||||
|
|
Loading…
Reference in a new issue