Panda3D
 All Classes Functions Variables Enumerations
config_collide.cxx
1 // Filename: config_collide.cxx
2 // Created by: drose (24Apr00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_collide.h"
16 #include "collisionBox.h"
17 #include "collisionEntry.h"
18 #include "collisionHandler.h"
19 #include "collisionHandlerEvent.h"
20 #include "collisionHandlerHighestEvent.h"
21 #include "collisionHandlerFloor.h"
22 #include "collisionHandlerGravity.h"
23 #include "collisionHandlerPhysical.h"
24 #include "collisionHandlerPusher.h"
25 #include "collisionHandlerFluidPusher.h"
26 #include "collisionHandlerQueue.h"
27 #include "collisionInvSphere.h"
28 #include "collisionLine.h"
29 #include "collisionLevelStateBase.h"
30 #include "collisionGeom.h"
31 #include "collisionNode.h"
32 #include "collisionParabola.h"
33 #include "collisionPlane.h"
34 #include "collisionPolygon.h"
35 #include "collisionFloorMesh.h"
36 #include "collisionRay.h"
37 #include "collisionRecorder.h"
38 #include "collisionSegment.h"
39 #include "collisionSolid.h"
40 #include "collisionSphere.h"
41 #include "collisionTraverser.h"
42 #include "collisionTube.h"
43 #include "collisionVisualizer.h"
44 #include "dconfig.h"
45 
46 Configure(config_collide);
47 NotifyCategoryDef(collide, "");
48 
49 ConfigureFn(config_collide) {
50  init_libcollide();
51 }
52 
53 ConfigVariableBool respect_prev_transform
54 ("respect-prev-transform", false,
55  PRC_DESC("Set this true to have all CollisionTraversers in the world respect "
56  "the previous frame's transform (position) for a given object when "
57  "determining motion for collision tests. If this is false, you must "
58  "explicitly enable motion detection for a particular traverser. It "
59  "is false by default to force programmers to decide on a "
60  "case-by-case basis whether they really need this feature."));
61 
62 ConfigVariableBool respect_effective_normal
63 ("respect-effective-normal", true,
64  PRC_DESC("This should be true to support the effective_normal interface of "
65  "polygons. Set it false to disable this feature, so that all "
66  "collision solids (including polygons and planes) use their actual "
67  "normal for intersection and physics tests."));
68 
69 ConfigVariableBool allow_collider_multiple
70 ("allow-collider-multiple", false,
71  PRC_DESC("Set this true to enable the use of a DoubleBitMask or QuadBitMask "
72  "to manage many "
73  "colliders added to a single traverser in one pass. If this is "
74  "false, a one-word BitMask is always used instead, which is faster "
75  "per pass, but may require more passes."));
76 
77 ConfigVariableBool flatten_collision_nodes
78 ("flatten-collision-nodes", false,
79  PRC_DESC("Set this true to allow NodePath::flatten_medium() and "
80  "flatten_strong() to combine multiple CollisionNodes "
81  "into a single CollisionNode--but only if they share the "
82  "same name and collide masks. When false, CollisionNodes "
83  "are never combined. This is false by default, since "
84  "collision tests rely heavily on bounding volume tests "
85  "to be efficient, and combining CollisionNodes is likely "
86  "to merge bounding volumes inappropriately."));
87 
88 ConfigVariableDouble collision_parabola_bounds_threshold
89 ("collision-parabola-bounds-threshold", 10.0,
90  PRC_DESC("This is the threshold size for a CollisionParabola to "
91  "make a bounding box (BoundingHexahedron). If the parabola "
92  "is smaller than this, it will make a BoundingSphere instead, "
93  "which is much easier to make and will be good enough for "
94  "small parabolas."));
95 
96 ConfigVariableInt collision_parabola_bounds_sample
97 ("collision-parabola-bounds-sample", 10,
98  PRC_DESC("This is the number of points along a CollisionParabola to "
99  "sample in order to determine an accurate bounding box."));
100 
101 ConfigVariableInt fluid_cap_amount
102 ("fluid-cap-amount", 100,
103  PRC_DESC("ensures that fluid pos doesn't check beyond X feet"));
104 
105 ConfigVariableBool pushers_horizontal
106 ("pushers-horizontal", false,
107  PRC_DESC("Set this true to make all CollisionHandlerPushers have the "
108  "set_horizontal() flag by default, false to let the move "
109  "in three dimensions by default."));
110 
111 ////////////////////////////////////////////////////////////////////
112 // Function: init_libcollide
113 // Description: Initializes the library. This must be called at
114 // least once before any of the functions or classes in
115 // this library can be used. Normally it will be
116 // called by the static initializers and need not be
117 // called explicitly, but special cases exist.
118 ////////////////////////////////////////////////////////////////////
119 void
120 init_libcollide() {
121  static bool initialized = false;
122  if (initialized) {
123  return;
124  }
125  initialized = true;
126 
127  CollisionBox::init_type();
128  CollisionEntry::init_type();
129  CollisionHandler::init_type();
130  CollisionHandlerEvent::init_type();
131  CollisionHandlerHighestEvent::init_type();
132  CollisionHandlerFloor::init_type();
133  CollisionHandlerGravity::init_type();
134  CollisionHandlerPhysical::init_type();
135  CollisionHandlerPusher::init_type();
136  CollisionHandlerFluidPusher::init_type();
137  CollisionHandlerQueue::init_type();
138  CollisionInvSphere::init_type();
139  CollisionLine::init_type();
140  CollisionLevelStateBase::init_type();
141  CollisionGeom::init_type();
142  CollisionNode::init_type();
143  CollisionParabola::init_type();
144  CollisionPlane::init_type();
145  CollisionPolygon::init_type();
146  CollisionFloorMesh::init_type();
147  CollisionRay::init_type();
148  CollisionSegment::init_type();
149  CollisionSolid::init_type();
150  CollisionSphere::init_type();
151  CollisionTraverser::init_type();
152  CollisionTube::init_type();
153 
154 #ifdef DO_COLLISION_RECORDING
155  CollisionRecorder::init_type();
156  CollisionVisualizer::init_type();
157 #endif
158 
171 }
static void register_with_read_factory()
Factory method to generate a CollisionPolygon object.
static void register_with_read_factory()
Factory method to generate a CollisionSphere object.
This is a convenience class to specialize ConfigVariable as a boolean type.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionTube.
This is a convenience class to specialize ConfigVariable as a floating-point type.
static void register_with_read_factory()
Factory method to generate a CollisionBox object.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionSegment.
static void register_with_read_factory()
Factory method to generate a CollisionInvSphere object.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionRay.
static void register_with_read_factory()
Factory method to generate a CollisionPolygon object.
static void register_with_read_factory()
Factory method to generate a CollisionPlane object.
This is a convenience class to specialize ConfigVariable as an integer type.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionNode.
static void register_with_read_factory()
Factory method to generate a CollisionParabola object.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionLine.