world crop
This commit is contained in:
parent
00420dd1ed
commit
9da3ffa0bb
@ -1,20 +1,24 @@
|
|||||||
set -eux
|
set -eux
|
||||||
#cd ./minecraft/gen
|
#cd ./minecraft/gen
|
||||||
PYTHON=pypy3.11
|
PYTHON=pypy3.11
|
||||||
cat <<EOF > ../grandlecturn/all_regions.txt
|
|
||||||
|
CROP=-200,-150:300,200
|
||||||
|
ALL_REGIONS=../grandlecturn/all_regions.txt
|
||||||
|
|
||||||
|
cat <<EOF > $ALL_REGIONS
|
||||||
$HOME/GrandLecturn/region/r.0.0.mcr
|
$HOME/GrandLecturn/region/r.0.0.mcr
|
||||||
$HOME/GrandLecturn/region/r.-1.-1.mcr
|
$HOME/GrandLecturn/region/r.-1.-1.mcr
|
||||||
$HOME/GrandLecturn/region/r.0.-1.mcr
|
$HOME/GrandLecturn/region/r.0.-1.mcr
|
||||||
$HOME/GrandLecturn/region/r.-1.0.mcr
|
$HOME/GrandLecturn/region/r.-1.0.mcr
|
||||||
EOF
|
EOF
|
||||||
$PYTHON mc.py $HOME/GrandLecturn/region/r.0.0.mcr ../grandlecturn/region.0.0 ../grandlecturn/all_regions.txt &
|
$PYTHON mc.py $HOME/GrandLecturn/region/r.0.0.mcr ../grandlecturn/region.0.0 $ALL_REGIONS $CROP &
|
||||||
$PYTHON mc.py $HOME/GrandLecturn/region/r.-1.-1.mcr ../grandlecturn/region.-1.-1 ../grandlecturn/all_regions.txt &
|
$PYTHON mc.py $HOME/GrandLecturn/region/r.-1.-1.mcr ../grandlecturn/region.-1.-1 $ALL_REGIONS $CROP &
|
||||||
$PYTHON mc.py $HOME/GrandLecturn/region/r.0.-1.mcr ../grandlecturn/region.0.-1 ../grandlecturn/all_regions.txt &
|
$PYTHON mc.py $HOME/GrandLecturn/region/r.0.-1.mcr ../grandlecturn/region.0.-1 $ALL_REGIONS $CROP &
|
||||||
$PYTHON mc.py $HOME/GrandLecturn/region/r.-1.0.mcr ../grandlecturn/region.-1.0 ../grandlecturn/all_regions.txt &
|
$PYTHON mc.py $HOME/GrandLecturn/region/r.-1.0.mcr ../grandlecturn/region.-1.0 $ALL_REGIONS $CROP &
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
|
||||||
cat ../grandlecturn/region*.lights.vtx > ../grandlecturn/global.lights.vtx
|
cat ../grandlecturn/region*.lights.vtx > ../grandlecturn/global.lights.vtx
|
||||||
|
|
||||||
cat ../grandlecturn/region*.dump > ../grandlecturn/global.dump
|
cat ../grandlecturn/region*.dump > ../grandlecturn/global.dump
|
||||||
$PYTHON intkeys.py ../grandlecturn/global.dump | $HOME/nbperf/nbperf -n grandlecturn_hash -I -a bpz -c 1.26 -m ../love2dworld/map.txt > ../grandlecturn/inthash.c
|
$PYTHON intkeys.py ../grandlecturn/global.dump | $HOME/nbperf/nbperf -n grandlecturn_hash -I -a bpz -c 1.24 -m ../love2dworld/map.txt > ../grandlecturn/inthash.c
|
||||||
|
|||||||
@ -42,7 +42,15 @@ def neighbor_exists(level_table, chunk_x, chunk_z, nx, ny, nz):
|
|||||||
n_block_data = decode_block_data(level_table, chunk_x, chunk_z, n_block_index)
|
n_block_data = decode_block_data(level_table, chunk_x, chunk_z, n_block_index)
|
||||||
return block_ids.is_neighbor_block(n_block_id, n_block_data)
|
return block_ids.is_neighbor_block(n_block_id, n_block_data)
|
||||||
|
|
||||||
def block_neighbors(level_table, chunk_x, chunk_z, block_index):
|
def outside_crop(position, crop):
|
||||||
|
return (
|
||||||
|
position[0] < crop[0][0] or
|
||||||
|
position[2] < crop[0][1] or
|
||||||
|
position[0] > crop[1][0] or
|
||||||
|
position[2] > crop[1][1]
|
||||||
|
)
|
||||||
|
|
||||||
|
def block_neighbors(level_table, chunk_x, chunk_z, block_index, crop):
|
||||||
block_id = level_table[(chunk_x, chunk_z)].blocks[block_index]
|
block_id = level_table[(chunk_x, chunk_z)].blocks[block_index]
|
||||||
if block_id == data.BlockID.AIR or block_id == data.BlockID.BEDROCK:
|
if block_id == data.BlockID.AIR or block_id == data.BlockID.BEDROCK:
|
||||||
return
|
return
|
||||||
@ -51,6 +59,8 @@ def block_neighbors(level_table, chunk_x, chunk_z, block_index):
|
|||||||
|
|
||||||
xyz = mcregion.xyz_from_block_index(block_index)
|
xyz = mcregion.xyz_from_block_index(block_index)
|
||||||
center_position = vec3.add(xyz, (chunk_x * 16, 0, chunk_z * 16))
|
center_position = vec3.add(xyz, (chunk_x * 16, 0, chunk_z * 16))
|
||||||
|
if outside_crop(center_position, crop):
|
||||||
|
return # block is cropped
|
||||||
|
|
||||||
if not block_ids.is_cube_block(block_id, block_data):
|
if not block_ids.is_cube_block(block_id, block_data):
|
||||||
yield center_position, block_id, block_data, None
|
yield center_position, block_id, block_data, None
|
||||||
@ -66,10 +76,10 @@ def block_neighbors(level_table, chunk_x, chunk_z, block_index):
|
|||||||
if normal_indices:
|
if normal_indices:
|
||||||
yield center_position, block_id, block_data, normal_indices
|
yield center_position, block_id, block_data, normal_indices
|
||||||
|
|
||||||
def devoxelize_region(level_table, level_table_keys):
|
def devoxelize_region(level_table, level_table_keys, crop):
|
||||||
for chunk_x, chunk_z in level_table_keys:
|
for chunk_x, chunk_z in level_table_keys:
|
||||||
for block_index in range(128 * 16 * 16):
|
for block_index in range(128 * 16 * 16):
|
||||||
yield from block_neighbors(level_table, chunk_x, chunk_z, block_index)
|
yield from block_neighbors(level_table, chunk_x, chunk_z, block_index, crop)
|
||||||
|
|
||||||
def build_level_table(level_table, mem, locations):
|
def build_level_table(level_table, mem, locations):
|
||||||
for location in locations:
|
for location in locations:
|
||||||
@ -212,8 +222,9 @@ def dump_blocks(blocks):
|
|||||||
assert(len(buf) == 8)
|
assert(len(buf) == 8)
|
||||||
f.write(buf)
|
f.write(buf)
|
||||||
|
|
||||||
def main2(level_table, level_table_keys):
|
def main2(level_table, level_table_keys, crop):
|
||||||
blocks = devoxelize_region(level_table, level_table_keys)
|
print("crop", crop)
|
||||||
|
blocks = devoxelize_region(level_table, level_table_keys, crop)
|
||||||
blocks = list(blocks)
|
blocks = list(blocks)
|
||||||
dump_blocks(blocks)
|
dump_blocks(blocks)
|
||||||
build_block_instances(blocks)
|
build_block_instances(blocks)
|
||||||
@ -224,7 +235,15 @@ def parse_all_paths(path):
|
|||||||
buf = f.read()
|
buf = f.read()
|
||||||
return set(l.strip() for l in buf.split('\n') if l.strip())
|
return set(l.strip() for l in buf.split('\n') if l.strip())
|
||||||
|
|
||||||
def main(mcr_path, data_path, all_paths_path):
|
def parse_crop(crop):
|
||||||
|
min_xz, max_xz = crop.strip().split(":")
|
||||||
|
min_xz = tuple(int(c) for c in min_xz.split(","))
|
||||||
|
max_xz = tuple(int(c) for c in max_xz.split(","))
|
||||||
|
assert min_xz[0] < max_xz[0], crop
|
||||||
|
assert min_xz[1] < max_xz[1], crop
|
||||||
|
return min_xz, max_xz
|
||||||
|
|
||||||
|
def main(mcr_path, data_path, all_paths_path, crop):
|
||||||
all_paths = parse_all_paths(all_paths_path)
|
all_paths = parse_all_paths(all_paths_path)
|
||||||
assert mcr_path in all_paths
|
assert mcr_path in all_paths
|
||||||
level_table = {}
|
level_table = {}
|
||||||
@ -234,10 +253,10 @@ def main(mcr_path, data_path, all_paths_path):
|
|||||||
if path == mcr_path:
|
if path == mcr_path:
|
||||||
continue
|
continue
|
||||||
level_table_from_path(level_table, path)
|
level_table_from_path(level_table, path)
|
||||||
|
main2(level_table, level_table_keys, parse_crop(crop))
|
||||||
main2(level_table, level_table_keys)
|
|
||||||
|
|
||||||
mcr_path = sys.argv[1]
|
mcr_path = sys.argv[1]
|
||||||
data_path = sys.argv[2]
|
data_path = sys.argv[2]
|
||||||
all_paths_path = sys.argv[3]
|
all_paths_path = sys.argv[3]
|
||||||
main(mcr_path, data_path, all_paths_path)
|
crop = sys.argv[4]
|
||||||
|
main(mcr_path, data_path, all_paths_path, crop)
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1491494
minecraft/love2dworld/map.txt
1491494
minecraft/love2dworld/map.txt
File diff suppressed because it is too large
Load Diff
@ -27,13 +27,13 @@ uniform mat4 Transform;
|
|||||||
vec3 orientation(vec3 position)
|
vec3 orientation(vec3 position)
|
||||||
{
|
{
|
||||||
if (Special == 1) { // oriented torch
|
if (Special == 1) { // oriented torch
|
||||||
if (Data == 1)
|
if (Data == 1) // "facing east"
|
||||||
return vec3(position.z, position.y, -position.x);
|
return vec3(position.z, position.y, -position.x);
|
||||||
else if (Data == 2)
|
else if (Data == 2) // "facing west"
|
||||||
return vec3(-position.z, position.y, position.x);
|
return vec3(-position.z, position.y, position.x);
|
||||||
else if (Data == 4)
|
else if (Data == 4) // "facing north"
|
||||||
return vec3(position.x, position.y, -position.z);
|
return vec3(position.x, position.y, -position.z);
|
||||||
else
|
else // "facing south"
|
||||||
return position;
|
return position;
|
||||||
} else {
|
} else {
|
||||||
return position;
|
return position;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user