~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/blenlib/BLI_kdopbvh.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        int indexB;
50
50
} BVHTreeOverlap;
51
51
 
52
 
typedef struct BVHTreeNearest
53
 
{
54
 
        int index;                      /* the index of the nearest found (untouched if none is found within a dist radius from the given coordinates) */
55
 
        float co[3];            /* nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */
56
 
        float no[3];            /* normal at nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */
57
 
        float dist;                     /* squared distance to search arround */
 
52
/* flags */
 
53
#define BVH_ONQUAD (1 << 0)
 
54
 
 
55
typedef struct BVHTreeNearest {
 
56
        int index;          /* the index of the nearest found (untouched if none is found within a dist radius from the given coordinates) */
 
57
        float co[3];        /* nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */
 
58
        float no[3];        /* normal at nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */
 
59
        float dist;         /* squared distance to search arround */
 
60
        int flags;
58
61
} BVHTreeNearest;
59
62
 
60
 
typedef struct BVHTreeRay
61
 
{
62
 
        float origin[3];        /* ray origin */
63
 
        float direction[3];     /* ray direction */
64
 
        float radius;           /* radius around ray */
 
63
typedef struct BVHTreeRay {
 
64
        float origin[3];    /* ray origin */
 
65
        float direction[3]; /* ray direction */
 
66
        float radius;       /* radius around ray */
65
67
} BVHTreeRay;
66
68
 
67
 
typedef struct BVHTreeRayHit
68
 
{
69
 
        int index;                      /* index of the tree node (untouched if no hit is found) */
70
 
        float co[3];            /* coordinates of the hit point */
71
 
        float no[3];            /* normal on hit point */
72
 
        float dist;                     /* distance to the hit point */
 
69
typedef struct BVHTreeRayHit {
 
70
        int index;          /* index of the tree node (untouched if no hit is found) */
 
71
        float co[3];        /* coordinates of the hit point */
 
72
        float no[3];        /* normal on hit point */
 
73
        float dist;         /* distance to the hit point */
 
74
        int flags;
73
75
} BVHTreeRayHit;
74
76
 
75
77
/* callback must update nearest in case it finds a nearest result */
76
 
typedef void (*BVHTree_NearestPointCallback) (void *userdata, int index, const float *co, BVHTreeNearest *nearest);
 
78
typedef void (*BVHTree_NearestPointCallback)(void *userdata, int index, const float co[3], BVHTreeNearest *nearest);
77
79
 
78
80
/* callback must update hit in case it finds a nearest successful hit */
79
 
typedef void (*BVHTree_RayCastCallback) (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit);
 
81
typedef void (*BVHTree_RayCastCallback)(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit);
80
82
 
81
83
/* callback to range search query */
82
 
typedef void (*BVHTree_RangeQuery) (void *userdata, int index, float squared_dist);
 
84
typedef void (*BVHTree_RangeQuery)(void *userdata, int index, float squared_dist);
83
85
 
84
86
BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis);
85
87
void BLI_bvhtree_free(BVHTree *tree);
86
88
 
87
89
/* construct: first insert points, then call balance */
88
 
int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints);
 
90
int BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints);
89
91
void BLI_bvhtree_balance(BVHTree *tree);
90
92
 
91
93
/* update: first update points/nodes, then call update_tree to refit the bounding volumes */
92
 
int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints);
 
94
int BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const float co_moving[3], int numpoints);
93
95
void BLI_bvhtree_update_tree(BVHTree *tree);
94
96
 
95
97
/* collision/overlap: check two trees if they overlap, alloc's *overlap with length of the int return value */
96
98
BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int *result);
97
99
 
98
 
float BLI_bvhtree_getepsilon(BVHTree *tree);
99
 
 
100
 
/* find nearest node to the given coordinates (if nearest is given it will only search nodes where square distance is smaller than nearest->dist) */
101
 
int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata);
102
 
 
103
 
int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata);
104
 
 
105
 
float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3]);
 
100
float BLI_bvhtree_getepsilon(const BVHTree *tree);
 
101
 
 
102
/* find nearest node to the given coordinates
 
103
 * (if nearest is given it will only search nodes where square distance is smaller than nearest->dist) */
 
104
int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest,
 
105
                             BVHTree_NearestPointCallback callback, void *userdata);
 
106
 
 
107
int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit,
 
108
                         BVHTree_RayCastCallback callback, void *userdata);
 
109
 
 
110
float BLI_bvhtree_bb_raycast(const float bv[6], const float light_start[3], const float light_end[3], float pos[3]);
106
111
 
107
112
/* range query */
108
 
int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata);
 
113
int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius,
 
114
                            BVHTree_RangeQuery callback, void *userdata);
109
115
 
110
116
#ifdef __cplusplus
111
117
}
112
118
#endif
113
119
 
114
 
#endif // __BLI_KDOPBVH_H__
115
 
 
 
120
#endif  /* __BLI_KDOPBVH_H__ */