style cleanup: raytree code
This commit is contained in:
@@ -2301,7 +2301,7 @@ class VIEW3D_PT_view3d_cursor(Panel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
view = context.space_data
|
view = context.space_data
|
||||||
return (view)
|
return (view is not None)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
@@ -371,7 +371,7 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
|
|||||||
{
|
{
|
||||||
ClothModifierData *clmd = (ClothModifierData *)md1;
|
ClothModifierData *clmd = (ClothModifierData *)md1;
|
||||||
CollisionModifierData *collmd = (CollisionModifierData *) md2;
|
CollisionModifierData *collmd = (CollisionModifierData *) md2;
|
||||||
Cloth *cloth = clmd->clothObject;
|
/* Cloth *cloth = clmd->clothObject; */ /* UNUSED */
|
||||||
MFace *face1=NULL, *face2 = NULL;
|
MFace *face1=NULL, *face2 = NULL;
|
||||||
#ifdef USE_BULLET
|
#ifdef USE_BULLET
|
||||||
ClothVertex *verts1 = clmd->clothObject->verts;
|
ClothVertex *verts1 = clmd->clothObject->verts;
|
||||||
|
@@ -332,14 +332,12 @@ static int bvh_node_raycast(Node *node, Isect *isec)
|
|||||||
hit |= bvh_node_raycast(node->child[i], isec);
|
hit |= bvh_node_raycast(node->child[i], isec);
|
||||||
if (hit && isec->mode == RE_RAY_SHADOW) return hit;
|
if (hit && isec->mode == RE_RAY_SHADOW) return hit;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
hit |= RE_rayobject_intersect( (RayObject *)node->child[i], isec);
|
hit |= RE_rayobject_intersect( (RayObject *)node->child[i], isec);
|
||||||
if (hit && isec->mode == RE_RAY_SHADOW) return hit;
|
if (hit && isec->mode == RE_RAY_SHADOW) return hit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
for (i = BVH_NCHILDS - 1; i >= 0; i--)
|
for (i = BVH_NCHILDS - 1; i >= 0; i--)
|
||||||
if (!is_leaf(node->child[i]))
|
if (!is_leaf(node->child[i]))
|
||||||
@@ -350,8 +348,7 @@ static int bvh_node_raycast(Node *node, Isect *isec)
|
|||||||
if (hit && isec->mode == RE_RAY_SHADOW) return hit;
|
if (hit && isec->mode == RE_RAY_SHADOW) return hit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
hit |= RE_rayobject_intersect( (RayObject *)node->child[i], isec);
|
hit |= RE_rayobject_intersect( (RayObject *)node->child[i], isec);
|
||||||
if (hit && isec->mode == RE_RAY_SHADOW) return hit;
|
if (hit && isec->mode == RE_RAY_SHADOW) return hit;
|
||||||
}
|
}
|
||||||
|
@@ -69,8 +69,7 @@ static RayObjectAPI bvh_api =
|
|||||||
RE_rayobject_blibvh_hint_bb
|
RE_rayobject_blibvh_hint_bb
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct BVHObject
|
typedef struct BVHObject {
|
||||||
{
|
|
||||||
RayObject rayobj;
|
RayObject rayobj;
|
||||||
RayObject **leafs, **next_leaf;
|
RayObject **leafs, **next_leaf;
|
||||||
BVHTree *bvh;
|
BVHTree *bvh;
|
||||||
@@ -90,8 +89,7 @@ RayObject *RE_rayobject_blibvh_create(int size)
|
|||||||
return RE_rayobject_unalignRayAPI((RayObject *) obj);
|
return RE_rayobject_unalignRayAPI((RayObject *) obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BVHCallbackUserData
|
struct BVHCallbackUserData {
|
||||||
{
|
|
||||||
Isect *isec;
|
Isect *isec;
|
||||||
RayObject **leafs;
|
RayObject **leafs;
|
||||||
};
|
};
|
||||||
|
@@ -37,8 +37,7 @@
|
|||||||
#define HINT_ACCEPT 0
|
#define HINT_ACCEPT 0
|
||||||
#define HINT_DISCARD -1
|
#define HINT_DISCARD -1
|
||||||
|
|
||||||
struct HintBB
|
struct HintBB {
|
||||||
{
|
|
||||||
float bb[6];
|
float bb[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,8 +49,7 @@ inline int hint_test_bb(HintBB *obj, float *Nmin, float *Nmax)
|
|||||||
return HINT_ACCEPT;
|
return HINT_ACCEPT;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
struct HintFrustum
|
struct HintFrustum {
|
||||||
{
|
|
||||||
float co[3];
|
float co[3];
|
||||||
float no[4][3];
|
float no[4][3];
|
||||||
};
|
};
|
||||||
|
@@ -42,8 +42,7 @@
|
|||||||
|
|
||||||
#define DFS_STACK_SIZE 256
|
#define DFS_STACK_SIZE 256
|
||||||
|
|
||||||
struct QBVHTree
|
struct QBVHTree {
|
||||||
{
|
|
||||||
RayObject rayobj;
|
RayObject rayobj;
|
||||||
|
|
||||||
SVBVHNode *root;
|
SVBVHNode *root;
|
||||||
|
@@ -155,12 +155,13 @@ static void object_sort(Item *begin, Item *end, int axis)
|
|||||||
|
|
||||||
void rtbuild_done(RTBuilder *b, RayObjectControl *ctrl)
|
void rtbuild_done(RTBuilder *b, RayObjectControl *ctrl)
|
||||||
{
|
{
|
||||||
for (int i=0; i<3; i++)
|
for (int i = 0; i < 3; i++) {
|
||||||
if (b->sorted_begin[i]) {
|
if (b->sorted_begin[i]) {
|
||||||
if (RE_rayobjectcontrol_test_break(ctrl)) break;
|
if (RE_rayobjectcontrol_test_break(ctrl)) break;
|
||||||
object_sort(b->sorted_begin[i], b->sorted_end[i], i);
|
object_sort(b->sorted_begin[i], b->sorted_end[i], i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RayObject *rtbuild_get_primitive(RTBuilder *b, int index)
|
RayObject *rtbuild_get_primitive(RTBuilder *b, int index)
|
||||||
{
|
{
|
||||||
@@ -237,8 +238,7 @@ int rtbuild_mean_split(RTBuilder *b, int nchilds, int axis)
|
|||||||
b->child_offset[i] += Mleafs_per_child - mleafs_per_child;
|
b->child_offset[i] += Mleafs_per_child - mleafs_per_child;
|
||||||
missing_leafs -= Mleafs_per_child - mleafs_per_child;
|
missing_leafs -= Mleafs_per_child - mleafs_per_child;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
b->child_offset[i] += missing_leafs;
|
b->child_offset[i] += missing_leafs;
|
||||||
missing_leafs = 0;
|
missing_leafs = 0;
|
||||||
break;
|
break;
|
||||||
@@ -279,8 +279,7 @@ int rtbuild_median_split(RTBuilder *b, float *separators, int nchilds, int axis)
|
|||||||
{
|
{
|
||||||
return rtbuild_mean_split(b, nchilds, axis);
|
return rtbuild_mean_split(b, nchilds, axis);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
b->split_axis = axis;
|
b->split_axis = axis;
|
||||||
@@ -317,8 +316,7 @@ int rtbuild_median_split_largest_axis(RTBuilder *b, int nchilds)
|
|||||||
//Heuristics Object Splitter
|
//Heuristics Object Splitter
|
||||||
|
|
||||||
|
|
||||||
struct SweepCost
|
struct SweepCost {
|
||||||
{
|
|
||||||
float bb[6];
|
float bb[6];
|
||||||
float cost;
|
float cost;
|
||||||
};
|
};
|
||||||
|
@@ -52,10 +52,8 @@ extern "C" {
|
|||||||
#define RTBUILD_MAX_CHILDS 32
|
#define RTBUILD_MAX_CHILDS 32
|
||||||
|
|
||||||
|
|
||||||
typedef struct RTBuilder
|
typedef struct RTBuilder {
|
||||||
{
|
struct Object {
|
||||||
struct Object
|
|
||||||
{
|
|
||||||
RayObject *obj;
|
RayObject *obj;
|
||||||
float cost;
|
float cost;
|
||||||
float bb[6];
|
float bb[6];
|
||||||
@@ -63,8 +61,7 @@ typedef struct RTBuilder
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* list to all primitives added in this tree */
|
/* list to all primitives added in this tree */
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
Object *begin, *end;
|
Object *begin, *end;
|
||||||
int maxsize;
|
int maxsize;
|
||||||
} primitives;
|
} primitives;
|
||||||
|
@@ -42,8 +42,7 @@
|
|||||||
|
|
||||||
#define DFS_STACK_SIZE 256
|
#define DFS_STACK_SIZE 256
|
||||||
|
|
||||||
struct SVBVHTree
|
struct SVBVHTree {
|
||||||
{
|
|
||||||
RayObject rayobj;
|
RayObject rayobj;
|
||||||
|
|
||||||
SVBVHNode *root;
|
SVBVHNode *root;
|
||||||
@@ -56,8 +55,7 @@ struct SVBVHTree
|
|||||||
/*
|
/*
|
||||||
* Cost to test N childs
|
* Cost to test N childs
|
||||||
*/
|
*/
|
||||||
struct PackCost
|
struct PackCost {
|
||||||
{
|
|
||||||
float operator()(int n)
|
float operator()(int n)
|
||||||
{
|
{
|
||||||
return (n / 4) + ((n % 4) > 2 ? 1 : n % 4);
|
return (n / 4) + ((n % 4) > 2 ? 1 : n % 4);
|
||||||
|
@@ -57,8 +57,7 @@ int tot_hints = 0;
|
|||||||
|
|
||||||
#define DFS_STACK_SIZE 256
|
#define DFS_STACK_SIZE 256
|
||||||
|
|
||||||
struct VBVHTree
|
struct VBVHTree {
|
||||||
{
|
|
||||||
RayObject rayobj;
|
RayObject rayobj;
|
||||||
VBVHNode *root;
|
VBVHNode *root;
|
||||||
MemArena *node_arena;
|
MemArena *node_arena;
|
||||||
@@ -69,8 +68,7 @@ struct VBVHTree
|
|||||||
/*
|
/*
|
||||||
* Cost to test N childs
|
* Cost to test N childs
|
||||||
*/
|
*/
|
||||||
struct PackCost
|
struct PackCost {
|
||||||
{
|
|
||||||
float operator()(int n)
|
float operator()(int n)
|
||||||
{
|
{
|
||||||
return n;
|
return n;
|
||||||
@@ -107,8 +105,8 @@ void bvh_done<VBVHTree>(VBVHTree *obj)
|
|||||||
obj->root = NULL;
|
obj->root = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/*
|
/* TODO */
|
||||||
TODO
|
#if 0
|
||||||
MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vbvh arena2");
|
MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vbvh arena2");
|
||||||
BLI_memarena_use_malloc(arena2);
|
BLI_memarena_use_malloc(arena2);
|
||||||
|
|
||||||
@@ -119,7 +117,7 @@ void bvh_done<VBVHTree>(VBVHTree *obj)
|
|||||||
obj->root = Reorganize_VBVH<OVBVHNode>(arena1).transform(root);
|
obj->root = Reorganize_VBVH<OVBVHNode>(arena1).transform(root);
|
||||||
|
|
||||||
BLI_memarena_free(arena2);
|
BLI_memarena_free(arena2);
|
||||||
*/
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//Cleanup
|
//Cleanup
|
||||||
|
@@ -292,8 +292,7 @@ float bvh_refit(Node *node)
|
|||||||
#define MAX_CUT_SIZE 4 /* svbvh assumes max 4 children! */
|
#define MAX_CUT_SIZE 4 /* svbvh assumes max 4 children! */
|
||||||
#define MAX_OPTIMIZE_CHILDS MAX_CUT_SIZE
|
#define MAX_OPTIMIZE_CHILDS MAX_CUT_SIZE
|
||||||
|
|
||||||
struct OVBVHNode
|
struct OVBVHNode {
|
||||||
{
|
|
||||||
float bb[6];
|
float bb[6];
|
||||||
|
|
||||||
OVBVHNode *child;
|
OVBVHNode *child;
|
||||||
@@ -337,11 +336,13 @@ struct OVBVHNode
|
|||||||
}
|
}
|
||||||
assert(cutsize == 0);
|
assert(cutsize == 0);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
for (OVBVHNode *child = this->child; child && RE_rayobject_isAligned(child); child = child->sibling)
|
for (OVBVHNode *child = this->child; child && RE_rayobject_isAligned(child); child = child->sibling) {
|
||||||
child->set_cut(child->get_cut_size(cutsize), cut);
|
child->set_cut(child->get_cut_size(cutsize), cut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void optimize()
|
void optimize()
|
||||||
{
|
{
|
||||||
@@ -365,8 +366,7 @@ struct OVBVHNode
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template<class Node, class TestCost>
|
template<class Node, class TestCost>
|
||||||
struct VBVH_optimalPackSIMD
|
struct VBVH_optimalPackSIMD {
|
||||||
{
|
|
||||||
TestCost testcost;
|
TestCost testcost;
|
||||||
|
|
||||||
VBVH_optimalPackSIMD(TestCost testcost)
|
VBVH_optimalPackSIMD(TestCost testcost)
|
||||||
@@ -377,8 +377,7 @@ struct VBVH_optimalPackSIMD
|
|||||||
/*
|
/*
|
||||||
* calc best cut on a node
|
* calc best cut on a node
|
||||||
*/
|
*/
|
||||||
struct calc_best
|
struct calc_best {
|
||||||
{
|
|
||||||
Node *child[MAX_OPTIMIZE_CHILDS];
|
Node *child[MAX_OPTIMIZE_CHILDS];
|
||||||
float child_hit_prob[MAX_OPTIMIZE_CHILDS];
|
float child_hit_prob[MAX_OPTIMIZE_CHILDS];
|
||||||
|
|
||||||
|
@@ -41,8 +41,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
struct SVBVHNode
|
struct SVBVHNode {
|
||||||
{
|
|
||||||
float child_bb[24];
|
float child_bb[24];
|
||||||
SVBVHNode *child[4];
|
SVBVHNode *child[4];
|
||||||
int nchilds;
|
int nchilds;
|
||||||
@@ -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
|
* Builds a SVBVH tree form a VBVHTree
|
||||||
*/
|
*/
|
||||||
template<class OldNode>
|
template<class OldNode>
|
||||||
struct Reorganize_SVBVH
|
struct Reorganize_SVBVH {
|
||||||
{
|
|
||||||
MemArena *arena;
|
MemArena *arena;
|
||||||
|
|
||||||
float childs_per_node;
|
float childs_per_node;
|
||||||
|
@@ -40,8 +40,7 @@
|
|||||||
/*
|
/*
|
||||||
* VBVHNode represents a BVHNode with support for a variable number of childrens
|
* VBVHNode represents a BVHNode with support for a variable number of childrens
|
||||||
*/
|
*/
|
||||||
struct VBVHNode
|
struct VBVHNode {
|
||||||
{
|
|
||||||
float bb[6];
|
float bb[6];
|
||||||
|
|
||||||
VBVHNode *child;
|
VBVHNode *child;
|
||||||
@@ -107,8 +106,7 @@ void append_sibling(Node *node, Node *sibling)
|
|||||||
* Builds a binary VBVH from a rtbuild
|
* Builds a binary VBVH from a rtbuild
|
||||||
*/
|
*/
|
||||||
template<class Node>
|
template<class Node>
|
||||||
struct BuildBinaryVBVH
|
struct BuildBinaryVBVH {
|
||||||
{
|
|
||||||
MemArena *arena;
|
MemArena *arena;
|
||||||
RayObjectControl *control;
|
RayObjectControl *control;
|
||||||
|
|
||||||
@@ -195,8 +193,7 @@ struct BuildBinaryVBVH
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
template<class Tree, class OldNode>
|
template<class Tree, class OldNode>
|
||||||
struct Reorganize_VBVH
|
struct Reorganize_VBVH {
|
||||||
{
|
|
||||||
Tree *tree;
|
Tree *tree;
|
||||||
|
|
||||||
Reorganize_VBVH(Tree *t)
|
Reorganize_VBVH(Tree *t)
|
||||||
|
Reference in New Issue
Block a user