mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
intra:: fixed portals to/from S3 and H3
This commit is contained in:
parent
6b17cd6412
commit
80b9d9533c
@ -91,6 +91,10 @@ hyperpoint portal_data::to_poco(hyperpoint h) const {
|
||||
else {
|
||||
h = T * h;
|
||||
h /= h[3];
|
||||
if(sphere)
|
||||
h[2] /= sqrt(1+h[0]*h[0]+h[1]*h[1]);
|
||||
if(hyperbolic)
|
||||
h[2] /= sqrt(1-h[0]*h[0]-h[1]*h[1]);
|
||||
return h;
|
||||
}
|
||||
}
|
||||
@ -126,6 +130,10 @@ hyperpoint portal_data::from_poco(hyperpoint h) const {
|
||||
}
|
||||
else {
|
||||
h[3] = 1;
|
||||
if(sphere)
|
||||
h[2] *= sqrt(1+h[0]*h[0]+h[1]*h[1]);
|
||||
if(hyperbolic)
|
||||
h[2] *= sqrt(1-h[0]*h[0]-h[1]*h[1]);
|
||||
return normalize(iT * h);
|
||||
}
|
||||
}
|
||||
|
@ -1575,22 +1575,28 @@ void raygen::add_functions() {
|
||||
|
||||
add_if("to_poco_h3",
|
||||
"mediump vec4 to_poco_h3(mediump vec4 pos) {\n"
|
||||
" return pos / pos[3];\n"
|
||||
" pos = pos / pos[3];\n"
|
||||
" pos[2] /= sqrt(1.-pos.x*pos.x-pos.y*pos.y);\n"
|
||||
" return pos;\n"
|
||||
" }\n\n");
|
||||
|
||||
add_if("from_poco_h3",
|
||||
"mediump vec4 from_poco_h3(mediump vec4 pos) {\n"
|
||||
" pos[2] *= sqrt(1.-pos.x*pos.x-pos.y*pos.y);\n"
|
||||
" float s = 1. - dot(pos.xyz, pos.xyz);\n"
|
||||
" return pos / sqrt(s);\n"
|
||||
" }\n\n");
|
||||
|
||||
add_if("to_poco_s3",
|
||||
"mediump vec4 to_poco_s3(mediump vec4 pos) {\n"
|
||||
" return pos / pos[3];\n"
|
||||
" pos = pos / pos[3];\n"
|
||||
" pos[2] /= sqrt(1.+pos.x*pos.x+pos.y*pos.y);\n"
|
||||
" return pos;\n"
|
||||
" }\n\n");
|
||||
|
||||
add_if("from_poco_s3",
|
||||
"mediump vec4 from_poco_s3(mediump vec4 pos) {\n"
|
||||
" pos[2] *= sqrt(1.+pos.x*pos.x+pos.y*pos.y);\n"
|
||||
" float s = 1. + dot(pos.xyz, pos.xyz);\n"
|
||||
" return pos / sqrt(s);\n"
|
||||
" }\n\n");
|
||||
|
Loading…
Reference in New Issue
Block a user