-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
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++; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
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?
d1d6c6d
to
e54e6a1
Compare
Rebased this PR onto |
InternalLightProcessor
SunlightRegenBatchPropagator
populateMinAdjacent2D
fromChunkMath
toBatchPropagator
Contributes to #3832
Follow-up to #4391