Skip to content

Commit

Permalink
chore: remove the hypen in world-space & view-space
Browse files Browse the repository at this point in the history
  • Loading branch information
emre-aki committed Nov 11, 2023
1 parent a31d8dd commit 20154a1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/engine/r_camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@

//
// R_UpdateCamera
// Update the orientation and the position of the camera in world-space
// Update the orientation and the position of the camera in world space
//
function R_UpdateCamera (mult: number): void
{
Expand Down
32 changes: 16 additions & 16 deletions src/engine/r_draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@
if (lx !== undefined && ly !== undefined && lz !== undefined)
lightLevel = lx * nXUnit + ly * nYUnit + lz * nZUnit;
/* draw a single pixel in screen-space sampled from the
* perspective-corrected texture-space
* perspective-corrected texture space
*/
const sampleIndex = (sY * texWidth + sX) << 2;
const sampleRed = bitmap[sampleIndex];
Expand Down Expand Up @@ -639,7 +639,7 @@
let topX = ax, topY = ay;
let midX = bx, midY = by;
let bottomX = cx, bottomY = cy;
/* coordinates of the triangle in perspective-corrected texture-space */
/* coordinates of the triangle in perspective-corrected texture space */
let topC = ac / aw, midC = bc / bw, bottomC = cc / cw;
let topU = au * topC, topV = av * topC;
let midU = bu * midC, midV = bv * midC;
Expand Down Expand Up @@ -761,31 +761,31 @@
let xUpper = preStepFromTop * stepXAlongUpper + topX;
let xLower = preStepFromMid * stepXAlongLower + midX;
let xMajor = preStepFromTop * stepXAlongMajor + topX;
/* current `u` coordinates in perspective-correct texture-space */
/* current `u` coordinates in perspective-correct texture space */
let uUpper = preStepFromTop * stepUAlongUpper + topU;
let uLower = preStepFromMid * stepUAlongLower + midU;
let uMajor = preStepFromTop * stepUAlongMajor + topU;
/* current `v` coordinates in perspective-correct texture-space */
/* current `v` coordinates in perspective-correct texture space */
let vUpper = preStepFromTop * stepVAlongUpper + topV;
let vLower = preStepFromMid * stepVAlongLower + midV;
let vMajor = preStepFromTop * stepVAlongMajor + topV;
/* current `c` coordinates in perspective-correct space */
let cUpper = preStepFromTop * stepCAlongUpper + topC;
let cLower = preStepFromMid * stepCAlongLower + midC;
let cMajor = preStepFromTop * stepCAlongMajor + topC;
/* current `nx` coordinates in perspective-correct world-space */
/* current `nx` coordinates in perspective-correct world space */
let nXUpper = preStepFromTop * stepNXAlongUpper + topNX;
let nXLower = preStepFromMid * stepNXAlongLower + midNX;
let nXMajor = preStepFromTop * stepNXAlongMajor + topNX;
/* current `ny` coordinates in perspective-correct world-space */
/* current `ny` coordinates in perspective-correct world space */
let nYUpper = preStepFromTop * stepNYAlongUpper + topNY;
let nYLower = preStepFromMid * stepNYAlongLower + midNY;
let nYMajor = preStepFromTop * stepNYAlongMajor + topNY;
/* current `nz` coordinates in perspective-correct world-space */
/* current `nz` coordinates in perspective-correct world space */
let nZUpper = preStepFromTop * stepNZAlongUpper + topNZ;
let nZLower = preStepFromMid * stepNZAlongLower + midNZ;
let nZMajor = preStepFromTop * stepNZAlongMajor + topNZ;
/* current `nw` coordinates in perspective-correct world-space */
/* current `nw` coordinates in perspective-correct world space */
let nWUpper = preStepFromTop * stepNWAlongUpper + topNW;
let nWLower = preStepFromMid * stepNWAlongLower + midNW;
let nWMajor = preStepFromTop * stepNWAlongMajor + topNW;
Expand Down Expand Up @@ -930,7 +930,7 @@
/* determine how bright & translucent the image is going to be drawn */
const ALPHA = alpha !== undefined ? alpha : 1;
const LIGHT_LEVEL = lightLevel !== undefined ? lightLevel : 1;
// 1 step in screen-space equals how many steps in texture-space
// 1 step in screen-space equals how many steps in texture space
const scaleX = sw / dw, scaleY = sh / dh;
// raster clipping: clip the screen coordinates against the bounds of
// the buffer
Expand All @@ -947,29 +947,29 @@
*/
const preStepFromLeft = dStartX + 0.5 - dx;
const preStepFromTop = dStartY + 0.5 - dy;
/* where to start sampling in the texture-space */
/* where to start sampling in the texture space */
const sampleStartX = preStepFromLeft * scaleX + sx;
const sampleStartY = preStepFromTop * scaleY + sy;
let sampleY = sampleStartY; // current `y` coordinate in texture-space
let sampleY = sampleStartY; // current `y` coordinate in texture space
for (let y = dStartY; y < dEndY && y < SCREEN_H; ++y)
{
const imgY = Math.floor(sampleY);
// skip drawing this scanline if we're not yet within the bounds of
// the texture-space along the y-axis
// the texture space along the y-axis
if (imgY < 0) { sampleY += scaleY; continue; }
// stop drawing any further scanlines if we've gone out-of-bounds in
// the texture-space along the y-axis
// the texture space along the y-axis
else if (imgY >= imgHeight) break;
// current `x` coordinate in texture-space
// current `x` coordinate in texture space
let sampleX = sampleStartX;
for (let x = dStartX; x < dEndX && x < SCREEN_W; ++x)
{
const imgX = Math.floor(sampleX);
// skip drawing this pixel if we're not yet within the bounds of
// the texture-space along the x-axis
// the texture space along the x-axis
if (imgX < 0) { sampleX += scaleX; continue; }
// stop drawing any further pixels if we've gone out-of-bounds
// in the texture-space along the x-axis
// in the texture space along the x-axis
else if (imgX >= imgWidth) break;
const sampleIndex = (imgY * imgWidth + imgX) << 2;
const sampleRed = bitmap[sampleIndex];
Expand Down
4 changes: 2 additions & 2 deletions src/engine/r_geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
/* ...the same goes for the vertex normals */
clippedTriVertexNormalQueue[0] =
Tri3(nInside[0], nInside[1], nInside[2]);
// ...the same goes for the vertices in the texture-space
// ...the same goes for the vertices in the texture space
clippedUvMapQueue[0] = Tri3(uvInside[0], uvInside[1], uvInside[2]);
/* the vertices that fall inside the near-clipping plane form a quad,
* triangulate it by forming an additional triangle and save that in the
Expand All @@ -398,7 +398,7 @@
/* ...the same goes for the vertex normals */
clippedTriVertexNormalQueue[1] =
Tri3(nInside[2], nInside[3], nInside[0]);
// ...the same goes for the vertices in the texture-space
// ...the same goes for the vertices in the texture space
clippedUvMapQueue[1] = Tri3(uvInside[2], uvInside[3], uvInside[0]);
}

Expand Down
4 changes: 2 additions & 2 deletions tools/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function ObjToTmp3D (pathToObj, pathToMtl, outputFilename, zOffset)
{
case "v": // vertex
{
const vertex = tokens.slice(1); // world-space coordinates
const vertex = tokens.slice(1); // world space coordinates
/* rotate the vertex read around the x-axis by π radians as the
* +y axis in Tmp3D point down whereas in Blender it points up
*/
Expand All @@ -144,7 +144,7 @@ function ObjToTmp3D (pathToObj, pathToMtl, outputFilename, zOffset)
}
case "vt": // texture vertices
{
const uv = tokens.slice(1); // texture-space coordinates
const uv = tokens.slice(1); // texture space coordinates
// flip the `v` coordinate, as it points up in Blender but down
// in Tmp3D
uvVertices.push([parseFloat(uv[0]), 1 - parseFloat(uv[1])]);
Expand Down

0 comments on commit 20154a1

Please sign in to comment.