Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
xelatihy committed Jan 31, 2024
1 parent cc744c8 commit fb7a878
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions libs/yocto/yocto_shape.cpp
Expand Up @@ -680,7 +680,7 @@ static shape_data make_quads(vec2i steps, vec2f scale, vec2f uvscale) {
shape.positions[j * (steps.x + 1) + i] = {
(2 * uv.x - 1) * scale.x, (2 * uv.y - 1) * scale.y, 0};
shape.normals[j * (steps.x + 1) + i] = {0, 0, 1};
shape.texcoords[j * (steps.x + 1) + i] = vec2f{uv.x, uv.y} * uvscale;
shape.texcoords[j * (steps.x + 1) + i] = vec2f{uv.x, 1 - uv.y} * uvscale;
}
}

Expand Down Expand Up @@ -903,7 +903,7 @@ shape_data make_uvsphere(vec2i steps, float scale, vec2f uvscale) {
auto shape = make_rect(steps, {1, 1});
for (auto i : range(shape.positions.size())) {
auto uv = shape.texcoords[i];
auto a = vec2f{2 * pif * uv.x, pif * (1 - uv.y)};
auto a = vec2f{2 * pif * uv.x, pif * uv.y};
shape.positions[i] =
vec3f{cos(a.x) * sin(a.y), sin(a.x) * sin(a.y), cos(a.y)} * scale;
shape.normals[i] = normalize(shape.positions[i]);
Expand Down Expand Up @@ -1012,7 +1012,7 @@ shape_data make_uvcylinder(vec3i steps, vec2f scale, vec3f uvscale) {
auto uv = qshape.texcoords[i];
auto phi = 2 * pif * uv.x;
qshape.positions[i] = {
cos(phi) * scale.x, sin(phi) * scale.x, (2 * uv.y - 1) * scale.y};
cos(phi) * scale.x, sin(phi) * scale.x, -(2 * uv.y - 1) * scale.y};
qshape.normals[i] = {cos(phi), sin(phi), 0};
qshape.texcoords[i] = uv * vec2f{uvscale.x, uvscale.y};
}
Expand Down
2 changes: 1 addition & 1 deletion libs/yocto/yocto_shape.h
Expand Up @@ -373,7 +373,7 @@ inline shape_data make_quads(vec2i steps, PFunc&& position, NFunc&& normal) {
auto idx = j * (steps.x + 1) + i;
shape.positions[idx] = position(uv);
shape.normals[idx] = normal(uv);
shape.texcoords[idx] = uv;
shape.texcoords[idx] = {uv.x, 1 - uv.y};
}
}
shape.quads = vector<vec4i>(steps.x * steps.y);
Expand Down

0 comments on commit fb7a878

Please sign in to comment.