edit block performance fix
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-04-29 13:11:54 -04:00
parent 1ded83c968
commit a81e9e203d
4 changed files with 26 additions and 1 deletions

Binary file not shown.

View File

@ -1583,6 +1583,8 @@ Grid alignment actually aligns entity to grid
Fix door tree physics
BlockFab metadata
Structure editing tab in editor view
Reduce physics generation calls on GriddedDataCellManager
Fab selection doesn't overflow anymore

View File

@ -132,6 +132,7 @@ public class FabSelectionPanel {
newButton.setMarginTop(MARGIN_EACH_SIDE);
//label
Label fabLabel = Label.createLabel(fabFile.getName());
fabLabel.setMaxWidth(FAB_BUTTON_WIDTH);
//icon/model
ImagePanel texturePanel = ImagePanel.createImagePanel(AssetDataStrings.TEXTURE_DEFAULT);
texturePanel.setWidth(FAB_BUTTON_TEXTURE_DIM);

View File

@ -152,6 +152,11 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
*/
int numCleaned = 0;
/**
* Queue of cells that need to have their physics regenerated (ie on block edits)
*/
Map<Long,Vector3i> physicsQueue = new HashMap<Long,Vector3i>();
/**
* Constructor
* @param parent The gridded data cell manager's parent realm
@ -658,6 +663,20 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
public void simulate(){
Globals.profiler.beginCpuSample("GriddedDataCellManager.simulate");
loadedCellsLock.lock();
//regenerate physics where relevant
terrainEditLock.acquireUninterruptibly();
if(physicsQueue.size() > 0){
for(Vector3i pos : physicsQueue.values()){
this.createTerrainPhysicsEntities(pos);
}
physicsQueue.clear();
}
terrainEditLock.release();
//micro simulation
boolean runMicroSim = Globals.microSimulation != null && Globals.microSimulation.isReady();
for(ServerDataCell cell : this.groundDataCells.values()){
if(runMicroSim && this.shouldSimulate(cell)){
@ -1041,7 +1060,10 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
ServerDataCell cell = groundDataCells.get(this.getServerDataCellKey(worldPosition));
if(cell != null){
//update physics
this.createTerrainPhysicsEntities(worldPosition);
long key = this.getServerDataCellKey(worldPosition);
if(!this.physicsQueue.containsKey(key)){
this.physicsQueue.put(key,worldPosition);
}
//broadcast update
cell.broadcastNetworkMessage(TerrainMessage.constructUpdateBlockMessage(