mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
using internal coord only; diagonal round todo
This commit is contained in:
@@ -264,10 +264,10 @@ object LightmapRenderer {
|
|||||||
fun r1() {
|
fun r1() {
|
||||||
// TODO test non-parallel
|
// TODO test non-parallel
|
||||||
swipeDiag = false
|
swipeDiag = false
|
||||||
for (line in for_y_start - overscan_open..for_y_end) {
|
for (line in 1 until LIGHTMAP_HEIGHT - 1) {
|
||||||
swipeLight(
|
swipeLight(
|
||||||
for_x_start - overscan_open + 1, line,
|
1, line,
|
||||||
for_x_end + overscan_open - 1, line,
|
LIGHTMAP_WIDTH - 2, line,
|
||||||
1, 0
|
1, 0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -275,14 +275,47 @@ object LightmapRenderer {
|
|||||||
fun r2() {
|
fun r2() {
|
||||||
// TODO test non-parallel
|
// TODO test non-parallel
|
||||||
swipeDiag = false
|
swipeDiag = false
|
||||||
for (line in for_x_start - overscan_open..for_x_end) {
|
for (line in 1 until LIGHTMAP_WIDTH - 1) {
|
||||||
swipeLight(
|
swipeLight(
|
||||||
line, for_y_start - overscan_open + 1,
|
line, 1,
|
||||||
line, for_y_end + overscan_open - 1,
|
line, LIGHTMAP_HEIGHT - 2,
|
||||||
0, 1
|
0, 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun r3() {
|
||||||
|
// TODO test non-parallel
|
||||||
|
swipeDiag = true
|
||||||
|
for (linx in -LIGHTMAP_HEIGHT + 1 until LIGHTMAP_WIDTH - 1) {
|
||||||
|
/* construct indices such that:
|
||||||
|
56789ABC
|
||||||
|
4 1 w-2
|
||||||
|
3 \---\---+
|
||||||
|
2 \\···\··|
|
||||||
|
1 \\\···\·|
|
||||||
|
0 \\\\···\|
|
||||||
|
h-2 \\\\\---\
|
||||||
|
|
||||||
|
0 (1, h-2) -> (1, h-2)
|
||||||
|
1 (1, h-2-1) -> (2, h-2)
|
||||||
|
2 (1, h-2-2) -> (3, h-2)
|
||||||
|
3 (1, h-2-3) -> (4, h-2)
|
||||||
|
4 (1, 1) -> (5, h-2)
|
||||||
|
5 (2, 1) -> (6, h-2)
|
||||||
|
6 (3, 1) -> (7, h-2)
|
||||||
|
7 (4, 1) -> (8, h-2)
|
||||||
|
8 (5, 1) -> (w-2, h-2)
|
||||||
|
9 (6, 1) -> (w-2, h-2-1)
|
||||||
|
10 (7, 1) -> (w-2, h-2-2)
|
||||||
|
11 (8, 1) -> (w-2, h-2-3)
|
||||||
|
12 (w-2, 1) -> (w-2, 1)
|
||||||
|
|
||||||
|
number of indices: internal_width + internal_height - 1
|
||||||
|
*/
|
||||||
|
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// each usually takes 8..12 ms total when not threaded
|
// each usually takes 8..12 ms total when not threaded
|
||||||
// - with direct memory access of world array and pre-calculating things in the start of the frame,
|
// - with direct memory access of world array and pre-calculating things in the start of the frame,
|
||||||
@@ -300,8 +333,7 @@ object LightmapRenderer {
|
|||||||
|
|
||||||
//r3();r4();r1();r2();r3();
|
//r3();r4();r1();r2();r3();
|
||||||
|
|
||||||
r1()
|
r1();r2();//r3()
|
||||||
r2()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (world.worldIndex != -1) { // to avoid updating on the null world
|
else if (world.worldIndex != -1) { // to avoid updating on the null world
|
||||||
@@ -550,10 +582,10 @@ object LightmapRenderer {
|
|||||||
|
|
||||||
private var swipeX = -1
|
private var swipeX = -1
|
||||||
private var swipeY = -1
|
private var swipeY = -1
|
||||||
private var swipeTx = -1
|
|
||||||
private var swipeTy = -1
|
|
||||||
private var swipeDiag = false
|
private var swipeDiag = false
|
||||||
private fun _swipeTask(x: Int, y: Int, x2: Int, y2: Int) {
|
private fun _swipeTask(x: Int, y: Int, x2: Int, y2: Int) {
|
||||||
|
if (x2 < 0 || y2 < 0 || x2 >= LIGHTMAP_WIDTH || y2 >= LIGHTMAP_HEIGHT) return
|
||||||
|
|
||||||
_ambientAccumulator.r = _mapLightLevelThis.getR(x, y)
|
_ambientAccumulator.r = _mapLightLevelThis.getR(x, y)
|
||||||
_ambientAccumulator.g = _mapLightLevelThis.getG(x, y)
|
_ambientAccumulator.g = _mapLightLevelThis.getG(x, y)
|
||||||
_ambientAccumulator.b = _mapLightLevelThis.getB(x, y)
|
_ambientAccumulator.b = _mapLightLevelThis.getB(x, y)
|
||||||
@@ -578,13 +610,12 @@ object LightmapRenderer {
|
|||||||
lightmap.setVec(x, y, _ambientAccumulator)
|
lightmap.setVec(x, y, _ambientAccumulator)
|
||||||
}
|
}
|
||||||
private fun swipeLight(sx: Int, sy: Int, ex: Int, ey: Int, dx: Int, dy: Int) {
|
private fun swipeLight(sx: Int, sy: Int, ex: Int, ey: Int, dx: Int, dy: Int) {
|
||||||
|
|
||||||
swipeX = sx; swipeY = sy
|
swipeX = sx; swipeY = sy
|
||||||
while (swipeX <= ex && swipeY <= ey) {
|
while (swipeX <= ex && swipeY <= ey) {
|
||||||
// conduct the task #1
|
// conduct the task #1
|
||||||
// spread towards the end
|
// spread towards the end
|
||||||
swipeTx = swipeX.convX()
|
_swipeTask(swipeX, swipeY, swipeX-dx, swipeY-dy)
|
||||||
swipeTy = swipeY.convY()
|
|
||||||
_swipeTask(swipeTx, swipeTy, swipeTx-dx, swipeTy-dy)
|
|
||||||
|
|
||||||
swipeX += dx
|
swipeX += dx
|
||||||
swipeY += dy
|
swipeY += dy
|
||||||
@@ -594,9 +625,7 @@ object LightmapRenderer {
|
|||||||
while (swipeX >= sx && swipeY >= sy) {
|
while (swipeX >= sx && swipeY >= sy) {
|
||||||
// conduct the task #2
|
// conduct the task #2
|
||||||
// spread towards the start
|
// spread towards the start
|
||||||
swipeTx = swipeX.convX()
|
_swipeTask(swipeX, swipeY, swipeX+dx, swipeY+dy)
|
||||||
swipeTy = swipeY.convY()
|
|
||||||
_swipeTask(swipeTx, swipeTy, swipeTx+dx, swipeTy+dy)
|
|
||||||
|
|
||||||
swipeX -= dx
|
swipeX -= dx
|
||||||
swipeY -= dy
|
swipeY -= dy
|
||||||
|
|||||||
Reference in New Issue
Block a user