[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12472] branches/qdune/blender/extern/ qdune/primitives/CCSubdivision.cpp: Changed order of functions, apparently caused a problem for some

Alfredo de Greef eeshlo at yahoo.com
Sun Nov 4 20:06:11 CET 2007


Revision: 12472
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12472
Author:   eeshlo
Date:     2007-11-04 20:06:11 +0100 (Sun, 04 Nov 2007)

Log Message:
-----------
Changed order of functions, apparently caused a problem for some
compiler(s?).

Modified Paths:
--------------
    branches/qdune/blender/extern/qdune/primitives/CCSubdivision.cpp

Modified: branches/qdune/blender/extern/qdune/primitives/CCSubdivision.cpp
===================================================================
--- branches/qdune/blender/extern/qdune/primitives/CCSubdivision.cpp	2007-11-04 19:01:31 UTC (rev 12471)
+++ branches/qdune/blender/extern/qdune/primitives/CCSubdivision.cpp	2007-11-04 19:06:11 UTC (rev 12472)
@@ -709,278 +709,7 @@
 	// old face list now discarded
 }
 
-//---------------------------------------------------------------------------------------------------------
-// CCSubdivisionMesh
 
-CCSubdivisionMesh::CCSubdivisionMesh(RtInt nf, RtInt nverts[], RtInt verts[], RtInt ntags, RtToken tags[],
-                                     RtInt nargs[], RtInt intargs[], RtFloat floatargs[], RtInt n, RtToken tokens[], RtPointer *parms)
-{
-	unsigned int num_faces = nf;
-
-	// test if all quad, if not, one global subdivision iteration is needed
-	presubd = false;
-	int sum_faceverts = 0; // sum of verts ( == max possible vertex index == sizeof verts[] array)
-	for (unsigned int i=0; i<num_faces; i++) {
-		if (nverts[i] != 4) presubd = true;
-		sum_faceverts += nverts[i];
-	}
-
-	// determine number of expected "P" vertices from the highest index referenced (+1) in verts[]
-	int num_verts = 0;
-	for (int i=0; i<sum_faceverts; i++)
-		num_verts = MAX2(num_verts, verts[i]);
-	num_verts++;
-
-	vert_list.resize(num_verts);
-
-	// get "P" param (others TODO)
-	for (int i=0; i<n; i++) {
-		if (!strcmp(tokens[i], RI_P)) {
-			RtPoint* P = (RtPoint*)parms[i];
-			for (int vi=0; vi<num_verts; vi++)
-				vert_list[vi].co.set(P[vi][0], P[vi][1], P[vi][2]);
-			// others TODO, so can break once "P" found
-			break;
-		}
-	}
-
-	// init faces, and set face pointers in vert_list
-	int lv = 0;
-	face_list.resize(num_faces);
-	for (unsigned int i=0; i<num_faces; i++) {
-		ccFace* f = &face_list[i];
-		for (int j=0; j<nverts[i]; j++) {
-			f->verts.push_back(verts[lv + j]);
-			vert_list[verts[lv+j]].faces.push_back(f);
-		}
-		lv += nverts[i];
-	}
-
-	// Prepare the initial edge list
-	aatree_t<uint64, unsigned int> edge_id;
-	hashtable_t<const ccVert*, array_t<int>* > edge_verts;
-	unsigned int num_edges = INIT_EDGES(edge_id, edge_verts, vert_list, face_list, vert_list.size(), face_list.size());
-
-	// Finalize initial edge list, and set flags.
-	// In rebuildLists() & makeExplicitSDPatch() edgelists are rebuilt using slightly
-	// different code to account for proper propagation of flags.
-	edge_list.resize(num_edges);
-	for (unsigned int fi=0; fi<num_faces; ++fi) {
-		const array_t<int>& fcverts = face_list[fi].verts;
-		const unsigned int nv = fcverts.size();
-		for (unsigned int vi=0; vi<nv; ++vi)
-			SET_EDGE(edge_id, edge_verts, edge_list, fcverts[vi], fcverts[(vi+1) % nv], vert_list, face_list, vert_list.size(), fi);
-	}
-
-	// edges done, now can check for interpolateboundary/crease tags
-	intpolBD = false;
-	int ac = 0, fidx = 0, lastevi = 0;
-	if (ntags) {
-		for (int i=0; i<ntags; ++i) {
-			if (!strcmp(tags[i], "interpolateboundary")) {
-				intpolBD = true;
-				ac += 2;
-			}
-			else if (!strcmp(tags[i], "crease")) {
-				const int numi = nargs[ac]; //, numf = nargs[ac+1];
-				for (int evi=lastevi; evi<(lastevi + numi - 1); ++evi) {
-					unsigned int idx1 = intargs[evi], idx2 = intargs[evi+1];
-					if (idx1 > idx2) SWAP(idx1, idx2);
-					unsigned int* e_idx = edge_id.find(idx1 + (uint64)num_verts*idx2);
-					if (e_idx == NULL)
-						printf("[ERROR] crease edge with incorrect vertex index/indices? skipping...\n");
-					else if (floatargs[fidx] >= 1.f) {	// sharpness must be at least 1 to be considered a crease edge
-						ccEdge& edge = edge_list[*e_idx];
-						edge.flags |= SD_CREASE;
-						edge.sharpness = (unsigned short)floatargs[fidx];
-					}
-				}
-				lastevi += numi;
-				ac += 2;
-				fidx++;
-			}
-		}
-	}
-
-	// delete array pointers in edge_verts and set edge boundary flags
-	edge_verts.clear_delete();
-	setBoundaryFlags(edge_list);
-
-	// process any primitive variables
-	Primitive::initPrimVars(n, tokens, parms, num_faces, num_verts, num_verts, sum_faceverts);
-
-	// Now store every primvar per face, decoupling it from main primitive.
-	// For simplicity, varying/vertex vars are converted to facevaring.
-	// Currently, vertex data is still linearly interpolated.
-	if (primvars) {
-		sklist_t<vardata_t*>& varlist = const_cast<PrimVars*>(primvars)->pvars;
-		vardata_t** vdt = varlist.first();
-		while (vdt) {
-			const char* name = varlist.getName();
-			decParam_t& dp = (*vdt)->param;
-			if (dp.ct_flags & DT_FLOAT) {
-				const RtFloat* fdata = (*vdt)->data;
-				if (dp.ct_flags & SC_FACEVARYING) {
-					for (FaceIter fi=face_list.begin(); fi!=face_list.end(); ++fi) {
-						const unsigned int vs = fi->verts.size();
-						decParam_t ndp = {dp.ct_flags, 1, vs};
-						vardata_t* nvdt = new vardata_t(ndp);
-						nvdt->data = new float[vs];
-						memcpy(nvdt->data, fdata, sizeof(float)*vs);
-						if (fi->pv == NULL) fi->pv = new PrimVars();
-						fi->pv->pvars.insert(name, nvdt);
-						fdata += vs;
-					}
-				}
-				else if (dp.ct_flags & (SC_VERTEX | SC_VARYING)) {
-					for (FaceIter fi=face_list.begin(); fi!=face_list.end(); ++fi) {
-						const unsigned int vs = fi->verts.size();
-						decParam_t ndp = {SC_FACEVARYING | DT_FLOAT, 1, vs};
-						vardata_t* nvdt = new vardata_t(ndp);
-						nvdt->data = new float[vs];
-						unsigned int dtidx = 0;
-						for (array_t<int>::const_iterator vci=fi->verts.begin(); vci!=fi->verts.end(); ++vci, ++dtidx)
-							nvdt->data[dtidx] = fdata[*vci];
-						if (fi->pv == NULL) fi->pv = new PrimVars();
-						fi->pv->pvars.insert(name, nvdt);
-					}
-				}
-				else if (dp.ct_flags & SC_UNIFORM) {
-					for (FaceIter fi=face_list.begin(); fi!=face_list.end(); ++fi) {
-						decParam_t ndp = {dp.ct_flags, 1, 1};
-						vardata_t* nvdt = new vardata_t(ndp);
-						nvdt->data = new float[1];
-						nvdt->data[0] = fdata[0];
-						if (fi->pv == NULL) fi->pv = new PrimVars();
-						fi->pv->pvars.insert(name, nvdt);
-						fdata++;
-					}
-				}
-			}
-			else if (dp.ct_flags & DT_FLOAT3MASK) {
-				const RtVector* vdata = (RtVector*)(*vdt)->data;
-				if (dp.ct_flags & SC_FACEVARYING) {
-					for (FaceIter fi=face_list.begin(); fi!=face_list.end(); ++fi) {
-						const unsigned int vs = fi->verts.size();
-						decParam_t ndp = {dp.ct_flags, 1, vs*3};
-						vardata_t* nvdt = new vardata_t(ndp);
-						RtVector* nva = new RtVector[vs];
-						memcpy(nva, vdata, sizeof(RtVector)*vs);
-						nvdt->data = reinterpret_cast<float*>(nva);
-						if (fi->pv == NULL) fi->pv = new PrimVars();
-						fi->pv->pvars.insert(name, nvdt);
-						vdata += vs;
-					}
-				}
-				else if (dp.ct_flags & (SC_VERTEX | SC_VARYING)) {
-					for (FaceIter fi=face_list.begin(); fi!=face_list.end(); ++fi) {
-						const unsigned int vs = fi->verts.size();
-						decParam_t ndp = {SC_FACEVARYING | (dp.ct_flags & DT_FLOAT3MASK), 1, vs*3};
-						vardata_t* nvdt = new vardata_t(ndp);
-						RtVector* nva = new RtVector[vs];
-						nvdt->data = reinterpret_cast<float*>(nva);
-						unsigned int dtidx = 0;
-						for (array_t<int>::const_iterator vci=fi->verts.begin(); vci!=fi->verts.end(); ++vci, ++dtidx)
-							vcopy(nva[dtidx], vdata[*vci]);
-						if (fi->pv == NULL) fi->pv = new PrimVars();
-						fi->pv->pvars.insert(name, nvdt);
-					}
-				}
-				else if (dp.ct_flags & SC_UNIFORM) {
-					for (FaceIter fi=face_list.begin(); fi!=face_list.end(); ++fi) {
-						decParam_t ndp = {dp.ct_flags, 1, 3};
-						vardata_t* nvdt = new vardata_t(ndp);
-						RtVector* nva = new RtVector[1];
-						vcopy(nva[0], vdata[0]);
-						nvdt->data = reinterpret_cast<float*>(nva);
-						if (fi->pv == NULL) fi->pv = new PrimVars();
-						fi->pv->pvars.insert(name, nvdt);
-						vdata++;
-					}
-				}
-			}
-			vdt = varlist.next();
-		}
-		// delete primvars
-		delete primvars;
-		primvars = NULL;
-	}
-
-}
-
-
-CCSubdivisionMesh::~CCSubdivisionMesh()
-{
-	// nothing to do
-}
-
-
-void CCSubdivisionMesh::post_init()
-{
-	// transform vertices to camera space
-	for (VertIter v=vert_list.begin(); v!=vert_list.end(); ++v)
-		v->co = *xform * v->co;
-}
-
-
-Bound CCSubdivisionMesh::bound()
-{
-	Bound b;
-	for (VertIter v=vert_list.begin(); v!=vert_list.end(); ++v)
-		b.include(v->co);
-	b.addEpsilon();
-	// already in camspace
-	return b;
-}
-
-
-void CCSubdivisionMesh::split(const Framework &f, bool usplit, bool vsplit, splitbprims_t* spb)
-{
-#ifndef SKIP_GLOBAL_SUBDIVISION
-	// do one iteration of global subdivision if mesh is not totally quadrilateral yet
-	if (presubd) {
-		//printf("Initial subdivision to make mesh quadrilateral\n");
-		Subdivide(vert_list, edge_list, face_list);
-		rebuildLists(vert_list, edge_list, face_list);
-	}
-
-	// another global subdivision to isolate extra-ordinary vertices,
-	// but first test if this is in fact needed at all.
-	// (maybe it is best to actually just always do this, since in some cases,
-	//  if skipped, the result might be a lot of explicit subdivision patches...)
-	int numeo = 0;
-	for (FaceConstIter fi=face_list.begin(); fi!=face_list.end(); ++fi) {
-		const unsigned int sz = fi->verts.size();
-		numeo = 0;
-		for (unsigned int fvi=0; fvi<sz; ++fvi) {
-			const ccVert& v = vert_list[fi->verts[fvi]];
-			const unsigned int val = v.edges.size();
-			// for boundary case, 'perfect' valence is 3, otherwise 4
-			if (val != 2) {
-				if (val != ((v.flags & SD_BOUNDARY) ? 3 : 4)) numeo++;
-			}
-		}
-		if (numeo > 1) break;
-	}
-	if (numeo > 1) {
-		//printf("Mesh has more than 1 eo.vert per face, global subdivision required\n");
-		Subdivide(vert_list, edge_list, face_list);
-		rebuildLists(vert_list, edge_list, face_list);
-	}
-#endif
-
-	// make the subdivision patches. See getSubdivData() for prerender flag purpose
-	JS_SDPatch::prerender = State::Instance()->rendering();
-	makePatches(vert_list, edge_list, face_list, this, &f, spb);
-	JS_SDPatch::prerender = not JS_SDPatch::prerender;
-}
-
-void CCSubdivisionMesh::dice(MicroPolygonGrid &g, bool Pclose)
-{
-	printf("[ERROR]: CCSubdivisionMesh()->dice() called?\n");
-}
-
-
 // For each face, make a subdivision patch.
 // The patch consists of the main face, with its one ring neighbourhood of faces.
 void makePatches(const fsArray_t<ccVert> &vert_list,
@@ -1266,6 +995,278 @@
 	//printf("Total explicit subdivision patches created: %d\n", estot);
 }
 
+//---------------------------------------------------------------------------------------------------------

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list