mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:22:57 +02:00
change how polyvox neighbors are notified of updates
This commit is contained in:
parent
f54d924f4a
commit
16ee5199e8
2 changed files with 58 additions and 25 deletions
|
@ -164,8 +164,6 @@ bool RenderablePolyVoxEntityItem::setVoxel(int x, int y, int z, uint8_t toValue)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheNeighbors();
|
|
||||||
|
|
||||||
_volDataLock.lockForWrite();
|
_volDataLock.lockForWrite();
|
||||||
bool result = setVoxelInternal(x, y, z, toValue);
|
bool result = setVoxelInternal(x, y, z, toValue);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -748,25 +746,6 @@ bool RenderablePolyVoxEntityItem::setVoxelInternal(int x, int y, int z, uint8_t
|
||||||
_volData->setVoxelAt(x, y, z, toValue);
|
_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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,6 +780,10 @@ void RenderablePolyVoxEntityItem::decompressVolumeData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// take compressed data and expand it into _volData.
|
// take compressed data and expand it into _volData.
|
||||||
void RenderablePolyVoxEntityItem::decompressVolumeDataAsync() {
|
void RenderablePolyVoxEntityItem::decompressVolumeDataAsync() {
|
||||||
_voxelDataLock.lockForRead();
|
_voxelDataLock.lockForRead();
|
||||||
|
@ -1136,7 +1119,7 @@ void RenderablePolyVoxEntityItem::getMeshAsync() {
|
||||||
_meshLock.unlock();
|
_meshLock.unlock();
|
||||||
_volDataDirty = false;
|
_volDataDirty = false;
|
||||||
_volDataLock.unlock();
|
_volDataLock.unlock();
|
||||||
|
bonkNeighbors();
|
||||||
_threadRunning.release();
|
_threadRunning.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1294,15 +1277,42 @@ void RenderablePolyVoxEntityItem::computeShapeInfoWorkerAsync() {
|
||||||
|
|
||||||
|
|
||||||
void RenderablePolyVoxEntityItem::setXNNeighborID(const EntityItemID& xNNeighborID) {
|
void RenderablePolyVoxEntityItem::setXNNeighborID(const EntityItemID& xNNeighborID) {
|
||||||
PolyVoxEntityItem::setXNNeighborID(xNNeighborID);
|
if (xNNeighborID != _xNNeighborID) {
|
||||||
|
PolyVoxEntityItem::setXNNeighborID(xNNeighborID);
|
||||||
|
cacheNeighbors();
|
||||||
|
EntityItemPointer currentXNNeighbor = _xNNeighbor.lock();
|
||||||
|
if (currentXNNeighbor && currentXNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||||
|
auto polyVoxXNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentXNNeighbor);
|
||||||
|
polyVoxXNNeighbor->setXPNeighborID(_id);
|
||||||
|
polyVoxXNNeighbor->rebakeMesh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderablePolyVoxEntityItem::setYNNeighborID(const EntityItemID& yNNeighborID) {
|
void RenderablePolyVoxEntityItem::setYNNeighborID(const EntityItemID& yNNeighborID) {
|
||||||
PolyVoxEntityItem::setYNNeighborID(yNNeighborID);
|
if (yNNeighborID != _yNNeighborID) {
|
||||||
|
PolyVoxEntityItem::setYNNeighborID(yNNeighborID);
|
||||||
|
cacheNeighbors();
|
||||||
|
EntityItemPointer currentYNNeighbor = _yNNeighbor.lock();
|
||||||
|
if (currentYNNeighbor && currentYNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||||
|
auto polyVoxYNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentYNNeighbor);
|
||||||
|
polyVoxYNNeighbor->setYPNeighborID(_id);
|
||||||
|
polyVoxYNNeighbor->rebakeMesh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderablePolyVoxEntityItem::setZNNeighborID(const EntityItemID& zNNeighborID) {
|
void RenderablePolyVoxEntityItem::setZNNeighborID(const EntityItemID& zNNeighborID) {
|
||||||
PolyVoxEntityItem::setZNNeighborID(zNNeighborID);
|
if (zNNeighborID != _zNNeighborID) {
|
||||||
|
PolyVoxEntityItem::setZNNeighborID(zNNeighborID);
|
||||||
|
cacheNeighbors();
|
||||||
|
EntityItemPointer currentZNNeighbor = _yNNeighbor.lock();
|
||||||
|
if (currentZNNeighbor && currentZNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||||
|
auto polyVoxZNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentZNNeighbor);
|
||||||
|
polyVoxZNNeighbor->setZPNeighborID(_id);
|
||||||
|
polyVoxZNNeighbor->rebakeMesh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1332,3 +1342,25 @@ void RenderablePolyVoxEntityItem::rebakeMesh() {
|
||||||
QReadLocker(&this->_volDataLock);
|
QReadLocker(&this->_volDataLock);
|
||||||
_volDataDirty = true;
|
_volDataDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderablePolyVoxEntityItem::bonkNeighbors() {
|
||||||
|
clearOutOfDateNeighbors();
|
||||||
|
cacheNeighbors();
|
||||||
|
|
||||||
|
EntityItemPointer currentXNNeighbor = _xNNeighbor.lock();
|
||||||
|
EntityItemPointer currentYNNeighbor = _yNNeighbor.lock();
|
||||||
|
EntityItemPointer currentZNNeighbor = _zNNeighbor.lock();
|
||||||
|
|
||||||
|
if (currentXNNeighbor && currentXNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||||
|
auto polyVoxXNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentXNNeighbor);
|
||||||
|
polyVoxXNNeighbor->rebakeMesh();
|
||||||
|
}
|
||||||
|
if (currentYNNeighbor && currentYNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||||
|
auto polyVoxYNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentYNNeighbor);
|
||||||
|
polyVoxYNNeighbor->rebakeMesh();
|
||||||
|
}
|
||||||
|
if (currentZNNeighbor && currentZNNeighbor->getType() == EntityTypes::PolyVox) {
|
||||||
|
auto polyVoxZNNeighbor = std::dynamic_pointer_cast<RenderablePolyVoxEntityItem>(currentZNNeighbor);
|
||||||
|
polyVoxZNNeighbor->rebakeMesh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -169,6 +169,7 @@ private:
|
||||||
void clearOutOfDateNeighbors();
|
void clearOutOfDateNeighbors();
|
||||||
void cacheNeighbors();
|
void cacheNeighbors();
|
||||||
void copyUpperEdgesFromNeighbors();
|
void copyUpperEdgesFromNeighbors();
|
||||||
|
void bonkNeighbors();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue