mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-17 10:41:42 +02:00
Starting on delta encoding.
This commit is contained in:
parent
f2ebd76362
commit
11e729c3cc
3 changed files with 62 additions and 0 deletions
|
@ -141,6 +141,9 @@ public:
|
|||
virtual void read(Bitstream& in, void*& value, bool isLeaf) const = 0;
|
||||
virtual void write(Bitstream& out, void* value, bool isLeaf) const = 0;
|
||||
|
||||
virtual void readDelta(Bitstream& in, void*& value, void* reference, bool isLeaf) const { read(in, value, isLeaf); }
|
||||
virtual void writeDelta(Bitstream& out, void* value, void* reference, bool isLeaf) const { write(out, value, isLeaf); }
|
||||
|
||||
virtual bool equal(void* first, void* second) const = 0;
|
||||
|
||||
/// Merges the value of a parent and its children.
|
||||
|
|
|
@ -98,6 +98,12 @@ void MetavoxelData::write(Bitstream& out) const {
|
|||
}
|
||||
}
|
||||
|
||||
void MetavoxelData::readDelta(const MetavoxelData& reference, Bitstream& in) {
|
||||
}
|
||||
|
||||
void MetavoxelData::writeDelta(const MetavoxelData& reference, Bitstream& out) const {
|
||||
}
|
||||
|
||||
MetavoxelNode::MetavoxelNode(const AttributeValue& attributeValue) {
|
||||
_attributeValue = attributeValue.copy();
|
||||
for (int i = 0; i < CHILD_COUNT; i++) {
|
||||
|
@ -183,6 +189,53 @@ void MetavoxelNode::write(const AttributePointer& attribute, Bitstream& out) con
|
|||
}
|
||||
}
|
||||
|
||||
void MetavoxelNode::readDelta(const AttributePointer& attribute, const MetavoxelNode& reference, Bitstream& in) {
|
||||
bool different;
|
||||
in >> different;
|
||||
if (!different) {
|
||||
return;
|
||||
}
|
||||
bool leaf;
|
||||
in >> leaf;
|
||||
attribute->readDelta(in, _attributeValue, reference._attributeValue, leaf);
|
||||
if (leaf) {
|
||||
clearChildren(attribute);
|
||||
|
||||
} else {
|
||||
if (reference.isLeaf()) {
|
||||
for (int i = 0; i < CHILD_COUNT; i++) {
|
||||
_children[i]->read(attribute, in);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < CHILD_COUNT; i++) {
|
||||
_children[i]->readDelta(attribute, *reference._children[i], in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MetavoxelNode::writeDelta(const AttributePointer& attribute, const MetavoxelNode& reference, Bitstream& out) const {
|
||||
if (this == &reference) {
|
||||
out << false;
|
||||
return;
|
||||
}
|
||||
out << true;
|
||||
bool leaf = isLeaf();
|
||||
out << leaf;
|
||||
attribute->writeDelta(out, _attributeValue, reference._attributeValue, leaf);
|
||||
if (!leaf) {
|
||||
if (reference.isLeaf()) {
|
||||
for (int i = 0; i < CHILD_COUNT; i++) {
|
||||
_children[i]->write(attribute, out);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < CHILD_COUNT; i++) {
|
||||
_children[i]->writeDelta(attribute, *reference._children[i], out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MetavoxelNode::destroy(const AttributePointer& attribute) {
|
||||
attribute->destroy(_attributeValue);
|
||||
for (int i = 0; i < CHILD_COUNT; i++) {
|
||||
|
|
|
@ -44,6 +44,9 @@ public:
|
|||
void read(Bitstream& in);
|
||||
void write(Bitstream& out) const;
|
||||
|
||||
void readDelta(const MetavoxelData& reference, Bitstream& in);
|
||||
void writeDelta(const MetavoxelData& reference, Bitstream& out) const;
|
||||
|
||||
private:
|
||||
|
||||
QHash<AttributePointer, MetavoxelNode*> _roots;
|
||||
|
@ -75,6 +78,9 @@ public:
|
|||
void read(const AttributePointer& attribute, Bitstream& in);
|
||||
void write(const AttributePointer& attribute, Bitstream& out) const;
|
||||
|
||||
void readDelta(const AttributePointer& attribute, const MetavoxelNode& reference, Bitstream& in);
|
||||
void writeDelta(const AttributePointer& attribute, const MetavoxelNode& reference, Bitstream& out) const;
|
||||
|
||||
void destroy(const AttributePointer& attribute);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue