Panda3D
Loading...
Searching...
No Matches
bulletPersistentManifold.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 bulletPersistentManifold.cxx
10 * @author enn0x
11 * @date 2010-03-07
12 */
13
15
16#include "bulletManifoldPoint.h"
17#include "bulletWorld.h"
18
19/**
20 *
21 */
22BulletPersistentManifold::
23BulletPersistentManifold(btPersistentManifold *manifold) : _manifold(manifold) {
24
25}
26
27/**
28 *
29 */
30PN_stdfloat BulletPersistentManifold::
31get_contact_breaking_threshold() const {
32 LightMutexHolder holder(BulletWorld::get_global_lock());
33
34 return (PN_stdfloat)_manifold->getContactBreakingThreshold();
35}
36
37/**
38 *
39 */
40PN_stdfloat BulletPersistentManifold::
41get_contact_processing_threshold() const {
42 LightMutexHolder holder(BulletWorld::get_global_lock());
43
44 return (PN_stdfloat)_manifold->getContactProcessingThreshold();
45}
46
47/**
48 *
49 */
50void BulletPersistentManifold::
51clear_manifold() {
52 nassertv_always(_manifold != nullptr);
53
54 LightMutexHolder holder(BulletWorld::get_global_lock());
55
56 _manifold->clearManifold();
57}
58
59/**
60 *
61 */
62PandaNode *BulletPersistentManifold::
63get_node0() {
64 nassertr_always(_manifold != nullptr, nullptr);
65
66 LightMutexHolder holder(BulletWorld::get_global_lock());
67
68#if BT_BULLET_VERSION >= 281
69 const btCollisionObject *obj = _manifold->getBody0();
70#else
71 const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody0();
72#endif
73
74 return (obj) ? (PandaNode *)obj->getUserPointer(): nullptr;
75}
76
77/**
78 *
79 */
80PandaNode *BulletPersistentManifold::
81get_node1() {
82 nassertr_always(_manifold != nullptr, nullptr);
83
84 LightMutexHolder holder(BulletWorld::get_global_lock());
85
86#if BT_BULLET_VERSION >= 281
87 const btCollisionObject *obj = _manifold->getBody1();
88#else
89 const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody1();
90#endif
91
92 return (obj) ? (PandaNode *)obj->getUserPointer(): nullptr;
93}
94
95/**
96 *
97 */
98int BulletPersistentManifold::
99get_num_manifold_points() const {
100 nassertr_always(_manifold != nullptr, 0);
101
102 LightMutexHolder holder(BulletWorld::get_global_lock());
103
104 return _manifold->getNumContacts();
105}
106
107/**
108 *
109 */
110BulletManifoldPoint *BulletPersistentManifold::
111get_manifold_point(int idx) const {
112 LightMutexHolder holder(BulletWorld::get_global_lock());
113
114 nassertr(idx < _manifold->getNumContacts(), nullptr)
115
116 return new BulletManifoldPoint(_manifold->getContactPoint(idx));
117}
118
119/**
120 *
121 */
123__get_manifold_point(int idx) const {
124 LightMutexHolder holder(BulletWorld::get_global_lock());
125 return BulletManifoldPoint(_manifold->getContactPoint(idx));
126}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Similar to MutexHolder, but for a light mutex.
A basic node of the scene graph or data graph.
Definition pandaNode.h:65