[Bf-committers] derivedmesh iterators

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jun 2 12:45:14 CEST 2008


I've been working a bit on an iterator interface for derivedmesh, and a derivedmesh wrapper for displists. I didn't intend to write anything about it yet because the design is a work in progress with incomplete code and bugs in it, but apparently it came up as at topic at the meeting so I'm posting a patch against the apricot branch here for people who want to look at it.


And some example code from the patch:

DMVertIterator v;
DMIteratorData origlayer;
int orig, count = 0;

dm->getVertIterator(dm, &v);
dm->getVertIteratorData(dm, &origlayer, CD_ORIGINDEX, NULL);

/* get the average of all verts with (original index == nr) */
for(v.begin(&v); v.valid; v.next(&v)) {
	orig= *((int*)v.data(&v, &origlayer));

	if(orig == nr) {
		VecAddf(vec, vec, v.co);

if (count==0) /* keep as 0,0,0 */
	memset(vec, 0, sizeof(float)*3);
	VecMulf(vec, 1.0f/count);

dm->freeVertIterator(dm, &v);


More information about the Bf-committers mailing list