mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
rebake mesh when a neighbor changes
This commit is contained in:
parent
4ab8ac29b9
commit
9256917f15
3 changed files with 77 additions and 6 deletions
|
@ -746,6 +746,25 @@ bool RenderablePolyVoxEntityItem::setVoxelInternal(int x, int y, int z, uint8_t
|
|||
_volData->setVoxelAt(x, y, z, toValue);
|
||||
}
|
||||
|
||||
EntityItemPointer currentXNNeighbor = _xNNeighbor.lock();
|
||||
EntityItemPointer currentYNNeighbor = _yNNeighbor.lock();
|
||||
EntityItemPointer currentZNNeighbor = _zNNeighbor.lock();
|
||||
|
||||
if (result) {
|
||||
if (x == 0 && currentXNNeighbor && currentXNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||
auto polyVoxXNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentXNNeighbor);
|
||||
polyVoxXNNeighbor->rebakeMesh();
|
||||
}
|
||||
if (y == 0 && currentYNNeighbor && currentYNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||
auto polyVoxYNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentYNNeighbor);
|
||||
polyVoxYNNeighbor->rebakeMesh();
|
||||
}
|
||||
if (z == 0 && currentZNNeighbor && currentZNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||
auto polyVoxZNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentZNNeighbor);
|
||||
polyVoxZNNeighbor->rebakeMesh();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1274,3 +1293,44 @@ void RenderablePolyVoxEntityItem::computeShapeInfoWorkerAsync() {
|
|||
_threadRunning.release();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void RenderablePolyVoxEntityItem::setXNNeighborID(const EntityItemID& xNNeighborID) {
|
||||
PolyVoxEntityItem::setXNNeighborID(xNNeighborID);
|
||||
}
|
||||
|
||||
void RenderablePolyVoxEntityItem::setYNNeighborID(const EntityItemID& yNNeighborID) {
|
||||
PolyVoxEntityItem::setYNNeighborID(yNNeighborID);
|
||||
}
|
||||
|
||||
void RenderablePolyVoxEntityItem::setZNNeighborID(const EntityItemID& zNNeighborID) {
|
||||
PolyVoxEntityItem::setZNNeighborID(zNNeighborID);
|
||||
}
|
||||
|
||||
|
||||
void RenderablePolyVoxEntityItem::setXPNeighborID(const EntityItemID& xPNeighborID) {
|
||||
if (xPNeighborID != _xPNeighborID) {
|
||||
PolyVoxEntityItem::setXPNeighborID(xPNeighborID);
|
||||
rebakeMesh();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderablePolyVoxEntityItem::setYPNeighborID(const EntityItemID& yPNeighborID) {
|
||||
if (yPNeighborID != _yPNeighborID) {
|
||||
PolyVoxEntityItem::setYPNeighborID(yPNeighborID);
|
||||
rebakeMesh();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderablePolyVoxEntityItem::setZPNeighborID(const EntityItemID& zPNeighborID) {
|
||||
if (zPNeighborID != _zPNeighborID) {
|
||||
PolyVoxEntityItem::setZPNeighborID(zPNeighborID);
|
||||
rebakeMesh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RenderablePolyVoxEntityItem::rebakeMesh() {
|
||||
QReadLocker(&this->_volDataLock);
|
||||
_volDataDirty = true;
|
||||
}
|
||||
|
|
|
@ -106,6 +106,16 @@ public:
|
|||
std::shared_ptr<render::Scene> scene,
|
||||
render::PendingChanges& pendingChanges);
|
||||
|
||||
virtual void setXNNeighborID(const EntityItemID& xNNeighborID);
|
||||
virtual void setYNNeighborID(const EntityItemID& yNNeighborID);
|
||||
virtual void setZNNeighborID(const EntityItemID& zNNeighborID);
|
||||
|
||||
virtual void setXPNeighborID(const EntityItemID& xPNeighborID);
|
||||
virtual void setYPNeighborID(const EntityItemID& yPNeighborID);
|
||||
virtual void setZPNeighborID(const EntityItemID& zPNeighborID);
|
||||
|
||||
virtual void rebakeMesh();
|
||||
|
||||
private:
|
||||
// The PolyVoxEntityItem class has _voxelData which contains dimensions and compressed voxel data. The dimensions
|
||||
// may not match _voxelVolumeSize.
|
||||
|
|
|
@ -105,25 +105,26 @@ class PolyVoxEntityItem : public EntityItem {
|
|||
virtual const QString& getZTextureURL() const { return _zTextureURL; }
|
||||
|
||||
virtual void setXNNeighborID(const EntityItemID& xNNeighborID) { _xNNeighborID = xNNeighborID; }
|
||||
virtual void setXNNeighborID(const QString& xNNeighborID) { _xNNeighborID = QUuid(xNNeighborID); }
|
||||
void setXNNeighborID(const QString& xNNeighborID) { setXNNeighborID(QUuid(xNNeighborID)); }
|
||||
virtual const EntityItemID& getXNNeighborID() const { return _xNNeighborID; }
|
||||
virtual void setYNNeighborID(const EntityItemID& yNNeighborID) { _yNNeighborID = yNNeighborID; }
|
||||
virtual void setYNNeighborID(const QString& yNNeighborID) { _yNNeighborID = QUuid(yNNeighborID); }
|
||||
void setYNNeighborID(const QString& yNNeighborID) { setYNNeighborID(QUuid(yNNeighborID)); }
|
||||
virtual const EntityItemID& getYNNeighborID() const { return _yNNeighborID; }
|
||||
virtual void setZNNeighborID(const EntityItemID& zNNeighborID) { _zNNeighborID = zNNeighborID; }
|
||||
virtual void setZNNeighborID(const QString& zNNeighborID) { _zNNeighborID = QUuid(zNNeighborID); }
|
||||
void setZNNeighborID(const QString& zNNeighborID) { setZNNeighborID(QUuid(zNNeighborID)); }
|
||||
virtual const EntityItemID& getZNNeighborID() const { return _zNNeighborID; }
|
||||
|
||||
virtual void setXPNeighborID(const EntityItemID& xPNeighborID) { _xPNeighborID = xPNeighborID; }
|
||||
virtual void setXPNeighborID(const QString& xPNeighborID) { _xPNeighborID = QUuid(xPNeighborID); }
|
||||
void setXPNeighborID(const QString& xPNeighborID) { setXPNeighborID(QUuid(xPNeighborID)); }
|
||||
virtual const EntityItemID& getXPNeighborID() const { return _xPNeighborID; }
|
||||
virtual void setYPNeighborID(const EntityItemID& yPNeighborID) { _yPNeighborID = yPNeighborID; }
|
||||
virtual void setYPNeighborID(const QString& yPNeighborID) { _yPNeighborID = QUuid(yPNeighborID); }
|
||||
void setYPNeighborID(const QString& yPNeighborID) { setYPNeighborID(QUuid(yPNeighborID)); }
|
||||
virtual const EntityItemID& getYPNeighborID() const { return _yPNeighborID; }
|
||||
virtual void setZPNeighborID(const EntityItemID& zPNeighborID) { _zPNeighborID = zPNeighborID; }
|
||||
virtual void setZPNeighborID(const QString& zPNeighborID) { _zPNeighborID = QUuid(zPNeighborID); }
|
||||
void setZPNeighborID(const QString& zPNeighborID) { setZPNeighborID(QUuid(zPNeighborID)); }
|
||||
virtual const EntityItemID& getZPNeighborID() const { return _zPNeighborID; }
|
||||
|
||||
virtual void rebakeMesh() {};
|
||||
|
||||
protected:
|
||||
glm::vec3 _voxelVolumeSize; // this is always 3 bytes
|
||||
|
|
Loading…
Reference in a new issue