mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 21:43:13 +02:00
More work on subdivision.
This commit is contained in:
parent
5710bfcf6c
commit
6be1810967
4 changed files with 47 additions and 0 deletions
|
@ -147,6 +147,14 @@ void SharedObject::readExtraDelta(Bitstream& in, const SharedObject* reference)
|
||||||
// nothing by default
|
// nothing by default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SharedObject::writeExtraSubdivision(Bitstream& out) {
|
||||||
|
// nothing by default
|
||||||
|
}
|
||||||
|
|
||||||
|
void SharedObject::readExtraSubdivision(Bitstream& in) {
|
||||||
|
// nothing by default
|
||||||
|
}
|
||||||
|
|
||||||
QAtomicInt SharedObject::_nextID(1);
|
QAtomicInt SharedObject::_nextID(1);
|
||||||
WeakSharedObjectHash SharedObject::_weakHash;
|
WeakSharedObjectHash SharedObject::_weakHash;
|
||||||
QReadWriteLock SharedObject::_weakHashLock;
|
QReadWriteLock SharedObject::_weakHashLock;
|
||||||
|
|
|
@ -92,6 +92,12 @@ public:
|
||||||
/// Reads the delta-encoded non-property contents of this object from the specified stream.
|
/// Reads the delta-encoded non-property contents of this object from the specified stream.
|
||||||
virtual void readExtraDelta(Bitstream& in, const SharedObject* reference);
|
virtual void readExtraDelta(Bitstream& in, const SharedObject* reference);
|
||||||
|
|
||||||
|
/// Writes the subdivision of the non-property contents of this object to the specified stream.
|
||||||
|
virtual void writeExtraSubdivision(Bitstream& out);
|
||||||
|
|
||||||
|
/// Reads the subdivision of the non-property contents of this object from the specified stream.
|
||||||
|
virtual void readExtraSubdivision(Bitstream& in);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int _id;
|
int _id;
|
||||||
|
|
|
@ -2731,6 +2731,37 @@ void Heightfield::readExtraDelta(Bitstream& in, const SharedObject* reference) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Heightfield::writeExtraSubdivision(Bitstream& out) {
|
||||||
|
MetavoxelLOD lod, referenceLOD;
|
||||||
|
if (out.getContext()) {
|
||||||
|
MetavoxelStreamBase* base = static_cast<MetavoxelStreamBase*>(out.getContext());
|
||||||
|
lod = transformLOD(base->lod);
|
||||||
|
referenceLOD = transformLOD(base->referenceLOD);
|
||||||
|
}
|
||||||
|
HeightfieldStreamBase base = { out, lod, referenceLOD };
|
||||||
|
HeightfieldStreamState state = { base, glm::vec2(), 1.0f };
|
||||||
|
|
||||||
|
if (state.becameSubdivided()) {
|
||||||
|
out << SharedObjectPointer(this);
|
||||||
|
_root->writeSubdivision(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Heightfield::readExtraSubdivision(Bitstream& in) {
|
||||||
|
MetavoxelLOD lod, referenceLOD;
|
||||||
|
if (in.getContext()) {
|
||||||
|
MetavoxelStreamBase* base = static_cast<MetavoxelStreamBase*>(in.getContext());
|
||||||
|
lod = transformLOD(base->lod);
|
||||||
|
referenceLOD = transformLOD(base->referenceLOD);
|
||||||
|
}
|
||||||
|
HeightfieldStreamBase base = { in, lod, referenceLOD };
|
||||||
|
HeightfieldStreamState state = { base, glm::vec2(), 1.0f };
|
||||||
|
|
||||||
|
if (state.becameSubdividedOrCollapsed()) {
|
||||||
|
setRoot(HeightfieldNodePointer(_root->readSubdivision(state)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray Heightfield::getRendererClassName() const {
|
QByteArray Heightfield::getRendererClassName() const {
|
||||||
return "HeightfieldRenderer";
|
return "HeightfieldRenderer";
|
||||||
}
|
}
|
||||||
|
|
|
@ -592,6 +592,8 @@ public:
|
||||||
virtual void readExtra(Bitstream& in);
|
virtual void readExtra(Bitstream& in);
|
||||||
virtual void writeExtraDelta(Bitstream& out, const SharedObject* reference) const;
|
virtual void writeExtraDelta(Bitstream& out, const SharedObject* reference) const;
|
||||||
virtual void readExtraDelta(Bitstream& in, const SharedObject* reference);
|
virtual void readExtraDelta(Bitstream& in, const SharedObject* reference);
|
||||||
|
virtual void writeExtraSubdivision(Bitstream& out);
|
||||||
|
virtual void readExtraSubdivision(Bitstream& in);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue