Panda3D

physicsManager.I
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 physicsManager.I
10 * @author charles
11 * @date 2000-06-14
12 */
13
14 /**
15 * Registers a Physical class with the manager
16 */
17 INLINE void PhysicsManager::
18 attach_physical(Physical *p) {
19 nassertv(p && p->_physics_manager == nullptr);
20 p->_physics_manager = this;
21 PhysicalsVector::iterator found;
22 found = find(_physicals.begin(), _physicals.end(), p);
23 if (found == _physicals.end()) {
24 _physicals.push_back(p);
25 }
26 }
27
28 /**
29 * Adds a global linear force to the physics manager
30 */
31 INLINE void PhysicsManager::
32 add_linear_force(LinearForce *f) {
33 nassertv(f);
34 LinearForceVector::iterator found;
35 PT(LinearForce) ptlf = f;
36 found = find(_linear_forces.begin(), _linear_forces.end(), ptlf);
37 if (found == _linear_forces.end()) {
38 _linear_forces.push_back(f);
39 }
40 }
41
42 /**
43 * Please call attach_physical_node instead.
44 */
45 INLINE void PhysicsManager::
46 attach_physicalnode(PhysicalNode *p) {
47 std::cerr<<"attach_physicalnode (aka attachPhysicalnode) has been"
48 <<"replaced with attach_physical_node (aka attachPhysicalNode)."
49 <<" Please change the spelling of the function in your code."
50 <<std::endl;
51 attach_physical_node(p);
52 }
53
54 /**
55 * Registers a physicalnode with the manager
56 */
57 INLINE void PhysicsManager::
58 attach_physical_node(PhysicalNode *p) {
59 nassertv(p);
60 for (size_t i = 0; i < p->get_num_physicals(); ++i) {
61 attach_physical(p->get_physical(i));
62 }
63 }
64
65 /**
66 * Resets the physics manager force vector
67 */
68 INLINE void PhysicsManager::
69 clear_linear_forces() {
70 _linear_forces.erase(_linear_forces.begin(), _linear_forces.end());
71 }
72
73 /**
74 * Adds a global angular force to the physics manager
75 */
76 INLINE void PhysicsManager::
77 add_angular_force(AngularForce *f) {
78 nassertv(f);
79 AngularForceVector::iterator found;
80 PT(AngularForce) ptaf = f;
81 found = find(_angular_forces.begin(), _angular_forces.end(), ptaf);
82 if (found == _angular_forces.end())
83 _angular_forces.push_back(f);
84 }
85
86 /**
87 * Resets the physics manager force vector
88 */
89 INLINE void PhysicsManager::
90 clear_angular_forces() {
91 _angular_forces.erase(_angular_forces.begin(), _angular_forces.end());
92 }
93
94 /**
95 * Resets the physics manager objects vector
96 */
97 INLINE void PhysicsManager::
98 clear_physicals() {
99 _physicals.erase(_physicals.begin(), _physicals.end());
100 }
101
102 /**
103 * Set the global viscosity.
104 */
105 INLINE void PhysicsManager::
106 set_viscosity(PN_stdfloat viscosity) {
107 _viscosity=viscosity;
108 }
109
110 /**
111 * Get the global viscosity.
112 */
113 INLINE PN_stdfloat PhysicsManager::
114 get_viscosity() const {
115 return _viscosity;
116 }
117
118 /**
119 * Hooks a linear integrator into the manager
120 */
121 INLINE void PhysicsManager::
122 attach_linear_integrator(LinearIntegrator *i) {
123 nassertv(i);
124 _linear_integrator = i;
125 }
126
127 /**
128 * Hooks an angular integrator into the manager
129 */
130 INLINE void PhysicsManager::
131 attach_angular_integrator(AngularIntegrator *i) {
132 nassertv(i);
133 _angular_integrator = i;
134 }
AngularForce
pure virtual parent of all quat-based forces.
Definition: angularForce.h:22
AngularIntegrator
Pure virtual base class for physical modeling.
Definition: angularIntegrator.h:25
LinearForce
A force that acts on a PhysicsObject by way of an Integrator.
Definition: linearForce.h:23
LinearIntegrator
Pure virtual base class for physical modeling.
Definition: linearIntegrator.h:26
PhysicalNode
Graph node that encapsulated a series of physical objects.
Definition: physicalNode.h:28
Physical
Defines a set of physically modeled attributes.
Definition: physical.h:37
PhysicsManager::get_viscosity
PN_stdfloat get_viscosity() const
Get the global viscosity.
Definition: physicsManager.I:114
PhysicsManager::attach_linear_integrator
void attach_linear_integrator(LinearIntegrator *i)
Hooks a linear integrator into the manager.
Definition: physicsManager.I:122
PhysicsManager::clear_angular_forces
void clear_angular_forces()
Resets the physics manager force vector.
Definition: physicsManager.I:90
PhysicsManager::clear_physicals
void clear_physicals()
Resets the physics manager objects vector.
Definition: physicsManager.I:98
PhysicsManager::clear_linear_forces
void clear_linear_forces()
Resets the physics manager force vector.
Definition: physicsManager.I:69
PhysicsManager::attach_physicalnode
void attach_physicalnode(PhysicalNode *p)
Please call attach_physical_node instead.
Definition: physicsManager.I:46
PhysicsManager::attach_physical
void attach_physical(Physical *p)
Registers a Physical class with the manager.
Definition: physicsManager.I:18
PhysicsManager::set_viscosity
void set_viscosity(PN_stdfloat viscosity)
Set the global viscosity.
Definition: physicsManager.I:106
PhysicsManager::attach_angular_integrator
void attach_angular_integrator(AngularIntegrator *i)
Hooks an angular integrator into the manager.
Definition: physicsManager.I:131
PhysicsManager::attach_physical_node
void attach_physical_node(PhysicalNode *p)
Registers a physicalnode with the manager.
Definition: physicsManager.I:58
PhysicsManager::add_linear_force
void add_linear_force(LinearForce *f)
Adds a global linear force to the physics manager.
Definition: physicsManager.I:32
PhysicsManager::add_angular_force
void add_angular_force(AngularForce *f)
Adds a global angular force to the physics manager.
Definition: physicsManager.I:77