[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21158] branches/soc-2009-chingachgook/ source/blender/collada/DocumentImporter.cpp: Quick fix to allow reading of <polylist> and <polygons>.

Arystanbek Dyussenov arystan.d at gmail.com
Thu Jun 25 18:25:07 CEST 2009


Revision: 21158
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21158
Author:   kazanbas
Date:     2009-06-25 18:25:07 +0200 (Thu, 25 Jun 2009)

Log Message:
-----------
Quick fix to allow reading of <polylist> and <polygons>.
Treating <polylist> as <polygons> in OpenCollada seems intentional, not a bug.

Modified Paths:
--------------
    branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp

Modified: branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp
===================================================================
--- branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp	2009-06-25 15:41:27 UTC (rev 21157)
+++ branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp	2009-06-25 16:25:07 UTC (rev 21158)
@@ -216,12 +216,7 @@
 	virtual bool writeGeometry ( const COLLADAFW::Geometry* cgeom ) 
 	{
 		// - create a mesh object
-		// - enter editmode getting editmesh
 		// - write geometry
-		// - exit editmode
-		// 
-		// - unlink mesh from object
-		// - remove object
 
 		// - ignore usupported primitive types
 
@@ -245,19 +240,20 @@
 		
 		for (i = 0; i < prim_arr.getCount(); i++) {
 			
-			COLLADAFW::MeshPrimitive *mp = prim_arr.getData()[i];
+			COLLADAFW::MeshPrimitive *mp = prim_arr[i];
 			COLLADAFW::MeshPrimitive::PrimitiveType type = mp->getPrimitiveType();
 
 			const char *type_str = primTypeToStr(type);
 
-			if (type == COLLADAFW::MeshPrimitive::POLYLIST) {
+			// OpenCollada passes POLYGONS type for <polylist>
+			if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
 
 				COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
 				COLLADAFW::Polygons::VertexCountArray& vca = mpvc->getGroupedVerticesVertexCountArray();
 				
 				bool ok = true;
 				for(int j = 0; j < vca.getCount(); j++){
-					int count = vca.getData()[j];
+					int count = vca[j];
 					if (count != 3 && count != 4) {
 						fprintf(stderr, "%s has at least one face with vertex count > 4 or < 3\n",
 								type_str);
@@ -313,13 +309,8 @@
 		}
 
 		// count totface
-		int totface = 0;
+		int totface = cmesh->getFacesCount();
 
-		for (i = 0; i < prim_arr.getCount(); i++) {
-			COLLADAFW::MeshPrimitive *mp = prim_arr.getData()[i];
-			totface += mp->getFaceCount();
-		}
-
 		// allocate faces
 		me->mface = (MFace*)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, totface);
 		me->totface = totface;
@@ -328,7 +319,7 @@
 		MFace *mface = me->mface;
 		for (i = 0; i < prim_arr.getCount(); i++){
 			
- 			COLLADAFW::MeshPrimitive *mp = prim_arr.getData()[i];
+ 			COLLADAFW::MeshPrimitive *mp = prim_arr[i];
 			
 			// faces
 			size_t prim_totface = mp->getFaceCount();
@@ -345,13 +336,13 @@
 					mface++;
 				}
 			}
-			else if (type == COLLADAFW::MeshPrimitive::POLYLIST) {
+			else if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
 				COLLADAFW::Polygons *mpvc =	(COLLADAFW::Polygons*)mp;
 				COLLADAFW::Polygons::VertexCountArray& vca =
 					mpvc->getGroupedVerticesVertexCountArray();
 				for (k = 0; k < prim_totface; k++) {
 					
-					if (vca.getData()[k] == 3){
+					if (vca[k] == 3){
 						mface->v1 = indices[0];
 						mface->v2 = indices[1];
 						mface->v3 = indices[2];





More information about the Bf-blender-cvs mailing list