2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-10-25 18:17:26 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2011-10-25 18:17:26 +02:00
|
|
|
*/
|
|
|
|
|
2013-04-16 07:23:34 +02:00
|
|
|
#pragma once
|
2010-12-23 03:14:03 +01:00
|
|
|
|
2024-03-23 17:43:38 +01:00
|
|
|
#include "BLI_span.hh"
|
2020-03-02 15:07:49 +01:00
|
|
|
|
2019-01-28 11:08:24 +01:00
|
|
|
struct BMBVHTree;
|
2009-10-07 23:19:58 +02:00
|
|
|
struct BMEditMesh;
|
|
|
|
struct BMFace;
|
2013-11-18 08:20:21 +01:00
|
|
|
struct BMLoop;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct BMVert;
|
|
|
|
struct BMesh;
|
2010-09-25 03:54:58 +02:00
|
|
|
struct BVHTree;
|
2009-11-04 03:12:00 +01:00
|
|
|
|
2009-10-07 23:19:58 +02:00
|
|
|
typedef struct BMBVHTree BMBVHTree;
|
|
|
|
|
2015-01-13 13:54:14 +01:00
|
|
|
typedef bool (*BMBVHTree_FaceFilter)(struct BMFace *f, void *userdata);
|
|
|
|
|
2014-07-30 08:48:20 +02:00
|
|
|
BMBVHTree *BKE_bmbvh_new_from_editmesh(struct BMEditMesh *em,
|
|
|
|
int flag,
|
|
|
|
const float (*cos_cage)[3],
|
2022-01-07 01:38:08 +01:00
|
|
|
bool cos_cage_free);
|
2014-07-30 08:48:20 +02:00
|
|
|
BMBVHTree *BKE_bmbvh_new_ex(struct BMesh *bm,
|
2024-03-23 17:43:38 +01:00
|
|
|
blender::Span<std::array<BMLoop *, 3>> looptris,
|
2014-07-30 08:48:20 +02:00
|
|
|
int flag,
|
|
|
|
const float (*cos_cage)[3],
|
2022-01-07 01:38:08 +01:00
|
|
|
bool cos_cage_free,
|
2014-07-30 08:48:20 +02:00
|
|
|
bool (*test_fn)(struct BMFace *, void *user_data),
|
|
|
|
void *user_data);
|
|
|
|
BMBVHTree *BKE_bmbvh_new(struct BMesh *bm,
|
2024-03-23 17:43:38 +01:00
|
|
|
blender::Span<std::array<BMLoop *, 3>> looptris,
|
2014-07-30 08:48:20 +02:00
|
|
|
int flag,
|
|
|
|
const float (*cos_cage)[3],
|
2022-01-07 01:38:08 +01:00
|
|
|
bool cos_cage_free);
|
2013-04-16 07:59:48 +02:00
|
|
|
void BKE_bmbvh_free(BMBVHTree *tree);
|
|
|
|
struct BVHTree *BKE_bmbvh_tree_get(BMBVHTree *tree);
|
2015-01-13 13:54:14 +01:00
|
|
|
|
|
|
|
struct BMFace *BKE_bmbvh_ray_cast(BMBVHTree *tree,
|
|
|
|
const float co[3],
|
|
|
|
const float dir[3],
|
2022-01-07 01:38:08 +01:00
|
|
|
float radius,
|
2015-01-13 13:54:14 +01:00
|
|
|
float *r_dist,
|
|
|
|
float r_hitout[3],
|
|
|
|
float r_cagehit[3]);
|
|
|
|
|
|
|
|
struct BMFace *BKE_bmbvh_ray_cast_filter(BMBVHTree *tree,
|
|
|
|
const float co[3],
|
|
|
|
const float dir[3],
|
2022-01-07 01:38:08 +01:00
|
|
|
float radius,
|
2015-01-13 13:54:14 +01:00
|
|
|
float *r_dist,
|
|
|
|
float r_hitout[3],
|
|
|
|
float r_cagehit[3],
|
2019-10-02 23:31:24 +02:00
|
|
|
BMBVHTree_FaceFilter filter_cb,
|
|
|
|
void *filter_userdata);
|
2015-01-13 13:54:14 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Find a vert closest to co in a sphere of radius dist_max.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
struct BMVert *BKE_bmbvh_find_vert_closest(BMBVHTree *tree, const float co[3], float dist_max);
|
|
|
|
struct BMFace *BKE_bmbvh_find_face_closest(BMBVHTree *tree, const float co[3], float dist_max);
|
2009-10-07 23:19:58 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
2023-12-14 02:08:21 +01:00
|
|
|
* Overlap indices reference the looptris.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2015-08-20 11:09:20 +02:00
|
|
|
struct BVHTreeOverlap *BKE_bmbvh_overlap(const BMBVHTree *bmtree_a,
|
|
|
|
const BMBVHTree *bmtree_b,
|
|
|
|
unsigned int *r_overlap_tot);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
2023-12-14 02:08:21 +01:00
|
|
|
* Overlap indices reference the looptris.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2020-09-22 16:00:06 +02:00
|
|
|
struct BVHTreeOverlap *BKE_bmbvh_overlap_self(const BMBVHTree *bmtree,
|
2020-10-01 14:29:26 +02:00
|
|
|
unsigned int *r_overlap_tot);
|
2020-09-22 16:00:06 +02:00
|
|
|
|
2019-06-26 04:40:22 +02:00
|
|
|
/** #BKE_bmbvh_new flag parameter. */
|
2012-04-18 18:27:11 +02:00
|
|
|
enum {
|
2019-06-26 04:40:22 +02:00
|
|
|
/** Use with 'cos_cage', returns hits in relation to original geometry. */
|
|
|
|
BMBVH_RETURN_ORIG = (1 << 0),
|
|
|
|
/** Restrict to hidden geometry (overrides BMBVH_RESPECT_HIDDEN). */
|
|
|
|
BMBVH_RESPECT_SELECT = (1 << 1),
|
|
|
|
/** Omit hidden geometry. */
|
|
|
|
BMBVH_RESPECT_HIDDEN = (1 << 2),
|
2012-04-18 18:27:11 +02:00
|
|
|
};
|