Panda3D
 All Classes Functions Variables Enumerations
config_pgraph.cxx
1 // Filename: config_pgraph.cxx
2 // Created by: drose (21Feb02)
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_pgraph.h"
16 
17 #include "alphaTestAttrib.h"
18 #include "audioVolumeAttrib.h"
19 #include "auxBitplaneAttrib.h"
20 #include "antialiasAttrib.h"
21 #include "auxSceneData.h"
22 #include "billboardEffect.h"
23 #include "camera.h"
24 #include "clipPlaneAttrib.h"
25 #include "colorAttrib.h"
26 #include "colorBlendAttrib.h"
27 #include "colorScaleAttrib.h"
28 #include "colorWriteAttrib.h"
29 #include "compassEffect.h"
30 #include "cullFaceAttrib.h"
31 #include "cullBin.h"
32 #include "cullBinAttrib.h"
33 #include "cullResult.h"
34 #include "cullTraverser.h"
35 #include "cullableObject.h"
36 #include "decalEffect.h"
37 #include "depthOffsetAttrib.h"
38 #include "depthTestAttrib.h"
39 #include "depthWriteAttrib.h"
40 #include "findApproxLevelEntry.h"
41 #include "fog.h"
42 #include "fogAttrib.h"
43 #include "geomDrawCallbackData.h"
44 #include "geomNode.h"
45 #include "geomTransformer.h"
46 #include "lensNode.h"
47 #include "light.h"
48 #include "lightAttrib.h"
49 #include "lightRampAttrib.h"
50 #include "loader.h"
51 #include "loaderFileType.h"
52 #include "loaderFileTypeBam.h"
53 #include "loaderFileTypeRegistry.h"
54 #include "materialAttrib.h"
55 #include "modelFlattenRequest.h"
56 #include "modelLoadRequest.h"
57 #include "modelSaveRequest.h"
58 #include "modelNode.h"
59 #include "modelRoot.h"
60 #include "nodePath.h"
61 #include "nodePathComponent.h"
62 #include "pandaNode.h"
63 #include "paramNodePath.h"
64 #include "planeNode.h"
65 #include "polylightEffect.h"
66 #include "polylightNode.h"
67 #include "portalNode.h"
68 #include "occluderEffect.h"
69 #include "occluderNode.h"
70 #include "portalClipper.h"
71 #include "renderAttrib.h"
72 #include "renderEffect.h"
73 #include "renderEffects.h"
74 #include "renderModeAttrib.h"
75 #include "renderState.h"
76 #include "rescaleNormalAttrib.h"
77 #include "sceneSetup.h"
78 #include "scissorAttrib.h"
79 #include "scissorEffect.h"
80 #include "shadeModelAttrib.h"
81 #include "shaderInput.h"
82 #include "shaderAttrib.h"
83 #include "shader.h"
84 #include "showBoundsEffect.h"
85 #include "stencilAttrib.h"
86 #include "stateMunger.h"
87 #include "texMatrixAttrib.h"
88 #include "texProjectorEffect.h"
89 #include "textureAttrib.h"
90 #include "texGenAttrib.h"
91 #include "transformState.h"
92 #include "transparencyAttrib.h"
93 
94 #include "dconfig.h"
95 
96 ConfigureDef(config_pgraph);
97 NotifyCategoryDef(pgraph, "");
98 NotifyCategoryDef(loader, "");
99 NotifyCategoryDef(portal, "");
100 
101 ConfigureFn(config_pgraph) {
102  init_libpgraph();
103 }
104 
105 ConfigVariableBool fake_view_frustum_cull
106 ("fake-view-frustum-cull", false,
107  PRC_DESC("Set this true to cause culling to be performed by rendering the "
108  "object in red wireframe, rather than actually culling it. This "
109  "helps make culling errors obvious. This variable only has an "
110  "effect when Panda is not compiled for a release build."));
111 
112 ConfigVariableBool clip_plane_cull
113 ("clip-plane-cull", true,
114  PRC_DESC("This is normally true; set it false to disable culling of objects "
115  "that are completely behind one or more clip planes (primarily "
116  "useful for debugging) This also disables the use of occluders."));
117 
118 ConfigVariableBool allow_portal_cull
119 ("allow-portal-cull", false,
120  PRC_DESC("Set this true to enable portal clipping. This will enable the "
121  "renderer to cull more objects that are clipped if not in the "
122  "current list of portals. This is still somewhat experimental."));
123 
124 ConfigVariableBool debug_portal_cull
125 ("debug-portal-cull", false,
126  PRC_DESC("Set this true to enable debug visualization during portal clipping."
127  "(You first need to enable portal culling, using the allow-portal-cull"
128  "variable.)"));
129 
130 ConfigVariableBool show_occluder_volumes
131 ("show-occluder-volumes", false,
132  PRC_DESC("Set this true to enable debug visualization of the volumes used "
133  "to cull objects behind an occluder."));
134 
135 ConfigVariableBool unambiguous_graph
136 ("unambiguous-graph", false,
137  PRC_DESC("Set this true to make ambiguous path warning messages generate an "
138  "assertion failure instead of just a warning (which can then be "
139  "trapped with assert-abort)."));
140 
141 ConfigVariableBool detect_graph_cycles
142 ("detect-graph-cycles", true,
143  PRC_DESC("Set this true to attempt to detect cycles in the scene graph "
144  "(e.g. a node which is its own parent) as soon as they are "
145  "made. This has no effect in NDEBUG mode."));
146 
147 ConfigVariableBool no_unsupported_copy
148 ("no-unsupported-copy", false,
149  PRC_DESC("Set this true to make an attempt to copy an unsupported type "
150  "generate an assertion failure instead of just a warning (which "
151  "can then be trapped with assert-abort)."));
152 
153 ConfigVariableBool allow_unrelated_wrt
154 ("allow-unrelated-wrt", true,
155  PRC_DESC("Set this true to allow unrelated NodePaths (that is, nodes which "
156  "have no common ancestor) to be adjusted relative to each other. If "
157  "true, these will be treated as if they had a common node above "
158  "their top nodes."));
159 
160 ConfigVariableBool paranoid_compose
161 ("paranoid-compose", false,
162  PRC_DESC("Set this true to double-check the componentwise transform compose "
163  "(or invert) operation against the equivalent matrix-based "
164  "operation. This has no effect if NDEBUG is defined."));
165 
166 ConfigVariableBool compose_componentwise
167 ("compose-componentwise", true,
168  PRC_DESC("Set this true to perform componentwise compose and invert "
169  "operations when possible. If this is false, the compositions "
170  "are always computed by matrix."));
171 
172 ConfigVariableBool paranoid_const
173 ("paranoid-const", false,
174  PRC_DESC("Set this true to double-check that nothing is inappropriately "
175  "modifying the supposedly const structures like RenderState, "
176  "RenderAttrib, TransformState, and RenderEffect. This has no effect "
177  "if NDEBUG is defined."));
178 
179 ConfigVariableBool auto_break_cycles
180 ("auto-break-cycles", true,
181  PRC_DESC("Set this true to automatically detect and break reference-count "
182  "cycles in the TransformState and RenderState caches. When this "
183  "is false, you must explicitly call TransformState.clear_cache() "
184  "from time to time to prevent gradual memory bloat."));
185 
186 ConfigVariableBool garbage_collect_states
187 ("garbage-collect-states", true,
188  PRC_DESC("Set this true to defer destruction of TransformState and "
189  "RenderState objects until the end of the frame (or whenever "
190  "TransformState::garbage_collect() and RenderState::garbage_collect() "
191  "are called). This is a particularly useful thing to do when "
192  "using multiple threads, because it improves parallelization."));
193 
194 ConfigVariableDouble garbage_collect_states_rate
195 ("garbage-collect-states-rate", 1.0,
196  PRC_DESC("The fraction of the total number of TransformStates "
197  "(or RenderStates, or whatever) that are processed with "
198  "each garbage collection step. Setting this smaller than "
199  "1.0 will collect fewer states each frame, which may require "
200  "less processing time, but risks getting unstable cache "
201  "performance if states accumulate faster than they can be "
202  "cleaned up."));
203 
204 ConfigVariableBool transform_cache
205 ("transform-cache", true,
206  PRC_DESC("Set this true to enable the cache of TransformState objects. "
207  "Using the cache saves time computing transforms and inverse "
208  "transforms, but imposes some overhead for maintaining the "
209  "cache itself."));
210 
211 ConfigVariableBool state_cache
212 ("state-cache", true,
213  PRC_DESC("Set this true to enable the cache of RenderState objects, "
214  "similar to the TransformState cache controlled via "
215  "transform-cache."));
216 
217 ConfigVariableBool uniquify_transforms
218 ("uniquify-transforms", true,
219  PRC_DESC("Set this true to ensure that equivalent TransformStates "
220  "are pointerwise equal. This may improve caching performance, "
221  "but also adds additional overhead to maintain the cache, "
222  "including the need to check for a composition cycle in "
223  "the cache."));
224 
225 ConfigVariableBool uniquify_states
226 ("uniquify-states", true,
227  PRC_DESC("Set this true to ensure that equivalent RenderStates "
228  "are pointerwise equal. This may improve caching performance, "
229  "but also adds additional overhead to maintain the cache, "
230  "including the need to check for a composition cycle in "
231  "the cache."));
232 
233 ConfigVariableBool uniquify_attribs
234 ("uniquify-attribs", true,
235  PRC_DESC("Set this true to ensure that equivalent RenderAttribs "
236  "are pointerwise equal. This may improve caching performance, "
237  "but also adds additional overhead to maintain the cache, "
238  "including the need to check for a composition cycle in "
239  "the cache."));
240 
241 ConfigVariableBool retransform_sprites
242 ("retransform-sprites", true,
243  PRC_DESC("To render sprite-based particle effects, Panda must convert "
244  "the sprite points from object space into clip space, and compute "
245  "the corners of the quads in clip space. When this variable is "
246  "false, the resulting quads are then sent to the graphics "
247  "hardware in clip space. When this is true, the quads are "
248  "re-transformed back into the original object space, which is "
249  "necessary in order for fog to work correctly on the sprites."));
250 
251 ConfigVariableBool depth_offset_decals
252 ("depth-offset-decals", true,
253  PRC_DESC("Set this true to allow decals to be implemented via the advanced "
254  "depth offset feature, if supported, instead of via the traditional "
255  "(and slower) two-pass approach. This is currently the only method "
256  "by which decals are implemented in Panda3D, and as such, this "
257  "setting is ignored."));
258 
259 ConfigVariableInt max_collect_vertices
260 ("max-collect-vertices", 65534,
261  PRC_DESC("Specifies the maximum number of vertices that are allowed to be "
262  "accumulated into any one GeomVertexData structure as a result "
263  "of collecting objects together during a flatten operation. "
264  "This prevents the accidental generation of large vertex buffers "
265  "from lots of smaller vertex buffers, while not "
266  "imposing a limit on the original size of any one "
267  "GeomVertexData structure."));
268 
269 ConfigVariableInt max_collect_indices
270 ("max-collect-indices", 65535,
271  PRC_DESC("Specifies the maximum number of vertex indices that are allowed "
272  "to be accumulated into any one GeomPrimitive as a result "
273  "of collecting objects together during a flatten operation. "
274  "This prevents the accidental generation of large index buffers "
275  "from lots of smaller index buffers, while not "
276  "imposing a limit on the original size of any one "
277  "GeomPrimitive."));
278 
279 ConfigVariableBool premunge_data
280 ("premunge-data", true,
281  PRC_DESC("Set this true to preconvert vertex data at model load time to "
282  "match the data requirements of the current GSG. For instance, "
283  "color columns are pre-converted to match OpenGL or DirectX "
284  "encoding requirements, as appropriate. When this is false, the "
285  "data will be munged at render time instead."));
286 
287 ConfigVariableBool preserve_geom_nodes
288 ("preserve-geom-nodes", false,
289  PRC_DESC("This specifies the default value for the \"preserved\" flag on "
290  "every GeomNode created. When this is true, GeomNodes will not "
291  "be flattened, so setting this true effectively disables the "
292  "use of flatten to combine GeomNodes."));
293 
294 ConfigVariableBool flatten_geoms
295 ("flatten-geoms", true,
296  PRC_DESC("When this is true (the default), NodePath::flatten_strong() and "
297  "flatten_medium() will attempt to combine multiple Geoms into "
298  "as few Geoms as possible, by combing GeomVertexDatas and then "
299  "unifying. Setting this false disables this behavior, so that "
300  "NodePath flatten operations will only reduce nodes. This affects "
301  "only the NodePath interfaces; you may still make the lower-level "
302  "SceneGraphReducer calls directly."));
303 
304 ConfigVariableInt max_lenses
305 ("max-lenses", 100,
306  PRC_DESC("Specifies an upper limit on the maximum number of lenses "
307  "and the maximum lens index number) that may be associated with "
308  "a single LensNode. There is no technical reason for this "
309  "limitation, but very large numbers are probably a mistake, so "
310  "this can be used as a simple sanity check. Set it larger or "
311  "smaller to suit your needs."));
312 
313 ConfigVariableBool default_antialias_enable
314 ("default-antialias-enable", false,
315  PRC_DESC("Set this true to enable the M_auto antialiasing mode for all "
316  "nodes by default."));
317 
318 ConfigVariableBool polylight_info
319 ("polylight-info", false,
320  PRC_DESC("Set this true to view some info statements regarding the polylight. "
321  "It is helpful for debugging."));
322 
323 ConfigVariableBool show_vertex_animation
324 ("show-vertex-animation", false,
325  PRC_DESC("Set this true to flash any objects whose vertices are animated "
326  "by Panda on the CPU (flash red) or by hardware (flash blue). "
327  "This only has effect when NDEBUG is not defined."));
328 
329 ConfigVariableBool show_transparency
330 ("show-transparency", false,
331  PRC_DESC("Set this true to flash any objects that are rendered in "
332  "some transparency mode. The color chosen is based on the "
333  "particular transparency mode in effect. This only has effect "
334  "when NDEBUG is not defined."));
335 
336 ConfigVariableBool m_dual
337 ("m-dual", true,
338  PRC_DESC("Set this false to disable TransparencyAttrib::M_dual altogether "
339  "(and use M_alpha in its place)."));
340 
341 ConfigVariableBool m_dual_opaque
342 ("m-dual-opaque", true,
343  PRC_DESC("Set this false to disable just the opaque part of M_dual."));
344 
345 ConfigVariableBool m_dual_transparent
346 ("m-dual-transparent", true,
347  PRC_DESC("Set this false to disable just the transparent part of M_dual."));
348 
349 ConfigVariableBool m_dual_flash
350 ("m-dual-flash", false,
351  PRC_DESC("Set this true to flash any objects that use M_dual, for debugging."));
352 
353 ConfigVariableList load_file_type
354 ("load-file-type",
355  PRC_DESC("List the model loader modules that Panda will automatically "
356  "import when a new, unknown model type is loaded. This may be "
357  "either the name of a module, or a space-separate list of filename "
358  "extensions, followed by the name of the module."));
359 
360 ConfigVariableString default_model_extension
361 ("default-model-extension", "",
362  PRC_DESC("This specifies the filename extension (with leading dot) that "
363  "should be assumed if an attempt is made to load a filename that "
364  "has no extension. This is primarily designed to support legacy "
365  "code that used the now-deprecated implicit-extension feature of "
366  "Panda's loader; new code should probably give the correct name "
367  "for each model file they intend to load."));
368 
369 ConfigVariableBool allow_live_flatten
370 ("allow-live-flatten", true,
371  PRC_DESC("Set this true to allow the use of flatten_strong() or any "
372  "variant on a node that is attached to a live scene graph node, "
373  "or false to disallow this. Flattening a live scene graph node "
374  "can cause problems when threading is enabled. This variable "
375  "only has an effect when Panda is not compiled for a release "
376  "build."));
377 
378 ////////////////////////////////////////////////////////////////////
379 // Function: init_libpgraph
380 // Description: Initializes the library. This must be called at
381 // least once before any of the functions or classes in
382 // this library can be used. Normally it will be
383 // called by the static initializers and need not be
384 // called explicitly, but special cases exist.
385 ////////////////////////////////////////////////////////////////////
386 void
387 init_libpgraph() {
388  static bool initialized = false;
389  if (initialized) {
390  return;
391  }
392  initialized = true;
393 
394  AlphaTestAttrib::init_type();
395  AntialiasAttrib::init_type();
396  AudioVolumeAttrib::init_type();
397  AuxBitplaneAttrib::init_type();
398  AuxSceneData::init_type();
399  BillboardEffect::init_type();
400  Camera::init_type();
401  ClipPlaneAttrib::init_type();
402  ColorAttrib::init_type();
403  ColorBlendAttrib::init_type();
404  ColorScaleAttrib::init_type();
405  ColorWriteAttrib::init_type();
406  CompassEffect::init_type();
407  CullFaceAttrib::init_type();
408  CullBin::init_type();
409  CullBinAttrib::init_type();
410  CullResult::init_type();
411  CullTraverser::init_type();
412  CullableObject::init_type();
413  DecalEffect::init_type();
414  DepthOffsetAttrib::init_type();
415  DepthTestAttrib::init_type();
416  DepthWriteAttrib::init_type();
417  FindApproxLevelEntry::init_type();
418  Fog::init_type();
419  FogAttrib::init_type();
420  GeomDrawCallbackData::init_type();
421  GeomNode::init_type();
422  GeomTransformer::init_type();
423  LensNode::init_type();
424  Light::init_type();
425  LightAttrib::init_type();
426  LightRampAttrib::init_type();
427  Loader::init_type();
428  LoaderFileType::init_type();
429  LoaderFileTypeBam::init_type();
430  MaterialAttrib::init_type();
431  ModelFlattenRequest::init_type();
432  ModelLoadRequest::init_type();
433  ModelSaveRequest::init_type();
434  ModelNode::init_type();
435  ModelRoot::init_type();
436  NodePath::init_type();
437  NodePathComponent::init_type();
438  PandaNode::init_type();
439  PandaNodePipelineReader::init_type();
440  ParamNodePath::init_type();
441  PlaneNode::init_type();
442  PolylightNode::init_type();
443  PolylightEffect::init_type();
444  PortalNode::init_type();
445  OccluderEffect::init_type();
446  OccluderNode::init_type();
447  PortalClipper::init_type();
448  RenderAttrib::init_type();
449  RenderEffect::init_type();
450  RenderEffects::init_type();
451  RenderModeAttrib::init_type();
452  RenderState::init_type();
453  RescaleNormalAttrib::init_type();
454  SceneSetup::init_type();
455  ScissorAttrib::init_type();
456  ScissorEffect::init_type();
457  ShadeModelAttrib::init_type();
458  ShaderInput::init_type();
459  ShaderAttrib::init_type();
460  ShowBoundsEffect::init_type();
461  StateMunger::init_type();
462  StencilAttrib::init_type();
463  TexMatrixAttrib::init_type();
464  TexProjectorEffect::init_type();
465  TextureAttrib::init_type();
466  TexGenAttrib::init_type();
467  TransformState::init_type();
468  TransparencyAttrib::init_type();
469 
470  AlphaTestAttrib::register_with_read_factory();
473  AuxBitplaneAttrib::register_with_read_factory();
479  ColorBlendAttrib::register_with_read_factory();
489  FogAttrib::register_with_read_factory();
493  LightRampAttrib::register_with_read_factory();
494  MaterialAttrib::register_with_read_factory();
510  ShaderInput::register_with_read_factory();
516  TextureAttrib::register_with_read_factory();
518  TransformState::register_with_read_factory();
519  TransparencyAttrib::register_with_read_factory();
520 
521  // By initializing the _states map up front, we also guarantee that
522  // the _states_lock mutex gets created before we spawn any threads
523  // (assuming no one is creating threads at static init time).
524  TransformState::init_states();
527 
529 
532 }
static void register_with_read_factory()
Tells the BamReader how to create objects of type OccluderEffect.
static void register_with_read_factory()
Tells the BamReader how to create objects of type PlaneNode.
Definition: planeNode.cxx:304
static void register_with_read_factory()
Tells the BamReader how to create objects of type ModelRoot.
Definition: modelRoot.cxx:40
static void register_with_read_factory()
Tells the BamReader how to create objects of type ShowBoundsEffect.
static void register_with_read_factory()
Tells the BamReader how to create objects of type ModelNode.
Definition: modelNode.cxx:169
static void register_with_read_factory()
Tells the BamReader how to create objects of type DepthWriteAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Shader.
Definition: shader.cxx:3052
static void register_with_read_factory()
Tells the BamReader how to create objects of type Fog.
Definition: fog.cxx:209
static void register_with_read_factory()
Tells the BamReader how to create objects of type Camera.
Definition: camera.cxx:305
static void register_with_read_factory()
Tells the BamReader how to create objects of type OccluderNode.
static void register_with_read_factory()
Tells the BamReader how to create objects of type ScissorEffect.
This is a convenience class to specialize ConfigVariable as a boolean type.
static LoaderFileTypeRegistry * get_global_ptr()
Returns a pointer to the global LoaderFileTypeRegistry object.
static void register_with_read_factory()
Tells the BamReader how to create objects of type TexProjectorEffect.
static void init_states()
Make sure the global _states map is allocated.
static void init_attribs()
Make sure the global _attribs map is allocated.
static void register_with_read_factory()
Tells the BamReader how to create objects of type TexMatrixAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type RenderState.
static void register_with_read_factory()
Tells the BamReader how to create objects of type PolylightNode.
This class is similar to ConfigVariable, but it reports its value as a list of strings.
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:4153
This defines the Loader interface to read Bam files.
static void register_with_read_factory()
Tells the BamReader how to create objects of type DepthTestAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type DepthOffsetAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type PortalNode.
Definition: portalNode.cxx:439
static void register_with_read_factory()
Tells the BamReader how to create objects of type ScissorAttrib.
void register_type(LoaderFileType *type)
Defines a new LoaderFileType in the universe.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CullBinAttrib.
This is a convenience class to specialize ConfigVariable as a floating-point type.
static void register_with_read_factory()
Tells the BamReader how to create objects of type LensNode.
Definition: lensNode.cxx:243
This is a convenience class to specialize ConfigVariable as a string type.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CullFaceAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type TexGenAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type ColorWriteAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type RenderEffects.
static void register_with_read_factory()
Factory method to generate a Shader object.
static void register_with_read_factory()
Tells the BamReader how to create objects of type ColorScaleAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CompassEffect.
This class maintains the set of all known LoaderFileTypes in the universe.
static void register_with_read_factory()
Tells the BamReader how to create objects of type AntialiasAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type AudioVolumeAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type GeomNode.
Definition: geomNode.cxx:1075
static void register_with_read_factory()
Tells the BamReader how to create objects of type DecalEffect.
Definition: decalEffect.cxx:75
static void register_with_read_factory()
Tells the BamReader how to create objects of type ColorAttrib.
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 RenderModeAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type ShadeModelAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type ClipPlaneAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type BillboardEffect.
static void register_with_read_factory()
Tells the BamReader how to create objects of type LightAttrib.
static void register_with_read_factory()
Tells the BamReader how to create objects of type RescaleNormalAttrib.
static void init_states()
Make sure the global _states map is allocated.