|
|
In article <3E679DE7.6CF6C2A2@hotmail.com>,
John VanSickle <evi### [at] hotmailcom> wrote:
> If the same normal vector is supplied for all three vertices, POV-Ray
> appears to completely ignore them, treats the triangle as a flat
> triangle, and assigns the default normal.
If the normals are equal, it calculates its own normal? That's bad...it
isn't an overoptimization though, just a misimplementation.
Hmm, the true normal is used by the intersection code, so you can't just
change that...the quick fix would be to just remove the optimization.
However, all triangles store the normal indices, they just aren't always
used...you could store the specified normal in N1. In the parse code for
smooth triangles, change:
{
/* Flat triangle. */
Compute_Mesh_Triangle(&Triangles[number_of_triangles], false,
P1, P2, P3, N);
}
to:
{
/* Flat triangle. */
Triangles[number_of_triangles].N1 =
Mesh_Hash_Normal(&number_of_normals, &max_normals, &Normals, N1);
Compute_Mesh_Triangle(&Triangles[number_of_triangles], false,
P1, P2, P3, N);
}
or move the N1 computation line to just before the if() statement, and
in the part that parses solid triangles, after the line:
Triangles[number_of_triangles].Normal_Ind =
Mesh_Hash_Normal(&number_of_normals, &max_normals, &Normals, N);
Put this line:
Triangles[number_of_triangles].N1 =
Triangles[number_of_triangles].Normal_Ind;
In the mesh code, change this line of the non-smooth normal calculation
part of Mesh_Normal() from:
Assign_SNGL_Vect(Result, Mesh->Data->Normals[Triangle->Normal_Ind]);
to:
Assign_SNGL_Vect(Result, Mesh->Data->Normals[Triangle->N1]);
I think that's all...saves the specified normal, but avoids
interpolating between 3 identical normals. It is entirely untested,
though. And I haven't even looked at the mesh2 parsing code.
--
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/
Post a reply to this message
|
|