Blender V5.3
BKE_collision.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
9
11
12#include "DNA_listBase.h"
13
14namespace blender {
15
16struct BVHTree;
17struct Collection;
19struct Depsgraph;
20struct ListBase;
21struct Object;
22
23/* -------------------------------------------------------------------- */
28
29/* COLLISION FLAGS */
32#ifdef WITH_ELTOPO
33 COLLISION_USE_COLLFACE = (1 << 2),
34 COLLISION_IS_EDGES = (1 << 3),
35#endif
37};
38
39struct CollPair {
40 unsigned int face1; /* cloth face */
41 unsigned int face2; /* object face */
42 float distance;
43 float normal[3];
44 float vector[3]; /* unnormalized collision vector: p2-p1 */
45 float pa[3], pb[3]; /* collision point p1 on face1, p2 on face2 */
46 int flag;
47 float time; /* collision time, from 0 up to 1 */
48
49 /* mesh-mesh collision */
50#ifdef WITH_ELTOPO /* Either ap* or bp* can be set, but not both. */
51 float bary[3];
52 int ap1, ap2, ap3, collp, bp1, bp2, bp3;
53 int collface;
54#else
55 int ap1, ap2, ap3, bp1, bp2, bp3;
56#endif
57 /* Barycentric weights of the collision point. */
58 float aw1, aw2, aw3, bw1, bw2, bw3;
59 int pointsb[4];
60};
61
63 unsigned int p11, p12, p21, p22;
64 float normal[3];
65 float vector[3];
66 float time;
68 float pa[3], pb[3]; /* collision point p1 on face1, p2 on face2 */
69};
70
72 unsigned int p11, p12, p13, p21;
73 float normal[3];
74 float vector[3];
75 float time;
77 float pa[3], pb[3]; /* collision point p1 on face1, p2 on face2 */
78};
79
81
82/* Forward declarations. */
83
84/* -------------------------------------------------------------------- */
89struct BVHTree *bvhtree_build_from_mvert(const float (*positions)[3],
90 const int3 *vert_tris,
91 int tri_num,
92 float epsilon);
93void bvhtree_update_from_mvert(struct BVHTree *bvhtree,
94 const float (*positions)[3],
95 const float (*positions_moving)[3],
96 const int3 *vert_tris,
97 int tri_num,
98 bool moving);
100
101/* -------------------------------------------------------------------- */
104
111 float step,
112 float prevstep,
113 bool moving_bvh);
114
115void collision_get_collider_velocity(float vel_old[3],
116 float vel_new[3],
117 struct CollisionModifierData *collmd,
118 struct CollPair *collpair);
119
121
122/* -------------------------------------------------------------------- */
127
132
138ListBaseT<CollisionRelation> *BKE_collision_relations_create(struct Depsgraph *depsgraph,
139 struct Collection *collection,
140 unsigned int modifier_type);
141void BKE_collision_relations_free(ListBaseT<CollisionRelation> *relations);
142
143/* Collision object lists for physics simulation evaluation. */
144
149struct Object **BKE_collision_objects_create(struct Depsgraph *depsgraph,
150 struct Object *self,
151 struct Collection *collection,
152 unsigned int *numcollobj,
153 unsigned int modifier_type);
154void BKE_collision_objects_free(struct Object **objects);
155
157
158/* -------------------------------------------------------------------- */
161
167
172ListBaseT<ColliderCache> *BKE_collider_cache_create(struct Depsgraph *depsgraph,
173 struct Object *self,
174 struct Collection *collection);
175void BKE_collider_cache_free(ListBaseT<ColliderCache> **colliders);
176
178
179} // namespace blender
These structs are the foundation for all linked lists in the library system.
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
BMesh Iterators.
void BKE_collider_cache_free(ListBaseT< ColliderCache > **colliders)
void collision_move_object(struct CollisionModifierData *collmd, float step, float prevstep, bool moving_bvh)
Definition collision.cc:62
@ COLLISION_IN_FUTURE
@ COLLISION_INACTIVE
void BKE_collision_relations_free(ListBaseT< CollisionRelation > *relations)
void collision_get_collider_velocity(float vel_old[3], float vel_new[3], struct CollisionModifierData *collmd, struct CollPair *collpair)
struct BVHTree * bvhtree_build_from_mvert(const float(*positions)[3], const int3 *vert_tris, int tri_num, float epsilon)
Definition collision.cc:92
VecBase< int32_t, 3 > int3
ListBaseT< ColliderCache > * BKE_collider_cache_create(struct Depsgraph *depsgraph, struct Object *self, struct Collection *collection)
struct Object ** BKE_collision_objects_create(struct Depsgraph *depsgraph, struct Object *self, struct Collection *collection, unsigned int *numcollobj, unsigned int modifier_type)
void bvhtree_update_from_mvert(struct BVHTree *bvhtree, const float(*positions)[3], const float(*positions_moving)[3], const int3 *vert_tris, int tri_num, bool moving)
Definition collision.cc:116
ListBaseT< CollisionRelation > * BKE_collision_relations_create(struct Depsgraph *depsgraph, struct Collection *collection, unsigned int modifier_type)
void BKE_collision_objects_free(struct Object **objects)
unsigned int face1
unsigned int face2
struct ColliderCache * next
struct ColliderCache * prev
struct CollisionModifierData * collmd
struct CollisionRelation * prev
struct CollisionRelation * next