Skip to content

Texture Coords Written to Normal when Normal is Missing #605

@TChapman500

Description

@TChapman500

In Mesh.cpp, on lines 894-897, if the mesh is flagged as having normals, but a vertex is missing the normal vector, then one or both components of the texture coords will be written to the normal instead.

Fix

if (bnormal) {
  j = sscanf (cbuf, "%f%f%f%f%f%f%f%f", &v.x, &v.y, &v.z, &v.nx, &v.ny, &v.nz, &v.tu, &v.tv);
  if (j < 6) {
    // Set the calculate normal flag
    calcnml = true;
    // Move the texture coords to their proper location
    v.tu = v.nx;
    v.tv = v.ny;
    // Zero-out the normal vector so that CalcNormals() will not skip this vertex
    t.nx = 0.0f;
    t.ny = 0.0f;
    t.nz = 0.0f;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions