1
0
Fork 0

Rename vertex point to vertex position

This commit is contained in:
Austin Morlan 2018-09-20 19:37:48 -07:00
parent bedc30038b
commit 6dcbb35e86
Signed by: austin
GPG Key ID: FD6B27654AF5E348
5 changed files with 25 additions and 25 deletions

View File

@ -55,7 +55,7 @@ struct UVList
struct Vertex
{
Point point;
Point position;
Vector normal;
ColorF32 color;
};

View File

@ -64,8 +64,8 @@ int EngineInit(char *objFilename, char *mtlFilename)
// Mesh configuration
mesh.position.z = 50;
mesh.position.y = -175;
mesh.position.z = 125;
mesh.position.y = -125;
mesh.scale = 1.0f;
@ -208,8 +208,8 @@ static void ComputeNormals(void)
Vertex &vert2 = verts.data[face.vertIndex[2]];
Vector v01 = vert1.point - vert0.point;
Vector v02 = vert2.point - vert0.point;
Vector v01 = vert1.position - vert0.position;
Vector v02 = vert2.position - vert0.position;
Vector normal = VectorCross(v01, v02);
@ -253,8 +253,8 @@ static void TransformToClipSpace(void)
for (size_t v = 0; v < localVerts.size; ++v)
{
transVerts.data[v].point =
localVerts.data[v].point * tScale * tRotate * tTranslate * tView * tPersp;
transVerts.data[v].position =
localVerts.data[v].position * tScale * tRotate * tTranslate * tView * tPersp;
transVerts.data[v].normal =
localVerts.data[v].normal * tScale * tRotate * tTranslate;
@ -273,9 +273,9 @@ void ClipAndCull(void)
{
Face &face = localFaces.data[f];
Point &p0 = verts.data[face.vertIndex[0]].point;
Point &p1 = verts.data[face.vertIndex[1]].point;
Point &p2 = verts.data[face.vertIndex[2]].point;
Point &p0 = verts.data[face.vertIndex[0]].position;
Point &p1 = verts.data[face.vertIndex[1]].position;
Point &p2 = verts.data[face.vertIndex[2]].position;
// Ignore this face if its Z is outside the Z clip planes
if ( (p0.z < -p0.w)
@ -315,10 +315,10 @@ static void TransformToScreenSpace(void)
for (size_t v = 0; v < verts.size; ++v)
{
verts.data[v].point *= tScreen;
verts.data[v].point.x /= verts.data[v].point.w;
verts.data[v].point.y /= verts.data[v].point.w;
verts.data[v].point.z /= verts.data[v].point.w;
verts.data[v].position *= tScreen;
verts.data[v].position.x /= verts.data[v].position.w;
verts.data[v].position.y /= verts.data[v].position.w;
verts.data[v].position.z /= verts.data[v].position.w;
}
}

View File

@ -20,7 +20,7 @@ ColorF32 ComputeLight(
Vertex &vert, Material &material, Light &light, Camera &camera)
{
// Distance from light to vertex
Vector direction = light.position - vert.point;
Vector direction = light.position - vert.position;
float distance = VectorLength(direction);
@ -65,7 +65,7 @@ static ColorF32 ComputeDiffuseLight(
Material &material, ColorF32 &intensity, Vertex &vert, Light &light)
{
// Vector from the light to the vertex
Vector direction = light.position - vert.point;
Vector direction = light.position - vert.position;
VectorNormalize(direction);
float normalDotDirection = VectorDot(vert.normal, direction);
@ -82,12 +82,12 @@ static ColorF32 ComputeSpecularLight(
Camera &camera)
{
// Vector from the camera to the vertex
Vector view = camera.position - vert.point;
Vector view = camera.position - vert.position;
VectorNormalize(view);
// Vector from the light to the vertex
Vector direction = light.position - vert.point;
Vector direction = light.position - vert.position;
VectorNormalize(direction);

View File

@ -69,11 +69,11 @@ int ParseOBJ(char *filename, EngineMemory &memory)
if (strcmp(type, "v") == 0)
{
sscanf( data, "%f %f %f",
&verts.data[vertIndex].point.x,
&verts.data[vertIndex].point.y,
&verts.data[vertIndex].point.z);
&verts.data[vertIndex].position.x,
&verts.data[vertIndex].position.y,
&verts.data[vertIndex].position.z);
verts.data[vertIndex].point.w = 1.0f;
verts.data[vertIndex].position.w = 1.0f;
++vertIndex;
}

View File

@ -41,9 +41,9 @@ void Render(EngineBuffer &buffer, EngineMemory &memory)
{
Face &face = faces.data[f];
Point &p0 = verts.data[face.vertIndex[0]].point;
Point &p1 = verts.data[face.vertIndex[1]].point;
Point &p2 = verts.data[face.vertIndex[2]].point;
Point &p0 = verts.data[face.vertIndex[0]].position;
Point &p1 = verts.data[face.vertIndex[1]].position;
Point &p2 = verts.data[face.vertIndex[2]].position;
// Bounding box for barycentric calculations (top-left fill convention)