Panda3D

bulletContactResult.cxx
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file bulletContactResult.cxx
10 * @author enn0x
11 * @date 2010-03-08
12 */
13
14 #include "bulletContactResult.h"
15
16 btManifoldPoint BulletContact::_empty;
17 BulletContact BulletContactResult::_empty;
18
19 /**
20 *
21 */
22 BulletContact::
23 BulletContact() : _mp(_empty) {
24
25 _node0 = nullptr;
26 _node1 = nullptr;
27 }
28
29 /**
30 *
31 */
32 BulletContact::
33 BulletContact(const BulletContact &other) : _mp(other._mp) {
34
35 _node0 = other._node0;
36 _node1 = other._node1;
37 _part_id0 = other._part_id0;
38 _part_id1 = other._part_id1;
39 _idx0 = other._idx0;
40 _idx1 = other._idx1;
41 }
42
43 /**
44 *
45 */
46 BulletContactResult::
47 BulletContactResult() : btCollisionWorld::ContactResultCallback() {
48
49 #if BT_BULLET_VERSION >= 281
50 _filter_cb = nullptr;
51 _filter_proxy = nullptr;
52 _filter_set = false;
53 #endif
54 }
55
56 #if BT_BULLET_VERSION >= 281
57 /**
58 *
59 */
60 void BulletContactResult::
61 use_filter(btOverlapFilterCallback *cb, btBroadphaseProxy *proxy) {
62
63 nassertv(cb);
64 nassertv(proxy);
65
66 _filter_cb = cb;
67 _filter_proxy = proxy;
68 _filter_set = true;
69 }
70
71 /**
72 *
73 */
74 bool BulletContactResult::
75 needsCollision(btBroadphaseProxy *proxy0) const {
76
77 if (_filter_set) {
78 return _filter_cb->needBroadphaseCollision(proxy0, _filter_proxy);
79 }
80 else {
81 return true;
82 }
83 }
84
85 /**
86 *
87 */
88 btScalar BulletContactResult::
89 addSingleResult(btManifoldPoint &mp,
90 const btCollisionObjectWrapper *wrap0, int part_id0, int idx0,
91 const btCollisionObjectWrapper *wrap1, int part_id1, int idx1) {
92
93 const btCollisionObject *obj0 = wrap0->getCollisionObject();
94 const btCollisionObject *obj1 = wrap1->getCollisionObject();
95
96 BulletContact contact;
97
98 contact._mp = BulletManifoldPoint(mp);
99 contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : nullptr;
100 contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : nullptr;
101 contact._part_id0 = part_id0;
102 contact._part_id1 = part_id1;
103 contact._idx0 = idx0;
104 contact._idx1 = idx1;
105
106 _contacts.push_back(contact);
107
108 return 1.0f;
109 }
110 #else
111 /**
112 *
113 */
114 btScalar BulletContactResult::
115 addSingleResult(btManifoldPoint &mp,
116 const btCollisionObject *obj0, int part_id0, int idx0,
117 const btCollisionObject *obj1, int part_id1, int idx1) {
118
119 BulletContact contact;
120
121 contact._mp = BulletManifoldPoint(mp);
122 contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : nullptr;
123 contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : nullptr;
124 contact._part_id0 = part_id0;
125 contact._part_id1 = part_id1;
126 contact._idx0 = idx0;
127 contact._idx1 = idx1;
128
129 _contacts.push_back(contact);
130
131 return 1.0f;
132 }
133 #endif
bulletContactResult.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BulletManifoldPoint
Definition: bulletManifoldPoint.h:27
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
BulletContact
Definition: bulletContactResult.h:27