Panda3D
Loading...
Searching...
No Matches
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 */
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 */
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 */
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;
52}
53
54/**
55 * Registers a physicalnode with the manager
56 */
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 */
70 _linear_forces.erase(_linear_forces.begin(), _linear_forces.end());
71}
72
73/**
74 * Adds a global angular force to the physics manager
75 */
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 */
91 _angular_forces.erase(_angular_forces.begin(), _angular_forces.end());
92}
93
94/**
95 * Resets the physics manager objects vector
96 */
99 _physicals.erase(_physicals.begin(), _physicals.end());
100}
101
102/**
103 * Set the global viscosity.
104 */
106set_viscosity(PN_stdfloat viscosity) {
107 _viscosity=viscosity;
108}
109
110/**
111 * Get the global viscosity.
112 */
113INLINE PN_stdfloat PhysicsManager::
114get_viscosity() const {
115 return _viscosity;
116}
117
118/**
119 * Hooks a linear integrator into the manager
120 */
123 nassertv(i);
124 _linear_integrator = i;
125}
126
127/**
128 * Hooks an angular integrator into the manager
129 */
132 nassertv(i);
133 _angular_integrator = i;
134}
pure virtual parent of all quat-based forces.
Pure virtual base class for physical modeling.
A force that acts on a PhysicsObject by way of an Integrator.
Definition linearForce.h:23
Pure virtual base class for physical modeling.
Graph node that encapsulated a series of physical objects.
Defines a set of physically modeled attributes.
Definition physical.h:37
PN_stdfloat get_viscosity() const
Get the global viscosity.
void attach_linear_integrator(LinearIntegrator *i)
Hooks a linear integrator into the manager.
void clear_angular_forces()
Resets the physics manager force vector.
void clear_physicals()
Resets the physics manager objects vector.
void clear_linear_forces()
Resets the physics manager force vector.
void attach_physicalnode(PhysicalNode *p)
Please call attach_physical_node instead.
void attach_physical(Physical *p)
Registers a Physical class with the manager.
void set_viscosity(PN_stdfloat viscosity)
Set the global viscosity.
void attach_angular_integrator(AngularIntegrator *i)
Hooks an angular integrator into the manager.
void attach_physical_node(PhysicalNode *p)
Registers a physicalnode with the manager.
void add_linear_force(LinearForce *f)
Adds a global linear force to the physics manager.
void add_angular_force(AngularForce *f)
Adds a global angular force to the physics manager.