mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-27 14:30:14 +00:00
Skip empty cave slice copies
- snapshot copies only present palette values and drops sections without cells
This commit is contained in:
1 parent
184a04d97f
commit
8d93431319
1 file changed
+24
-35
@@ -127,52 +127,42 @@ public final class CaveTerrainSnapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void captureSection(int section, Matter matter) {
|
private void captureSection(int section, Matter matter) {
|
||||||
MatterCavern[] sectionCaverns = copy(matter.getSlice(MatterCavern.class), MatterCavern[]::new);
|
caverns[section] = copy(matter.getSlice(MatterCavern.class), MatterCavern[]::new);
|
||||||
HydrologyCaveCell[] sectionHydrology = copy(matter.getSlice(HydrologyCaveCell.class), HydrologyCaveCell[]::new);
|
hydrology[section] = copy(matter.getSlice(HydrologyCaveCell.class), HydrologyCaveCell[]::new);
|
||||||
MatterSlice<PreObjectMatterCell> journal = matter.getSlice(PreObjectMatterCell.class);
|
MatterSlice<PreObjectMatterCell> journal = matter.getSlice(PreObjectMatterCell.class);
|
||||||
if (journal instanceof MappedHunk<?> mapped) {
|
if (journal instanceof MappedHunk<?> mapped) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<Integer, PreObjectMatterCell> entries = (Map<Integer, PreObjectMatterCell>) mapped.getData();
|
Map<Integer, PreObjectMatterCell> entries = (Map<Integer, PreObjectMatterCell>) mapped.getData();
|
||||||
for (Map.Entry<Integer, PreObjectMatterCell> entry : entries.entrySet()) {
|
for (Map.Entry<Integer, PreObjectMatterCell> entry : entries.entrySet()) {
|
||||||
int position = entry.getKey();
|
restoreOriginals(section, entry.getKey(), entry.getValue());
|
||||||
PreObjectMatterCell cell = entry.getValue();
|
|
||||||
if (cell.cavernCaptured() && (sectionCaverns != null || cell.cavern() != null)) {
|
|
||||||
if (sectionCaverns == null) {
|
|
||||||
sectionCaverns = new MatterCavern[SECTION_VOLUME];
|
|
||||||
}
|
|
||||||
sectionCaverns[position] = cell.cavern();
|
|
||||||
}
|
|
||||||
if (cell.hydrologyCaptured() && (sectionHydrology != null || cell.hydrology() != null)) {
|
|
||||||
if (sectionHydrology == null) {
|
|
||||||
sectionHydrology = new HydrologyCaveCell[SECTION_VOLUME];
|
|
||||||
}
|
|
||||||
sectionHydrology[position] = cell.hydrology();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (journal != null) {
|
} else if (journal != null) {
|
||||||
for (int position = 0; position < SECTION_VOLUME; position++) {
|
for (int position = 0; position < SECTION_VOLUME; position++) {
|
||||||
PreObjectMatterCell cell = journal.get(position & 15, (position >> 4) & 15, position >> 8);
|
PreObjectMatterCell cell = journal.get(position & 15, (position >> 4) & 15, position >> 8);
|
||||||
if (cell == null) {
|
if (cell != null) {
|
||||||
continue;
|
restoreOriginals(section, position, cell);
|
||||||
}
|
|
||||||
if (cell.cavernCaptured() && (sectionCaverns != null || cell.cavern() != null)) {
|
|
||||||
if (sectionCaverns == null) {
|
|
||||||
sectionCaverns = new MatterCavern[SECTION_VOLUME];
|
|
||||||
}
|
|
||||||
sectionCaverns[position] = cell.cavern();
|
|
||||||
}
|
|
||||||
if (cell.hydrologyCaptured() && (sectionHydrology != null || cell.hydrology() != null)) {
|
|
||||||
if (sectionHydrology == null) {
|
|
||||||
sectionHydrology = new HydrologyCaveCell[SECTION_VOLUME];
|
|
||||||
}
|
|
||||||
sectionHydrology[position] = cell.hydrology();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
caverns[section] = sectionCaverns;
|
if (hydrology[section] != null && containsAny(hydrology[section])) {
|
||||||
if (sectionHydrology != null && containsAny(sectionHydrology)) {
|
|
||||||
hydrology[section] = sectionHydrology;
|
|
||||||
hydrologyPresent = true;
|
hydrologyPresent = true;
|
||||||
|
} else {
|
||||||
|
hydrology[section] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreOriginals(int section, int position, PreObjectMatterCell cell) {
|
||||||
|
if (cell.cavernCaptured() && (caverns[section] != null || cell.cavern() != null)) {
|
||||||
|
if (caverns[section] == null) {
|
||||||
|
caverns[section] = new MatterCavern[SECTION_VOLUME];
|
||||||
|
}
|
||||||
|
caverns[section][position] = cell.cavern();
|
||||||
|
}
|
||||||
|
if (cell.hydrologyCaptured() && (hydrology[section] != null || cell.hydrology() != null)) {
|
||||||
|
if (hydrology[section] == null) {
|
||||||
|
hydrology[section] = new HydrologyCaveCell[SECTION_VOLUME];
|
||||||
|
}
|
||||||
|
hydrology[section][position] = cell.hydrology();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,8 +174,7 @@ public final class CaveTerrainSnapshot {
|
|||||||
T[] values = allocator.apply(SECTION_VOLUME);
|
T[] values = allocator.apply(SECTION_VOLUME);
|
||||||
if (slice instanceof PaletteOrHunk<?> storage && storage.isPalette()
|
if (slice instanceof PaletteOrHunk<?> storage && storage.isPalette()
|
||||||
&& slice.getWidth() == 16 && slice.getHeight() == 16 && slice.getDepth() == 16) {
|
&& slice.getWidth() == 16 && slice.getHeight() == 16 && slice.getDepth() == 16) {
|
||||||
((DataContainer<T>) storage.palette()).copyAll(values);
|
return ((DataContainer<T>) storage.palette()).copyPresent(values) == 0 ? null : values;
|
||||||
return values;
|
|
||||||
}
|
}
|
||||||
int width = Math.min(16, slice.getWidth());
|
int width = Math.min(16, slice.getWidth());
|
||||||
int height = Math.min(16, slice.getHeight());
|
int height = Math.min(16, slice.getHeight());
|
||||||
|
|||||||
Reference in new issue
Block a user