Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(JOML): migrate BatchPropagator #4395

Merged
merged 8 commits into from
Jan 13, 2021

Conversation

skaldarnar
Copy link
Member

  • feature(JOML): migrate InternalLightProcessor
  • chore: remove unused vector
  • feat(JOML): migrate SunlightRegenBatchPropagator
  • refactor: remove duplicate code
  • refactor: move populateMinAdjacent2D from ChunkMath to BatchPropagator

Contributes to #3832
Follow-up to #4391

Comment on lines 226 to 222
int initialDepth = Math.max(ChunkConstants.SUNLIGHT_REGEN_THRESHOLD - start, 0);
int finalDepth = depth[depthIndex];

int strength = Math.min(start + initialDepth - ChunkConstants.SUNLIGHT_REGEN_THRESHOLD + 1, ChunkConstants.MAX_SUNLIGHT);

for (int i = initialDepth; i <= finalDepth; ++i) {
sunlightPropagator.propagateFrom(toChunk.chunkToWorldPosition(x, ChunkConstants.SIZE_Y - i - 1, z),
(byte) (strength));
if (strength < ChunkConstants.MAX_SUNLIGHT) {
strength++;
}
}
initialDepth = Math.max(Chunks.SUNLIGHT_REGEN_THRESHOLD - start, 0);
} else {
int initialDepth = Math.max(adjDepths[depthIndex], ChunkConstants.SUNLIGHT_REGEN_THRESHOLD - start);
byte strength = (byte) Math.min(ChunkConstants.MAX_SUNLIGHT, start + initialDepth - ChunkConstants.SUNLIGHT_REGEN_THRESHOLD + 1);
for (int i = initialDepth; i <= depth[depthIndex]; ++i) {
sunlightPropagator.propagateFrom(toChunk.chunkToWorldPosition(x, ChunkConstants.SIZE_Y - i - 1, z), strength);
if (strength < ChunkConstants.MAX_SUNLIGHT) {
strength++;
}
pos.y--;
initialDepth = Math.max(Chunks.SUNLIGHT_REGEN_THRESHOLD - start, adjDepths[depthIndex]);
}
byte strength = (byte) Math.min(Chunks.MAX_SUNLIGHT, start + initialDepth - Chunks.SUNLIGHT_REGEN_THRESHOLD + 1);
for (int i = initialDepth; i <= depth[depthIndex]; ++i) {
sunlightPropagator.propagateFrom(toChunk.chunkToWorldPosition(x, Chunks.SIZE_Y - i - 1, z, pos), strength);
if (strength < Chunks.MAX_SUNLIGHT) {
strength++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you moved the iterator out since its replicated in both conditions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I started with doing small changes, bringing arguments in the same order, inlining some parts, and suddenly it was highlighted as duplicate 😅

* @param target
* @param populateMargins Whether to populate the edges of the target array
*/
default void populateMinAdjacent2D(int[] source, int[] target, int dimX, int dimY, boolean populateMargins) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking static but this might work better. allows for different implementations. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know whether we actually want different implementations? Maybe we should keep it static and only open that up if we actually find a use case for that?

pollend
pollend previously approved these changes Jan 10, 2021
@skaldarnar skaldarnar changed the base branch from develop to joml/migrate-world-propagation-2 January 10, 2021 20:48
Base automatically changed from joml/migrate-world-propagation-2 to develop January 10, 2021 23:15
@jdrueckert jdrueckert dismissed pollend’s stale review January 10, 2021 23:15

The base branch was changed.

@skaldarnar skaldarnar force-pushed the joml/migrate-world-propagation-3 branch from d1d6c6d to e54e6a1 Compare January 11, 2021 19:56
@skaldarnar skaldarnar marked this pull request as ready for review January 11, 2021 19:56
@skaldarnar
Copy link
Member Author

Rebased this PR onto develop after base PR was merged. No further changes.

@skaldarnar skaldarnar merged commit 224f8ad into develop Jan 13, 2021
@skaldarnar skaldarnar deleted the joml/migrate-world-propagation-3 branch January 13, 2021 21:00
@skaldarnar skaldarnar added this to the v4.2.0 milestone Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants