[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13232] trunk/blender/source/blender/ render/intern/source/renderdatabase.c:

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jan 14 12:08:00 CET 2008


Revision: 13232
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13232
Author:   blendix
Date:     2008-01-14 12:07:59 +0100 (Mon, 14 Jan 2008)

Log Message:
-----------

Bugfix for rendering of duplis again, this time with multiple
dupligroups containing the same dupliverts.

Modified Paths:
--------------
    trunk/blender/source/blender/render/intern/source/renderdatabase.c

Modified: trunk/blender/source/blender/render/intern/source/renderdatabase.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/renderdatabase.c	2008-01-14 10:41:36 UTC (rev 13231)
+++ trunk/blender/source/blender/render/intern/source/renderdatabase.c	2008-01-14 11:07:59 UTC (rev 13232)
@@ -688,11 +688,6 @@
 	obr->index= index;
 	obr->psysindex= psysindex;
 
-	if(!re->objecthash)
-		re->objecthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
-	if(!BLI_ghash_lookup(re->objecthash, ob))
-		BLI_ghash_insert(re->objecthash, ob, obr);
-
 	return obr;
 }
 
@@ -823,11 +818,6 @@
 		re->instancetable.first= re->instancetable.last= NULL;
 	}
 
-	if(re->objecthash) {
-		BLI_ghash_free(re->objecthash, NULL, NULL);
-		re->objecthash= NULL;
- 	}
-
 	if(re->sortedhalos) {
 		MEM_freeN(re->sortedhalos);
 		re->sortedhalos= NULL;
@@ -1285,9 +1275,34 @@
 	return obi;
 }
 
+void find_dupli_objectren(Render *re, ObjectInstanceRen *obi, ObjectInstanceRen *lastobi)
+{
+	ObjectRen *obr;
+
+	/* see if last object did the same lookup, so we can just reuse result */
+	if(lastobi && obi->ob == lastobi->ob && obi->par == lastobi->par && obi->psysindex == lastobi->psysindex) {
+		obi->obr= lastobi->obr;
+		return;
+	}
+
+	/* dupli objects are created after object instances, so we look through
+	 * object list to find it */
+	obr= re->objecttable.first;
+	while(obr && (obr->ob != obi->ob || obr->par != obi->par || obr->psysindex != obi->psysindex))
+		obr= obr->next;
+
+	if(!obr) {
+		obr= re->objecttable.first;
+		while(obr && (obr->ob != obi->ob || obr->psysindex != obi->psysindex) && obr->par == NULL)
+			obr= obr->next;
+	}
+
+	obi->obr= obr;
+}
+
 void RE_makeRenderInstances(Render *re)
 {
-	ObjectInstanceRen *obi, *oldobi;
+	ObjectInstanceRen *obi, *oldobi, *lastobi= NULL;
 	ListBase newlist;
 	int tot;
 
@@ -1302,12 +1317,8 @@
 		*obi= *oldobi;
 
 		if(!obi->obr) {
-			/* dupli objects are created after object instances, so they were
-			 * stored in a object -> objectren hash, we do lookup of the actual
-			 * pointer here */
-			if(re->objecthash && (obi->obr=BLI_ghash_lookup(re->objecthash, obi->ob)))
-				while(obi->obr && obi->obr->psysindex != obi->psysindex)
-					obi->obr= obi->obr->next;
+			find_dupli_objectren(re, obi, lastobi);
+			lastobi= obi;
 		}
 
 		if(obi->obr) {
@@ -1319,10 +1330,6 @@
 			re->totinstance--;
 	}
 
-	if(re->objecthash) {
-		BLI_ghash_free(re->objecthash, NULL, NULL);
-		re->objecthash= NULL;
-	}
 	BLI_freelistN(&re->instancetable);
 	re->instancetable= newlist;
 }





More information about the Bf-blender-cvs mailing list