[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22584] branches/volume25: * Point density texture works again

Matt Ebb matt at mke3.net
Tue Aug 18 00:09:38 CEST 2009


Revision: 22584
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22584
Author:   broken
Date:     2009-08-18 00:09:36 +0200 (Tue, 18 Aug 2009)

Log Message:
-----------
* Point density texture works again

Modified Paths:
--------------
    branches/volume25/release/ui/buttons_texture.py
    branches/volume25/source/blender/blenkernel/intern/texture.c
    branches/volume25/source/blender/blenlib/intern/BLI_kdopbvh.c
    branches/volume25/source/blender/blenloader/intern/readfile.c
    branches/volume25/source/blender/makesdna/DNA_texture_types.h
    branches/volume25/source/blender/makesrna/intern/rna_texture.c
    branches/volume25/source/blender/render/intern/source/pointdensity.c
    branches/volume25/source/blender/render/intern/source/volumetric.c

Modified: branches/volume25/release/ui/buttons_texture.py
===================================================================
--- branches/volume25/release/ui/buttons_texture.py	2009-08-17 20:30:11 UTC (rev 22583)
+++ branches/volume25/release/ui/buttons_texture.py	2009-08-17 22:09:36 UTC (rev 22584)
@@ -680,8 +680,18 @@
 		pd = tex.pointdensity
 
 		layout.itemR(pd, "point_source")
-
+		layout.itemR(pd, "object")
+		if pd.point_source == 'PARTICLE_SYSTEM':
+			layout.item_pointerR(pd, "particle_system", pd.object, "particle_systems", text="")
+		layout.itemR(pd, "radius")
 		layout.itemR(pd, "falloff")
+		if pd.falloff == 'SOFT':
+			layout.itemR(pd, "falloff_softness")
+		layout.itemR(pd, "color_source")
+		layout.itemR(pd, "turbulence")
+		layout.itemR(pd, "turbulence_size")
+		layout.itemR(pd, "turbulence_depth")
+		layout.itemR(pd, "turbulence_influence")
 		
 
 bpy.types.register(TEXTURE_PT_context_texture)

Modified: branches/volume25/source/blender/blenkernel/intern/texture.c
===================================================================
--- branches/volume25/source/blender/blenkernel/intern/texture.c	2009-08-17 20:30:11 UTC (rev 22583)
+++ branches/volume25/source/blender/blenkernel/intern/texture.c	2009-08-17 22:09:36 UTC (rev 22584)
@@ -922,6 +922,8 @@
 	pd->speed_scale = 1.0f;
 	pd->totpoints = 0;
 	pd->coba = add_colorband(1);
+	pd->object = NULL;
+	pd->psys = NULL;
 	return pd;
 } 
 
@@ -982,6 +984,7 @@
 	vd->interp_type= TEX_VD_LINEAR;
 	vd->file_format= TEX_VD_SMOKE;
 	vd->int_multiplier = 1.0;
+	vd->object = NULL;
 	
 	return vd;
  }

Modified: branches/volume25/source/blender/blenlib/intern/BLI_kdopbvh.c
===================================================================
--- branches/volume25/source/blender/blenlib/intern/BLI_kdopbvh.c	2009-08-17 20:30:11 UTC (rev 22583)
+++ branches/volume25/source/blender/blenlib/intern/BLI_kdopbvh.c	2009-08-17 22:09:36 UTC (rev 22584)
@@ -72,10 +72,10 @@
 	char 	start_axis, stop_axis; // KDOP_AXES array indices according to axis
 };
 
