r717 - trunk

lordhavoc at icculus.org lordhavoc at icculus.org
Fri May 12 07:19:17 EDT 2006


Author: lordhavoc
Date: 2006-05-12 07:19:17 -0400 (Fri, 12 May 2006)
New Revision: 717

Modified:
   trunk/model.c
Log:
now preserves smooth shading across texture seams in obj models that
contain vertex normals


Modified: trunk/model.c
===================================================================
--- trunk/model.c	2006-05-12 11:04:48 UTC (rev 716)
+++ trunk/model.c	2006-05-12 11:19:17 UTC (rev 717)
@@ -1240,7 +1240,12 @@
 	// to use the incomplete data
 	if (!error)
 	{
-		Model_Build_Compile(model, true, true, true, true, true, true);
+		// generate new vertex normals if the loaded model does not have any
+		// (we detect this by checking if the first vertex's normal is
+		//  zero-length or if the array is missing entirely)
+		Nbool generatenormals = !model->data_meshes || !model->data_meshes[0].data_normal3f || !VectorLength2(model->data_meshes[0].data_normal3f);
+		Nbool generatetangents = !model->data_meshes || !model->data_meshes[0].data_svector3f || !VectorLength2(model->data_meshes[0].data_svector3f);
+		Model_Build_Compile(model, true, true, generatenormals, generatetangents, true, true);
 		r->data = model;
 	}
 }




More information about the neither-commits mailing list