Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/render/intern/raytrace/svbvh.h')
-rw-r--r--source/blender/render/intern/raytrace/svbvh.h70
1 files changed, 34 insertions, 36 deletions
diff --git a/source/blender/render/intern/raytrace/svbvh.h b/source/blender/render/intern/raytrace/svbvh.h
index ff402446b9f..a58094e5021 100644
--- a/source/blender/render/intern/raytrace/svbvh.h
+++ b/source/blender/render/intern/raytrace/svbvh.h
@@ -41,8 +41,7 @@
#include <stdio.h>
#include <algorithm>
-struct SVBVHNode
-{
+struct SVBVHNode {
float child_bb[24];
SVBVHNode *child[4];
int nchilds;
@@ -120,12 +119,12 @@ static int svbvh_node_stack_raycast(SVBVHNode *root, Isect *isec)
node = stack[--stack_pos];
if (!svbvh_node_is_leaf(node)) {
- int nchilds= node->nchilds;
+ int nchilds = node->nchilds;
if (nchilds == 4) {
- float *child_bb= node->child_bb;
- int res = svbvh_bb_intersect_test_simd4(isec, ((__m128*) (child_bb)));
- SVBVHNode **child= node->child;
+ float *child_bb = node->child_bb;
+ int res = svbvh_bb_intersect_test_simd4(isec, ((__m128 *) (child_bb)));
+ SVBVHNode **child = node->child;
RE_RC_COUNT(isec->raycounter->simd_bb.test);
@@ -135,8 +134,8 @@ static int svbvh_node_stack_raycast(SVBVHNode *root, Isect *isec)
if (res & 8) { stack[stack_pos++] = child[3]; RE_RC_COUNT(isec->raycounter->simd_bb.hit); }
}
else {
- float *child_bb= node->child_bb;
- SVBVHNode **child= node->child;
+ float *child_bb = node->child_bb;
+ SVBVHNode **child = node->child;
int i;
for (i = 0; i < nchilds; i++) {
@@ -147,7 +146,7 @@ static int svbvh_node_stack_raycast(SVBVHNode *root, Isect *isec)
}
}
else {
- hit |= RE_rayobject_intersect((RayObject*)node, isec);
+ hit |= RE_rayobject_intersect((RayObject *)node, isec);
if (SHADOW && hit) break;
}
}
@@ -160,7 +159,7 @@ template<>
inline void bvh_node_merge_bb<SVBVHNode>(SVBVHNode *node, float min[3], float max[3])
{
if (is_leaf(node)) {
- RE_rayobject_merge_bb((RayObject*)node, min, max);
+ RE_rayobject_merge_bb((RayObject *)node, min, max);
}
else {
int i;
@@ -180,7 +179,7 @@ inline void bvh_node_merge_bb<SVBVHNode>(SVBVHNode *node, float min[3], float ma
}
}
- for ( ; i < node->nchilds; i++) {
+ for (; i < node->nchilds; i++) {
DO_MIN(node->child_bb + 6 * i, min);
DO_MAX(node->child_bb + 3 + 6 * i, max);
}
@@ -193,8 +192,7 @@ inline void bvh_node_merge_bb<SVBVHNode>(SVBVHNode *node, float min[3], float ma
* Builds a SVBVH tree form a VBVHTree
*/
template<class OldNode>
-struct Reorganize_SVBVH
-{
+struct Reorganize_SVBVH {
MemArena *arena;
float childs_per_node;
@@ -220,14 +218,14 @@ struct Reorganize_SVBVH
printf("%f childs per node\n", childs_per_node / nodes);
printf("%d childs BB are useless\n", useless_bb);
for (int i = 0; i < 16; i++) {
- printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes, nodes_with_childs[i]/float(nodes));
+ printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes, nodes_with_childs[i] / float(nodes));
}
}
}
SVBVHNode *create_node(int nchilds)
{
- SVBVHNode *node = (SVBVHNode*)BLI_memarena_alloc(arena, sizeof(SVBVHNode));
+ SVBVHNode *node = (SVBVHNode *)BLI_memarena_alloc(arena, sizeof(SVBVHNode));
node->nchilds = nchilds;
return node;
@@ -235,22 +233,22 @@ struct Reorganize_SVBVH
void copy_bb(float *bb, const float *old_bb)
{
- std::copy(old_bb, old_bb+6, bb);
+ std::copy(old_bb, old_bb + 6, bb);
}
void prepare_for_simd(SVBVHNode *node)
{
- int i=0;
+ int i = 0;
while (i + 4 <= node->nchilds) {
- float vec_tmp[4*6];
- float *res = node->child_bb+6*i;
- std::copy(res, res+6*4, vec_tmp);
-
- for (int j=0; j<6; j++) {
- res[4*j+0] = vec_tmp[6*0+j];
- res[4*j+1] = vec_tmp[6*1+j];
- res[4*j+2] = vec_tmp[6*2+j];
- res[4*j+3] = vec_tmp[6*3+j];
+ float vec_tmp[4 * 6];
+ float *res = node->child_bb + 6 * i;
+ std::copy(res, res + 6 * 4, vec_tmp);
+
+ for (int j = 0; j < 6; j++) {
+ res[4 * j + 0] = vec_tmp[6 * 0 + j];
+ res[4 * j + 1] = vec_tmp[6 * 1 + j];
+ res[4 * j + 2] = vec_tmp[6 * 2 + j];
+ res[4 * j + 3] = vec_tmp[6 * 3 + j];
}
i += 4;
@@ -260,15 +258,15 @@ struct Reorganize_SVBVH
/* amt must be power of two */
inline int padup(int num, int amt)
{
- return ((num+(amt-1))&~(amt-1));
+ return ((num + (amt - 1)) & ~(amt - 1));
}
SVBVHNode *transform(OldNode *old)
{
if (is_leaf(old))
- return (SVBVHNode*)old;
+ return (SVBVHNode *)old;
if (is_leaf(old->child))
- return (SVBVHNode*)old->child;
+ return (SVBVHNode *)old->child;
int nchilds = count_childs(old);
int alloc_childs = nchilds;
@@ -282,27 +280,27 @@ struct Reorganize_SVBVH
if (nchilds < 16)
nodes_with_childs[nchilds]++;
- useless_bb += alloc_childs-nchilds;
+ useless_bb += alloc_childs - nchilds;
while (alloc_childs > nchilds) {
const static float def_bb[6] = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MIN, FLT_MIN, FLT_MIN };
alloc_childs--;
node->child[alloc_childs] = NULL;
- copy_bb(node->child_bb+alloc_childs*6, def_bb);
+ copy_bb(node->child_bb + alloc_childs * 6, def_bb);
}
- int i=nchilds;
+ int i = nchilds;
for (OldNode *o_child = old->child; o_child; o_child = o_child->sibling) {
i--;
node->child[i] = transform(o_child);
if (is_leaf(o_child)) {
float bb[6];
- INIT_MINMAX(bb, bb+3);
- RE_rayobject_merge_bb((RayObject*)o_child, bb, bb+3);
- copy_bb(node->child_bb+i*6, bb);
+ INIT_MINMAX(bb, bb + 3);
+ RE_rayobject_merge_bb((RayObject *)o_child, bb, bb + 3);
+ copy_bb(node->child_bb + i * 6, bb);
break;
}
else {
- copy_bb(node->child_bb+i*6, o_child->bb);
+ copy_bb(node->child_bb + i * 6, o_child->bb);
}
}
assert(i == 0);