-typedef struct BVHOverlapData
-{
-	BVHTree *tree1, *tree2;
-	BVHTreeOverlap *overlap;
+typedef struct BVHOverlapData 
+{  
+	BVHTree *tree1, *tree2; 
+	BVHTreeOverlap *overlap; 
 	int i, max_overlap; /* i is number of overlaps */
 	int start_axis, stop_axis;
 } BVHOverlapData;
@@ -109,7 +109,7 @@
 
 ////////////////////////////////////////////////////////////////////////
 // Bounding Volume Hierarchy Definition
-//
+// 
 // Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below
 // Notes: You have to choose the type at compile time ITM
 // Notes: You can choose the tree type --> binary, quad, octree, choose below
@@ -188,10 +188,10 @@
 
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////
-// Introsort
+// Introsort 
 // with permission deriven from the following Java code:
 // http://ralphunden.net/content/tutorials/a-guide-to-introsort/
-// and he derived it from the SUN STL
+// and he derived it from the SUN STL 
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 static int size_threshold = 16;
 /*
@@ -362,7 +362,7 @@
 	float newminmax;
 	float *bv = node->bv;
 	int i, k;
-
+	
 	// don't init boudings for the moving case
 	if(!moving)
 	{
@@ -372,7 +372,7 @@
 			bv[2*i + 1] = -FLT_MAX;
 		}
 	}
-
+	
 	for(k = 0; k < numpoints; k++)
 	{
 		// for all Axes.
@@ -394,7 +394,7 @@
 	int i, j;
 	float *bv = node->bv;
 
-
+	
 	for (i = tree->start_axis; i < tree->stop_axis; i++)
 	{
 		bv[2*i] = FLT_MAX;
@@ -406,10 +406,10 @@
 // for all Axes.
 		for (i = tree->start_axis; i < tree->stop_axis; i++)
 		{
-			newmin = tree->nodes[j]->bv[(2 * i)];
+			newmin = tree->nodes[j]->bv[(2 * i)];   
 			if ((newmin < bv[(2 * i)]))
 				bv[(2 * i)] = newmin;
-
+ 
 			newmax = tree->nodes[j]->bv[(2 * i) + 1];
 			if ((newmax > bv[(2 * i) + 1]))
 				bv[(2 * i) + 1] = newmax;
@@ -427,14 +427,14 @@
 	middle_point[0] = (bv[1]) - (bv[0]); // x axis
 	middle_point[1] = (bv[3]) - (bv[2]); // y axis
 	middle_point[2] = (bv[5]) - (bv[4]); // z axis
-	if (middle_point[0] > middle_point[1])
+	if (middle_point[0] > middle_point[1]) 
 	{
 		if (middle_point[0] > middle_point[2])
 			return 1; // max x axis
 		else
 			return 5; // max z axis
 	}
-	else
+	else 
 	{
 		if (middle_point[1] > middle_point[2])
 			return 3; // max y axis
@@ -448,24 +448,24 @@
 static void node_join(BVHTree *tree, BVHNode *node)
 {
 	int i, j;
-
+	
 	for (i = tree->start_axis; i < tree->stop_axis; i++)
 	{
 		node->bv[2*i] = FLT_MAX;
 		node->bv[2*i + 1] = -FLT_MAX;
 	}
-
+	
 	for (i = 0; i < tree->tree_type; i++)
 	{
-		if (node->children[i])
+		if (node->children[i]) 
 		{
 			for (j = tree->start_axis; j < tree->stop_axis; j++)
 			{
-				// update minimum
-				if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)])
+				// update minimum 
+				if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) 
 					node->bv[(2 * j)] = node->children[i]->bv[(2 * j)];
-
-				// update maximum
+				
+				// update maximum 
 				if (node->children[i]->bv[(2 * j) + 1] > node->bv[(2 * j) + 1])
 					node->bv[(2 * j) + 1] = node->children[i]->bv[(2 * j) + 1];
 			}
@@ -518,7 +518,7 @@
 static void verify_tree(BVHTree *tree)
 {
 	int i, j, check = 0;
-
+	
 	// check the pointer list
 	for(i = 0; i < tree->totleaf; i++)
 	{
@@ -538,7 +538,7 @@
 			check = 0;
 		}
 	}
-
+	
 	// check the leaf list
 	for(i = 0; i < tree->totleaf; i++)
 	{
@@ -558,7 +558,7 @@
 			check = 0;
 		}
 	}
-
+	
 	printf("branches: %d, leafs: %d, total: %d\n", tree->totbranch, tree->totleaf, tree->totbranch + tree->totleaf);
 }
 #endif
@@ -703,7 +703,7 @@
 
 	BVHBuildHelper data;
 	int depth;
-
+	
 	// set parent from root node to NULL
 	BVHNode *tmp = branches_array+0;
 	tmp->parent = NULL;
@@ -722,7 +722,7 @@
 	}
 
 	branches_array--;	//Implicit trees use 1-based indexs
-
+	
 	build_implicit_tree_helper(tree, &data);
 
 	//Loop tree levels (log N) loops
@@ -806,11 +806,11 @@
 {
 	BVHTree *tree;
 	int numnodes, i;
-
+	
 	// theres not support for trees below binary-trees :P
 	if(tree_type < 2)
 		return NULL;
-
+	
 	if(tree_type > MAX_TREETYPE)
 		return NULL;
 
@@ -820,13 +820,13 @@
 	//so that tangent rays can still hit a bounding volume..
 	//this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces
 	epsilon = MAX2(FLT_EPSILON, epsilon);
-
+	
 	if(tree)
 	{
 		tree->epsilon = epsilon;
-		tree->tree_type = tree_type;
+		tree->tree_type = tree_type; 
 		tree->axis = axis;
-
+		
 		if(axis == 26)
 		{
 			tree->start_axis = 0;
@@ -863,13 +863,13 @@
 		numnodes = maxsize + implicit_needed_branches(tree_type, maxsize) + tree_type;
 
 		tree->nodes = (BVHNode **)MEM_callocN(sizeof(BVHNode *)*numnodes, "BVHNodes");
-
+		
 		if(!tree->nodes)
 		{
 			MEM_freeN(tree);
 			return NULL;
 		}
-
+		
 		tree->nodebv = (float*)MEM_callocN(sizeof(float)* axis * numnodes, "BVHNodeBV");
 		if(!tree->nodebv)
 		{
@@ -886,7 +886,7 @@
 		}
 
 		tree->nodearray = (BVHNode *)MEM_callocN(sizeof(BVHNode)* numnodes, "BVHNodeArray");
-
+		
 		if(!tree->nodearray)
 		{
 			MEM_freeN(tree->nodechild);
@@ -902,14 +902,14 @@
 			tree->nodearray[i].bv = tree->nodebv + i * axis;
 			tree->nodearray[i].children = tree->nodechild + i * tree_type;
 		}
-
+		
 	}
 
 	return tree;
 }
 
 void BLI_bvhtree_free(BVHTree *tree)
-{
+{	
 	if(tree)
 	{
 		MEM_freeN(tree->nodes);
@@ -946,27 +946,27 @@
 {
 	int i;
 	BVHNode *node = NULL;
-
+	
 	// insert should only possible as long as tree->totbranch is 0
 	if(tree->totbranch > 0)
 		return 0;
-
+	
 	if(tree->totleaf+1 >= MEM_allocN_len(tree->nodes)/sizeof(*(tree->nodes)))
 		return 0;
-
+	
 	// TODO check if have enough nodes in array
-
+	
 	node = tree->nodes[tree->totleaf] = &(tree->nodearray[tree->totleaf]);
 	tree->totleaf++;
-
+	
 	create_kdop_hull(tree, node, co, numpoints, 0);
 	node->index= index;
-
+	
 	// inflate the bv with some epsilon
 	for (i = tree->start_axis; i < tree->stop_axis; i++)
 	{
-		node->bv[(2 * i)] -= tree->epsilon; // minimum
-		node->bv[(2 * i) + 1] += tree->epsilon; // maximum
+		node->bv[(2 * i)] -= tree->epsilon; // minimum 
+		node->bv[(2 * i) + 1] += tree->epsilon; // maximum 
 	}
 
 	return 1;
@@ -978,23 +978,23 @@
 {
 	int i;
 	BVHNode *node= NULL;
-
+	
 	// check if index exists
 	if(index > tree->totleaf)
 		return 0;
-
+	
 	node = tree->nodearray + index;
-
+	
 	create_kdop_hull(tree, node, co, numpoints, 0);
-
+	
 	if(co_moving)
 		create_kdop_hull(tree, node, co_moving, numpoints, 1);
-
+	
 	// inflate the bv with some epsilon
 	for (i = tree->start_axis; i < tree->stop_axis; i++)
 	{
-		node->bv[(2 * i)] -= tree->epsilon; // minimum
-		node->bv[(2 * i) + 1] += tree->epsilon; // maximum
+		node->bv[(2 * i)] -= tree->epsilon; // minimum 
+		node->bv[(2 * i) + 1] += tree->epsilon; // maximum 
 	}
 
 	return 1;
@@ -1030,24 +1030,24 @@
 	float *bv2 = node2->bv;
 
 	float *bv1_end = bv1 + (stop_axis<<1);
-
+		
 	bv1 += start_axis<<1;
 	bv2 += start_axis<<1;
-
+	
 	// test all axis if min + max overlap
 	for (; bv1 != bv1_end; bv1+=2, bv2+=2)
 	{
-		if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1)))
+		if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) 
 			return 0;
 	}
-
+	
 	return 1;
 }
 
 static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2)
 {
 	int j;
-
+	
 	if(tree_overlap(node1, node2, data->start_axis, data->stop_axis))
 	{
 		// check if node1 is a leaf
@@ -1056,17 +1056,17 @@
 			// check if node2 is a leaf
 			if(!node2->totnode)
 			{
-
+				
 				if(node1 == node2)
 				{
 					return;
 				}
-
+					
 				if(data->i >= data->max_overlap)
-				{
+				{	
 					// try to make alloc'ed memory bigger
 					data->overlap = realloc(data->overlap, sizeof(BVHTreeOverlap)*data->max_overlap*2);
-
+					
 					if(!data->overlap)
 					{
 						printf("Out of Memory in traverse\n");
@@ -1074,7 +1074,7 @@
 					}
 					data->max_overlap *= 2;
 				}
-
+				
 				// both leafs, insert overlap!
 				data->overlap[data->i].indexA = node1->index;
 				data->overlap[data->i].indexB = node2->index;
@@ -1092,7 +1092,7 @@
 		}
 		else
 		{
-
+			
 			for(j = 0; j < data->tree2->tree_type; j++)
 			{
 				if(node1->children[j])
@@ -1108,21 +1108,21 @@
 	int j, total = 0;
 	BVHTreeOverlap *overlap = NULL, *to = NULL;
 	BVHOverlapData **data;
-
+	
 	// check for compatibility of both trees (can't compare 14-DOP with 18-DOP)
 	if((tree1->axis != tree2->axis) && (tree1->axis == 14 || tree2->axis == 14) && (tree1->axis == 18 || tree2->axis == 18))
 		return 0;
-
+	
 	// fast check root nodes for collision before doing big splitting + traversal

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list