mirror of
https://github.com/overte-org/overte.git
synced 2025-08-14 14:39:55 +02:00
Merge pull request #268 from ZappoMan/render_voxels_optimization
create and delete voxels locally
This commit is contained in:
commit
6c140b3b2f
3 changed files with 40 additions and 0 deletions
|
@ -898,3 +898,30 @@ void VoxelSystem::collectStatsForTreesAndVBOs() {
|
|||
minInVBO, maxInVBO, _voxelsInWriteArrays, _voxelsInReadArrays);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void VoxelSystem::deleteVoxelAt(float x, float y, float z, float s) {
|
||||
//printLog("VoxelSystem::deleteVoxelAt(%f,%f,%f,%f)\n",x,y,z,s);
|
||||
_tree->deleteVoxelAt(x, y, z, s);
|
||||
setupNewVoxelsForDrawing();
|
||||
};
|
||||
|
||||
VoxelNode* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const {
|
||||
return _tree->getVoxelAt(x, y, z, s);
|
||||
};
|
||||
|
||||
void VoxelSystem::createVoxel(float x, float y, float z, float s, unsigned char red, unsigned char green, unsigned char blue) {
|
||||
//printLog("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s);
|
||||
_tree->createVoxel(x, y, z, s, red, green, blue);
|
||||
setupNewVoxelsForDrawing();
|
||||
};
|
||||
|
||||
void VoxelSystem::createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color) {
|
||||
_tree->createLine(point1, point2, unitSize, color);
|
||||
setupNewVoxelsForDrawing();
|
||||
};
|
||||
|
||||
void VoxelSystem::createSphere(float r,float xc, float yc, float zc, float s, bool solid, creationMode mode, bool debug) {
|
||||
_tree->createSphere(r, xc, yc, zc, s, solid, mode, debug);
|
||||
setupNewVoxelsForDrawing();
|
||||
};
|
||||
|
|
|
@ -70,6 +70,12 @@ public:
|
|||
VoxelDetail& detail, float& distance, BoxFace& face);
|
||||
|
||||
void collectStatsForTreesAndVBOs();
|
||||
|
||||
void deleteVoxelAt(float x, float y, float z, float s);
|
||||
VoxelNode* getVoxelAt(float x, float y, float z, float s) const;
|
||||
void createVoxel(float x, float y, float z, float s, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color);
|
||||
void createSphere(float r,float xc, float yc, float zc, float s, bool solid, creationMode mode, bool debug = false);
|
||||
|
||||
private:
|
||||
int _callsToTreesToArrays;
|
||||
|
|
|
@ -1529,6 +1529,9 @@ void addVoxelUnderCursor() {
|
|||
if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &detail, bufferOut, sizeOut)){
|
||||
AgentList::getInstance()->broadcastToAgents(bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1);
|
||||
delete bufferOut;
|
||||
|
||||
// create the voxel locally so it appears immediately
|
||||
voxels.createVoxel(detail.x, detail.y, detail.z, detail.s, detail.red, detail.green, detail.blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1547,6 +1550,10 @@ void deleteVoxelUnderCursor() {
|
|||
if (createVoxelEditMessage(PACKET_HEADER_ERASE_VOXEL, 0, 1, &detail, bufferOut, sizeOut)){
|
||||
AgentList::getInstance()->broadcastToAgents(bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1);
|
||||
delete bufferOut;
|
||||
|
||||
// delete the voxel locally so it disappears immediately
|
||||
voxels.deleteVoxelAt(detail.x, detail.y, detail.z, detail.s);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue