Skip to content

Commit

Permalink
lib+scripts: Fix & tweak instance testing script
Browse files Browse the repository at this point in the history
It should now work just by running the script. Amount of statues and
other parameters can be tweaked in the script directly.
  • Loading branch information
vkoskiv committed Apr 5, 2024
1 parent 469eaa6 commit 0448117
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
10 changes: 3 additions & 7 deletions scripts/scenes/lots_of_instances/hdr.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"outputFileName": "rendered",
"fileType": "png",
"count": 0,
"width": 1280,
"height": 800
"width": 1920,
"height": 1080
},
"display": {
"isFullscreen": false,
Expand Down Expand Up @@ -63,7 +63,7 @@
]
},
{
"FOV": 90.0,
"FOV": 100.0,
"focalDistance": 0.2,
"fstops": 0,
"transforms": [
Expand Down Expand Up @@ -445,10 +445,6 @@
{
"type": "translate",
"X": 0.08
},
{
"type": "rotateY",
"degrees": 0
}
]
}
Expand Down
19 changes: 12 additions & 7 deletions scripts/scenes/lots_of_instances/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,27 @@
with open(filename) as f:
data = json.load(f)

data["scene"]["outputFilePath"] = "scripts/scenes/"
data["scene"]["outputFileName"] = "lotsa_instances"
data["renderer"]["outputFilePath"] = "scripts/scenes/"
data["renderer"]["outputFileName"] = "lotsa_instances"

# Yoink primitives
data["scene"]["primitives"] = []

instancelist = data["scene"]["meshes"][1]["pick_instances"]
for i in range(1000000):
for i in range(100000):
skel = copy.deepcopy(instancelist[0])
skel["for"] = "Venus"
skel["materials"][0]["color"] = {'type': 'hsl', 'h': random.uniform(0,360), 's': 100, 'l': 75}
skel["transforms"][1]["X"] = random.uniform(0, 10) - 5
skel["transforms"][1]["Y"] = random.uniform(0, 10) - 5
skel["transforms"][1]["Z"] = random.uniform(0, 40) - 2.5
skel["transforms"].append({"type": "rotateX", "degrees": random.uniform(0, 360)})
skel["transforms"].append({"type": "rotateY", "degrees": random.uniform(0, 360)})
skel["transforms"].append({"type": "rotateZ", "degrees": random.uniform(0, 360)})
instancelist.append(skel)

#print("Dumping scene to subprocess...")
#proc = Popen('./bin/c-ray --asset-path input/ -s 25 -c 2 -j 0 --nodes 127.1,127.1:2323', stdin=PIPE, shell=True, bufsize=0)
#proc.stdin.write(json.dumps(data).encode())
#proc.communicate()
print(json.dumps(data))
proc = Popen('./bin/c-ray --asset-path input/ -s 25 -c 2', stdin=PIPE, shell=True, bufsize=1024)
proc.stdin.write(json.dumps(data).encode())
proc.communicate()
#print(json.dumps(data))
2 changes: 1 addition & 1 deletion src/common/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ file_data read_stdin(void) {
}

buf[buf_size ] = 0;
return (file_data){ .items = buf, .count = buf_size - 1, .capacity = buf_size - 1 };
return (file_data){ .items = buf, .count = buf_size, .capacity = buf_size };
}

char *human_file_size(unsigned long bytes, char *stat_buf) {
Expand Down

0 comments on commit 0448117

Please sign in to comment.